akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int a = sc.nextInt();
                int b = sc.nextInt();
                int c = sc.nextInt();
                sc.close();
                if(a <= c && c <= b){
                        System.out.println("Yes");
                }else{
                        System.out.println("No");
                }
        }
}
//フォロー推奨:@dt_want_to_dt

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,a) for(int i = 0; i < (a); ++i)

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int UI;

using namespace std;


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
	int n, a, b;
	cin >> n >> a >> b;

	if (n * a > b)
	{
		cout << b << endl;
	}
	else
	{
		cout << n * a << endl;
	}

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int swich(char);
int main()
{
	char x, y;
	int X = 0, Y = 0;
	cin >> x >> y;
	X = swich(x);
	Y = swich(y);

	if (X < Y)
		cout << "<" << endl;

	else if (X > Y)
		cout << ">" << endl;

	else
		cout << "=" << endl;

}
int swich(char s)
{
	int X = 0;
	switch (s)
	{
	case 'A':
		X = 10;
		break;
	case 'B':
		X = 11;
		break;
	case 'C':
		X = 12;
		break;
	case 'D':
		X = 13;
		break;
	case 'E':
		X = 14;
		break;
	case 'F':
		X = 15;
		break;
	}
	return X;
}

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

int main() {
  int a,b;
  cin >> a >> b;
  if ((a+b)%2 == 0) {
    cout << (a+b)/2 <<endl;
  }
  else{
    cout << (a+b+1)/2 << endl;
  }
}



Measured memory_bytes: 256
/*
ABHIJEET BISWAS
CSE 4th SEM 
MNNIT ALLAHBAD
*/

#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF (int )1e18
#define ll long long
#define ld long double
#define pii pair<int,int>
#define pli pair<long long,int>
#define pll pair<long long,long long>
#define MAX 1000009
#define pb push_back
#define mp map<int,int>
#define f first
#define s second
#define popi __builtin_popcount
#define popll __builtin_popcountll
#define grp vector<int> graph[MAX];
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ld pi=2.0*acos(0.0);
int dp[10004][102][2];
string in;
int n,d;
int solve(int id,int rem,int m)
{
	if(id>=n)
	{
		if(rem==0)
		return 1;
		return 0;
	}
	int &curr=dp[id][rem][m];
	if(curr!=-1)
	return curr;
	curr=0;
	if(m)
	{
		for(int i=0;i<=in[id]-'0';i++)
		{
			if(i==in[id]-'0')
				curr=(curr+solve(id+1,(rem+i)%d,1))%MOD;
			else
				curr=(curr+solve(id+1,(rem+i)%d,0))%MOD;
		}
	}
	else
	{
		for(int i=0;i<=9;i++)
		curr=(curr+solve(id+1,(rem+i)%d,0))%MOD;
	}
	return curr;
}
int main() {
	fastIO
	cin>>in>>d;
	n = in.size();
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<d;j++)
		for(int k=0;k<2;k++)
		dp[i][j][k]=-1;
	}
	cout<<(solve(0,0,1)+MOD-1)%MOD<<endl;
	return 0;
}

Measured memory_bytes: 9088
/*
    @uthor: Amit Kumar
    user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll    long long
#define ld    long double
#define ull   unsigned long long
#define endl "\n"
ll google_itr = 1;
#define google(x) cout<<"Case #"<<x<<":"
#define pi 3.14159265358979323846264338327950L

const ll mod = 1e9+7;
const ll inf = 1e18;

ll popcount(ll num){
    num = num - ((num >> 1) & 0x55555555);
    num = (num & 0x33333333) + ((num >> 2) & 0x33333333);
    return ((num + (num >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}

vector<pair<ll,ll>> factor_arr;

void myfactor(ll num){ 
    ll count = 0;   
    while (!(num % 2)) { 
        num >>= 1; count++; 
    }  
    if (count) factor_arr.push_back({2,count}); 
    for (auto i = 3; i <= sqrt(num); i += 2) { 
        count = 0; 
        while (num % i == 0) { 
            count++; 
            num /= i; 
        } 
        if (count) factor_arr.push_back({i,count}); 
    } 
    if (num > 2) factor_arr.push_back({num,1});
}

void virus(){
        string s;
        cin>>s;
        ll cnt = 0;
        vector<ll> arr;
        for(auto i:s){
            if(i == 'R') cnt += 1;
            else{
                arr.push_back(cnt); cnt = 0;
            }
        }
        arr.push_back(cnt);
        cout<<*max_element(arr.begin(),arr.end());
}


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

    ll t = 1;
    //cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
         //cout << "Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int W[1010],S[1010],V[1010];
pair<int,int> P[1010];

ll from[10101];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) {
		cin>>W[i]>>S[i]>>V[i];
		P[i]={W[i]+S[i],i};
	}
	sort(P,P+N);
	ll ma=0;
	FOR(i,N) {
		j=P[i].second;
		for(x=S[j];x>=0;x--) {
			ll v=from[x]+V[j];
			ma=max(ma,v);
			if(x+W[j]<=10000) from[x+W[j]]=max(from[x+W[j]],v);
		}
	}
	cout<<ma<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int n=s.length();
  string ans="Yes";
  for(int i=0;i<n;i++){
    if(s[i]!=s[n-1-i])ans="No";
  }
  for(int i=0;i<n/2;i++){
    if(s[i]!=s[n/2-1-i])ans="No";
  }
  for(int i=0;i<n/2;i++){
    if(s[i+(n+1)/2]!=s[n-1-i])ans="No";
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int c,q,i,j,z=0,k=1,m[1001][1001]={0},e[6][2]={0};
  for(i=0;i<6;i++){
    cin>>q>>c;
    if(q>c)m[q][c]++;
    else m[c][q]++;
  }
  for(i=0;i<1001;i++)for(j=0;j<1001;j++){
    if(m[i][j]){
      if(m[i][j]==6||m[i][j]==4)for(c=0;c<m[i][j]/2;c++){e[z][0]=i;e[z++][1]=j;}
      else {e[z][0]=i;e[z++][1]=j;}
    }
  }
  if(e[0][0]!=e[2][1]||e[1][0]!=e[2][0]||e[0][1]!=e[1][1])k=0;
  if(k)cout<<"yes"<<endl;
  else cout<<"no"<<endl;
}

Measured memory_bytes: 7004
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int m = scan.nextInt();
		boolean check = false;
		int num = 0;

		ArrayList<HashSet<Integer>> list = new ArrayList<HashSet<Integer>>(n);

		for(int i = 0;i < n;i++) {
			list.add(new HashSet<Integer>());
		}

		for(int i = 0;i < m;i++) {
			list.get(scan.nextInt() - 1).add(scan.nextInt());
		}

		if(m != 0) {
			for(int i = 0;i < n;i++) {
				if(list.get(0).contains(0)) {
					if(n != 1) {
						check = true;
						break;
					}
				}
				if(list.get(i).size() > 1) {
					check = true;
					break;
				}
			}

			if(check) {
				System.out.println(-1);
			}else {
				for(int i = 0;i < n ;i++) {
					if(list.get(i).isEmpty()) {
						if(i == 0) {
							num += 1 * Math.pow(10, n - 1);
						}

					}else {
						for (int a : list.get(i)) {
							num += a * Math.pow(10, n - 1 - i);
						}
					}
				}
				System.out.println(num);
			}
		}else {
			if(n == 1) {
				System.out.println(0);
			}else {
				num = (int) (1 * Math.pow(10, n - 1));
				System.out.println(num);
			}
		}
	}
}

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

b = 1 << 50
x = 0

for i in range(50):
    b = b >> 1

    if x + b > k:
        continue

    cnt = 0

    for j in a:
        if j & b:
            cnt += 1

    if cnt < len(a) / 2:
        x += b

ans = 0
for i in a:
    ans += i ^ x

print(ans)

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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int mod = 1e9+7;
const int maxn = 1e5+5;
VI G[maxn];

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n,k;
    while (cin >> n >> k) {
        FOR(i,1,n+1)
            G[i].clear();
        FOR(i,0,n-1) {
            int a,b; cin >> a >> b;
            G[a].push_back(b);
            G[b].push_back(a);
        }
        typedef tuple<int,int,int,int> node;
        queue<node> Q; Q.push(node(1,0,0,0));
        LL ans = 1;
        while (Q.size()) {            
            int u,p,d,c; tie(u,p,d,c) = Q.front(); Q.pop();
            int x = k-min(2,d)-c;
            ans *= x;
            ans %= mod;
            int i = 0;
            FOR_ALL(v,G[u]) if (p != *v) 
                Q.push(node(*v,u,d+1,i++));
        }
        cout << ans << endl;
    }
    return 0;
}


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

using namespace std;

int a,b;

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

	cin >> a >> b;
	int ans = -1;
	for (int i=1;i<=1000000;i++)
		if (i*8/100 == a && i*10/100 == b)
		{
			ans = i;
			break;
		}
	cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<<#X<<": "<<X<<" ";
#define ARDEB(i,X) cout<<#X<<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(X) {}
#define END {}
#endif
using namespace std;
int p,w,g,y;
int main(){ 
	int a;
	char s[110];
	cin>>a;
	for(int i=0;i<a;i++){
		cin>>s[i];
	}
	for(int i=0;i<a;i++){
		if(s[i]=='P')p=1;
		if(s[i]=='W')w=1;
		if(s[i]=='G')g=1;
		if(s[i]=='Y')y=1;
	}
	DEB(p)END DEB(w)END DEB(g)END DEB(y)END
	if(p+w+g+y==4)cout<<"Four"<<endl;
	else cout<<"Three"<<endl;
		return 0;
}


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

int main() {
  string S;
  cin >> S;
  
  if (S == "Sunny") {
    cout << "Cloudy" << endl;
  }
  
  else if (S == "Cloudy") {
    cout << "Rainy" << endl;
  }
  
  else {
    cout << "Sunny" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
#include <chrono>
#include <random>
#include <ctime>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ld PI = 3.14159265358979323846;
const ll MOD = 998244353;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	srand(time(0));
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	string s;
	cin >> n >> m >> s;
	n++;
	vector<int> dp(n, INT32_MAX), pred(n, -1);
	dp[0] = 0;
	set<pair<int, int>> mins;
	mins.insert({ 0, 0 });
	for (int i = 1; i < n; i++) {
		if (i >= m + 1) {
			mins.erase({ dp[i - m - 1], i - m - 1 });
		}
		if (s[i] == '1') {
			dp[i] = INT32_MAX;
			mins.insert({ INT32_MAX, i });
		}
		else {
			if (mins.begin()->first != INT32_MAX) {
				dp[i] = mins.begin()->first + 1;
				pred[i] = mins.begin()->second;
			}
			mins.insert({ dp[i], i });
		}
	}
	if (dp[n - 1] == INT32_MAX) {
		cout << -1;
	}
	else {
		vector<int> ans;
		for (int i = n - 1; pred[i] != -1; i = pred[i]) {
			ans.push_back(i - pred[i]);
		}
		for (int i = ans.size() - 1; i >= 0; i--) {
			cout << ans[i] << " ";
		}
	}
}

Measured memory_bytes: 8672
[A,B] = list(map(int,input().split()))
X = B-A

if A%2 == 0:
    if X%4 ==1:
        out=1
    elif X%4 ==2:
        out=1^B
    elif X%4 ==3:
        out=0
    else:
        out=B

else:
    if X%4 ==1:
        out=A^B
    elif X%4 ==2:
        out=A^1
    elif X%4 ==3:
        out=A^B^1
    else:
        out=A

print(out)


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

typedef long long ll;

int main()
{
	int n, q, c, a, b;
	scanf("%d%d", &n, &q);
	fenwick_tree<ll> fw(n);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a);
		fw.add(i, a);
	}
	while (q--) {
		scanf("%d%d%d", &c, &a, &b);
		if (c) {
			printf("%lld\n", fw.sum(a, b));
		}
		else {
			fw.add(a, b);
		}
	}
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  ll n;
  cin >> n;
  int ans= 0;
  // c = n - a*b
  // 1 <= n - a*b
  // a*b <= n-1
  for(int a = 1; a <= (n-1); ++a)
  {
    ans += (n - 1) / a;
  }

  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3576
import java.util.*;
public class Main {
    public static int[] accumulate (int[] array) {
  	//累積和
    for (int i=1; i<array.length; i++) {
    	array[i] += array[i-1];
    }
        return array;
    }
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int N = sc.nextInt(), Q = sc.nextInt();
	    String S = sc.next();
	    int[] numArray = new int [N];
	    for (int i=0; i<N-1; i++) {
	        numArray[i+1] = (S.substring(i,i+2).equals("AC"))? 1: 0;
	    }
	    int[] sumArray = accumulate(numArray);
	    for (int q=0; q<Q; q++) {
	        int l = sc.nextInt()-1, r = sc.nextInt()-1;
	        int ans = sumArray[r] - sumArray[l];
	        System.out.println(ans);
	    }
	}
}

Measured memory_bytes: 67696
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)

	buttons := make([]int, N)
	for i := range buttons {
		var a int
		fmt.Scan(&a)
		buttons[i] = a - 1
	}

	count := -1
	rightButtonIndex := 0
	for i := 0; i < N; i++ {
		rightButtonIndex = buttons[rightButtonIndex]
		if rightButtonIndex == 1 {
			count = i + 1
			break
		}
	}

	fmt.Println(count)
}


Measured memory_bytes: 7168
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    double num,ans;
    cin>>ans;
    ans/=100000;
    for(int i=1;i<n;i++){
        cin>>num;
        num/=100000;
        ans+=num;
    }
    ans/=n;
    int kawa=ans*100000;
    cout<<kawa<<endl;
}

Measured memory_bytes: 1228
#include<iostream>
#include<map>
#include<string>
#include<algorithm>

using namespace std;
int main(void){
    int n;
    std::cin >> n;
 
    std::map<string, int> mp;
    for (int i = 0; i < n; i++){
        string s;
        cin >> s;
        
        sort(s.begin(), s.end());
        mp[s]++;
    }
    
    long long ans = 0; 
    for (auto p : mp){
        int temp = p.second;
        ans += (long long) temp * (temp-1) / 2;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11136
//#include "oj/atcoder.h"
//#include "std.h"
#include <stdlib.h>
#include <stdbool.h>
#include <limits.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <assert.h>
#include <float.h>

#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define SWAP(T,a,b) do { T _tmp=a; a=b; b=_tmp; } while (0)

//#include "oj/io.h"

void print_ai(int *a, int n) {
	for (int i=0; i<n; i++) {
		if (i) printf(" ");
		printf("%d", a[i]);
	}
	printf("\n");
}

void scan_ai(int *a, int n) {
	for (int i=0; i<n; i++)
		scanf("%d", &a[i]);
}

//#include "oj/debug.h"

void print_hr() {
	printf("---------------------------\n");
}




#define MAXN 200000

int main() {
	char s[MAXN+1];
	long ct[26];
	while (scanf("%s", s)==1) {
		memset(ct, 0, sizeof(ct));
		for (int i=0; s[i]; i++)
			ct[s[i]-'a']++;
		long r = 1;
		for (int i=0; i<26; i++)
			for (int j=i+1; j<26; j++)
				r += ct[i] * ct[j];
		printf("%ld\n", r);
	}
}



Measured memory_bytes: 384
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> vec(n);
    for (int i = 0;i < n; i++){
        cin >> vec.at(i);
    }
    sort(vec.begin() , vec.end() , greater<int>());
    long long ans = 0;
    if (n%2 == 0){
        for(int i=0; i < n/2 ;i++){
            ans += vec.at(i)*2;
        }
    }
    else{
        for(int i=0; i < (n+1)/2 ;i++){
            ans += vec.at(i)*2;
        }
        ans -= vec.at(-1 + (n+1)/2);
    }
    ans -= vec.at(0);
    cout << ans << endl;
}

Measured memory_bytes: 4060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, d, x;
    cin >> n >> d >> x;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int ans = x;
    rep(i, n){
        int day = 1;
        while(day <= d){
            ans++;
            day += a[i];
        }
    }
    cout << ans << endl;
}

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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 1000000000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

int main(){
 ll N,M;cin >> N >> M;
 ll cnt[100010];
 bool frags[100010];
 fill(cnt,cnt+100010,1);
 frags[0] = 1;
 for(int  i = 0;i < M;i++){
   int x,y;cin >> x >> y;
   x--;y--;
   cnt[x]--;cnt[y]++;
   if(frags[x]){
     frags[y] = true;
   }
   if(cnt[x] == 0){
     frags[x] = false;
   }
 }
 int ans = 0;
 for(int i = 0;i < N;i++){
   if(frags[i]){
     ans++;
   }
 }
 cout << ans << endl;
}

Measured memory_bytes: 1152
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let x: usize = iterator.next().unwrap().parse().unwrap();
    let y: usize = iterator.next().unwrap().parse().unwrap();

    let ans = x + y / 2;
    return ans.to_string();
}


Measured memory_bytes: 2112
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);

int main() {
    // source
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    if (a[2] == a[0] + a[1]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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


Measured memory_bytes: 764
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		char map[] = new char[256];
		while (true)
		{
			int n = sc.nextInt();
			if (n == 0) break;
			for (int i = 0; i < 256; i++)
			{
				map[i] = (char) i;
			}
			for (int i = 0; i < n; i++)
			{
				map[(int)sc.next().charAt(0)] = sc.next().charAt(0);
			}
			int m = sc.nextInt();
			for (int i = 0; i < m; i++)
			{
				System.out.print(map[sc.next().charAt(0)]);
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  string a;
  cin>>a;
  ll b=a.size();
  vector<ll>vec(b);
  for(ll i=0;i<b;i++){
    for(ll j=i;j<b;j++){
      if(a.at(j)!='A'&&a.at(j)!='T'&&a.at(j)!='C'&&a.at(j)!='G'){
        break;
      }
      vec.at(i)+=1;
    }
  }
  sort(vec.begin(),vec.end());
  cout<<vec.at(b-1)<<endl;
    
  return 0;
}


Measured memory_bytes: 3636
//
//  main.cpp
//  E
//
//  Created by Vadim Zakharenko on 29/07/2017.
//  Copyright © 2017 Vadim Zakharenko. All rights reserved.
//

#include <iostream>
#include <memory.h>
#include <cstdio>
#include <algorithm>

using namespace std;

long long a[111];
int n;

int main(int argc, const char * argv[]) {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    long long ans = 0;
    for(;;) {
        long long iter = 0;
        for (int i = 1; i <= n; i++) {
            iter += a[i] / n;
        }
        ans += iter;
        for (int i = 1; i <= n; i++) {
            long long old_a = a[i];
            a[i] %= n;
            a[i] += iter - old_a / n;
        }
        if (*max_element(a + 1, a + n + 1) < n) {
            break;
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
import itertools

tako = input()
oishisa = [int(n) for n in input().split()]

tako_list = [int(n) for n in range(1, int(tako)+1)]
hutatoori = list(itertools.combinations(tako_list, 2))

result = sum([oishisa[toori[0]-1]*oishisa[toori[1]-1] for toori in hutatoori])
print(result)

Measured memory_bytes: 3188
using System;

namespace AtCoder.Common {
    class Dxxx {
        static void Main() => Solve();

        static void Solve() {
            var a = ReadInt();
            if (a == 1) {
                WriteAnswer("Hello World");
            } else {
                WriteAnswer(ReadInt() + ReadInt());
            }
        }

        static string ReadString() => Console.ReadLine().Trim();
        static int ReadInt() => int.Parse(ReadString());
        static long ReadLong() => long.Parse(ReadString());
        static float ReadFloat() => float.Parse(ReadString());
        static double ReadDouble => double.Parse(ReadString());

        static string[] ReadStringArray() => ReadString().Split(' ');
        static int[] ReadIntArray() => Array.ConvertAll(ReadString().Split(' '), int.Parse);
        static long[] ReadLongArray() => Array.ConvertAll(ReadString().Split(' '), long.Parse);
        static float[] ReadFloatArray() => Array.ConvertAll(ReadString().Split(' '), float.Parse);
        static double[] ReadDoubleArray() => Array.ConvertAll(ReadString().Split(' '), double.Parse);

        static T TypeConversion<T>(string s) {
            if (typeof(T) == typeof(int)) {
                return (T) Convert.ChangeType(int.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(long)) {
                return (T) Convert.ChangeType(long.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(double)) {
                return (T) Convert.ChangeType(double.Parse(s), typeof(T));
            } else {
                return (T) Convert.ChangeType(s, typeof(T));
            }
        }

        static void ReadMulti<T, U>(out T a, out U b) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
        }

        static void ReadMulti<T, U, V>(out T a, out U b, out V c) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
            c = TypeConversion<V>(str[2]);
        }

        static void WriteAnswer(object ans) => Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
#include<iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	int a;
	a = n / 1000;
	int b;
	b = (n - 1000 * a) / 100;
	int c;
	c = (n - 1000 * a - 100 * b) / 10;
	int d;
	d = n - 1000 * a - 100 * b - 10 * c;
	if (a + b + c + d == 7) {
		cout << a<<"+"<<b<<"+"<<c<<"+"<<d<<"="<<"7" << endl;
	}
	else if (a + b + c - d == 7) {
		cout << a << "+" << b << "+" << c << "-" << d << "=" << "7" << endl;
	}
	else if (a + b - c + d == 7) {
		cout << a << "+" << b << "-" << c << "+" << d << "=" << "7" << endl;
	}
	else if (a - b + c + d == 7) {
		cout << a << "-" << b << "+" << c << "+" << d << "=" << "7" << endl;
	}
	else if (a + b - c - d == 7) {
		cout << a << "+" << b << "-" << c << "-" << d << "=" << "7" << endl;
	}
	else if (a - b - c + d==7) {
		cout << a << "-" << b << "-" << c << "+" << d << "=" << "7" << endl;
	}
	else if (a - b + c - d == 7) {
		cout << a << "-" << b << "+" << c << "-" << d << "=" << "7" << endl;

	}
	else if (a - b - c - d == 7) {
		cout << a << "-" << b << "-" << c << "-" << d << "=" << "7" << endl;
	}
}

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

#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 1000000007
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define pii pair<int,int> 
#define pll pair<ll,ll> 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int> 
#define vll vector<ll>
#define all(c) c.begin(),c.end()
#define tr(it,c) for( typeof(c.begin()) it = c.begin() ; it!=c.end() ; it++)

ll modulo(ll num){ return ((num%mod)+mod)%mod;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),mod-2,MOD); }

int main()
{
    boost;
    
    ll i,n,sum,exor,j,ans = 0  ; 
    
    cin>>n;
    
    int a[n+10]; a[n]=0;
    sum = exor = j=0;
    for(i=0;i<n;i++) cin>>a[i];
    for(i=0;i<n;i++)
    {
        for(;j<=n;j++)
        {
            sum+=a[j];
            exor^=a[j];
            if(j==n or sum!=exor)
            {
              //  cout<<i<<" "<<j<<endl;
                ans += (j-i) ; 
                sum-=a[i];sum-=a[j];
                exor^=a[i];exor^=a[j];
                break;
            }
        }
    }
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
N = int(input())  # 1 <= N <= 100
b = 1 
for i in range(25):  # the limit 4 * 25 = 100
    b |= b << 4
for i in range(15):  # the limit 7 * 15 = 105
    b |= b << 7
ans = "Yes" if (b >> N) & 1 else "No"
print(ans)  

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

int main() {
  int N; cin >> N;
  bool ans = false;
  string s;
  for (int i = 0; i < N; i++) {
    cin >> s;
    if (s == "Y") {
      ans = true;
    }
  }
  if (ans) {
    cout << "Four" << endl;
  }
  else {
    cout << "Three" << endl;
  }
}


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

#include <cstdlib>  // abs() for integer 絶対値求めやつ

#include <cmath>    // abs() for float, and fabs()

#include <algorithm>
#include <vector>
#define rep(i,n) for(int i = 0; i< (n);i++)

#define SORT(a) sort((a).begin(),(a).end());

#define che(a,string) cout<<string<<":"<<(a)<<endl;

#define ch(a,string) cout<<string<<":"<<(a)<<" ";

using namespace std;

typedef pair<int,int> P;

int main(){
	string s ; 
	cin >> s ;
	int ans =0;
	rep(i,4){
	  if(s.at(i)=='+'){
		  ans ++;
		}
		else{
			ans--;
		  }
		  }
		  cout<<ans<<endl;
	  }




Measured memory_bytes: 256
mod=10**9+7

def framod(n, mod, a=1):
  for i in range(1,n+1):
    a=a * i % mod
  return a
  
def power(n, r, mod):
  if r == 0: return 1
  if r%2 == 0:
    return power(n*n % mod, r//2, mod) % mod
  if r%2 == 1:
    return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
  a=framod(n, mod)
  b=framod(k, mod)
  c=framod(n-k, mod)
  return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod
  
X, Y=map(int, input().split())
a=round(-X/3+2*Y/3, 6)
b=round(2*X/3-Y/3, 6)
if not (a.is_integer() and b.is_integer() and a>=0 and b>=0):
  print(0)
else:
  print(comb(int(a+b), int(a), mod))


Measured memory_bytes: 39152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false

	
int main(void){
    int X,N,a;
    vector<int> P;
    cin >> X >> N;
    REP(i,N){
        cin >> a;
        P.push_back(a);
    }
    vector<int> Q(114,0);
    REP(i,N){
        Q[P[i]]=1;
    }
    int Ans=0;
    for(int x=-10;x<=110;x++){
        if(x<0 || Q[x]==0){
            if(abs(Ans-X)>abs(x-X)){
                Ans=x;
            }
        }
    }
    cout << Ans << endl;
    
    return 0;
}



Measured memory_bytes: 3628
#include<cstdio>
#include<string>
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdlib>

using namespace std;

vector<string> res;
int flag[50],flag2[50],len;
string str;
void Enc(int x){
		if(x==-1){
			for(int i=0;i<26;i++)if(flag[i]>=1 && flag2[i]==0)return;
			res.push_back(str);
		}
		else{
			if(str[x]<'z' && flag2[str[x]+1-'a']==0){
				str[x]++;
				flag2[str[x]-'a']=1;
				Enc(x-1);
				flag2[str[x]-'a']=0;
				str[x]--;
			}
			if(flag2[str[x]-'a']>=1)return;
			if(str[x]>'a'){
				flag[str[x]-'a']++;
				Enc(x-1);
				flag[str[x]-'a']--;
			}else Enc(x-1);
		}
}

int main(void){
	while(1){
		cin >> str;
		if(str=="#")break;
		res.clear();
		len=str.size();
		memset(flag,0,sizeof(flag));
		memset(flag2,0,sizeof(flag2));
		Enc(len-1);
		printf("%d\n",res.size());
		sort(res.begin(),res.end());
		if(res.size()<=10)for(int i=0;i<res.size();i++)cout << res[i] << endl;
		else{
			for(int i=0;i<5;i++)cout << res[i] << endl;
			for(int i=res.size()-5;i<res.size();i++)cout << res[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2376
#include<stdio.h>
int main(void)
{
	int c1,c2,c3,c4,c5,c6,a;
	scanf("%d %d %d %d %d %d",&c1,&c2,&c3,&c4,&c5,&c6);
	c2*=5;
	c3*=10;
	c4*=50;
	c5*=100;
	c6*=500;
	a=c1+c2+c3+c4+c5+c6;
	if(a>=1000){
	printf("1\n");
	}
	else{
	printf("0\n");
	}
	return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}

int main(){
    ios::sync_with_stdio(false);
    int x,y;
    cin >> x >> y;
    int a=(4*x-y)/2;
    int b=(y-2*x)/2;
    if((a<=x)&&(b<=x)&&(a>=0)&&(b>=0)&&(y%2==0)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <math.h>
#include <queue>
#include <stack>
using namespace std;
typedef long long int lli;
const long long int MaxN=200005;
const lli mod=1e9+7;
#define fst first
#define snd second
#define mp make_pair
const float pi=3.1415926535897932384626433832795028;
	lli mcd(lli a,lli b){
		if(a==0)return b;
		return mcd(b%a,a);
	}
	lli dp[MaxN];
	lli arr[MaxN];
	void solve(){
		lli N,K,i,j,p,q;
		cin>>N>>K;
		for(i=1;i<=N;i++){
			cin>>arr[i];
		}	
		dp[1]=0;
		dp[2]=abs(arr[2]-arr[1]);
		for(i=2;i<=N;i++){
			dp[i]=1e17;
			for(j=1;j<=K;j++){
				if(i-j<=0)break;
				dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
			}
		}
		cout<<dp[N]<<"\n";
	}
int main(){
	//cin.tie(0),ios_base::sync_with_stdio(0);
	lli i,j,t;
	t=1;
	for(i=1;i<=t;i++){
		solve();
	}
	
}


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

#ifdef DEBUG
#define debug(...) __VA_ARGS__
#else
#define endl '\n'
#define debug(...)
#endif
#define debugf(...) debug(printf(__VA_ARGS__))

const int N = 5e5 + 5;
const int B = 25 * N;

int a[N];
int last[N];

int roots[N];
int ID;
int X[B], L[B], R[B];

int build(int l=0, int r=N) {
    int id = ++ID;
    if (r - l <= 1) {
        return id;
    }

    int mid = (l + r) / 2;
    L[id] = build(l, mid);
    R[id] = build(mid, r);
    return id;
}

int add(int u, int pos, int x, int l=0, int r=N) {
    int id = ++ID;
    if (r - l <= 1) {
        X[id] = X[u] + x;
        return id;
    }

    L[id] = L[u];
    R[id] = R[u];

    int mid = (l + r) / 2;
    if (pos < mid) {
        L[id] = add(L[u], pos, x, l, mid);
    } else {
        R[id] = add(R[u], pos, x, mid, r);
    }

    X[id] = X[L[id]] + X[R[id]];

    return id;
}

int query(int u, int tl, int tr, int l=0, int r=N) {
    if (l >= tr || r <= tl)
        return 0;

    if (l >= tl && r <= tr)
        return X[u];

    int mid = (l+r) / 2;
    return query(L[u], tl, tr, l, mid) +
           query(R[u], tl, tr, mid, r);
}

int (((((main)))))() <%
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int n, q;
    cin >> n >> q;
    for (int i = 1; i <= n; i++) {
        int x; cin >> x;
        a[i] = last[x];
        last[x] = i;
    }

    roots[0] = build();
    for (int i = 1; i <= n; i++) {
        roots[i] = add(roots[i-1], a[i], 1);
    }

    while (q--) {
        int l, r;
        cin >> l >> r;

        cout << query(roots[r], 0, l) - query(roots[l-1], 0, l) << endl;
    }

    return 0;
%>

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

bool compare_by_b(pair<string, int> a, pair<string, int> b)
{
    if (a.first == b.first)
    {
        return a.second > b.second;
    }
    else
    {
        return a.first < b.first;
    }
}

int main()
{
    int N;
    cin >> N;
    vector<pair<string, int>> SP(N);
    for (int i = 0; i < N; ++i)
    {
        string s;
        int p;
        cin >> s >> p;
        SP[i] = make_pair(s, p);
    }
    vector<pair<string, int>> SP2 = SP;

    sort(SP.begin(), SP.end(), compare_by_b);

    for (int i = 0; i < N; ++i)
    {
        for (int j = 0; j < N; ++j)
        {
            if (SP[i] == SP2[j])
            {
                cout << j + 1 << endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import fractions
n, X = map(int,input().split())
x = [int(i) for i in input().split()] 

GCD = abs(x[0] - X)
for i in range(1, n):
    GCD = fractions.gcd(GCD, abs(x[i] - X))
    #print(GCD)
print(GCD)


Measured memory_bytes: 16280
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if(a >= 13) cout << b << endl;
    else if(a > 5) cout << b / 2 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,c,d=-1,e;
  scanf("%d %d %d",&a,&b,&c);
  for(int i=0; i<b; i++){
    scanf("%d",&e);
    if(d==-1&&e>c){d=i;}
  }
  printf("%d",d<b-d?d:b-d);
  return 0;}

Measured memory_bytes: 128
h,w,k=map(int,input('').split(' '))
c=[]
for a in range(h):
    q=[]
    s=input('')
    for a in s:
        q.append(a)
    c.append(q)

bith=[]
bitw=[]
for a in range(h):
    bith.append(0)

for b in range(w):
    bitw.append(0)

p=0
while(1):
    s=0
    for a in range(h):
        if bith[a]==0:
            for b in range(w):
                if bitw[b]==0:
                    if c[a][b]=='#':
                        s=s+1

    if s==k:
        p=p+1

    bith[0]+=1
    for a in range(h-1):
        if bith[a]==2:
            bith[a]=0
            bith[a+1]+=1

    if bith[h-1]==2:
        bith[h-1]=0
        bitw[0]+=1

    for b in range(w-1):
        if bitw[b]==2:
            bitw[b]=0
            bitw[b+1]+=1
    if bitw[w-1]>=2:
        break

print(p)

Measured memory_bytes: 9272
#include<stdio.h>
int main(){

    int n,a,b,c,e;
    int i=1;
    int p = 1000000000;
    int q = 0;
    int x = 0;
    int y = 1000000000;


    scanf("%d",&n);

   while(i<=n){
       scanf("%d %d",&a,&b);
       
        if(a < p){
            p = a;
            x = b;
        }
        if(a > q){
            q = a;
            y = b;
        }
        i++;
    }

    c = p - 1;
    

    e = y + q;

    printf("%d\n",e);

    return 0;

        
        






}

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

#include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using namespace atcoder;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n, q;
  cin >> n >> q;
  fenwick_tree<ll> fw(n);
  rep(i, n) {
    ll a;
    cin >> a;
    fw.add(i, a);
  }
  rep(_, q) {
    int b;
    cin >> b;
    if (b == 1) {
      int l, r;
      cin >> l >> r;
      cout << fw.sum(l, r) << endl;
    } else {
      int p;
      ll x;
      cin >> p >> x;
      fw.add(p, x);
    }
  }
  return 0;
}

Measured memory_bytes: 8228
#include <bits/stdc++.h>
using namespace std;
int main(){
    int x, y;
    cin >> x >> y;
    if(y%2 == 0 && y >= 2*x && y <=4*x)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 3676
a, b, c, d = gets.chomp.split.map(&:to_i)

res_flg = 0
i = 0
while true do
  if i % 2 != 0
    a = a - d
  else
    c = c - b
  end
  if c <= 0 || a <= 0
    res_flg = 1 if c <= 0
    break
  end
  i += 1
end

puts res_flg == 1 ? 'Yes' : 'No'

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

map<string,int> M;

int main(){
  int n;
  cin >> n;

  rep(i,n){
    string a;
    cin >> a;
    M[a]++;
  }

  int mx = 0;
  for(auto it:M) mx = max(mx,it.second);
  for(auto it:M) if(mx == it.second) cout << it.first << endl; 

  return 0;
}

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


int main(void) {
  int N;
  cin >> N;

  int ans = N%1000 != 0 ? 1000 - (N % 1000) : 0;

  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3596
n=int(input())
s=input()
a = [0,0,0]
for c in s:
    if c=='R':
        a[0]+=1
    elif c=='G':
        a[1]+=1
    else:
        a[2]+=1
total = a[0]*a[1]*a[2]
for d in range(n):
    for i in range(n):
        j = i+d
        k = i+2*d
        if j>=n or k>=n:
            break
        if s[i]!=s[j] and s[j]!=s[k] and s[i]!=s[k]:
            total -= 1
print(total)

Measured memory_bytes: 68376
n = int(input())
a = list(map(int, input().split()))
mp = dict()
ans = 0
for i in range(n):
    try:
        mp[a[i]]+=1
    except:
        mp[a[i]]=1
    ans += a[i]


q= int(input())
while q:
    q-=1
    b,c = map(int, input().split())
    try:
        cnt = mp[b]
        try:
            mp[c]+=cnt
        except:
            mp[c]=cnt
        mp[b]=0
        ans += cnt*(c-b)
    except:
        pass
    print(ans)




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

int main(){
  int n;
  cin >> n;
  int a[n], b[n], c[n];
  rep(i, n) cin >> a[i] >> b[i] >> c[i];
  int dp[n+1][3];
  rep(i, n+1){
    rep(j, 3) dp[i][j] = 0;
  }
  dp[0][0] = 0, dp[0][1] = 0, dp[0][2] = 0;
  for(int i = 1; i <= n; i++){
    dp[i][0] = max(dp[i-1][1] + a[i-1], dp[i-1][2] + a[i-1]);
    dp[i][1] = max(dp[i-1][0] + b[i-1], dp[i-1][2] + b[i-1]);
    dp[i][2] = max(dp[i-1][0] + c[i-1], dp[i-1][1] + c[i-1]);
  }
  cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;
  return 0;
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e15;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

int main() {
    ll h, w, d;

    cin >> h >> w >> d;

    vector<P> board(h * w);

    rep(y, h) {
        rep(x, w) {
            int a;
            cin >> a;
            a--;
            board[a] = P(x, y);
        }
    }
    ll max_step = h * w / d;
    vector<vector<ll>> move_mp(d, vector<ll>(max_step, 0));

    for (ll i = 0; i <= h * w - d; i++) {
        ll da = i % d;
        ll p = i / d;
        assert(p * d + da == i);
        P before = board[i];
        if (i + d >= h * w) break;
        P next = board[i + d];
        move_mp[da][p] = abs(before.first - next.first) + abs(before.second - next.second);
    }

    vector<vector<ll>> move_sum(d, vector<ll>(max_step + 1, 0));
    for (ll da = 0; da < move_mp.size(); da++) {
        vector<ll> mmp = move_mp[da];
        for (ll p = 0; p < mmp.size(); p++) {
            move_sum[da][p + 1] = move_sum[da][p] + mmp[p];
        }
    }

    ll q;
    cin >> q;

    rep(i, q) {
        ll l, r;
        cin >> l >> r;

        l--;
        r--;

        ll l_da = l % d;
        ll l_p = l / d;

        ll r_da = r % d;
        ll r_p = r / d;

        ll now = move_sum[r_da][r_p] - move_sum[l_da][l_p];
        cout << now << endl;

    }

}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int taka = A;
  int aoki = C;
  while(taka > 0){
    while(aoki > 0){
    if(taka <= 0) break;
    else aoki = aoki - B;
        if(aoki <= 0) break;
        else taka = taka - D;
    }
    if(aoki <= 0) break;
  }
  if(taka > aoki) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3540
import sys
import math
INF = 1 << 20

def main():
    N, K = [int(i) for i in sys.stdin.readline().strip().split()]
    numbers = [int(i) for i in sys.stdin.readline().strip().split()]
    print("%d" % solve(N, K, numbers))


def solve(N, K, numbers):

    total = sum(numbers)
    ans = 1
    candidates = []
    
    divisor = 1
    # list all possible divisors
    while divisor * divisor <= total:
        if total % divisor == 0:
            candidates.append(divisor)
            candidates.append(total/divisor)
        divisor += 1
    candidates = sorted(candidates, reverse=True)

    for divisor in candidates:
        mods = []
        for number in numbers:
            mods.append(number % divisor)
        mods.sort()
        A = sum(mods)

        need = INF
        index = math.floor(-1 * A/divisor)
        need = sum(mods[0:index])
        if need <= K:
            ans = max(ans, divisor)

    return ans


if __name__ == "__main__":
    main()

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n;
    ll k;
    cin >> n >> k;
    vector<P> ope(n);
    rep(i,n){
        int a, b;
        cin >> a >> b;
        ope[i] = make_pair(a, b);
    }
    sort(all(ope));
    ll num = 0;
    rep(i,n){
        num += ope[i].second;
        if (k <= num){
            cout << ope[i].first << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3932
#include <iostream>
#include <vector>
using namespace std;

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    long long N;
    cin >> N;
  int sum =0;
  for(int i=1;i<N;i++){
    const auto &pf = prime_factorize(i);
    long long res = 1;
    for (auto p : pf) res *= p.second + 1;
    sum =sum+res;
  }
    cout << sum << endl;
}

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

int digitsum(int);

int main(){
    int N, A, B, minsum=10000;
    cin >> N;
    for(A=1; A<N; A++){
        B = N - A;
        if(minsum > digitsum(A) + digitsum(B)){
            minsum = digitsum(A) + digitsum(B);
        }   
    }
    cout << minsum << endl;
}


int digitsum(int num){
    int sum = 0;
    while(num!=0){
        sum += num%10;
        num = num/10;
    }
    return sum;
}

Measured memory_bytes: 256