akhauriyash/Code-Regression huggingface dataset:
# import bisect

k, s = map(int, input().split())

ans = 0

if k * 3 == s:
    print(1)
    exit(0)
else:
    for v in range(k + 1):
        # bisect.bisect_left([i for i in range(2 * k + 1)], s - v)
        for x in range(k + 1):
            if v + x > s:
                continue
            else:
                targ = s - v - x
                # hoge = bisect.bisect_left([i for i in range(k + 1)], targ)
                if targ < 0 or targ > k:
                    pass
                else:
                    ans += 1

print(ans)




Measured memory_bytes: 40796
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#pragma warning( disable:4996 )

int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a%b);

	}
}

int main(void) {
	int n, a[100001];
	int tempgcd;
	scanf("%d", &n);
	scanf("%d", &a[0]);
	tempgcd = a[0];
	for (int i = 1; i < n; i++) {
		scanf("%d", &a[i]);
		if (tempgcd > a[i]) {
			tempgcd = gcd(tempgcd, a[i]);
		}
		else {
			tempgcd = gcd(a[i], tempgcd);
		}
		
	}
	printf("%d\n", tempgcd);
	return 0;
}

Measured memory_bytes: 512
let input = stdin.ReadLine().Split() |> Array.map int
let N = input.[0]
let M = input.[1]

let A = stdin.ReadLine().Split() |> Array.map int
let sum = A |> Array.sum

if ((A |> Array.filter (fun x -> x * 4 * M >= sum) |> Array.length) < M) then "No" else "Yes"
|> printfn "%s"


Measured memory_bytes: 14160
#include <iostream>
#include <string>
#define llint long long
#define mod 1000000007

using namespace std;

llint n;
llint cnt[100005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	llint a, ans = 1;
	for(int i = 1; i <= n; i++){
		cin >> a;
		if(a == 0){
			cnt[1]++;
			continue;
		}
		ans *= cnt[a], ans %= mod;
		cnt[a]--, cnt[a+1]++;
	}
	llint sum = 0;
	for(int i = 1; i <= n; i++) sum += cnt[i];
	if(sum > 3) ans = 0;
	if(sum == 1) ans *= 3, ans %= mod;
	else ans *= 6, ans %= mod;
	cout << ans << endl;
	
	return 0;
}

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

typedef long long ll;

ll binser(ll target) {
	ll res = 0;
	ll lo = 1;
	ll hi = 1e9;
	while(lo <= hi) {
		ll mid = (lo + hi) / 2;
		if(mid * mid <= target) {
			res = mid;
			lo = mid + 1;
		} else hi = mid - 1;
	}
	return res;
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int q;
	cin>>q;
	#define endl '\n'
	while(q--) {
		ll a, b;
		cin>>a>>b;
		if(a > b) swap(a, b);
		ll lower = binser(a * b - 1);
		ll result = 2 * lower;
		if(lower * (lower + 1) >= a * b) result--;
		if(a <= lower) result--;
		if(b <= lower) result--;
		cout<<result<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define ll long long 
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vvvl vector<vector<vector<ll> > >
using namespace std;
int main(void){
    ll n,k; cin>>n>>k;
    ll ans = 0;
    while(n!=0){n/=k; ans++;}
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main() {
	int d, b, c;
	cin >> d >> b>>c;
	int a[13] = { 0,1,2,1,3,1,3,1,1,3,1,3,1 };
	if (a[d] == a[b])cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

using namespace std;

int main()
{
    vector<int> mincnt(26, 100);

    int n;
    cin >> n;

    string s;
    for (int i = 0; i < n;i++)
    {
        cin >> s;
        vector<int> cnt(26, 0);
        for (int j = 0; j < s.length();j++)
        {
            cnt[s[j] - 'a']++;
        }
        for (int i = 0; i < 26;i++)
        {
            mincnt[i] = min(mincnt[i], cnt[i]);
        }
    }

    for (int i = 0; i < 26;i++)
    {
        for (int j = 0; j < mincnt[i];j++)
        {
            cout << char(i + 'a');
        }
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 256
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 2000100;



int main(){
        _
        string s;
        cin >> s;
        sort(all(s));
        for(int i = 0; i<sz(s)-1; i++){
            if(s[i]==s[i+1]){
                cout<<"no"<<endl;
                return 0;
            }
        }
        cout<< "yes" <<endl;


return 0;
}




Measured memory_bytes: 256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <memory>        // unique_ptr, shared_ptr, weak_ptr
#include <cstring>
#include <cmath>

using namespace std;

using ll = long long int;
using vi = vector<int>;
using vvi = vector<vi>;

#define _LIBCPP_DEBUG 0
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
	int a, b, c;
	cin >> a >> b >> c;

	int res = 0;
	if (a == b && a == c && a % 2 == 0) {
		cout << "-1" << endl;
	}
	else{
		while (1) {
			if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) break;

			a /= 2;
			int a1 = a;

			b /= 2;
			int b1 = b;

			c /= 2;
			int c1 = c;

			a = b1 + c1;
			b = a1 + c1;
			c = a1 + b1;

			res++;
		}
		cout << res << endl;
	}

	return 0;
}


Measured memory_bytes: 3132
#include<stdio.h>
int main() {
	int n, m, i, j, k, data[301][301] = {}, a, b,flag;
	scanf("%d%d", &n, &m);
	for (i = 1; i <= m; ++i) {
		scanf("%d%d", &a, &b);
		data[a][b] = 1;
	}
	for (i = 1; i <= n; ++i) {
		for (j = 1; j <= n; ++j) {
			for (k = 1; k <= n; ++k) {
				if (data[j][i] && data[i][k]) data[j][k] = 1;
			}
		}
	}
	for (i = 1; i <= n; ++i) {
		flag = 0;
		for (j = 1; j <= n; ++j) {
			if (i == j) {
				if (flag) printf(" ");
				printf("%d",i); flag = 1;
			}
			if (i != j && data[i][j] && data[j][i]) {
				if (flag) printf(" ");
				printf("%d", j); flag = 1;
			}
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 3096
N = int ( input())
ans = [0]*N
for x in range (1,101):
  for y in range (1,101):
    for z in range (1,101):
      m = (x+y+z)**2-(x*y+y*z+z*x)
      if m <= N:
        ans[m-1] += 1
for i in ans:
  print(i)

Measured memory_bytes: 9324
#include <stdio.h>

#define M 100001
#define N 200000
#define INFTY 1000000000
long long count;

void merge(int A[],int left,int  mid, int  right)
{
	int i,j,k,n1,n2,L[M],R[M];
 	n1 = mid - left;
  	n2 = right - mid;
  
	
	for (i = 0; i<n1; i++) 
	{
		L[i]=A[left+i];
	}
	for(i = 0; i<n2; i++)
	{
		R[i]=A[mid+i];
 
	}

  	L[n1] = INFTY;
  	R[n2] = INFTY;
  	i = 0;
  	j = 0;
  	
	for (k = left; k<right; k++)
	{
		if (L[i] <= R[j]) 
		{
			A[k] = L[i];
      		i++;
		}
    else 
		{
			A[k] = R[j];
      		j++;
			count += n1-i;
		}
	}
}


void mergeSort(int A[],int left,int right)
{
	int mid;
	if (left+1 < right)
	{
    	mid = (left + right)/2;
    	mergeSort(A,left, mid);
    	mergeSort(A,mid, right);
    	merge(A,left, mid, right);
	}
}


int main()
{
	
	int n,i,A[N];
	count = 0;
	scanf("%d",&n);
	for(i = 0; i< n; i++)
	{
		scanf("%d",&A[i]);
	}
	
	mergeSort(A,0,n);
	
	 printf("%ld\n", count);   
	return 0;
}


Measured memory_bytes: 3360
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
	char a[1000];
	bool b=0,c=0;
	int d;
	cin>>a;
	d=strlen(a);
	for(int i=0;i<d;i++){
		if(a[i]=='C'){
			b=1;
		}
		if(a[i]=='F'&&b==1){
			c=1;
			break;
		}
	}
	if(b==1&&c==1){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;

int main() {
	long long n;
	cin >> n;
	for (int i = (int)sqrt(n); i >= 0; i--) {
		if (n % i == 0) {
			cout << i - 1 + n / i - 1 << '\n';
			return 0;
		}
	}
}

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

int main() {
    int n;
    cin >> n;
    vector<int> as(n + 1), bs(n);
    for (int i = 0; i <= n; i++) cin >> as[i];
    for (int i = 0; i < n; i++) cin >> bs[i];
    long long ans = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (bs[i] > as[i + 1]) {
            ans += as[i + 1];
            bs[i] -= as[i + 1];
            if (bs[i] > as[i]) {
                ans += as[i];
                as[i] = 0;
            } else {
                ans += bs[i];
                as[i] -= bs[i];
            }
        } else {
            ans += bs[i];
            as[i + 1] -= bs[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static String I = "IMPOSSIBLE";
	public static String B = "Bad";
	public static String G = "Good";
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		int k = ni();

		long sum = 0l;

		for (int a = 1; a <= k; a++) {
			for (int b = 1; b <= k; b++) {
				for (int c = 1; c <= k; c++) {
					sum += gcd(gcd(a, b), c);
				}
			}
		}
		out(sum);

	}

	/*
	 * 以下メソッド集
	 */
	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static int max(int a, int b) {
		return Math.max(a, b);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static int min(int a, int b) {
		return Math.min(a, b);
	}

	static long min(long a, long b) {
		return Math.min(a, b);
	}
}


Measured memory_bytes: 35808
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int n = Integer.parseInt(str[0]);
		int m = Integer.parseInt(str[1]);

		int a[] = new int[m];
		int b[] = new int[m];

		for (int i = 0; i < m; i++) {
			str = br.readLine().split(" ");
			a[i] = Integer.parseInt(str[0]) - 1;
			b[i] = Integer.parseInt(str[1]) - 1;
		}

		int ans = 0;
		for (int i = 0; i < m; i++) {
			UnionFindTree uf = new UnionFindTree(n);

			for (int j = 0; j < m; j++) {
				if (j != i)
					uf.union(a[j], b[j]);
			}

			int count = 0;
			for (int j = 0; j < n; j++) {
				if (uf.find(j) == j) {
					count++;
				}
			}
			if (1 < count) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}

class UnionFindTree {

	int[] parent;
	int[] rank;

	public UnionFindTree(int size) {
		this.parent = new int[size];
		this.rank = new int[size];

		for (int i = 0; i < size; i++) {
			makeSet(i);
		}
	}

	public void makeSet(int i) {
		parent[i] = i;
		rank[i] = 0; // 集合の高さ
	}

	public void union(int x, int y) {
		int xRoot = find(x);
		int yRoot = find(y);

		// xが属する木の方が大きい場合
		if (rank[xRoot] > rank[yRoot]) {
			parent[yRoot] = xRoot; // yの親をxに更新

		} else if (rank[xRoot] < rank[yRoot]) {
			parent[xRoot] = yRoot;

		} else if (xRoot != yRoot) {
			parent[yRoot] = xRoot;
			rank[xRoot]++; // 同じ高さの木がルートの子として着くから大きさ++;
		}
	}

	// 引数の属する木のルートのidを返す
	public int find(int i) {
		if (i != parent[i]) {
			parent[i] = find(parent[i]);
		}
		return parent[i];
	}

	// 同じ木に属しているか
	public boolean same(int x, int y) {
		return find(x) == find(y);
	}
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define F2(i,a,b) for(int i=a;i<(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define dF2(i,a,b) for(int i=a;i>(b);--i)
#define eF(i,u) for(int i=h[u];i;i=nxt[i])
#define SZ(x) ((int)(x).size())
#define prts(x) return puts(x),0
#define pirtf(x) return printf("%d\n",x),0
#define re return
typedef long long LL;
typedef double ld;
typedef pair<int,int> pii;
inline int Gcd(int X,int Y){return Y?Gcd(Y,X%Y):X;}
inline LL Gcd(LL X,LL Y){return Y?Gcd(Y,X%Y):X;}
inline int Pow(int B,LL E,int M){if(!(B%=M))return 0;int A=1;for(;E;E>>=1,B=(LL)B*B%M)E&1?A=(LL)A*B%M:0;return A;}
inline LL Pow(LL B,LL E,LL M){if(!(B%=M))return 0;LL A=1;for(;E;E>>=1,B=B*B%M)E&1?A=A*B%M:0;return A;}
const int INF=0x3f3f3f3f;

map<int,int> mp;
set<int> st;

int n,q,m,k;
pii a[200005];

int main(){
	scanf("%d%d%d",&n,&m,&k);
	F(i,1,k) scanf("%d%d",&a[i].first,&a[i].second);
	sort(a+1,a+k+1);
	int shx=0;
	F(i,1,k){
		if(a[i].first-shx>a[i].second)
			return printf("%d\n",a[i].first-1),0;
		if(a[i].first-shx==a[i].second)
			++shx;
	}
	printf("%d\n",n);
	return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"

using namespace std;
using ll = long long;

#define endl '\n'

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> dp(3, 0);
    for (int day = 0; day < n; ++day) {
        vector<int> h(3), new_dp(3, 0);
        for (int& x : h) cin >> x;
        for (int i = 0; i < 3; ++i) {
            for (int j = 0; j < 3; ++j) {
                if (i != j) {
                    new_dp[j] = max(new_dp[j], dp[i] + h[j]);
                }
            }
        }
        dp = new_dp;
    }
    cout << *max_element(dp.begin(), dp.end()) << endl;
    return 0;
}

Measured memory_bytes: 3616
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  private static long gcd(long a, long b) {
    if (b == 0L) return a;
    return gcd(b, a % b);
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    int[] a = sc.nextIntArray(n);
    int[] c = new int[1000001];
    for (int ai: a) {
      c[ai]++;
    }
    boolean isPairwiseCoprime = true;
    for (int i = 2; i <= 1000000; i++) {
      int count = 0;
      for (int j = i; j <= 1000000; j += i) {
        count += c[j];
      }
      if (count > 1) isPairwiseCoprime = false;
    }
    if (isPairwiseCoprime) {
      System.out.println("pairwise coprime");
      return;
    }
    long result = a[0];
    for (int i = 1; i < n; i++) {
      result = gcd(result, a[i]);
      if (result == 1L) break;
    }
    if (result == 1L) System.out.println("setwise coprime");
    else System.out.println("not coprime");
  }
}

Measured memory_bytes: 76324
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.15f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto S = RD!string;

	string ans;
	if (S[0] == 'S')
		ans = "Cloudy";
	else if (S[0] == 'C')
		ans = "Rainy";
	else
		ans = "Sunny";

	writeln(ans);
	stdout.flush();
	debug readln();
}

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

using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	set<char> st;
	map<char,int> mp;
	for (char c:s){
		st.insert(c);
		mp[c]++;
	}
	for (auto x : st){
		if (mp[x] != 2){
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = (1e9)+7;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  string s;
  cin>>s;
  int pos = 0;
  ll tot = 0;
  for(int i=0;i<s.length();i++){
  	if(s[i]=='W'){
  		tot+=abs(i-pos);
  		pos++;
  	}
  }
  cout<<tot<<endl;
} 









Measured memory_bytes: 720
#include <stdio.h>

int main(void) {
  char S[4];
  int cnt = 0;

  scanf("%s", S);
  for (int i = 0; i < 3; i++) {
    cnt += S[i] == 'o';
  }
  printf("%d\n", 700 + 100*cnt);

  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
	Scanner scan = new Scanner(System.in);
	int W = scan.nextInt();
	int H = scan.nextInt();
	int x = scan.nextInt();
	int y = scan.nextInt();
	int r = scan.nextInt();
	
	if(0<=x-r && x+r<=W && 0<=y-r && y+r<=H){
		System.out.println("Yes");
	}else{	
	System.out.println("No");
	}
	}


}

Measured memory_bytes: 26256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long N,M;cin >> N>>M;
    long long int ans=0;
    if(N<M/2){
        ans += N;
        M -= 2*N;
        ans += M/4;
    }else{
        ans += (M/2);
    }
    //cout<<ans<<" "<<M/4<<" "<<M<<endl;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <numeric>
#define ll long long
using namespace std;

int main() {
	ll r, d, x;
	cin >> r >> d >> x;
	for (int i = 0; i < 10; i++) {
		x = r * x - d;
		cout << x << endl;
	}
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  int c[n];
  vector<int> a(n);
  
  for(int i=0;i<n;i++){
    cin >> c[i];
  }
  a[0] =0;
  for(int i=1;i<n;i++){
    if(i==1){a[i] = a[0]+abs(c[i]-c[i-1]);
            continue;}else{
    a[i]= min(abs(c[i]-c[i-2])+a[i-2],abs(c[i]-c[i-1])+a[i-1]);}
  }
  cout << a[n-1] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath> //abs();
using namespace std;

int main(void)
{
    long long int a,b,c,d,i,j,k,n,x[10];
    string s1,s2,s3;
    char C[5];

    cin >> s1 >> s2 >> s3;

    cout << (char)(s1.at(0)-32) << (char)(s2.at(0)-32) << (char)(s3.at(0)-32);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
  int MAX_V = 1000000;
  int prime[MAX_V+1];
  int i, k, v;
  for(i = 2; i <= MAX_V; i++) {
      prime[i] = 1;
    }
      for(i = 2; i*i <= MAX_V; i++) {
        if(prime[i]) {
          for(k = 2 * i; k <= MAX_V; k += i) {
            prime[k] = 0;
          }
        }
      }

  while(scanf("%d", &v) != EOF) {
      int s = 0;
      for(int i = 0;i <= v;i++){
        int isprime = prime[i];
        if(isprime){
          s++;
        }
      }
      printf("%d\n",s);
    }

    return 0;
  }

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

int main(void) {
	string S, T;
	cin >> S >> T;
	string ans = "Yes";
	int N = S.size();
	map<char, char> mp, imp;
	for (int i = 0; i < N; ++i) {
		char s = S[i], t = T[i];
		mp[s] = t; imp[t] = s;
	}
	for (int i = 0; i < N; ++i) {
		char s = S[i], t = T[i];
		if (mp.count(s) && mp[s] != t)ans = "No";
		if (imp.count(t) && imp[t] != s)ans = "No";
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
   int n;
   cin >> n;
   vector<int> p(n),q(n);
   rep(i,n) cin >> p[i];
   rep(i,n) cin >> q[i];
   vector<int> a(n);
   rep(i,n) a[i] = i+1;
   
   map<vector<int>, int> mp;
   do {
      mp[a] = mp.size();
   }while (next_permutation(a.begin(),a.end()));
      
   cout << abs(mp[q]-mp[p]) << endl;
   return 0;  
}

Measured memory_bytes: 5248
#include <iostream>
using namespace std;
int main() {
    const int MAX_N = 100, MAX_V = 100, INF = 1000000001;
    int N, W, v[MAX_N], w[MAX_N];
    cin >> N >> W;
    for (int i = 0; i < N; ++i) {
        cin >> v[i] >> w[i];
    }
    int dp[MAX_N + 1][MAX_N * MAX_V + 1];
    fill(dp[0], dp[0] + MAX_N * MAX_V + 1, INF);
    dp[0][0] = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= MAX_N * MAX_V; ++j) {
            if (j < v[i]) {
                dp[i + 1][j] = dp[i][j];
            } else {
                dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
            }
        }
    }
    int res = 0;
    for (int j = 0; j <= MAX_N * MAX_V; ++j) {
        if (dp[N][j] <= W) {
            res = j;
        }
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 7080
gets.chomp.to_i

gets.chomp.split(' ').each{|i|
  ii = i.to_i
  if ii % 2 == 0
    if (ii % 3 != 0) && (ii % 5 != 0)
      puts 'DENIED'
      exit 0
    end
  end
}

puts 'APPROVED'


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
map<int,int> mp;
int main(){
	int N;
	cin>>N;
	rep(i,N){
		int x;
		cin>>x;
		mp[x]++;
	}
	typedef long long ll;
	vector<ll> vc;
	rep(t,2){
		int mx = 0;
		for(auto p:mp){
			if(p.sc>=2) mx = p.fs;
		}
		vc.pb(mx);
		mp[mx] -= 2;
	}
	cout<<vc[0]*vc[1]<<endl;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b) - 1; i >= (a); --i)
#define sz(a) (int)a.size()
#define de(c) cout << #c << " = " << c << endl
#define dd(c) cout << #c << " = " << c << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;

typedef db T;
struct P{
  T x,y; P(){} P(T x,T y):x(x),y(y){}
  P operator - (const P&b) const {return P(x-b.x,y-b.y);}
  P operator + (const P&b) const {return P(x+b.x,y+b.y);}
  T operator * (const P&b) const {return x*b.x+y*b.y;}
  P operator * (const T&k) const {return P(x*k,y*k);}
};
T norm(P a){return a*a;}
P proj(P p,P a,P b){return (b-a)*((p-a)*(b-a)/norm(b-a))+a;}

P a, b, p;

int main() {
	std::ios::sync_with_stdio(0);
	std::cin.tie(0);
	cin >> a.x >> a.y >> b.x >> b.y;
	int q;
	cin >> q;
	cout << setiosflags(ios::fixed);
	cout << setprecision(10);
	while(q--) {
		cin >> p.x >> p.y;
		P r = proj(p, a, b);
		cout << r.x << " " << r.y << endl;
	}
	return 0;
}


Measured memory_bytes: 3320
/*
    ____        __
   / __ \____  / /_  ____ _____ ___
  / /_/ / __ \/ __ \/ __ `/ __ `__ \
 / _, _/ /_/ / / / / /_/ / / / / / /
/_/ |_|\____/_/ /_/\__,_/_/ /_/ /_/
*/
#include<bits/stdc++.h>

typedef long long ll ;

#define X   first
#define Y   second
#define mp  make_pair
#define pii pair<int , int>
#define vec vector
#define vpii vector<pair<int , int>>
#define i_n   int i = 0 ; i< n ; i++
#define cn  int n ; cin>>n
#define file_io freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define cina int a[n] ; for(int i = 0 ; i < n ; i++) cin>>a[i]
#define pb push_back
#define SZ(x) ll(x.size())

using namespace std;
const int maxn = 1000*100+5 ;

int main()
{
	migmig ;
	int n , m ;
	cin>>n>>m ;  
	int x[m] , y[m] ; 
	
	for(int  i = 0 ; i < m ; i ++) cin>>x[i]>>y[i] ; 
	
	sort(x , x+m) ; 
	sort(y , y+m) ; 
	
	cout<<max(0 , y[0] - x[m-1] + 1) ; 
}
//////
////////
///////////



Measured memory_bytes: 1024
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

string s[100];
int pos[100];

string get(string s) {
	string t(s.size(), 'a');
	for (int j = 0; j < s.size(); ++j)
		t[pos[j]] = s[j];
	return t;
}

multiset<uint> ss;

uint geths(string &s) {
	uint hs = 0;
	for (int i = 0; i < s.size(); ++i)
		hs = hs * 239 + s[i];
	return hs;
}

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; ++i)
		cin >> s[i];
	for (int i = 0; i < (1 << m); ++i) {
		if (__builtin_popcount(i) != (m + 1) / 2)
			continue;
		if (!(i & 1))
			continue;
		vector<int> v1, v2;
		for (int j = 0; j < m; ++j) {
			if ((i >> j) & 1) {
				v1.push_back(j);
			}
			else {
				v2.push_back(j);
			}
		}
		do {
			for (int j = 0; j < v1.size(); ++j)
				pos[v1[j]] = j;
			for (int j = 0; j < v2.size(); ++j)
				pos[v2[j]] = v1.size() + j;
			ss.clear();
			int now = 0;
			for (int j = 0; j < n; ++j) {
				string tmp = get(s[j]);
				string tmp2 = tmp;
				reverse(tmp2.begin(), tmp2.end());
				int a = geths(tmp2);
				int b = geths(tmp);
				auto it = ss.find(a);
				if (it != ss.end()) {
					if (a == b)
						--now;
					ss.erase(it);
				}
				else {
					ss.insert(b);
					if (a == b)
						++now;
				}
			}
			if (ss.size() == 0) {
				cout << "YES\n";
				return 0;
			}
			else if (ss.size() == 1) {
				if (now == 1) {
					cout << "YES\n";
					return 0;
				}
			}
		} while (next_permutation(v1.begin(), v1.end()));
	}
	cout << "NO\n";
	return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;

int main() {
    int N; cin >> N;
    map<int, int> A;
    for(int i = 0; i < N; i++) {
        int t; cin >> t; A[t] = i+1;
    }
    for(int i = 0; i< N; i++) {
        cout << A[i+1] << " ";
    }
}

Measured memory_bytes: 5504
/* 44 - 01*/

#include <iostream>
#include <vector>
#include <queue>
using namespace std;

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

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

class NODE{
public:
	int x1;
	int y1;
	int x2;
	int y2;
	int depth;
};

int main(){
	int X,Y,tx,ty,kx,ky;
	bool data[52][52];
	while(cin >> X >> Y , X){
		cin >> tx >> ty >> kx >> ky;
		rep(i,52)rep(j,52)data[i][j] = 1;
		rep(i,Y)rep(j,X){
			cin >> data[1+i][1+j];
		}
		queue<NODE> Q;
		NODE t = {tx,ty,kx,ky,0};
		Q.push(t);
		bool done[52][52][52][52] = {0};
		while(Q.size()){
			NODE q = Q.front();Q.pop();
			if(q.depth >= 100)continue;
			if( done[q.x1][q.y1][q.x2][q.y2] )continue;
			done[q.x1][q.y1][q.x2][q.y2] = true;
			
			if(q.x1 == q.x2 && q.y1 == q.y2){
				cout << q.depth << endl;
				goto end;
			}
			rep(i,4){
				NODE next;
				next.x1 = q.x1 + dx[i];
				next.y1 = q.y1 + dy[i];
				next.x2 = q.x2 - dx[i];
				next.y2 = q.y2 - dy[i];
				next.depth = q.depth + 1;
				if(data[next.y1][next.x1] == 1){
					next.x1 = q.x1;
					next.y1 = q.y1;
				}
				if(data[next.y2][next.x2] == 1){
					next.x2 = q.x2;
					next.y2 = q.y2;
				}
				Q.push(next);
			}
		}
		cout << "NA" << endl;
		end:;	
	}

}

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

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int T; cin >> T;
	while (T--) {
		int N, D;
		cin >> N >> D;
		cout << 127 * (N - 1) + (N % 2 ? D : 127 - D) << '\n';
	}
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K  =sc.nextInt();
		int[] D = new int[K];
		for(int i = 0 ; i < K ; i++) {
			D[i] = sc.nextInt();
		}
		LOOP:while(true) {
			String number = String.valueOf(N);
			int n = number.length();
			N++;
			for(int i = 0 ; i < n ; i++) {
				for(int j = 0 ; j < K ; j++) {
					if(number.charAt(i) == String.valueOf(D[j]).charAt(0)) {
						continue LOOP;
					}
				}
			}
			System.out.println(number);
			return;
		}
	}
}

Measured memory_bytes: 36412
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())
    total = 0
    for a in A:
        total ^= a

    for a in A:
        print(a ^ total)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 110508
#include <iostream>
int main(int argc, char *argv[]) {
  int N;
  std::cin >> N;
  int fx = 0, n = N;
  while (n > 1) {
    fx += n % 10;
    n /= 10;
  }
  fx += n;
  std::cout << ((N % fx == 0) ? "Yes" : "No") << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

int main(void){
  string S;cin >> S;
  int count=0;
  int i;REP(i,S.length()) if(S[i] == 'o') count++;
  count += 15-S.length();
  if(count>=8) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<(int)n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const ld PI = acos(-1.0);

int32_t main(){
	fast;
	int n;
	cin >> n;
	int ok = 1;
	for(int i=0 ; i<n ; i++)
	{
		int a;
		cin >> a;
		if(a %2 == 0)
		{
			if(a %3 != 0&& a%5 !=0)
				ok = 0;
		}
	}
	cout << (ok ? "APPROVED" : "DENIED");
}



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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int K,X; cin>>K>>X;
    int first, last;

    first = X - K + 1;
    last = X + K - 1;

    for (int i = first; i <= last; i++)
        cout << i << (i==last?"\n":" ");
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int a, b;
	char op;

	while (1) {
		scanf("%d %c %d", &a, &op, &b);
		if (op == '?')
			break;

		if (op == '+')
			a += b;
		else if (op == '-')
			a -= b;
		else if (op == '*')
			a *= b;
		else
			a /= b;
		printf("%d\n", a);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL INF = 1LL << 60;
LL a[100], b[100];
LL dp[100][100];

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%lld %lld", &a[i], &b[i]);
	}
	
	for (int i = 0; i < 100; i++){
		for (int j = 0; j < 100; j++){
			dp[i][j] = INF;
		}
		dp[i][i] = 0;
	}
	
	for (int w = 1; w < n; w++){
		for (int l = 0; l + w < n; l++){
			for (int i = l; i <= l + w; i++){
				LL C = a[l] * b[i] * a[i + 1] * b[l + w];
				LL sum = dp[l][i] + dp[i + 1][l + w] + C;
				dp[l][l + w] = min(dp[l][l + w], sum);
			}
		}
	}
	
	printf("%lld\n", dp[0][n - 1]);
	
	return 0;
}

Measured memory_bytes: 1268
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
import bisect
import numpy as np

N = int(input())

maxi_num = 0
ans = 1

def div_count(x):
    num = 0
    while True:
        if x % 2 == 0:
            x /= 2
            num += 1
        else:
            break
    
    return num

for i in range(1, N+1):
    count = div_count(i)
    if maxi_num < count:
        maxi_num = count
        ans = i

print(ans)


Measured memory_bytes: 12100
using System;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] busket = new int[101];
        for (int i = 0; i < n; i++)
            busket[int.Parse(Console.ReadLine())]++;
        int ans = 0;
        for (int i = 1; i < 101; i++)
        {
            if (busket[i] > 0) ans++;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
ans = []
while True:
    n,x = map(int,input().split())
    if n == 0 and x == 0: break
    cnt = 0
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                if i + j + k == x: cnt += 1
    ans.append(cnt)
print("\n".join(map(str,ans)))


Measured memory_bytes: 5604
n=int(input())
d,x=map(int,input().split())
a=list(int(input())for i in range(n))
ans=0
def f(x):
    num=0
    count=0
    i=0
    while num<=d:
        num=i*x+1
        i+=1
        count+=1
    return count-1
for i in range(n):
    ans+=f(a[i])
print(ans+x)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;

        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var t = Console.ReadLine();
            var ans = "Yes";

            for(int i = 0; i < s.Length; i++)
            {
                if (s[i] != t[i]) ans = "No";
            }
            
            
            Console.WriteLine(ans);



        }






    





        static public long Input()
        {
            return long.Parse(Console.ReadLine());
        }

        static public string[] Input2()
        {
            return Console.ReadLine().Split();
        }
        
        static public long[] Input3()
        {
            string[] data = Console.ReadLine().Split();
            long[] res = new long[data.LongLength];
            for(long i = 0; i < data.LongLength; i++)
            {
                res[i] = long.Parse(data[i]);
            }
            return res;
        }
        public static long Choose(long n, long a)
        {
            long x = 1;
            long y = 1;
            for (long i = 0; i < a; i++)
            {
                x *= n - i;
                y *= i + 1;
            }
            return x / y;
        }

        public static long Gcd(long a, long b)
        {
            long x = Math.Max(a, b);
            long y = Math.Min(a, b);
            if (x % y == 0) return y;
            else return Gcd(y, x % y);
        }
    }
}


Measured memory_bytes: 25880
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;
 
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string N;
    cin >> N;
    if(N[0] == N[2]){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

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

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

class UF {
	public:
	static const int ufmax=100052;
	int ufpar[ufmax],ufrank[ufmax],ufcnt[ufmax];
	UF() { init();}
	void init(){int i; rep(i,ufmax) { ufpar[i]=i; ufrank[i]=0; ufcnt[i]=1; } }
	int find(int x) {	return (ufpar[x]==x)?(x):(ufpar[x] = find(ufpar[x]));}
	int operator[](int x) {return find(x);}
	int count(int x) {return ufcnt[find(x)];}
	void unite(int x,int y) {
		x = find(x); y = find(y);
		if(x==y) return;
		if(ufrank[x]<ufrank[y]) ufpar[x]=y, ufcnt[y]+=ufcnt[x];
		else {ufpar[y]=x; ufcnt[x]+=ufcnt[y]; if(ufrank[x]==ufrank[y]) ufrank[x]++;}
	}
};



void mainmain(){
	int n,m;
	cin>>n>>m;
	UF uf;
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		uf.unite(a,b);
	}
	set<int> se;
	int a,b=0;
	rep(i,n){
		if(i==uf[i]) b++;
		else se.insert(uf[i]);
	}
	a=se.size();
	b-=a;
	cout<<abs(a-b)<<endl;
	// cout<<a<<" "<<b<<endl;
	// cout<<abs((int)se.size()-(n-(int)se.size()))<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 4372
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
 		Scanner scanner = new Scanner(System.in);
 		int K = scanner.nextInt();
 		int[] x = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
 		System.out.println(x[K - 1]);
 	}
}

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

b = [0]*n
r = [0]*n
index = 0
for i in range(1,n+1) :
    if b[a[index]-1] != 0 :
        break
    b[a[index]-1] = i
    index = a[index] - 1

for i in range(1,n+1) :
    if r[a[index]-1] != 0 :
        break
    r[a[index]-1] = i
    index = a[index] - 1

maxb = max(b)
maxr = max(r)
if k <= maxb :
    print(b.index(k)+1)
else :
    k = k - maxb
    if k%maxr == 0 :
        print(r.index(maxr)+1)
    else :
        print(r.index(k%maxr)+1)

Measured memory_bytes: 100080
#include<bits/stdc++.h>
using namespace std;
const int N=100010;
typedef long long ll;
struct data{ll x,v;}t[N];
ll a[N],b[N],c[N],d[N];
inline bool cmp(const data &A,const data &B) {
    return A.x<B.x;
}
int main(){
    int n;
    ll C,ans=0;
    cin>>n>>C;
    for(int i=1;i<=n;i++)
	scanf("%lld%lld",&t[i].x,&t[i].v);
    sort(t+1,t+n+1,cmp);
    ll sum=0;
    for(int i=1;i<=n;i++) {
	sum=sum+t[i].v;
	a[i]=max(a[i-1],sum-t[i].x);
	b[i]=max(b[i-1],sum-t[i].x*2);
    }
    sum=0;
    for(int i=n;i;i--) {
	sum=sum+t[i].v;
	c[i]=max(c[i+1],sum-(C-t[i].x));
	d[i]=max(d[i+1],sum-(C-t[i].x)*2);
    }
    for(int i=1;i<=n;i++) {
	ans=max(ans,max(a[i],c[i]));
	ans=max(ans,a[i-1]+d[i]);
	ans=max(ans,b[i-1]+c[i]);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 4992
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    if (n == 0) {
      pw.println(0);
      return;
    }
    pw.println((1000 - (n % 1000)) % 1000);
  }
}


Measured memory_bytes: 35576
line = gets.chomp!
/(\d+)\s*(\d+)/ =~ line
N = $1.to_i
Q = $2.to_i

S = gets.chomp!

tar=S.split("")
array=[0]

count=0
for cnt in 1..(N-1) do
  if (tar[cnt-1]=='A' and tar[cnt]=='C') then
    count += 1
  end
  array.push(count)
end

for cnt in 1..Q do
  line = gets.chomp!
  /(\d+)\s*(\d+)/ =~ line
  l = $1.to_i 
  r = $2.to_i
  puts array[r-1]-array[l-1]
  
end


Measured memory_bytes: 12308
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <string>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main()
{
	int n;
	scanf("%d",&n);
	int T=n;
	while(T%2==0) T/=2;
	if(T==1) puts("No");
	else
	{
		puts("Yes");
		int z=n;
		if(z%2==0) z--;
		for(int i=2;i<=z;i+=2)
		{
			printf("%d %d\n",1,i);
			printf("%d %d\n",i,i+1);
			printf("%d %d\n",1,n+i+1);
			printf("%d %d\n",n+i+1,n+i);
		}
		printf("%d %d\n",n+1,3);
		if(n%2==0)
		{
			for(int i=20;i>=0;i--)
			{
				if(n>>i&1)
				{
					int A=(1<<i),B=n-A;
					printf("%d %d\n",A,n);
					printf("%d %d\n",B+n+1,2*n);
					break;
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;

int main(){
    ll a,b;
    cin>>a>>b;
    if(a*b%2==0){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 256
r1 = []
r2 = []
r3 = []
r4 = []
for i in range(3):
    a,b = map(int,input().split())
    if a == 1:
        r1.append(b)
    elif a == 2:
        r2.append(b)
    elif a == 3:
        r3.append(b)
    else:
        r4.append(b)

    if b == 1:
        r1.append(a)
    elif b == 2:
        r2.append(a)
    elif b == 3:
        r3.append(a)
    else:
        r4.append(a)
if len(r1) <= 2 and len(r2) <= 2 and len(r3) <= 2 and len(r4) <= 2:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3064
#include <stdio.h>

int fact(void);
void factor(void);
int hit1(void);
int blow1(void);

int a[4],b[4],hit,blow,i,j;

int main(){
  int c;

  while(1){
    hit = 0;
    blow = 0;
    c = fact();
    if(c == 0)
      break;
    factor();
    hit1();
    blow1();
    printf("%d %d\n",hit,blow);
  }
  return 0;
}
int fact(void)
{
  int i;

  for(i = 0 ; i < 4 ; i++){
    if(scanf("%d",&a[i]) == EOF)
      return 0;
  }
  return 1;
}
void factor(void)
{
  int i;

  for(i = 0 ; i < 4 ; i++){
    scanf("%d",&b[i]);
  }
}
int hit1(void)
{
  for(i = 0 ; i < 4 ; i++){
    for(j = 0 ;j < 4 ; j++){
      if(a[i] == b[j] && i == j)
	hit++;
    }
  }
  return hit;
}
int blow1(void)
{
  for(i = 0 ; i < 4 ; i++){
    for(j = 0 ;j < 4 ; j++){
      if(a[i] == b[j] && i != j)
	blow++;
    }
  }
  return blow;
}

Measured memory_bytes: 596