akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <set>
#include <cmath>

using namespace std;

int n,m;
int g[50][50]={0};
int visit[50]={0};
int a[50]={0},b[50]={0};

void dfs(int v){
    visit[v]=1;
    for(int v2=0;v2<n;v2++){
        if(g[v][v2]==0) continue;
        if(visit[v2]==1) continue;
        dfs(v2);
    }
}

int main(){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
        a[i]--;b[i]--;
        g[a[i]][b[i]]=g[b[i]][a[i]]=1;
    }
    
    int ans=0;
    
    for(int i=0;i<m;i++){
        g[a[i]][b[i]]=g[b[i]][a[i]]=0;
        for(int j=0;j<n;j++){
            visit[j]=0;
        }
        dfs(0);
        
        bool bri=false;
        for(int j=0;j<n;j++){
            if(visit[j]==false){
                bri=true;
            }
        }
        if(bri){
            ans+=1;
        }
        
         g[a[i]][b[i]]=g[b[i]][a[i]]=1;
    }
    
    cout<<ans<<endl;
    return 0;
}

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

// input
int N, Q;
string S;
vector<int> L, R;

vector<int> w;


void input() {
    cin >> N >> Q >> S;
    L = R = vector<int>(Q);
    rep(i, Q) cin >> L[i] >> R[i];
}


int main() {
    input();
    w = vector<int>(N + 1, 0);
    bool a = false;
    rep(i, N) {
        w[i + 1] = w[i];
        if (S[i] == 'A') {
            a = true;
        } else {
            if (a && S[i] == 'C') w[i + 1]++;
            a = false;
        }
    }
    rep(i, Q) {
        int l = L[i], r = R[i];
        int ans = w[r] - w[l];
        cout << ans << endl;
    }
}


Measured memory_bytes: 4512
using System;

namespace _8_D
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            s = s + s;
            string p = Console.ReadLine();
            int n = s.IndexOf(p);
            if (n >= 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            Console.ReadLine();
        }
    }
}

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

int main(){
  int L,R;
  cin >> L >> R;
  
  int ans = 2018;
  int tmp;
  bool flg = false;
  for(int i = L; i <= min(R-1, i+2018); i++){
    for(int j = i+1; j <= min(R,i+2019); j++){
      tmp = (i % 2019) * (j%2019);
      tmp = tmp % 2019;
      
      if(tmp < ans){
        ans = tmp;
      }
      if(tmp == 0){
        flg = true;
        break;
      }
    }
    if(flg){
      break;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <deque>
#include <tuple>
#include <unordered_set>
#include <array>
#include <string>

using namespace std;
#define ll long long
#define ar array

int main()
{	
	int n;
	cin >> n;
	ll a[n]={};
	for (int i=0; i<n; i++) cin >> a[i];
	sort(a, a+n);
	ll ans=0;
	for (int i=0; i<n-2; i++) {
		for (int j=i+1; j<n-1; j++) {
			if (a[i]==a[j]) continue;
			for (int k=j+1; k<n; k++) {
				if (a[k]==a[i]||a[k]==a[j]) continue;
				if (a[i]+a[j]<=a[k]) break;
				ans++;
				//cout << a[i] << " " << a[j] << " " << a[k] << endl;
			}
		}
	}
	cout << ans;
	return 0;
}

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

int main() {
  int N = 0;
  cin >> N;
  int64_t Li = 2;
  int64_t Lj = 1;
  int64_t Lk = 0;
  if (N == 1) { cout << 1; return 0; }
  for (int i = 2; i <= N; i++) {
    Lk = Li + Lj;
    Li = Lj;
    Lj = Lk;
  }
  cout << Lk;
}

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

using namespace std;

int solve(const std::string& s) {
  int const n = s.length();
  int ret = 0;
  int i = 0;
  int current = 0;
  std::string const acgt = "ACGT";
  for (; i < n; ++i) {
    char const c = s[i];
    if (acgt.find(c) == std::string::npos) {
      ret = std::max(current, ret);
      current = 0;
      continue;
    }
    current++;
  }
  ret = std::max(current, ret);
  return ret;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  std::string s;
  std::cin >> s;
  std::cout << solve(s) << std::endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long s = Long.parseLong(sc.next());
		
		long []x = new long [3];
		long []y = new long [3];
		
		x[0] = y[0] = 0;
		x[1] = 1000000000;
		y[1] = 1;
		
		
		y[2] = s/1000000000;
		if(s % 1000000000 != 0) {
		y[2]++;
		}
		x[2] = (1000000000 -  s % 1000000000)%1000000000;
		
		
		
		System.out.println(x[0]+" "+y[0]+" "+x[1]+" "+y[1]+" "+x[2]+" "+y[2]);
	//	System.out.println(x[1]*y[2] - x[2]*y[1]);
			}
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
using namespace std;

int N;
int h[100];
int flowers[100] = {};
int h_greater[100] = {};
int cnt = 0;

int main(void) {

    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> h[i];
        h_greater[i] = h[i];
    }

    // 先頭順に並べ替え
    sort(h_greater, h_greater + N);

    for (int i = 0; i < N; ++i) {
        int target = h_greater[i];
        if (i > 0 && h_greater[i - 1] == target) continue;


        int head = 0;
        // headが末端なら終わる
        while (head < N) {
            int tail = head;

            bool found = false;
            for (int k = head; k < N; ++k) {
                // ターゲットより低い数字が出たら
                if (h[k] < target) {
                    tail = k - 1;
                    found = true;
                    break;
                }
            }
            if (!found) tail = N - 1;

            // 花壇を更新
            if (head <= tail) {
                cnt += (target - flowers[head]);
                for (int k = head; k <= tail; ++k) {
                    flowers[k] = target;
                }

                // for (int k = 0; k < N; ++k) {
                //     cout << flowers[k] << " ";
                // }
                // cout << "count :" << cnt << endl;
            }


            // 次回の探索は末尾の2つ先
            head = tail + 2;
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
a,b,k = gets.chomp.split(" ").map(&:to_i)
gcd = 1
array = []
a > b ? min = b : min = a


while gcd <= min
  array.push(gcd) if a % gcd == 0 && b % gcd == 0
  gcd += 1
end

puts array.reverse.slice(k-1)




Measured memory_bytes: 1788
n,k = map(int,input().split())
a = list(map(int,input().split()))

ML = 50
r = min(ML,k)

for l in range(r):
    imos = [0]*(n+1)
    for i in range(n):
        left = max(0,i-a[i])
        right = min(n,i+a[i]+1)
        
        imos[left] += 1
        imos[right] -= 1
        
    c = 0
    for i in range(n):
        c += imos[i]
        a[i] = c
        
print(*a)

Measured memory_bytes: 171540
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    mat A(3, vec(3));
    Rep (i, 3) {
        Rep (j, 3) {
            cin >> A[i][j];
        }
    }

    ll N;
    cin >> N;
    vector<vector<bool>> check(3, vector<bool>(3, false));
    while (N--) {
        ll b;
        cin >> b;
        Rep (i, 3) {
            Rep (j, 3) {
                if (A[i][j] == b) {
                    check[i][j] = true;
                }
            }
        }
    }

    bool ans = false;

    Rep (i, 3) {
        bool flag = true;
        Rep (j, 3) {
            flag = flag && check[i][j];    
        }
        if (flag) ans = true;
    }

    Rep (i, 3) {
        bool flag = true;
        Rep (j, 3) {
            flag = flag && check[j][i];
        }
        ans = ans || flag;
    }

    bool flag = true;
    Rep (i, 3) {
        flag = flag && check[i][i];
    }
    ans = ans || flag;

    flag = true;
    Rep (i, 3) {
        flag = flag && check[i][2-i];
    }
    ans = ans || flag;

    if (ans) cout << "Yes\n";
    else cout << "No\n";

}

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

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  int a,b;
  cin>>a>>b;
  if (a<=5) {
    cout << 0 << endl;
  } else if (a>=13) {
    cout << b << endl;
  } else {
    cout << b/2 << endl;
  }
}

int main()
{
  solve();
  return 0;
}


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

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define repr(i, n) for (ll i = n - 1; i >= 0; --i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;

void solve(void)
{
    int n, C;
    cin >> n >> C;
    vector<int> s(n), t(n), c(n);
    rep(i, n) cin >> s[i] >> t[i] >> c[i], s[i]--, c[i]--;
    int mn = MN(s);
    int mx = MX(t);
    vector<vector<int>> list(C, vector<int>(mx - mn, 0));
    rep(i, n)
    {
        for (int j = s[i] - mn; j < t[i] - mn; ++j)
            list[c[i]][j] = 1;
    }
    // cout << mn << " " << mx << endl;
    // rep(i, C)
    // {
    //     rep(j, mx - mn) cout << list[i][j] << " ";
    //     cout << endl;
    // }
    int ans = 0, res;
    rep(i, mx - mn + 1)
    {
        res = 0;
        rep(j, C) res += list[j][i];
        ans = max(ans, res);
    }
    cout << ans << endl;
}
int main(void)
{
    solve();
}

Measured memory_bytes: 16720
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

int n;
char board[502][502];
int row[502], col[502];

int solve()
{
	{
		int sum = 0;
		for (int i = 0; i < n; i++) sum += n - row[i];
		if (sum == 0) {
			return -1;
		}
	}

	int ncol = 0;
	for (int i = 0; i < n; i++) if (col[i] > 0) ncol++;
	{
		for (int i = 0; i < n; i++) {
			if (row[i] == 0) {
				return ncol;
			}
		}
	}

	int ans = 2 * n;
	for (int i = 0; i < n; i++) {
		int now = ncol + row[i];
		if (col[i] == n) continue;
		ans = MIN(now, ans);
	}
	return ans;
}

int trow[502], tcol[502];

int mains() {
	for (int i = 0; i < n; i++) {
		row[i] = col[i] = 0;
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (board[i][j] == '.') {
				row[i]++;
				col[j]++;
			}
		}
	}
	for (int k = 0; k < n; k++) trow[k] = row[k], tcol[k] = col[k];
	int a = solve();
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			// apply row[i] to col[j].
			for (int k = 0; k < n; k++)
				row[k] = trow[k], col[k] = tcol[k];

			col[j] = row[i];
			row[i] -= board[i][j] == '.';
			row[i] += board[i][i] == '.';
			int b = solve();
			if (b == -1) continue;
			b++;
			if (a == -1) a = b;
			a = MIN(a, b);
		}
	}
	return a;
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%s", board[i]);
	printf("%d\n", mains());
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
int main()
{
	int a, b;
	scanf("%d%d", &a, &b);
	if(b != 1 && a > b)printf("Alice\n");
	else if(a != 1 && a < b)printf("Bob\n");
	else if(a == 1 && b != 1)printf("Alice\n");
	else if(b == 1 && a != 1)printf("Bob\n");
	else if(a == b)printf("Draw\n");
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;


public class Main{

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String[] firstLine = s.nextLine().split(" ");
		int vertexCnt = Integer.parseInt(firstLine[0]);
		int edgeCnt = Integer.parseInt(firstLine[1]);
		int[][] input = new int[vertexCnt][vertexCnt];
		for(int j=0 ; j<vertexCnt ; j++) {
			for(int k=0 ; k<vertexCnt ; k++) {
				if(j==k) {
					input[j][k] = 0;
				}else {
					input[j][k] = Integer.MAX_VALUE;
				}
			}
		}
		for(int i= 0 ; i<edgeCnt ; i++) {
			String[] line = s.nextLine().split(" ");
			input[Integer.parseInt(line[0])][Integer.parseInt(line[1])] = Integer.parseInt(line[2]);
		}
		int[][] result = solve(input);
		for(int l=0 ; l<vertexCnt ; l++) {
			if(result[l][l] < 0) {
				System.out.println("NEGATIVE CYCLE");
				return;
			}
		}
		for(int a=0 ; a<result.length ; a++) {
			String str = "";
			for(int b=0 ; b<result.length ; b++) {
				if(result[a][b]==Integer.MAX_VALUE) {
					str = str + "INF ";
				}else {
					str = str + result[a][b] + " ";
				}
			}
			System.out.println(str.trim());
		}

	}

	public static int[][] solve(int[][] input) {
		int[][] result = new int[input.length][input.length];
		for(int i=0 ; i<input.length ; i++) {
			for(int j=0 ; j<input.length ; j++) {
				for(int k=0 ; k<input.length ; k++) {
					if(input[j][i]!=Integer.MAX_VALUE && input[i][k]!=Integer.MAX_VALUE)
						input[j][k] = Math.min(input[j][k], input[j][i] + input[i][k]);
				}
			}
		}
		return input;
	}

}

Measured memory_bytes: 63564
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cstring>
using namespace std;
typedef long long ll;
const ll maxn = 1e6+10;
const ll inf = 1e16;

int N,K;
int main(){
//    freopen("in.txt", "r", stdin);
    cin>>N>>K;
    cout<<N-K+1<<endl;
    

    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 100000000
#define MOD 100000007
#define SIZE 100005
#define PI 	3.14159265358979323846

int main()
{
	cin.tie(0);
   	ios::sync_with_stdio(false);
    ll H,W;
    string a[105];
    cin >> H >> W;
    REP(i,H){
        bool canPlessW = 0;
        cin >> a[i];
        REP(j,W){
            //cout << i << ":" << j << endl;
            //cout << a[i][j] << endl;
            if(a[i][j] == '#'){
                canPlessW = 1;
            }
            //cout << a[i][j] << "::" << canPlessW << endl;
        }
        //cout << canPlessW << endl;
        if(!canPlessW){
            i--;
            H--;
        }
    }

    
    bool canPlessH[105]={0};
    REP(i,W){
        REP(j,H){
            if(a[j][i] == '#'){
                canPlessH[i] = 1;
                break;
            }
        }
        //cout << canPlessH[i] << endl;
    }
    REP(i,H){
        REP(j,W){
            if(canPlessH[j]){
                cout << a[i][j];
            }
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    A = [list(map(int, input().split())) for _ in range(N)]
    ans = 0
    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            direct = True
            for k in range(N):
                if i == k or j == k:
                    continue
                if A[i][j] > A[i][k] + A[k][j]:
                    print(-1)
                    return
                if A[i][j] == A[i][k] + A[k][j] and i != k and j != k:
                    direct = False
            if direct:
                ans += A[i][j]
    print(ans // 2)


if __name__ == "__main__":
    main()


Measured memory_bytes: 42844
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a;
  cin >> a;
  vector<int> s(a);
  for(int i = 0;i<a;i++)
    cin >> s.at(i);
  sort(s.begin(),s.end());
  int odd = 0,even = 0;
  for(int i = 0;i<a;i++){
    if(i%2 == 0)
      even += s.at(i);
    else
      odd += s.at(i);
  }
  if(even > odd)
    cout << even - odd << endl;
  else
    cout << odd - even << endl;
}

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

using namespace std;

#define ll long long
#define uint unsigned int

int main() {
    int a, b;
    string s;

    cin >> a >> b >> s;

    if (s.size() != a + b + 1) {
        return cout << "No\n", 0;
    }

    for (int i = 0; i < s.size(); ++i) {
        if (i == a) {
            if (s[i] != '-') {
                return cout << "No\n", 0;
            }
        } else {
            if (!isdigit(s[i])) {
                return cout << "No\n", 0;
            }
        }
    }

    cout << "Yes\n";

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
int main() {
	int i, j, n, p[10001] = {0};
	for (i = 2; i <= 10000; i++) if(p[i]==0) for (j = 2*i ;j <= 10000; j+=i) p[j] = 1;
		
	while (scanf("%d", &n),n!=0) {
		for (i = n; i >= 2; --i)
			if (p[i] == 0 && p[i - 2] == 0) {
				printf("%d %d\n", i - 2, i);
				break;
			}
	}
	return 0;
}

Measured memory_bytes: 644
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");
var a = Number(tmp[0]);
var b = Number(tmp[1]);
if(a+b >= 10){
console.log("error");
}else{
console.log(a+b);
}
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<algorithm>
#include<queue>
#include<functional>
#define ll long long
#define PLL pair<ll,ll>
#define VS vector<string>
#define VL vector<ll>
#define rep(i,a) for (ll i=0;i<a;i++)
#define nrep(i,n,a) for (ll i=n;i<a;i++)
#define mrep(i,a) for(ll i=a;i>=0;i--)
#define INF 1145141919810
#define VMIN(vec) *std::max_element(vec.begin(),vec.end())
#define VMIN(vec) *std::max_element(vec.begin(),vec.end())
#define TS(n) to_string(n)

using namespace std;


int main() {
	ll n, x, y, a = 1, b = 1,temp;
	cin >> n;
	rep(i, n){
		cin >> x >> y;
		temp = max((a%x == 0) ? a / x : a / x + 1, (b%y == 0) ? b / y : b / y + 1);
		a = x*temp;
		b = y*temp;
	}cout << a + b << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N,X,T;
  cin >> N >> X >> T;
  int time=0;
  for(int i=0;i<N;i+=X){
  	time += T;
  }
  cout << time << endl;
  return 0;
}

Measured memory_bytes: 3620
n,m = map(int,input().split())

l = []

for i in range(m):
    a,b = map(int,input().split())
    l.append((a,b))
l.sort(reverse=True)

res = 0
while l:
    start,end = l.pop()
    while end > start and l:
        s,t = l[-1]
        start = max(s,start)
        end = min(t,end)
        if end >start:
            l.pop()
    res += 1

print(res)


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

//thanks to pyf ...
//thanks to qhl ...
const int N = 1e5 + 7;
int cnt[N];
int main()
{
	ios :: sync_with_stdio(false);
	int n;
	while (cin >> n)
	{
		memset(cnt, 0, sizeof(cnt));
		for (int i = 0; i < n; i++)
		{
			int x;
			cin >> x;
			cnt[x] ++;
		}
		int ans = cnt[0] + cnt[1];
		for (int i = 1; i <= 1e5; i++)
			ans = max(ans, cnt[i] + cnt[i - 1] + cnt[i + 1]);
		cout << ans << endl;
	}
}

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

namespace CsharpProgramTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var a = int.Parse(input[0]);
            var b = int.Parse(input[1]);
            var val = (a * b) %2;
            var ans = val == 0 ? "Even" : "Odd";

            Console.WriteLine(ans);
        }
    }
}

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

using namespace std;

#define MOD 998244353

int n, hv[2005];
char x[2005];
long long ncr[4005][4005], dp[2005][2005], ans;

int main() {
	for (int i = 0; i < 4005; i++) {
		ncr[i][0] = ncr[i][i] = 1;
		for (int j = 1; j < i; j++) {
			ncr[i][j] = ncr[i - 1][j - 1] + ncr[i - 1][j];
			if (ncr[i][j] >= MOD)
				ncr[i][j] -= MOD;
		}
	}
	scanf("%s", x);
	n = strlen(x);
	for (int i = 0; i < n; i++)
		hv[i + 1] = hv[i] + (x[i] - '0');
	dp[0][0] = 1;
	for (int i = 0; i < n; i++)
		for (int j = max(0, hv[i + 1] - i - 1); j <= min(i + 1, hv[i + 1]); j++) {
			dp[i + 1][j] = dp[i][j];
			if (j) {
				dp[i + 1][j] += dp[i][j - 1];
				if (dp[i + 1][j] >= MOD)
					dp[i + 1][j] -= MOD;
			}
		}
	for (int i = max(0, hv[n] - n); i <= min(n, hv[n]); i++)
		ans = (ans + dp[n][i] * ncr[n][hv[n] - i]) % MOD;
	printf("%lld\n", ans);
	return 0;
}

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

using namespace std;

struct UnionFind
{
  vector< int > data;

  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }

  void unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x != y) {
      if(data[x] > data[y]) swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
  }

  int find(int k)
  {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
};

struct edge
{
  int u, v, cost, used;
  bool company;

  bool operator<(const edge& e)
  {
    if(company != e.company) return (company < e.company);
    return (cost < e.cost);
  }
};

int main()
{
  int N, M, K;
  edge e[600];

  while(scanf("%d %d %d", &N, &M, &K), N) {
    int B = 0;
    for(int i = 0; i < M; i++) {
      int u, v, w;
      char l;
      scanf("%d %d %d %c", &u, &v, &w, &l);
      e[i] = (edge) {--u, --v, w, false, l == 'A'};
      B += l == 'B';
    }
    sort(e, e + M);

    UnionFind tree(N);
    int cost = 0, ac = 0, bc = 0;
    for(int i = 0; i < M; i++) {
      if(tree.find(e[i].u) != tree.find(e[i].v)) {
        tree.unite(e[i].u, e[i].v);
        cost += e[i].cost;
        e[i].used = true;
        i < B ? ++bc : ++ac;
      }
    }

    while(ac < K) {
      tuple< int, int, int > flip(INT_MIN, -1, -1);
      for(int i = 0; i < B; i++) {
        if(!e[i].used) continue;
        UnionFind tree2(N);
        for(int j = 0; j < M; j++) {
          if(i != j && e[j].used) tree2.unite(e[j].u, e[j].v);
        }
        for(int j = B; j < M; j++) {
          if(tree2.find(e[j].u) != tree2.find(e[j].v)) {
            flip = max(flip, make_tuple(e[i].cost - e[j].cost, i, j));
          }
        }
      }
      int costt, x, y;
      tie(costt, x, y) = flip;
      if(costt == INT_MIN) break;
      swap(e[x].used, e[y].used);
      cost -= costt;
      ++ac, --bc;
    }
    if(ac + bc != N - 1 || ac != K) puts("-1");
    else printf("%d\n", cost);
  }
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
int t;
int main() {
  int64_t N,A,B;
  cin>>N>>A>>B;
  for(int i=1;i<N;i++){
    int64_t X,Y;
    cin>>X>>Y;
    int64_t Q=max(1+(A-1)/X,1+(B-1)/Y);
    A=X*Q,B=Y*Q;
  }
  cout<<A+B<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 50005, P = 1e9, M = 200000;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int s = 0;
    for (int i = 0; i < 5; i++) {
        int x;
        cin >> x;
        s += x;
    }
    cout << 15 - s << '\n';
    return 0;
}

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

using namespace std;

using LL = long long;
using PII = pair<int, int>;
using ll = long long;
using DBL = double;
using VI = vector<int>;
using VD = vector<DBL>;
using VVI = vector<VI>;
using VVD = vector<VD>;

#define FOR(i,a,b) for(int i = a; i < b; i++)
#define REP(i,n) FOR(i,0,n)
#define SZ(a) ((int)((a).size()))
#define ALL(x) (x).begin(), (x).end()
#define SET(a,v) memset((a), (v), sizeof(a))
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define ST first
#define ND second

//#define trace(...) {__f(#__VA_ARGS__, __VA_ARGS__);}
//template<typename Arg> void __f(const char* name, Arg&& arg) {
//  cerr << name << " = " << arg << std::endl;
//} template <typename Arg1, typename... Args>
//void __f(const char* names, Arg1&& arg1, Args&&... args) {
//  const char* comma = strchr(names + 1, ',');
//  cerr.write(names, comma - names) << " = " << arg1<<" | ";__f(comma+1, args...); }
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds; // OST: find_by_order, order_of_key
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//#pragma GCC optimize("Ofast")
//optimize("unroll-loops")
//target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
///*** RNGS ***/
//SEED=chrono::steady_clock::now().time_since_epoch().count();
//// or high_resolution_clock
//mt19937 rng(SEED); /*or*/ random_device rd; mt19937 rng(rd());
//uniform_int_distribution<> dis(MIN, MAX);// usage: dis(rng)
//struct chash {int operator()(int x) const {return x^SEED;}};
//gp_hash_table<int,int,chash>m;//use cc if very less updates
///*** FAST IO ***/
//inline int scan(){ bool y=0; int x=0; char c=getchar_unlocked();
//while(c<'0'||c>'9'){ if(c=='-')y=1; c=getchar_unlocked();}
//while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+c-'0';c=getchar_unlocked();}
//return y?-x:x; }

const int MAXN = 128, MAXK = 100010;
const int MOD = 1000000007;
int a[MAXN], dp[MAXK], psum[MAXK];

int main() {
    #ifdef LOCAL_EXEC
//    freopen("sample.in", "r", stdin);
//    freopen("sample.out", "w", stdout);
    #else
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    #endif
    int n, k;
    cin >> n >> k;
    for(int i=1; i<=n; ++i) {
        cin >> a[i];
    }
    dp[0] = 1;
    for(int pos=1; pos<=n; ++pos) {
        psum[0] = dp[0];
        for(int i=1; i<MAXK; ++i) {
            psum[i] = dp[i] + psum[i-1];
            if(psum[i] >= MOD) psum[i] -= MOD;
        }
        for(int left=0; left<=k; ++left) {
            int l = left - min(left, a[pos]);
            int r = left;
            dp[left] = psum[r] - (l == 0 ? 0 : psum[l-1]);
            if(dp[left] < 0) dp[left] += MOD;
        }
    }
    cout << dp[k] << endl;
	return 0;
}


Measured memory_bytes: 4372
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long a[5];
  cin>>a[0]>>a[1]>>a[2];
  if(a[0]%2==0||a[1]%2==0||a[2]%2==0){
    cout<<'0'<<endl;
  }
  else{
    sort(a,a+3);
    cout<<a[0]*a[1]<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <set>

int main()
{
  int N;
  std::cin >> N;
  int d[N];
  std::set<int> values;
  for ( int i = 0; i < N; i++ ) {
    std::cin >> d[i];
    values.insert(d[i]);
  }
  std::cout << values.size() << std::endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int N = sc.nextInt();
 
   int sum = 0 ;
   int l=0;
   int r=0;
   for(int i=0;i<N;i++)
   {
	 l=sc.nextInt();
     r=sc.nextInt();
     sum += r-l+1;
   }
   System.out.println(sum);
 }
}

Measured memory_bytes: 25044
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	h := make([]int, n)
	temp := make([]int, n)

	for i, _ := range h {
		fmt.Scan(&h[i])
	}
	for i := 0; i < m; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		temp[a-1] = max(temp[a-1], h[b-1])
		temp[b-1] = max(temp[b-1], h[a-1])
	}

	ans := 0
	for i, v := range temp {
		if h[i] > v {
			ans++
		}
	}
	fmt.Println(ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

Measured memory_bytes: 6492
//set many funcs template
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384
 
int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
 
int main(void){
    long long n,l[128],i;
    l[0]=2;l[1]=1;
    scanf("%lld",&n);
    for(i=2;i<=n;i++){l[i]=l[i-2]+l[i-1];}
    printf("%lld\n",l[n]);
    return 0;
}

Measured memory_bytes: 128
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}



fn main() {
    input!{
    	i: i32,
    }
    print!("{}",i*i*i);
}


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

inline void read(int &a)
{
    a=0;int c=getchar();
    while(c>'9'||c<'0') c=getchar();
    while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();
}

const int N=15;
int n,m;
int s[N][N],p[N],ans;

int main()
{
	read(n);read(m);
	for(int i=1;i<=m;i++)
	{
		read(s[i][0]);
		for(int j=1;j<=s[i][0];j++)
		{
			read(s[i][j]);
		}
	}
	for(int i=1;i<=m;i++) read(p[i]);
	for(int i=0;i<(1<<n);i++)
	{
		bool flag=0;
		for(int j=1;j<=m;j++)
		{
			int cnt=0;
			for(int k=1;k<=s[j][0];k++)
			{
				if(i&(1<<(s[j][k]-1))) cnt++;
			}
			if(cnt%2!=p[j]) {flag=1;break;}
			
			
		}
		if(!flag) ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i=0;i<n;++i) cin >> p[i];
    
    sort(p.begin(), p.end());
    cout << p[n/2] - p[n/2-1] << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
ll N, M, K;

ll imos[1005000];

int main() {
    cin >> N >> M >> K;
    vector<ll> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(), A.end());
    ll sum = 0;
    for(int i = N - 1; i >= 0; i--) {
        ll rest = M - sum;
        if(rest < A[i]) {
            imos[A[i]]++;
            ll tmp = A[i] - rest;
            imos[A[i]-tmp]--;
            //cerr << i << " " << A[i] << " " << A[i]- tmp - 1 << endl;
        }
        sum += A[i];
        chmin(sum, M);
    }
    for(int i = 1e6; i >= 0; i--) {
        imos[i] += imos[i+1];
    }
    /*
    for(int i = 0; i <= 10; i++) {
        cerr << i << " "<< imos[i] << endl;
    }
    */
    ll ans = 0;
    for(int i = 1e6; i >= 1; i--) {
        ll tmp = min(imos[i], K);
        imos[i] -= tmp;
        K -= tmp;
        //if(i <= 10) cerr << i << " " << imos[i] << endl;
        ans += i * imos[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11596
#include <iostream>
#include <vector>
#include <iomanip>
int main()
{
	int N;
	std::cin >> N;
	std::vector<double> As(N);
	for (int i = 0; i < N; ++i) {
		std::cin >> As[i];
	}

	double runningdenom = 0;

	for (int i = 0; i < N; ++i) {
		runningdenom += 1.0 / As[i];
	}

	const double res = 1.0 / runningdenom;
	std::cout << std::setprecision(10) << res << "\n";

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;
public class Main {

	static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		while (read())
			solve();
	}
	
	static final int INF = 100000000;
	static int N,M,L,K,A,H;
	static boolean[] HOS = new boolean[110];
	static int[][] W = new int[110][110];
	static boolean read() {
		N = sc.nextInt();
		M = sc.nextInt();
		L = sc.nextInt();
		K = sc.nextInt();
		A = sc.nextInt();
		H = sc.nextInt();
		if (N == 0) return false;
		
		for (int i = 0; i < 110; i++) {
			fill(W[i], INF);
			W[i][i] = 0;
		}
		
		fill(HOS, false);
		for (int i = 0; i < L; i++) {
			int hos = sc.nextInt();
			HOS[hos] = true;
		}
		
		for (int i = 0; i < K; i++) {
			int X = sc.nextInt(), Y = sc.nextInt(), T = sc.nextInt();
			W[X][Y] = W[Y][X] = T;
		}
		
		return true;
	}

	/*
	static void solve() {
		PriorityQueue<State> que = new PriorityQueue<State>();
		que.add(new State(H, M, 0));
		int[][] time = new int[1000][1000]; // XÔ âÔ
		for (int i = 0; i < 100; i++) fill(time[i], INF);
		int ans = INF;
		while (!que.isEmpty()) {
			State s = que.poll();
			int cur = s.n, lim = s.t, t = s.c;
			if (time[cur][lim] != INF) continue;
			
			time[cur][lim] = t;
			
			if (cur == A) {
				ans = t;
				break;
			}	
			
			// ÄâÈµÉs®
			for (int i = 0; i < N; i++) {
				int from = cur, to = i;
				int lim2 = lim - W[from][to], nt = t + W[from][to];
				// s®ªÂ\Å êÎ
				if (lim2 >= 0 && time[to][lim2] == INF)
					que.add(new State(to, lim2, nt));
			}

			// Äâ{Ýª êÎ
			if (HOS[cur]) {
				// ÄâðÝé
				for (int i = lim + 1; i <= M; i++) {
					int to = cur, lim2 = i, nt = t + (lim2 - lim);
					if (nt < time[to][lim2] && time[to][lim2] == INF)
						que.add(new State(to, lim2, nt));
				}
			}
		}
		
		if (ans == INF) {
			System.out.println("Help!");
		} else {
			System.out.println(ans);
		}
	}	
	*/
	
	static void solve() {
		
		// CÓÌ2_ÔÌÅZ£ðßé
		for (int k = 0; k < 110; k++) {
			for (int i = 0; i < 110; i++) {
				for (int j = 0; j < 110; j++) {
					W[i][j] = min(W[i][j], W[i][k] + W[k][j]);
				}
			}
		}
		
		for (int i = 0; i < 110; i++) {
			for (int j = 0; j < 110; j++) {
				// 2_ÔªMæèå«¢êA»à»à»Ì¹ðÊé±ÆªÅ«È¢ÌÅAINF
				if (W[i][j] > M) W[i][j] = INF;
				// Ç¿ç©ªñsAa@Aâ{ÝÅÈ¢êAINF
				if ((HOS[i] || i == A || i == H) && (HOS[j] || j == A || j == H)) {}
				else W[i][j] = INF;
			}
		}

		for (int k = 0; k < 110; k++) {
			for (int i = 0; i < 110; i++) {
				for (int j = 0; j < 110; j++) {
					W[i][j] = min(W[i][j], W[i][k] + W[k][j]);
				}
			}
		}		
		
		if (W[A][H] == INF) 
			System.out.println("Help!");
		else {
			System.out.println((W[A][H] + max(0, W[A][H] - M)));
		}
		
	}
}

class State implements Comparable<State> {
	int n, t, c; // XÔ âcÔ ©©Á½Ô
	State(int n, int t, int c) {
		this.n = n;
		this.t = t;
		this.c = c;
	}
	
	public int compareTo(State s) {
		return this.c - s.c;
	}
}

Measured memory_bytes: 12000
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    int n = 0;
    cin >> n;
    string s = "", t = "";
    cin >> s >> t;
    for (int i=0; i<n; i++) {
        bool flag =true;
        for (int j=0; j<n-i; j++) {
            if (t.at(j) != s.at(i+j)) {
                flag = false;
                break;
            }
        }
        if (flag) {
            cout << n+i << endl;
            return 0;
        }
    }
    cout << 2*n << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

// Lib
//

int main(){
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int N, M; cin >> N >> M;
    vector<int> nums(N, 1);
    vector<bool> can(N, false);
    can[0] = true;

    for (int i = 0; i < M; ++i) {
        int a, b; cin >> a >> b;
        --a, --b;
        if (can[a]){
            can[b] = true;
            if (nums[a] == 1){
                can[a] = false;
            }
        }
        --nums[a];
        ++nums[b];
    }

    int res = 0;
    for (int i = 0; i < N; ++i){
        if (can[i] && nums[i] > 0){
            ++res;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 640
x = int(input())
while True :
    calc = input()
    if calc == '=' :
        break
    y = int(input())
    
    if calc == '+' :
        x += y
    elif calc == '-' :
        x -= y
    elif calc == '*' :
        x *= y
    else :
        x = x // y
print(x)


Measured memory_bytes: 5588
#include<bits/stdc++.h>
#include <time.h>
using namespace std;
#include <math.h>
#define ll long long 
// to increase precision
// std::cout<<std::fixed;
// 	std::cout<<std::setprecision(6)<<z;
//clock_t tStart = clock();
//printf("Time taken: %.9fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
#define max1 100001
vector<vector<int> > arr(max1);




int main(){	
	int n,m,x;
	cin>>n>>m>>x;
	int cost[n];
	int a[n][m];
	for (int i = 0; i <n; ++i)
	{
		cin>>cost[i];
		for (int j = 0; j < m; ++j)
		{
			cin>>a[i][j];
		}
	}
	int fc=1e9;
	for(int i=0;i<(1<<n);i++){
		int sum[m]={0};
		int tc=0;
		for(int j=0;j<n;j++){
			if(i&(1<<j)){
				tc+=cost[j];
				for (int k = 0; k < m; ++k)
				{
					sum[k]+=a[j][k];
				}
			}
		}
		int flag=1;
		for(int j=0;j<m;j++){
			flag=flag&(sum[j]>=x);
		}
		if(flag){
			fc=min(fc,tc);
		}
	}
	if(fc==1e9){
		cout<<-1<<endl;
	}
	else{
	cout<<fc<<endl;
}
}

Measured memory_bytes: 5396
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	string S;
	cin >> S;
	int sum = 0;
	int tmp;
	int num = S[S.size() - 1] - '0';
	for (int i = 0; i < (1 << (S.size() - 1)); i++)
	{
		tmp = 0;
		for (int j = 0; j < S.size() - 1; j++)
		{
			if (((i >> j) & 1) == 1)
			{
				tmp += S[j] - '0';
				sum += tmp;
				tmp = 0;
			}
			else
			{
				tmp += S[j] - '0';
				tmp *= 10;
			}
		}
		sum += tmp;
		sum += num;
	}
	cout << sum;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		for (int i=0;i<s.length();i++) {
			if (s.charAt(i)=='C') {
				for (;i<s.length();i++) {
					if (s.charAt(i)=='F') {
						System.out.println("Yes");
						return ;
					}
				}
			}
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e9+7
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 long long int gcd(long long int m,long long int n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
long long int lcm(long long int number1,long long int number2){
	return number1 * number2 / gcd(number1,number2);	

}
int main(){
  ll N,K;
  cin>>N>>K;
  
  vector<ll>A(N);
  vector<ll>date;

  rep(i,N){
    cin>>A[i];
    
    }

  sort(all(A));
    ll sum=1;
    for(ll i=1;i<N;i++){
      if(A[i]==A[i-1]){
        sum++;
      }
      else{
        date.push_back(sum);
        sum=1;
      }
      if(i==N-1){
        
date.push_back(sum);
      }
    }
sort(all(date));
    
    ll ans=0;
    
rep(i,date.size()-K){
  ans+=date[i];
}
    

  
  cout<<ans<<endl;
}
  
  

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

int main() {
  int n;
  cin >> n;
  
  string s[n];
  for(int i = 0; i < n; i++) {
    cin >> s[i];
  }
  
  int m;
  cin >> m;
  
  string t[m];
  for(int j = 0; j < m; j++) {
    cin >> t[j];
  }
  
  int p_max = 0;
  for(int k = 0; k < n; k++) {
    int point = 0;
    string key = s[k];
    if(key == "") continue;

    for(int l = 0; l < n; l++) {
      if(key == s[l]) {
        point++;
        s[l] = "";
      }
    }
    for(int o = 0; o < m; o++) {
      if(key == t[o]) {
        point--;
        t[o] = "";
      }
    }
    
    if(point > p_max) p_max = point;
  }
  
  cout << p_max << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N;
vector<ll> A, B;
int main()
{
    cin >> N;
    A.resize(N);
    B.resize(N);
    ll res = LL_INF;
    ll sum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i] >> B[i];
        sum += A[i];
        if (A[i] > B[i])
        {

            res = min(res, B[i]);
        }
    }
    if (A == B)
    {
        cout << 0 << endl;
        return 0;
    }
    cout << sum - res << endl;

    return 0;
}

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

ll inf=1ll<<60;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int x,a,b;
	cin>>x>>a>>b;
	if (abs(b-x)>abs(a-x)){
		cout<<"A";
	}
	else {
		cout<<"B";
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder output = new StringBuilder();
		Set<String> Dic = new HashSet<String>();
		
		int n = sc.nextInt();
		String order;
		String str;
		
		for(int i=0; i<n; i++) {
			order = sc.next();
			str = sc.next();
			if( order.equals("insert") ) { Dic.add(str); }
			else {
				if( Dic.contains(str) ) { output.append("yes\n"); }
				else { output.append("no\n"); }
			}
		}
		System.out.print(output);
	}
}



Measured memory_bytes: 231728
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

s=SI()
s=s[::-1]
i=0
while i<len(s):
    if s[i:i+5]=="maerd" or s[i:i+5]=="esare":
        i+=5
    elif s[i:i+6]=="resare":
        i+=6
    elif s[i:i+7]=="remaerd":
        i+=7
    else:
        print("NO")
        sys.exit()
print("YES")




Measured memory_bytes: 9400