akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int n,m,vis[210000],head[210000],cnt;
struct node
{
	int v,nex;
}bian[210000];
void add(int a,int b)
{
	bian[++cnt].v=b;
	bian[cnt].nex=head[a];
	head[a]=cnt;
}
void dfs(int x)
{
	vis[x]=1;
	for(int i=head[x];i;i=bian[i].nex)
	{
		int v=bian[i].v;
		if(vis[v]) continue;
		dfs(v);
	}
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y),add(y,x);
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(!vis[i]) ans++,dfs(i);
	 } 
	 cout<<ans-1;
}
 

Measured memory_bytes: 6812
#include<stdio.h>
#include<stdlib.h>

#define MAXNUM 256

void save_str(int array_num, char **str) {
    int i = 0, j = 0, count = 0;
    char temp[MAXNUM];
  
    if(scanf("%[^\n]", temp));
    while (temp[++i] != '\0') {
      if (temp[i] == ' ') {
        count++;
        temp[i] = '\0';
      }
    }
    if (count + 1 != array_num) return;
  
  
    str[0] = &temp[0];
    for (i = 1; i < array_num; i++) {
      while (temp[++j] != '\0');
      str[i] = &temp[++j];
    }
    return;
}

int main(void) {
  int a, k, num[4];
  char **val;

  val = (char **)malloc(MAXNUM * sizeof(char *));
  for (k = 0; k < 4; k++) {
    val[k] = (char *)malloc(MAXNUM * sizeof(char));
  }
  save_str(4, val);

  for (a = 0; a < 4; a++) {
    num[a] = atoi(val[a]);
  }
  
  while (1) {
    if((num[2] -= num[1]) <= 0) {
      printf("Yes");
      break;
    } else if((num[0] -= num[3]) <= 0) {
      printf("No");
      break;
    }

  }

  return 0;

}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

int main(){
    ll h, w, k;
    cin >> h >> w >> k;

    //dp[i][j] : 高さiで幅jに行ける本数
    ll dp[h+2][w+2] = {};
    dp[0][0] = 1;
    rep(i, h)rep(j, w){
        //
        rep(bit, (1<<(w-1))){
            //正しい線の引き方か？
            bool isok = true;
            rep(b, w)if((1<<b) & bit){
                if((1<<(b-1) & bit)){
                    isok = false;
                    break;
                }
                if(b > 0 && (1<<(b-1) & bit)){
                    isok = false;
                    break;
                }
            }
            if(!isok)continue;

            //右方向へ移動する
            if((1<<j) & bit){
                dp[i+1][j+1] += dp[i][j];
                dp[i+1][j+1] %= MOD;
            }
            //左方向へ移動する
            else if(j > 0 && ((1<<(j-1)) & bit)){
                dp[i+1][j-1] += dp[i][j];
                dp[i+1][j-1] %= MOD;
            }
            //そのまま下へ
            else {
                dp[i+1][j] += dp[i][j];
                dp[i+1][j] %= MOD;
            }
        }
    }

    cout << dp[h][k-1] << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>

using namespace std;

typedef long ll;

int main(int, char**)
{
	ll n, k, ans = 0;
	string str;
	cin >> str;

	int x =( str[0] - '0') * 10 +  str[1] - '0';
	int y =( str[2] - '0') * 10 +  str[3] - '0';

	bool isX = true;
	bool isY = true;
	if ((x == 0)|| x > 12) isX = false;
	if ((y == 0)|| y > 12) isY = false;

	if (isX && ! isY) cout << "MMYY" << endl;
	else if (! isX && isY) cout << "YYMM" << endl;
	else if (isX && isY) cout << "AMBIGUOUS" << endl;
	else cout << "NA" << endl;


	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;

int n,m;
int c[16],x[20000];

long dp[20001][256];

long rec(int p, int y){ //?????¨p???????????¨???????????????????????????????????????y???x[n]??¨????????????????????????
	if(dp[p][y]>=0) return dp[p][y];
	
	if(p==n) return 0;
	
	long ret=LONG_MAX;
	for(int i=0; i<m; ++i){ //??????????????????????????¨????????????????????°????????????
		int ny = y+c[i];
		if(ny<0) ny=0;
		else if(ny>255) ny=255;
		
		ret = min(ret, rec(p+1,ny)+(ny-x[p])*(ny-x[p]));
	}
	
	return dp[p][y]=ret;
}

int main(){
	while(1){		
		//input
		scanf(" %d %d", &n, &m);
		if(n==0) break;
		
		for(int i=0; i<m; ++i) scanf(" %d", &c[i]);
		for(int i=0; i<n; ++i) scanf(" %d", &x[i]);	
		
		memset(dp,-1,sizeof(dp));
		printf("%ld\n", rec(0,128));
	}
}

Measured memory_bytes: 42836
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ub upper_bound
#define int long long
#define vbe(sdk) sdk.begin(), sdk.end()
#define pb push_back
#define loop(i, a, b) for (int i = a; i < b; ++i)
#define rloop(i, a, b) for (int i = a; i >= b; --i)
#define mp make_pair
#define mod 1000000007
#define endl '\n'
#define vvll vector<vector<int>>
#define vll vector<int>
#define mint map<int, int>
#define arry(x) (int)x.size()
#define sll set<int>
#define pll pair<int, int>
#define F first
#define S second
#define pi 3.14159265358979323846
using namespace std;
const int MAX = 100001;


void solve()
{
        int n;
        cin>>n;
        int a[n];
        int x=0;
        loop(i,0,n)
        {
            cin>>a[i];
            x^=a[i];
        }
        loop(i,0,n)
        {
            int z=a[i]^x;
            cout<<z<<"\n";
        }

}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #else
    // // online submission
    // #endif


    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 5096
using System;
using System.Collections.Generic;
using System.Linq;

namespace Problem_C
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var red = new List<Tuple<int, int>>();
            var blue = new List<Tuple<int, int>>();
            for (var i = 0; i < n; i++)
            {
                var p = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                red.Add(Tuple.Create(p[0], p[1]));
            }
            for (var i = 0; i < n; i++)
            {
                var p = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                blue.Add(Tuple.Create(p[0], p[1]));
            }

            red.Sort();
            blue.Sort();
            var count = 0;
            for (var i = 0; i < blue.Count; i++)
            {
                var maxY = int.MinValue;
                for (var j = 0; j < red.Count; j++)
                {
                    if (red[j] != null &&
                        red[j].Item1 < blue[i].Item1 && red[j].Item2 < blue[i].Item2)
                    {
                        maxY = Math.Max(maxY, red[j].Item2);
                    }
                }
                if (maxY > int.MinValue) count++;
                for (var k = 0; k < red.Count; k++)
                {
                    if (red[k] != null && red[k].Item2 == maxY) red[k] = null;
                }
            }
            Console.WriteLine($"{count}");
        }
    }
}


Measured memory_bytes: 13396
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
using namespace std;
int a[200001];
int p[200001];
int n;
bool win()
{
	for(int i=0;i<n-1;i++)
	{
		if(p[n-i]==p[n-i-1])
			return p[n-i];
		if(p[n+i]==p[n+i+1])
			return p[n+i];
	}
	return p[1];
}
bool judge(int x)
{
	for(int i=1;i<=2*n-1;i++)
		if(a[i]>=x)
			p[i]=1;
		else
			p[i]=0;
	return win();
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=2*n-1;i++)
		scanf("%d",&a[i]);
	int l=0,r=2*n;
	while(l+1<r)
	{
		int mid=(l+r)/2;
		if(judge(mid))
			l=mid;
		else
			r=mid;
	}
	printf("%d",l);
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define itn int
#define gI gi
#define int long long

using namespace std;

typedef long long ll;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline ll gl()
{
	ll f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int maxn = 100003;

int n, ans, m, a[maxn], vis[maxn];

signed main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	n = gi(), m = gi();
	for (int i = 1; i <= n; i+=1) a[i] = gi() / 2;
	int lcm = 1;
	for (int i = 1; i <= n; i+=1) 
	{
		lcm = lcm / __gcd(lcm, a[i]) * a[i];
		if (lcm > m) {puts("0"); return 0;}
	}
	for (int i = 1; i <= n; i+=1) 
	{
		if (lcm / a[i] % 2 == 0) {puts("0"); return 0;}
	}
	cout << m / lcm - m / (lcm * 2) << endl;
	return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <queue>
using namespace std;
typedef long long ll;

int dy[4] = {-1, 0, +1, 0};
int dx[4] = {0, +1, 0, -1};

int main(void){
    int h, w;
    cin >> h >> w;
    
    vector<string> field;
    
    field.resize(h);
    
    int seen[60][60] = {0};
    int dist[60][60] = {0};
    
    for(int i = 0; i < h; i++){
        string tmp;
        cin >> tmp;
        field[i] = tmp;
    }
    
    queue<int> qy;
    queue<int> qx;
    
    int sx = 0;
    int sy = 0;
    
    qy.push(sy);
    qx.push(sx);
    
    seen[0][0] = 1;
    
    bool finished = false;
    int minDist;
    
    while(!qy.empty()){
        int nowX = qx.front();
        int nowY = qy.front();
        
        qx.pop();
        qy.pop();
        
        for(int i = 0; i < 4; i++){
            int nextX = nowX + dx[i];
            int nextY = nowY + dy[i];
            
            if(nextY < 0 || nextY >= h || nextX < 0 || nextX >= w){
				continue;
			}
			
			if(seen[nextY][nextX] != 0){
				continue;
			}
            
            if(field[nextY][nextX] == '#'){
				continue;
			}
			
			seen[nextY][nextX] = 1;
			dist[nextY][nextX] = dist[nowY][nowX] + 1;
			
			if(nextY == h - 1 && nextX == w - 1){
			    minDist = dist[nextY][nextX] - 1;
			    finished = true;
			    break;
			}
			
			qx.push(nextX);
			qy.push(nextY);
        }
        if(finished)break;
    }
    
    int whiteCounter = 0;
    for(int y = 0; y < h; y++){
        for(int x = 0; x < w; x++){
            if(field[y][x] == '.'){
                if(y == 0 && x == 0)continue;
                if(y == h - 1 && x == w - 1)continue;
                whiteCounter++;
            }
        }
    }
    
    int ans = whiteCounter - minDist;
    
    if(seen[h - 1][w - 1] == 0){
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
def mapint_inp():
    return map(int, input().split())

def intinp():
    return int(input())

N, K = mapint_inp()

sunuke_set = set()

for _ in range(K):
    d = intinp()
    A = list(mapint_inp())
    for A_i in A:
        sunuke_set.add(A_i)

print(N - len(sunuke_set))

Measured memory_bytes: 9176
//2019/3/12
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		double x = 0;

		String u = "";

		double ans = 0;

		for(int i=0;i<N;i++) {

			x = sc.nextDouble();

			u = sc.next();

			if(u.equals("JPY")) ans += x;

			else if(u.equals("BTC")) ans += (x*380000.0);
		}

		System.out.println(ans);
	}

}


Measured memory_bytes: 23380
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    ll N, K, S;
    cin >> N >> K >> S;
    ll num = pow(10, 9);
    if(num == S){
        rep(i, K) cout << S << " ";
        rep(i, N-K) cout << 1 << " ";
        cout << endl;
    }else{
        rep(i, K) cout << S << " ";
        rep(i, N-K) cout << S+1 << " ";
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;

int main() {
    int N, M; cin >> N >> M;
    ll ans = (1900 * M + 100 * (N - M));
    for (int i = 0; i < M; i++){
        ans *= 2;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;


int main() {
    int n, k;
    cin >> n >> k;
    vector <int> v(n);
    for(int i = 0; i < n; i++) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    int ans = 0;
    for(int i = 0; i < min(k, n); i++) ans += v[i];
    cout << ans << endl;
}

Measured memory_bytes: 3636
import java.util.*;


public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N=in.nextInt();
        int sum=0;
        for (int i = 0; i < N; i++) {
            if (in.nextInt()%2==1) {
                sum++;
            }
        }
        if(sum%2==0) System.out.println("YES");
        else System.out.println("NO");
        }

        }

Measured memory_bytes: 48812
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

int main()
{
	int r,D;
	vector<int> x(11);
	cin>>r>>D>>x[0];

	for(int i=1; i<=10; i++)
	{
		x[i] = r*x[i-1] - D;
		cout<<x[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(long long i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
      char C;
      cin >> C;
      char a = C + 1;
      cout << a << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
int b[100];
int main ()
{
    char a;
    for(int i=0;i<4;i++)
    {
        cin>>a;
        b[(a-'A')]++;
    }
    for(int i=0;i<99;i++)
        if(b[i]==1||b[i]==4)
        {
            cout<<"No"<<endl;
            return 0;
        }


    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
using System;

public static class Program
{
    public static int Main(string[] args)
    {
        var input = int.Parse(Console.ReadLine());
        
        var h = input / 3600;
        
        var m = input % 3600 / 60;
        
        var s = input % 3600 % 60;
        
        Console.WriteLine("{0}:{1}:{2}",h,m,s);
        
        return 0;
    }
}


Measured memory_bytes: 19968
#define  _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}


#define int ll

unsigned long xor128() {
    static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned long t = (x ^ (x << 11));
    x = y; y = z; z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void solve(){
    int n, p, query;
    cin >> n >> p >> query;
    vector<int> inputs;
    int ans = 0;
    REP(i, n) {
        int c;
        cin >> c;
        ans += c;
        inputs.push_back(c);
    }
    REP(i, n) {
        int val = (query - i) * p;
        inputs[i] = val - inputs[i];
    }
    sort(ALL(inputs));
    reverse(ALL(inputs));
    int final_ans = ans;
    REP(i, n) {
        ans += inputs[i];
        ans += 2 * i * p;
        final_ans = max(final_ans, ans);
    }
    cout << final_ans << endl;
}

#undef int
int main() {
    init();
    solve();
}


Measured memory_bytes: 7100
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll n, k;
ll a[100002], b[100002], c[100002];
ll abSum, cSum;
ll minusC;

int main(){
    scanf("%lld %lld", &n, &k);
    for(ll i=k, j=1; j<=n; i++, j++){
        a[j] = i;
        abSum+=i;
    }
    for(ll i=k+n, j=1; j<=n; i++, j++){
        b[j] = i;
        abSum+=i;
    }
    for(ll i=k+n+n, j=1; j<=n; i++, j++){
        c[j] = i;
        cSum+=i;
    }
    if(abSum > cSum){
        printf("-1");
        return 0;
    }
    minusC = (cSum - abSum) / n;
    for(int i=1; i<=(n+1)/2; i++){
        printf("%lld %lld %lld\n", a[i], b[i+(n/2)], c[i*2-1]);
    }
    for(int i=(n+1)/2+1, j=1; i<=n; i++, j++){
        printf("%lld %lld %lld\n", a[i], b[j], c[2*j]);
    }
}


Measured memory_bytes: 4608
#include <stdio.h>

int main()
{
  int a,b,c,d;
  
  scanf("%d %d %d %d",&a,&b,&c,&d);
  
  int e,f;
  
  e=c/b;
  if(c%b!=0)e++;
  
  f=a/d;
  if(a%d!=0)f++;
  
  if(e<=f)
  {
    printf("Yes");
  }
  else
  {
    printf("No");
  }
  
  return 0;
}


Measured memory_bytes: 1708
#include<bits/stdc++.h> 
  
using namespace std; 
typedef long long ll;

 
int main()
{
  
  ll t=1,l;
 //  cin>>t;
 

  while(t--)
  {
    string a,b;
    cin>>a>>b;
    ll n = a.length();
    bool solvable = true;
    for(ll i = 0;i<n;i++)
    {
      if(a[i]!=b[i])
      {
        solvable= false;
        break;
      }

    }
    if(solvable)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;

  
   
  }
      
  return 0;
}



/*

  36 151 0 65

*/

// ll val=0,ind;
    // for(ll i=l;i<=r;i++)
    // {
    //   ll func = (x&i)*(y&i);
    //   if(func>val)
    //   {
    //     val = func;
    //     ind = i;
    //   }

    // }

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
int main(){
  uli x,y;
  cin>>x>>y;
  uli ans=1e18;
  if(x<=y)ans=min(ans,y-x);
  if(-x-y>=0)ans=min(ans,-x-y+1);
  if(x-y>=0)ans=min(ans,x-y+2);
  if(y+x>=0)ans=min(ans,y+x+1);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
// #include <iomanip>
// #include <vector>
#include <algorithm>
// #include <cmath>
// #include <utility>
#include <queue>
#include <unordered_set>
#include <unordered_map>
using namespace std;

int N;
pair<int, int> x[100000];
pair<int, int> y[100000];

int calc() {
	unordered_multimap<int, pair<int, int>> edges;	// 全辺（双方向）
	unordered_set<int> visited;					// 訪問済み点
	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> candidates;	// 訪問済み点から延びる辺

	sort(x, x + N);
	sort(y, y + N);
	for (int i = 0; i < N - 1; i++) {
		edges.insert(make_pair(x[i].second, make_pair(x[i + 1].first - x[i].first, x[i + 1].second)));
		edges.insert(make_pair(x[i + 1].second, make_pair(x[i + 1].first - x[i].first, x[i].second)));
		edges.insert(make_pair(y[i].second, make_pair(y[i + 1].first - y[i].first, y[i + 1].second)));
		edges.insert(make_pair(y[i + 1].second, make_pair(y[i + 1].first - y[i].first, y[i].second)));
	}
	long long answer = 0;

	visited.insert(0);
	auto range = edges.equal_range(0);
	for (auto itr = range.first; itr != range.second; itr++) {
		candidates.push(itr->second);
	}

	while (visited.size() < N) {
		pair<int, int> edge = candidates.top();
		candidates.pop();
		// cout << "edge to " << edge.second << " : " << edge.first << endl;
		if (visited.insert(edge.second).second) { // 挿入成功
			answer += edge.first;
			auto range = edges.equal_range(edge.second);
			for (auto itr = range.first; itr != range.second; itr++) {
				candidates.push(itr->second);
			}
			// cout << "\tAdded" << endl;
		}
	}

	return answer;
}

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> x[i].first >> y[i].first;
		x[i].second = i;
		y[i].second = i;
	}
	cout << calc() << endl;
}

Measured memory_bytes: 24820
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
using P = pair<int,int>;


int main(){
    char alp; cin >> alp;
    if(isupper(alp)){
        cout << 'A' << endl;
    } else {
        cout << 'a' << endl;
    }
    return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
 
  cin >> N;
  vector<string> S(N);
  vector<int> Snum(N,0);
  vector<int> Num(N,0);
  
  for (int i = 0; i < N; i++)
    cin >> S.at(i);
  
  cin >> M;
  vector<string> T(M);
  vector<int> Tnum(M,0);
  
  for (int i = 0; i < M; i++)
    cin >> T.at(i);
  
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++)
      if(S.at(i)==S.at(j))
        Snum.at(i) += 1; 
  
  for (int i = 0; i < M; i++)
    for (int j = 0; j < M; j++)
      if(T.at(i)==T.at(j))
        Tnum.at(i) += 1; 
  
  for (int i = 0; i < N; i++)
    for (int j = 0; j < M; j++){
      if(S.at(i) == T.at(j)){
        Num.at(i) = Snum.at(i) - Tnum.at(j);
  		break;
      }else{
        Num.at(i) = Snum.at(i);
      }
    }
  
  int max = 0;
  for (int i = 0; i < N; i++)
	if(Num.at(i) > max)
      max = Num.at(i);
   
  cout << max << endl;
}

Measured memory_bytes: 3572
#include<stdio.h>

int main(){

    int N,K,cnt=0;

    scanf("%d %d",&N,&K);

    int h[N];

    for(int i=1;i<=N;i++){

        scanf("%d",&h[i]);
    }

    for (int j=1;j<=N;j++){

        if (h[j]>=K) cnt++;
    
    }

    printf("%d",cnt);
 	return 0;


}

Measured memory_bytes: 512
n = int(input())
s = input()

t="RGBRGB"

c=0
cm=0
for i in range(3):
    for j in range(1,n-1):
        if s[j]==t[i] :
            low = s[:j].count(t[i+1])
            high = s[j:].count(t[i+2])
            c += low*high
            low = s[:j].count(t[i+2])
            high = s[j:].count(t[i+1])
            c += low*high
            for k in range(1,j+1):
                if j+k>n-1 :
                    break
                if s[j-k]!=t[i] and s[j+k]!=t[i] and s[j-k]!=s[j+k]:
                    cm+=1


print(c-cm)


Measured memory_bytes: 9160
/*
    STARK_BOY
*/
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i<=b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef vector< ll > vi;
typedef vector<pair<ll,ll> > vpii;
typedef pair<ll,ll> pii;
#define all(c) c.begin(),c.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define setbitc(x) __builtin_popcount(x)
#define init(x,a) memset(x,a,sizeof(x))
#define PI           3.14159265358979323846  /* pi */
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
#define N 3005
//Variables Start
ll inf=1e18,MOD=998244353;
ll n,m,k,ar[N],br[N],dp[N][N][2];
string s,s1;
//Variables End

ll sub(ll a, ll b){return (a-b+MOD)%MOD;}
ll add(ll a, ll b){return (a+b)%MOD;}
ll mul(ll a, ll b){return (a*b)%MOD;}
int main()
{
    ios
    int ti=1;
    //cin>>ti;
    while(ti--)
    {
		cin>>n>>k;
		vi in(n+1,0);
		rep(i,1,n+1)cin>>in[i];
		//dp[0][0][0]=1;
		rep(pos,1,n+1)
		{
			dp[pos][0][0]=1;
			if(k>=in[pos])dp[pos][in[pos]][0]=1;
			if(k>=in[pos])dp[pos][in[pos]][1]=1;
			rep(sum,0,k+1)
			{
				dp[pos][sum][0]=add(dp[pos][sum][0],dp[pos-1][sum][0]);
				if(sum>=in[pos])
				{
					dp[pos][sum][0]=add(dp[pos][sum][0],dp[pos-1][sum-in[pos]][0]);
					dp[pos][sum][1]=add(dp[pos][sum][1],dp[pos-1][sum-in[pos]][0]);
				}
				dp[pos][sum][1]=add(dp[pos][sum][1],dp[pos-1][sum][0]);
				dp[pos][sum][1]=add(dp[pos][sum][1],dp[pos-1][sum][1]);

				//cout<<pos<<" "<<sum<<" "<<dp[pos][sum][0]<<" "<<dp[pos][sum][1]<<endl;

			}
		}       

		cout<<dp[n][k][1]<<endl; 
    }
    return 0;
        
}

Measured memory_bytes: 141184
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	ll n, d, a; cin >> n >> d >> a;
	vector<P> xh(n);
	REP(i, n) {
		cin >> xh[i].first >> xh[i].second;
		xh[i].second = (xh[i].second + a - 1) / a;
	}
	sort(ALL(xh));
	queue<P> q;
	ll dmg = 0, ans = 0, dd;
	REP(i, n) {
		while (1) {
			if (q.empty())
				break;
			if (q.front().first < xh[i].first) {
				dmg -= q.front().second;
				q.pop();
			}
			else
				break;
		}
		if (xh[i].second - dmg > 0) {
			dd = xh[i].second - dmg;
			dmg += dd;
			ans += dd;
			q.push({ xh[i].first + 2 * d, dd });
		}
	}
	cout << ans;
}

Measured memory_bytes: 4992
n,q = map(int, input().split())
s = input()
lr = [list(map(lambda x: int(x)-1, input().split())) for _ in range(q)]

ac = [0]*n
for i in range(n-1):
    if s[i:i+2] == 'AC':
        ac[i+1]= ac[i]+1
    else:
        ac[i+1] = ac[i]
for x in lr:
    print(ac[x[1]] - ac[x[0]])

Measured memory_bytes: 32284
from collections import defaultdict
N, M = map(int, input().split())

G = defaultdict(list)

for _ in range(M):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)

for i in range(1, N + 1):
    l = G.get(i, None)
    if l is None:
        print(0)
    else:
        print(len(l))


Measured memory_bytes: 3316
#include "bits/stdc++.h"
using namespace std;

int main() {
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;

    vector<int> x(N);
    vector<int> y(M);
    for (int i = 0; i < N; i++) {
        cin >> x[i];
    }
    for (int i = 0; i < M; i++) {
        cin >> y[i];
    }

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    bool flag = true;
    if (x[N - 1] <= X && y[0] <= X) {
        flag = false;
    }
    else if (x[N - 1] >= Y && y[0] >= Y) {
        flag = false;
    }
    else {
        if (y[0] - x[N - 1] < 1) {
            flag = false;
        }
    }

    if (flag) {
        cout << "No War" << endl;
    }
    else {
        cout << "War" << endl;
    }
}

Measured memory_bytes: 256
import math
def main():
    A, B = map(int, input().split())
    i = 0
    if B == 1:
        print(0)
    else:
        if B <= A:
            print(1)
        else:
            con = B
            while True:
                con -= A - 1
                i += 1
                if con <= A:
                    i += 1
                    break
            print(i)
main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N,M;
  cin>>N>>M;
  char a[50][50],b[50][50];
  for(int i=0;i<N;i++) for(int j=0;j<N;j++)cin>>a[i][j];
  for(int i=0;i<M;i++) for(int j=0;j<M;j++)cin>>b[i][j];

  for(int i=0;i<N-M+1;i++){
    for(int j=0;j<N-M+1;j++){
      bool flg=true;
      for(int k=0;k<M;k++){
        for(int l=0;l<M;l++){
          if(a[i+k][j+l]!=b[k][l]) flg=false;
        }
      }
      if(flg){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


using pll = pair<long long, long long>; // (money, time)
using Edge = pair<int, pll>;
using Graph = vector<vector<Edge>>;
const long long INF = 1LL<<60;
const int MAX = 2500;

int N, M;
long long S;
Graph G;
vector<long long> C, D; // money, time

void solve() {
    if (S >= MAX) S = MAX;
    vector<vector<long long>> dp(N, vector<long long>(MAX+1, INF));
    priority_queue<pair<long long, pll>, vector<pair<long long, pll> >, greater<pair<long long, pll> > > que;
    long long t = 0;
    while (S <= MAX) {
        dp[0][S] = t;
        que.push(make_pair(t, pll(0, S))); // (time, vertex, money)
        S += C[0];
        t += D[0];
    }
    while (!que.empty()) {
        auto p = que.top(); que.pop();
        //COUT(p);
        long long time = p.first;
        int v = p.second.first;
        long long s = p.second.second;
        if (time > dp[v][s]) continue;
        for (auto e : G[v]) {
            if (s < e.second.first) continue;
            int nv = e.first;
            long long ns = s - e.second.first;
            long long ntime = time + e.second.second;
            while (ns <= MAX) {
                if (chmin(dp[nv][ns], ntime)) {
                    que.push(make_pair(ntime, pll(nv, ns)));
                }
                ns += C[nv];
                ntime += D[nv];
            }
        }
    }
    for (int v = 1; v < N; ++v) {
        long long res = INF;
        for (int s = 0; s <= MAX; ++s) chmin(res, dp[v][s]);
        cout << res << endl;
    }
}

int main() {
    while (cin >> N >> M >> S) {
        G.assign(N, vector<Edge>());
        for (int i = 0; i < M; ++i) {
            long long u, v, a, b;
            cin >> u >> v >> a >> b;
            --u, --v;
            G[u].push_back(Edge(v, pll(a, b)));
            G[v].push_back(Edge(u, pll(a, b)));
        }
        C.resize(N); D.resize(N);
        for (int i = 0; i < N; ++i) cin >> C[i] >> D[i];
        solve();
    }
}

















Measured memory_bytes: 101852
#include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#include<algorithm>
#include<set>
#define N 1000005
using namespace std;
bool a[N];
int b[N];
int c[10];
int main()
{
	int n,m;
	while(~scanf("%d%d",&n,&m))
	{
		if(!n&&!m) break;
		memset(a,false,sizeof(a));
		memset(b,0,sizeof(b));
		int res=0;
		a[n]=true;
		b[n]=res++;
		while(1)
		{
			for(int i=0;i<m;++i) c[i]=0;
			 int cnt=0;
			 while(n)
			 {
				 int b=n%10;
				 c[cnt++]=b;
				 n/=10;
			 }
			 sort(c,c+m);
			 int sum1=0,sum2=0;
			 for(int i=0;i<m;++i) sum1=sum1*10+c[i];
			 for(int i=m-1;i>=0;--i) sum2=sum2*10+c[i];
			 n=sum2-sum1;
			 if(a[n]) {printf("%d %d %d\n",b[n],n,res-b[n]);break;}
			 else {a[n]=1;b[n]=res++;}
		}
		
	}return 0;
}

Measured memory_bytes: 0
import collections
n = int(input())
A = list(map(int, input().split()))
B = collections.Counter(A)
s = 0; t = 0
B = sorted(B.items(), key=lambda x:x[0], reverse=True)
se = 0
for i in B:
    if i[1] > 3 and se == 0:
        se = i[0]**2
    if i[1] > 1 and s == 0:
        s = i[0]
    elif i[1] > 1 and t == 0:
        t = i[0]
print(max(s*t, se))

Measured memory_bytes: 22436
if __name__ == '__main__':
    n = int(input())
    a = [int(i) for i in input().split()]
    b = [int(i) for i in input().split()]
    c = [int(i) for i in input().split()]

    sum = 0

    for i in b:
        sum = sum+i
    for i in range(n):
        if i < n-1:
            if a[i]+1 == a[i+1] :
                sum = sum + c[a[i]-1]


    print(sum)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
//#include<unordered_map>
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(i,a,n) for(int i=a; i<n; ++i)
#define rep1(i,a,n) for(int i=n-1; i>=a; --i)
#define sd(a) scanf("%d",&a)
#define sf(a) scanf("%lf",&a)
#define sll(a) scanf("%lld",&a)
#define test(a) cout<<a<<endl
#define test2(a,b) cout<<a<<" "<<b<<endl
#define inf(a) memset(a,0x3f,sizeof(a))
#define While(a) for(;a;)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
const int N=1e5+10;
const ll  MAXN=1e18;
const int MAX=1e5+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const double eps=1e-7;

char o[N];
ll dp[N][5];

inline void solve(){
    scanf("%s",o+1);
    int n=strlen(o+1);
    dp[0][0]=1;
    rep(i,1,n+1){
        if(o[i]!='?')
            dp[i][o[i]-'A'+1]=dp[i-1][o[i]-'A'];
        else
            rep(j,1,4)
                dp[i][j]=dp[i-1][j-1];
        rep(j,0,4)
            (dp[i][j]+=dp[i-1][j])%=mod;
        if(o[i]=='?')
            rep(j,0,4)
                (((dp[i][j]+=dp[i-1][j])%=mod)+=dp[i-1][j])%=mod;
    }
    printf("%lld\n",dp[n][3]);
    return ;
}
//int t=1;
int main(){
#ifdef local
    freopen("in.txt","r",stdin);
//    freopen("in.txt","w",stdout);
#endif
    int casen=1;
//    IOS;
//    cin >> casen;
//    sd(casen);
//    init();
    int t=1;
//    init();
    While(casen--){
//        printf("Case %d: ",t++);
//          cout << "Case "<< t++ << ": ";
//        test(qpow(2,10));
        solve();
    }
    fclose(stdin);
    return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>

using namespace std;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int a, b, n_1, n_2;
	cin >> a >> b;
	
	n_1 = max(a, b);
	n_2 = min(a, b);
	
	if((n_1-1)>=n_2) cout << n_1+(n_1-1) << endl;
	else cout << (n_1+n_2) << endl;

	return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1000000000;
const double PI = acos(-1);

const int MAX_V = 301;
LL d[MAX_V][MAX_V];//d[i][j]はe={u,v}のコスト(存在しないときはINF,i==jのときは0)
int n;

void warshall_floyd() {
	for (int k = 0; k<n; k++) {
		for (int i = 0; i<n; i++) {
			for (int j = 0; j<n; j++) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
}
int a[301][301];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> d[i][j];
			a[i][j] = d[i][j];
		}
	}
	warshall_floyd();
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (d[i][j] != a[i][j]) {
				cout << -1 << endl;
				return 0;
			}
		}
	}
	LL ans = 0;
	for (int i = 0; i<n; i++) {
		for (int j = i + 1; j<n; j++) {
			bool flag = true;
			for (int k = 0; k<n; k++) {
				if (a[i][j] == a[i][k] + a[k][j] && k != i&&k != j)flag = false;
			}
			if (flag)ans += a[i][j];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.nextLine();
		String str = sc.nextLine(), temp;
		int mini;
		boolean sStable = true;
		String[] A = str.split(" "), B = str.split(" ");
		for (int i = 0; i <= A.length - 1; i++) {
			for (int j = A.length - 1; j >= i + 1; j--) {
				if (Integer.parseInt(A[j].replaceAll("[\\D]", "")) < Integer
						.parseInt(A[j - 1].replaceAll("[\\D]", ""))) { // i should stop using java for these problems
					temp = A[j];
					A[j] = A[j - 1];
					A[j - 1] = temp;
				}
			}
		}
		for (int i=0; i<A.length-1;i++) {
			System.out.print(A[i] + " ");
		}
		System.out.println(A[A.length-1]+"\nStable");
		for (int i = 0; i <= B.length - 1; i++) {
			mini = i;
			for (int j = i; j <= B.length - 1; j++) {
				if (Integer.parseInt(B[j].replaceAll("[\\D]", "")) < Integer
						.parseInt(B[mini].replaceAll("[\\D]", ""))) {
					mini = j;
				}
			}
			temp = B[i];
			B[i] = B[mini];
			B[mini] = temp;
		}
		for (int i = 0; i < B.length; i++) {
			sStable &= A[i].equals(B[i]);
		}
		for (int i = 0; i < B.length-1; i++) {
			System.out.print(B[i] + " ");
		}
		System.out.println(B[B.length-1]);
		if (sStable) {
			System.out.println("Stable");
		} else {
			System.out.println("Not stable");
		}
	}

}



Measured memory_bytes: 31544
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <sstream>
#include <cstdlib>
#include <cmath>
 
using namespace std;

int main(){
    long long int debt = 100000;
    long long int temp;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
    	debt +=  debt * 0.05;
    	temp = debt;
    	debt /= 1000.0;
    	if(temp - debt * 1000 != 0){ debt++; }
    	debt *= 1000.0;
    }
    cout << debt << endl;
    return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;

#define mem(a,b) memset(a, b, sizeof(a) )
#define gcd(a,b) __gcd(a,b)
#define sqr(a) ((a) * (a))

#define faster() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction(a) cout.unsetf(ios::floatfield); cout.precision(a); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);



template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
            return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
            os << "{";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}

template < typename T >
ostream &operator << ( ostream & os, const multiset< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << it -> first << " = " << it -> second ;
                                            }
                    return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

void faltu () {
            cerr << endl;
}

template <typename T>
void faltu( T a[], int n ) {
            for(int i = 0; i < n; ++i) cerr << a[i] << ' ';
                cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) {
            cerr << arg << ' ';
                faltu(rest...);
}

int main()
{
    faster();

    int n;
    cin>>n;
    int rem;
    rem = n%10;
    if(rem==1 || rem==0 || rem==6 || rem==8){
        cout<<"pon"<<endl;
    }
    else if(rem==3){
        cout<<"bon"<<endl;
    }
    else{
        cout<<"hon"<<endl;
    }


    return 0;
}



Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	string s;
	cin >> s;
	int count = 0;
	for(int i=0;i<6;i++){
		if(s[i]=='1'){
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
n,p=map(int,input().split())
s=input()
if 10%p==0:
  print(sum(i for i,x in enumerate(s,1) if int(x)%p==0))
  exit()
ans=0
u=0
d=1
l=[0]*p
l[0]=1
s=s[::-1]
for i in map(int,s):
  u=(u+i*d)%p
  l[u]+=1
  d=d*10%p
for i in l:
  ans+=i*(i-1)//2
print(ans)

Measured memory_bytes: 3500
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>

using namespace std;

#define ll long long

int cut(int x){
    if(x > 0){
        return x;
    }else{
        return 0;
    }
}

int main(void){
    int h, n;
    cin >> h >> n;

    vector<int> a(n), b(n);
    for(int i = 0;i < n;++i)    cin >> a[i] >> b[i];

    vector<int> dp(h+1, 1000000000);

    for(int i = 0;i < n;++i){
        dp[h] = 0;
    }

    for(int h_i = h;h_i > -1;--h_i){
        for(int i = 0;i < n;++i){
            if(dp[h_i] != 1000000000){
                dp[cut(h_i-a[i])] = min(dp[cut(h_i-a[i])], dp[h_i] + b[i]);
                
            }
        }
    }



    cout << dp[0] << endl;
    


    /*
    vector<pair<double, int>> eff(n, pair<double, int>());
    for(int i = 0;i < n;++i){
        eff[i].first = (double)b[i] / (double)a[i];
        //cout << eff[i].first << endl;
        eff[i].second = i;
    }

    sort(eff.begin(), eff.end());

    int ans=0;
    int eff_i = 0;
    do{
        ans += h/a[eff[eff_i].second] * b[eff[eff_i].second];
        h = h%a[eff[eff_i].second];
        eff_i++;

        cout << h << " " << ans << endl;
    }while(h > 0 && eff_i < n);
    cout << endl;
    cout << ans << endl;


    if(h > 0){
        int min_cost = 1000000000;
        int min_i;
        for(int i = 0;i < n;++i){
            int cost = (int)ceil((double)h/(double)a[i]) * b[i];
            cout << cost << endl;
            if(min_cost > cost){
                min_cost = cost;
                min_i = i;
            }
        }
        ans += min_cost;
    }

    /*
    int min_b = 1000000000;
    if(h > 0){
        for(int i = 0;i < n;++i){
            if(min_b > b[i] && h-a[i] <= 0){
                min_b = b[i];
            }
        }
        ans += min_b;
    }*/

    /*
    int min_cost = 1000000000;
    int min_i;
    for(int i = 0;i < n;++i){
        int cost = (int)ceil((double)h/(double)a[i]) * b[i];
        if(min_cost > cost){
            min_cost = cost;
            min_i = i;
        }
    }

    ans += min_cost;
    */

    //cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define ld long double
#define MOD 1000000007
#define nl cout << bl
#define rt ll Q[100005] = {0}
#define mp make_pair
#define test() \
    ull t;     \
    cin >> t;  \
    while (t--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define s(ar, n) sort(ar, ar + n)
#define rs(ar, n) sort(ar, ar + n, greater<ll>())
#define oa(a, n)               \
    for (ll i = 0; i < n; i++) \
        cout << a[i] << " ";
#define cn(a, n)               \
    for (ll i = 0; i < n; i++) \
        cin >> a[i];
#define ov(a, n)                    \
    for (ll i = n - 1; i >= 0; i--) \
        cout << a[i] << " ";        \
    nl
#define ovp(a, n)              \
    for (ll i = 0; i < n; i++) \
        cout << a[i].ff << " " << a[i].ss << bl;
#define maxa(ar, N) *max_element(ar, ar + N)
#define mina(ar, N) *min_element(ar, ar + N)
#define present(c, x) ((c).find(x) != (c).end())
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
typedef pair<int, int> pii;
ll fast_exp(ll base, ll exp)
{
    ll res = 1;
    while (exp > 0)
    {
        if (exp % 2 == 1)
            res = (res * base) % MOD;
        base = (base * base) % MOD;
        exp /= 2;
    }
    return res % MOD;
}
ll fib(ll n)
{
    if (n < 2)
        return n;
    ll a = 0, b = 1, pre;
    int i = 1;
    while (i < n)
    {
        pre = (a + b) % MOD;
        a = b;
        b = pre;
        i++;
    }
    return pre;
}
ll fac(ll n)
{
    if (n % 2 == 0)
        return 2;

    for (ll i = 3; i * i <= n; i += 2)
    {
        if (n % i == 0)
            return i;
    }

    return n;
}
ll Digits(ll n)
{
    ll largest = 0;
    ll smallest = 9;

    while (n)
    {
        ll r = n % 10;
        largest = max(r, largest);
        smallest = min(r, smallest);
        n = n / 10;
    }
    ll ans = largest * smallest;
    return ans;
}
int main()
{
    fastio();
    int k;
    string s;
    cin >> k >> s;
    if (s.length() <= k)
    {
        cout << s << "\n";
    }
    else
    {
        cout << s.substr(0, k) + "...";
    }
}


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <climits>

using edge_to = std::pair<long long, long long>;	// {weight, to}
using edge = std::vector<long long>;				// {weight, from, to}

// true : detected negative cycle
bool warshall_floyd(
	long long V,
	long long E,
	std::vector<edge>& edges,					// set of DIRECTED edges
	std::vector<std::vector<long long>>& dist	// should be sized V * V, filled with infinity
) {
	for (long long i = 0; i < V; i++) dist[i][i] = 0;
	for (auto i : edges) dist[i[1]][i[2]] = i[0];
	for (long long k = 0; k < V; k++) {
		for (long long i = 0; i < V; i++) {
			if (dist[i][k] == LLONG_MAX) continue;
			for (long long j = 0; j < V; j++) {
				if (dist[k][j] == LLONG_MAX) continue;
				dist[i][j] = std::min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}
	for (long long k = 0; k < V; k++) {
		for (long long i = 0; i < V; i++) {
			if (dist[i][k] == LLONG_MAX) continue;
			for (long long j = 0; j < V; j++) {
				if (dist[k][j] == LLONG_MAX) continue;
				if (dist[i][j] > dist[i][k] + dist[k][j]) {
					return true;
				}
			}
		}
	}
	return false;
}

int main() {
	long long V, E;
	std::cin >> V >> E;
	std::vector<edge> edges(0);
	for (long long i = 0; i < E; i++) {
		long long s, t, d;
		std::cin >> s >> t >> d;
		edges.push_back({d, s, t});
	}
	std::vector<std::vector<long long>> dist(V, std::vector<long long>(V, LLONG_MAX));
	if (warshall_floyd(V, E, edges, dist)) {
		std::cout << "NEGATIVE CYCLE\n";
	} else {
		for (auto i : dist) {
			for (long long j = 0; j < V - 1; j++) {
				if (i[j] == LLONG_MAX) std::cout << "INF ";
				else std::cout << i[j] << ' ';
			}
			if (i.back() == LLONG_MAX) std::cout << "INF\n";
			else std::cout << i.back() << '\n';
		}
	}
}


Measured memory_bytes: 3460