akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;


    void solve()
    {
        var S = cin.next;
        for (int i = 0; i < S.Length - 1; i++)
        {
            if (S[i] == 'A' && S[i + 1] == 'C')
            {
                WriteLine("Yes");
                return;
            }
        }
        WriteLine("No");
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

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

int cookieEx(ll a, ll b, ll c, ll ret) {
    if (a%2==1 || b%2==1 || c%2==1) return ret;
    ll A, B, C;
    A = b / 2 + c / 2;
    B = a / 2 + c / 2;
    C = a / 2 + b / 2;
    ret++;
    return cookieEx(A, B, C, ret);
}

int main(void)
{
    ll a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c && c == a)  {
        if (a%2!=0) {
            cout << 0 << endl;
            return (0);
        }
        cout << -1 <<endl;
        return (0);
    }
    ll ret = 0;
    ret = cookieEx(a, b, c, ret);
    cout << ret << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//bool sorted()
int main(){
	int n;
	cin >> n;
	int a[n];
	int b[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
		b[i]=a[i];
	}
	sort(a,a+n);
	int num=0;
	for(int i=0;i<n;i++){
		if(a[i]!=b[i]){
			num++;
		}
	}
	if(num>2){
		printf("NO");
	}
	else{
		printf("YES");
	}
	return 0;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N;
    cin >> N;
    Vl A(N), B(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    if (N & 1) {
        ll lb = A[N / 2];
        ll ub = B[N / 2];
        cout << ub - lb + 1 << "\n";
    }
    else {
        ll lb = A[N / 2 - 1] + A[N / 2];
        ll ub = B[N / 2 - 1] + B[N / 2];
        cout << ub - lb + 1 << "\n";
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

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

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

int main() {
	int n, X; cin >> n >> X;
	vector<int>x(n); for (auto&& y : x)cin >> y;
	x.push_back(X);
	sort(x.begin(), x.end());
	vector<int>dist;
	for (int i = 0; i < x.size() - 1; i++) {
		dist.push_back(x[i+1] - x[i]);
	}
	sort(dist.begin(), dist.end());
	if (dist.size() == 1) cout << dist[0] << endl;
	else {
		int ans = gcd(dist[0], dist[1]);
		for (int i = 2; i < dist.size(); i++) {
			ans = gcd(ans, dist[i]);
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1528
#横にn個入力
n, c, k = map(int, input().split())
d = []
for i in range(n):
    d.append(input())
# [d1, d2, d3, ..., dN]
t = [int(m) for m in d]#int型に直す

t.sort()
current = 0
ans = 0
psn = 0
getonpsn = 0
for i in range(n):
    psn += 1
    if i == 0:
        current = t[i]
    if t[i] - current > k:
        psn -= 1
        ans += psn // c
        getonpsn += (psn // c) * c
        if psn // c == 0:
            getonpsn += psn
            ans += 1
            psn = 0
            #if getonpsn != n:
            current = t[getonpsn]
            if i == n - 1:
                    ans += 1
        elif getonpsn != n:#iminai
            current = t[getonpsn]
            if i == n - 1:
                if t[i] - current > k:
                    ans += 2
                else:
                    ans += 1

        psn = psn % c


        psn += 1
    elif i == n - 1:
        ans += (psn + c + 1) // c


print(ans)

Measured memory_bytes: 14576
#include <stdio.h>
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <set>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <map>
#include <queue>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef long double ld;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<pii> vii;
typedef vector<string> vs;
//typedef long long int;

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  vl v(4);
  ll n;
  for (int i = 0; i < 4; ++i) cin >> v[i];
  for (int i = 1; i < 4; ++i) v[i] = min(v[i], 2 * v[i-1]);
  cin >> n;
  cout << v[3] * (n / 2) + v[2] * (n % 2) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
void solve(){
    long long n,x,t;
    cin>>n>>x>>t;
    long long val = n%x;
    long long ans = n/x;
    ans = ans * t;
    if(val!=0)
        ans = ans + t;
    cout<<ans<<'\n';
}
int main(){
int t=1;
// cin>>t;
while(t-->0)
    solve();
return 0;
}

Measured memory_bytes: 3636
#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
using namespace std;
#define int long long

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    string s,t;
    cin >> s >> t;
    cout << t + s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
  
#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed fixed<<setprecision(14)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline lol abs(A &a) { return (a < 0 ? -a : a); }
const lol inf=(1LL<<60);
const lol MOD=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
lol n,m,k,r;
int kari[3000];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string a,b;
  cin >>a>>b;
  vector<int> ans(a.size()+3);
  n=a.size();
  m=b.size();
  for(int i=n-1;i>=0;i--){
    int p=0;
    for(int j=m-1;j>=0;j--){
      if(b[j]=='.') continue;
      ans[n-i-1+p] += (a[i]-'0') * (b[j]-'0');
      p++;
    }
  }
  for(int i=0;i<n+2;i++){
    ans[i+1]+=ans[i]/10;
    ans[i]%=10;
  }
  bool p=false;
  for(int i=n+2;i>=2;i--){
    if(ans[i]!=0) p=true;
    if(p) cout <<ans[i];
  }
  if(!p) cout <<"0";
  cout <<'\n';
  return (0);
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CHADD(a, b) (a = ADD(a, b))
#define CHMUL(a, b) (a = MUL(a, b))
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define MOD 1000000007
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b){ if(a<b){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b){ if(a>b){ a=b; return true; } return false; }


int N;
PII AB[200010];


signed main(){
    cin >> N;
    rep(i, 0, N) cin >> AB[i].second >> AB[i].first;

    sort(RNG(AB, 0, N));

    int t = 0;
    int ans = true;
    rep(i, 0, N){
        int A = AB[i].second;
        int B = AB[i].first;
        t += A;
        if(B < t){ ans = false; break; }
    }

    if(ans) Yes;
    else No;

    return 0;
}

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

string s,t;
int len1,len2;
//dp[i][j]: i번째부터와 j번째 부터의 문자열에서 얻을 수 있는 최대 길이
int dp[3001][3001];

int solve(int i,int j){
	int& ret=dp[i][j];
	if(ret!=-1) return ret;
	if(i==len1 || j==len2) return ret=0;
	ret=0;
	ret=max(ret,(s[i]==t[j])+solve(i+1,j+1));
	ret=max(ret,solve(i+1,j));
	ret=max(ret,solve(i,j+1));
	return ret;
}

int main(){
	cin>>s>>t;
	len1=s.size();
	len2=t.size();
	memset(dp, -1, sizeof(dp));
	int v=solve(0,0);
	int i=0;
	int j=0;
	if(v==0){
		puts("");
		return 0;
	}
	while(i!=len1 && j!=len2){
		if(s[i]==t[j] && solve(i+1,j+1)+1==v){
			printf("%c",s[i]);
			i++;
			j++;
			v--;
		}else if(solve(i+1,j)==v){
			i++;
		}else if(solve(i,j+1)==v){
			j++;
		}
	}
	return 0;
}

Measured memory_bytes: 35712
#include <bits/stdc++.h>
#define ll long long int
#define ld double
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
int main()
{
	boost;
	int n;
	cin >> n;
	int ans = 0;
	for(int i = 1; i <= n; i++){
		int x = i;
		int cnt = 0;
		while(x){
			cnt++;
			x /= 10;
		}
		ans += (cnt & 1);
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void) {
  int N, S = 0;
  scanf("%d", &N);
  for (int i = N; i > 0; i /= 10) S += i % 10;
  if (N % S == 0) printf("Yes\n");
  else printf("No\n");

  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

 int main()
 {
 	int a, b, c;
 	scanf("%d",&a);
 	scanf("%d",&b);
 	scanf("%d",&c);
	if(a < b && b < c)
	{
		printf("Yes\n");
	}
	else 
	{
		printf("No\n");
	}
 	return 0;
 	
 }


Measured memory_bytes: 2556
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            int input = int.Parse(Console.ReadLine());
            int answer = input % 1000;
            if(answer > 0)
            {
                answer = 1000 - answer;
            }

            Console.WriteLine(answer);
        }
    }
}


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

int main(){
  int q;
  cin >> q;
  string e,r;
  getline(cin,e);
  getline(cin,r);
  int s;
  s = r.size();
  for(int i=0;i<s;i++){
    char ans;
    ans = r.at(i)+q;
    if(ans>'Z')ans-=26;
    cout << ans;
  }
  cout << endl;
}

Measured memory_bytes: 256
int main(void){
  int n,i,x;
  scanf("%d",&n);
 
  for(i=1;i<=n;i++){
    x=i;
    if ( x % 3 == 0 ){
      printf(" %d",i);
    }else{
      do{
        if ( x % 10 == 3 ){
          printf(" %d",i);
          x=0;
        }
        x /= 10;
      }while( x );
    }
  }
  printf("\n");
  return 0;
}


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

map<char,char> ma;

int main(){
  ios_base::sync_with_stdio(false);
  int n,m;
  char a,b;
  while(1){
    cin >> n;
    if(n==0) break;
    for(int i=0;i<n;i++){
      cin >> a >> b;
      ma[a]=b;
    }
    cin >> m;
    char temp;
    for(int i=0;i<m;i++){
      cin >> temp;
      if(ma[temp]!=0){
	cout << ma[temp];
      }else{
	cout << temp;
      }
    }    
    cout << endl;
    ma.clear();
  }

  return 0;
}

Measured memory_bytes: 3228
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
#define   ll long long int
#define maxn 300005

ll mod=1e9+7;

int main(){
int n;
cin>>n;
vector<ll> a(n);
ll ts=0;
for(int i=0;i<n;i++){
    cin>>a[i];
    ts+=a[i];
}
ll ans=0;
for(int i=0;i<n;i++){
    ts-=a[i];
    ts=ts%mod;
    ans+=(a[i]*ts)%mod;
    ans=ans%mod;
}
cout<<(ans+mod)%mod<<endl;


}


Measured memory_bytes: 4840
import java.util.*;

class Main{
    public static void main(String[] args){
    	Scanner sc= new Scanner(System.in);
    	int tp=0,hp=0;
    	for(int m=sc.nextInt();m>0;m--){
        int ec=0;
    		char[]t=sc.next().toCharArray();
    		char[]h=sc.next().toCharArray();	
        for(int i=0;i<Math.min(t.length,h.length);i++){
        	if(t[i]>h[i]){
        		tp+=3;break;
        	}else if(t[i]<h[i]){
        		hp+=3;break;
        	}else if(t[i]==h[i]) ec++;
        }
        if(ec==Math.min(t.length,h.length)){
        	if(t.length>h.length){tp+=3;}
        	else if(t.length<h.length){hp+=3;}
        	else{tp++;hp++;} 	
        }
    }
    System.out.println(tp+" "+hp);
    }
}

Measured memory_bytes: 29916
n, m, k = gets.split(" ").map(&:to_i)
MOD = 10**9 + 7

def f(n)
  ((n-1)*n*(n+1)/6) %MOD
end

## 二項係数 C(n,k) mod pの計算 ##
# a**b mod p by 繰り返し二乗法
def pow(a,b)
  return 1 if b == 0
  return a*pow(a,b-1)%MOD if b%2 == 1
  return pow(a**2%MOD, b/2)
end

# n! mod p
def fact(n)
  ret = 1
  n.times do |i|
    ret = ret * (i+1) %MOD
  end
  ret
end

# a**(-1) mod p
def inv(a)
  pow(a, MOD-2)%MOD
end

# C(n,k) mod p
def com(n,k)
  (fact(n) * inv(fact(k)))%MOD * inv(fact(n-k)) %MOD
end

puts (m**2 * f(n) + n**2 * f(m)) * com(m*n-2, k-2) %MOD
   

Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FOD(i,a,b) for(ll i=(a);i>=(b);--i)
#define name "a"
#define pb push_back
typedef pair < ll , ll > ii;
const ll maxn=1e5+7,oo=1e18,mod=1e9+7;
ll n,k,t,res,tmp;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen(name".inp","r",stdin);
    //freopen(name".out","w",stdout);
    cin>>n>>k;
    if(k==0)
    {
        cout<<n;
        return 0;
    }
    tmp=n/k;
    t=k*tmp;
    res=n-t;
    t=k*(tmp+1);
    cout<<min(n,min(res,t-n));
}


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

int main(){
    LL n;
    cin>>n;
    LL a[n][3];
    for(LL i=0;i<n;i++){
        for(LL j=0;j<3;j++){
            cin>>a[i][j];
        }
    }
    
    LL dp[n][3];
    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    
    for(LL i=1;i<n;i++){
        for(LL j=0;j<3;j++){
            if(j==0){
                dp[i][j]=a[i][j]+max(dp[i-1][1],dp[i-1][2]);
            }
            else if(j==1){
                dp[i][j]=a[i][j]+max(dp[i-1][0],dp[i-1][2]);
            }
            else if(j==2){
                dp[i][j]=a[i][j]+max(dp[i-1][0],dp[i-1][1]);
            }
        }
    }
    
    LL ans=max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    
    cout<<ans<<endl;
}

Measured memory_bytes: 4992
import java.util.*;

public class Main{
    Main(){
	Scanner sc = new Scanner(System.in);

	while(sc.hasNext()){
	    int d = sc.nextInt(), s = 0;
	    for(int i = d; i <= 600-d; i+=d) s += (d*i*i);
	    System.out.println(Integer.toString(s));
	}
    }

    public static void main(String[] args){
	new Main();
    }
}

Measured memory_bytes: 0
n = int(input())
li = list(map(int,input().split()))
li2 = [0] * n
li3 = [0] * n
cnt = 0
for i in range(len(li)):
    if i + li[i] < len(li):
        li2[i + li[i]] += 1
    if i - li[i] >= 0:
        li3[i - li[i]] += 1

for i in range(len(li)):
    if li2[i] > 0 and li3[i] > 0:
        cnt += li2[i] * li3[i]

print(cnt)

Measured memory_bytes: 32236
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	input := scanIntNum()
	if input%2 == 0 {
		fmt.Println(input / 2)
	} else {
		fmt.Println(input/2 + 1)
	}
}

func scanIntNum() (num int) {
	sc.Scan()

	num, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return num
}


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

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

  while(N > 1000){
    N -= 1000;

  }
  cout << 1000-N << endl;

}



  

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

bool IsPrime(int num) {
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;  // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main(void) {
    int x;
    cin >> x;
    while (!IsPrime(x)) {
        x++;
    }
    cout << x << endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<string>
using namespace std;
int main(){
	int N;
	while(cin>>N){
		if(N==0)break;
		int da[30][30]={};
		for(int i=0;i<N;i++){
			int x,y;
			cin>>x>>y;
			da[y][x]=1;
		}
		int M;
		cin>>M;
		int dx=10,dy=10;
		for(int i=0;i<M;i++){
			char d;
			int l;
			cin>>d;
			cin>>l;
			if(d=='N'){
				for(int i=1;i<=l;i++){
					dy++;
					da[dy][dx]=0;
				}
			}
			if(d=='E'){
				for(int i=1;i<=l;i++){
					dx++;
					da[dy][dx]=0;
				}
			}
			if(d=='W'){
				for(int i=1;i<=l;i++){
					dx--;
					da[dy][dx]=0;
				}
			}
			if(d=='S'){
				for(int i=1;i<=l;i++){
					dy--;
					da[dy][dx]=0;
				}
			}

		}
		string s="Yes";
		for(int i=0;i<22;i++){
			for(int j=0;j<22;j++){
				if(da[i][j]==1){
					s="No";
					break;
				}
			}
		}
		cout<<s<<endl;
	}
	return 0;
}

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

int main(){
    int N,K;cin>>N>>K;
    string S;cin>>S;
    int count=0;

    for(int i=0;i<N-1;i++){
    if(S[i]==S[i+1]){
        count+=1;
    }

    }
    int sum=count+K*2;
    cout<<min(sum,N-1)<<endl;

}

Measured memory_bytes: 512
// inputに入力データ全体が入る
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    tmp0 = input[0].split(" ");
    n = Number(tmp0[0]);
    tmp1 = input[1].split(" ");
    t = Number(tmp1[0]);
    a = Number(tmp1[1]);
    tmp2 = input[2].split(" ");

    h = Number(tmp2[0]);
    h= t-h*0.006;
//  console.log(h);
    min = 　Math.abs(h-a);　
    ans=1;
    for(i=1;i<n;i++){
        h = Number(tmp2[i]);
           h= t-h*0.006;
     // console.log(h);
           if( min > Math.abs(h-a)){ans=i+1;
                                    min=Math.abs(h-a);}
         
    }
   console.log(ans);
}
    
  //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
  Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//   

Measured memory_bytes: 8136
#include <stdio.h>
#include <math.h>
int main(void) {
	int n, v, i, a = 0;

	scanf("%d", &n);
	while (n--) {
		scanf("%d", &v);
		if (v == 2) {
			a += 1;
		} else if (v % 2 == 1) {
			for (i = 3; i < (int)sqrt(v) + 1; i += 2) {
				if (v % i == 0) {
					a -= 1;
					break;
				}
			}
			a += 1;
		}
	}
	printf("%d\n", a);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define yes(n) cout << ((n) ? "yes" : "no") << endl

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

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

template<typename T>
T gcd(T a, T b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}


int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    int ans = INF;
    rep(div, 1<<(h-1)) { // 縦の分割の方法を全探索
        int g = 0; // グループ数
        vector<int> id(h); // id[i]: i行目が属するgroupの番号
        rep(i, h) {
            id[i] = g;
            if (div>>i&1) ++g; // ビットが立っているところで横に区切る。
        }
        ++g; // groupの数は配列の添字より1大きい。

        vector<vector<int>> c(g, vector<int>(w, 0));
        rep(i,h)rep(j,w) c[id[i]][j] += (s[i][j] - '0'); // ホワイトチョコの数を数える。
        int num = g - 1; // 現時点で区切る回数はg-1。
        vector<int> now(g, 0); // 現時点でのgroupごとのホワイトチョコの数。
        auto add = [&](int j) {
            rep(i,g) now[i] += c[i][j];
            rep(i,g) if (now[i]>k) return false;
            return true;
        };
        rep(j,w) {
            if (!add(j)) {
                num++;
                now = vector<int>(g, 0);
                if (!add(j)) {
                    num = INF;
                    break;
                }
            }
        }
        ans = min(ans, num);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
////////////////////////////////////////////////////////////////
//
//    (☝ ՞ਊ ՞)☝ << Be accept!!
//
//    C++ format for competitive professional v1.0
//
//    need gcc & boost::c++
//
////////////////////////////////////////////////////////////////
#define BOOST
#define CGCC
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int66_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   //setfill(char)
#include <ios>       //left,right
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
#ifdef BOOST
#include <boost/multiprecision/cpp_int.hpp> // cpp_int
using namespace boost::multiprecision;
#endif
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using namespace std;
#ifdef CGCC
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif
int setup(void) { // set
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  return 0;
}
int lenght(char *str) { // getcharlengh
  int i = 0;
  while (str[i]) {
    i++;
  }
  return i;
}
int gcd(long long a, long long b) {
  if (a < b)
    return gcd(b, a);
  long long r;
  while ((r = a % b)) {
    a = b;
    b = r;
  }
  return b;
}
int iinput(void) {
  int a = 0;
  cin >> a;
  return a;
}
int dinput(void) {
  double a = 0;
  cin >> a;
  return a;
}
string sinput(void) {
  string a = "";
  cin >> a;
  return a;
}
int kuriup(double a) {
  int b = int(a);
  if (a != b) {
    return b + 1;
  } else {
    return b;
  }
}
int kuridown(double a) {
  int b = int(a);
  return b;
}
int run(void);
int main(){
  setup();
  run();
  return 0;
}
int run(void){

  int n,r;
  cin>>n>>r;
  int ans=0;
  if(10 > n){
    ans=r+(100*(10-n));
  }else{
    ans=r;
  }

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


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

int main(){
    int n;  //n人 : n<=15
    cin >> n;
    vector<int> a(n);
    int xy[n][n][2];
    rep(i,n){
        cin >> a[i];
        rep(j,a[i]){
            cin >> xy[i][j][0] >> xy[i][j][1];
        }
    }
    int ans = 0;
    rep(i,1<<(n)){
        int num = 0;
        vector<int> id(n,-1);
        rep(j,n){
            if(i>>j&1){
                id[j] = 1;
                num++;
            }
        }
        /*
        rep(j,n){
            cout << id[j] << endl;
        }
        cout << endl;
        */
        auto check = [&](int k,int ok){
            if(id[k-1]==-1){
                id[k-1] = ok;
                return true;
            }
            if(id[k-1]==ok) return true;
            else return false;
        };
        bool okok = true;
        rep(ni,n){
            if(id[ni]!=1) continue;
            rep(nj,a[ni]){
                if(!check(xy[ni][nj][0],xy[ni][nj][1])) okok = false;
            }
        }
        rep(ni,n){
            if(id[ni]!=1) continue;
            rep(nj,a[ni]){
                if(!check(xy[ni][nj][0],xy[ni][nj][1])) okok = false;
            }
        }
        if(okok) ans = max(ans,num);
    }

    cout << ans << endl;

    return 0;
}
/*
正直者であるための条件
ほかの正直者と、矛盾が生じないこと
bit全探索？
n<=15なので、正直者を全通り試す
正直者以外の発言は無視
正直者が正直者と判定した人が正直者か判定する？
*/

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#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() {
  queue<ll> X;
  for (int i=1;i<=9;i++) X.push(i);

  ll k;
  cin >> k;

  ll cnt = 0;

  while(1) {
    ll x = X.front();
    cnt++;
    if (cnt == k) {
      cout << x << endl;
      return 0;
    }
    X.pop();
    if (x % 10 != 0) X.push(10 * x + (x % 10) -1);
    X.push(10*x + (x % 10));
    if (x % 10 != 9) X.push(10 * x + (x % 10) +1);
  }

  return 0;
}


Measured memory_bytes: 1792
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) (a*a)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

int main() {
	int x[3];
	REP(i, 3) cin >> x[i];
	sort(x, x + 3);
	if (x[0] == 5 && x[1] == 5 && x[2] == 7)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
use std::collections::BTreeMap;
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn dfs(from: usize, depth: i64, childs: &Vec<Vec<usize>>) -> i64 {
    let mut ret = depth;
    for &to in childs[from].iter() {
        ret += dfs(to, depth + 1, childs);
    }
    return ret;
}

fn main() {
    let n = read::<usize>();
    let mut items = BTreeMap::<i64, usize>::new();
    for i in 0..n {
        let v = read::<i64>();
        items.insert(v, i);
    }
    let mut childs = vec![vec![]; n];
    let mut parents = vec![n; n];
    let mut cnts = vec![1; n];
    for (&v, &index) in items.iter().rev() {
        let tv = v - (n as i64 - 2 * cnts[index]);
        if cnts[index] == n as i64 || tv <= 0 || tv == v {
            break;
        }
        if let Some(&nindex) = items.get(&tv) {
            parents[index] = nindex;
            childs[nindex].push(index);
            cnts[nindex] += cnts[index];
        } else {
            println!("-1");
            return;
        }
    }
    let (&root_weight, &root) = items.iter().next().unwrap();
    let weight = dfs(root, 0, &childs);
    if weight != root_weight {
        println!("-1");
        return;
    }
    for i in 0..n {
        if parents[i] == n {
            continue;
        }
        println!("{} {}", i + 1, parents[i] + 1);
    }
}


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

ll gcd(ll a, ll b) {
    if(a < b) {ll tmp = a; a = b; b = tmp; }
    if(b == 0) return a;
    return gcd(b, a%b);
}

bool is_prime(ll a) {
    if(a < 2) return false;
    else if(a == 2) return true;;
    if(a%2 == 0) return false;

    for(ll i = 3; i <=a/i; i += 2) {
        if(a%i == 0) return false;
    }
    return true;
}

ll tansaku(ll g, ll p) {
    if(g == 1) return 1;
    if(is_prime(g)) return 2;
    ll i;
    for(i = p; i <= g; ++i) {
        if(g%i == 0) break;
    }
    while(g%i == 0) g /= i;
    return 1 + tansaku(g, i);
}

ll cnt(ll g) {
    if(g == 1) return 1;
    for(ll i = 2; i <= g/i; ++i) {
        if(g%i == 0) {
            while(g%i == 0) g /= i;
            return 1 + cnt(g);
        }
    }
    return 2;
}

void solve(ll g) {
    cout << cnt(g) << endl;
}

int main()
{
    ll A, B;
    cin >> A >> B;
    //cout << gcd(A, B) << endl;
    ll G = gcd(A, B);
    solve(G);
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
switches = []
cnt = 0

for i in range(m):
    array = list(map(int, input().split()))
    array.pop(0)
    switches.append(array)

p = list(map(int, input().split()))


def ch_binary(l, digit):
    num = [0] * digit
    for i in l:
        num[i-1] = 1
    return num

#スイッチのON、OFFをバイナリで表現する。
switches_2 = []
for i in switches:
    array = ch_binary(i, n)
    switches_2.append(array)



def check(a, b, digit, x):
    count = 0
    for i in range(digit):
        if a[i] == b[i] and b[i] == 1:
            count += 1
    if count % 2 == x:
        return 1
    else:
        return 0


for i in range(2**n):
    bin_str = list(map(int, format(i, 'b').zfill(n)))
    count = 0
    for j in range(m):
        y = check(switches_2[j], bin_str, n, p[j])
        count += y
    if count == m:
        cnt += 1

print(cnt)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

template<typename T>class BIT {
    public:
    int n;
    vector<T> bit;
    
    BIT(int n): n(n){
        bit.resize(n);
        fill(bit.begin(), bit.end(), (T)0);
    }

    void add(int idx, T x){
        for(int i=idx;i<=this->n;i+=i&-i) bit[i] += x;
    }

    //bit[1]からbit[end]までの和 (閉区間)
    T sum(int end){
        T ret = (T)0;
        for(int i=end;i>=1;i-=i&-i) ret += bit[i];
        return ret;
    }
};


int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n+1, 0), s(n+1, 0);
    for(int i=1;i<=n;++i){
        cin >> a[i];
        s[i] = (s[i-1] + (a[i]%k)) % k;
    }
    for(int i=1;i<=n;++i) {
        s[i] = (i - s[i] + k) % k;
        while(s[i] < 0LL) s[i] += k;
    }
    // for(int i=1;i<=n;++i) cerr << s[i] << " ";
    // cerr << endl;

    ll ans = 0LL;
    map<ll, ll> cnt;
    cnt[0] = 1;
    for(int i=1;i<=n;++i) {
        if(i >= k) --cnt[s[i-k]];
        ans += cnt[s[i]];
        ++cnt[s[i]];
    }

    cout << ans << endl;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
int n,ans=0;
map<int,int> mp;
int main(){
	cin>>n;
	int t;
	for(int i=0;i<n;i++){
		cin>>t;
		mp[t]++;
	}
	map<int,int>::iterator it=mp.begin();
	while(!mp.empty()){
		it=mp.end();
		it--;
		int x=it->first;
		if(mp[x]==0){
			throw;
		}
		mp[x]--;
		if(mp[x]==0){
			mp.erase(x);
		}
		int z=1;
		while(z<=x){
			z<<=1;
		}
		if(mp.count(z-x)>0){
			mp[z-x]--;
			if(mp[z-x]==0){
				mp.erase(z-x);
			}
			ans++;
		}
		
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 9600
#include <stdio.h>
#define N 999999

int Prime(int n);
int main(void) {
	int n;
	while(scanf("%d",&n)!=EOF){
		printf("%d\n",Prime(n));
	}
	return 0;
}

int Prime(int n){
	int i,j,prime[N],count=0;
	for(i=2;i<N;i++) {
    		prime[i]=0;
	}
	prime[1]=1;
	for(i=2;i*i<N;i++){
		if(prime[i]==0){
			for(j=i;j<=N/i;j++){
				prime[i*j]=1;
			}
		}
	}
	for(i=2;i<=n;i++){
		if(prime[i]==0){
			count++;
		}
	}
	return count;
}



Measured memory_bytes: 5600
S = input()
T = input()
String1 = list(S)
String2 = list(T)
N = len(String1)



for i in range(1,N):
    if String1 == String2:
        print("Yes")
        break
    Ex = String1.pop()
    String1.insert(0,Ex)
    if String1 == String2:
        print("Yes")
        break
else:
    print("No")

Measured memory_bytes: 9096
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int dp[101][3];
#define INF (1<<29)

int N;
int L;
P p[111];
bool flag[111];

int solve(int id,int c){
  if( dp[id][c] != -1 ) return dp[id][c];
  flag[id] = true;
  if( id == N ) return dp[id][c] = p[id-1].second;
  int nt;
  int nx;
  if( id == 0 ) nt = 0,nx=0;
  else nt = p[id-1].first, nx = p[id-1].second;
  int ret = INF;
  // cout << id << " " << c << " " << nt << " "<< nx << endl; 

  if( c == 3 ){
    int x = p[id].second;
    int t = p[id].first;
    if( t >= nt + nx*4 + x ){
      ret = min (ret, solve( id+1, 1 ) + nx + x );
    }
  } else {
    int x = p[id].second;
    int t = p[id].first;
    if( t >= nt + nx*(c+1) + x ){
      ret = min (ret, solve( id+1, 1 ) + nx + x);
    }
    if( t >= nt + abs(nx-x) * (c+1) ){
      ret = min( ret, solve( id+1, c+1 ) + abs(nx-x) );
    }
  }
  return dp[id][c] = ret;
}

int main(){
  while(cin >> N && N ){  
    for(int i=0;i<N;i++){
      cin >> p[i].second >> p[i].first;
    }
    sort(p,p+N);
    memset(dp,-1,sizeof(dp));
    memset(flag,0,sizeof(flag));
    int res = solve(0,0);
    if( res < INF ) cout << "OK " << res << endl;
    else {
      for(int i=0;i<=N;i++){
	if( !flag[i] ){
	  cout << "NG " << i << endl;
	  break;
	}      
      }
    }
  }
}

Measured memory_bytes: 1164
#include <stdio.h>

int main(){

int N, m=1, s=0, n, temp;
scanf("%d", &N);
n=N;

do{
m*=10;
temp=(n%m);
n-=temp;
s+=temp/(m/10);
}while(n/m);

if(N%s) printf("No");
else printf("Yes");

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int n ,k;
vector<int>vi;
long long mem[200005];
bool vis[200005];
long long solve(int indx ){
	if(indx == n-1)
		return 0;
	if(vis[indx])
		return mem[indx];
	vis[indx] = true;
	mem[indx] = 1e13;
	for(int i = indx+1; i <=min(indx+k , n-1) ; i++){
		mem[indx] = min(mem[indx] , solve(i ) + abs(vi[indx] - vi[i]));
	}
	return mem[indx];
}
//long long n , w;
//vector<pair<long long , long long>>vi;
//long long mem[105][100005];
//bool vis[105][100005];
//long long ans = 0;
//long long sol(int indx , int cost){
//	if(indx == n)
//		return 0;
//	if(vis[indx][cost])return mem[indx][cost];
//	mem[indx][cost] = 0;
//	long long fch = sol(indx + 1 , cost);
//	long long sch = 0;
//	if(mem[indx][cost] + vi[indx].first <= w){
//		sch = sol(indx + 1 , cost + vi[indx].second) + vi[indx].first;
//	}
//	return mem[indx][cost] = max()
//}
int main()
{
//	cin>>n>>w;
//	vi.resize(n);
//	for(int i = 0; i <n ; i++)
//		cin>>vi[i].first>>vi[i].second;
//
//	cout<<sol(0,0);

	cin>>n>>k;
	vi.resize(n);
	for(int i = 0; i <n ; i++)
		cin>>vi[i];
	cout<<solve(0);
	return 0;
}



Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define il inline
#define RG register
#define ll long long
#define N (500005)

using namespace std;

struct edge{ int nt,to,dis; }g[N];

int head[N],dis[N],vis[N],n,m,num;

il int gi(){
  RG int x=0,q=1; RG char ch=getchar();
  while ((ch<'0' || ch>'9') && ch!='-') ch=getchar();
  if (ch=='-') q=-1,ch=getchar();
  while (ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
  return q*x;
}

il void insert(RG int from,RG int to,RG int dis){
  g[++num]=(edge){head[from],to,dis},head[from]=num; return;
}

il void dfs(RG int x){
  vis[x]=1;
  for (RG int i=head[x],v;i;i=g[i].nt){
    v=g[i].to;
    if (!vis[v]) dis[v]=dis[x]+g[i].dis,dfs(v);
    else if (dis[v]!=dis[x]+g[i].dis) puts("No"),exit(0);
  }
  return;
}

int main(){
  n=gi(),m=gi();
  for (RG int i=1,l,r,d;i<=m;++i)
    l=gi(),r=gi(),d=gi(),insert(l,r,d),insert(r,l,-d);
  for (RG int i=1;i<=n;++i) if (!vis[i]) dfs(i);
  puts("Yes"); return 0;
}


Measured memory_bytes: 10624
s = input()
if s[0] == s[1] and s[2] == s[3] and s[0] != s[2]:
	print('Yes')
elif s[0] == s[2] and s[1] == s[3] and s[0] != s[1]:
	print('Yes')
elif s[0] == s[3] and s[1] == s[2] and s[0] != s[1]:
  	print('Yes')
else:
	print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;

#define DE 1
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define ALL(s) (s).begin(),(s).end()
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define EACH(i,s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl

template<class T1, class T2> ostream& operator<<(ostream &s, pair<T1,T2> P){return s<<'<'<<P.first<<", "<<P.second<<'>';}
template<class T> ostream& operator<<(ostream &s, vector<T> P) {s<<"{ ";for(int i=0;i<P.size();++i){if(i>0)s<<", ";s<<P[i];}return s<<" }"<<endl;}
template<class T1, class T2> ostream& operator<<(ostream &s, map<T1,T2> P) {s<<"{ ";for(__typeof__(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<'<'<<it->first<<"->"<<it->second<<'>';}return s<<" }"<<endl;}

const int MAX = 300;
int n;
int a[MAX][3];

int main() {
    cin >> n;
    for (int i =0; i < n; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> a[i][j];
        }
    }
    vint res(n, 0);
    for (int round = 0; round < 3; ++round) {
        for (int i = 0; i < n; ++i) {
            bool ok = true;
            for (int j = 0; j < n; ++j) {
                if (i == j) continue;
                if (a[i][round] == a[j][round]) {
                    ok = false; break;
                }
            }
            if (ok) res[i] += a[i][round];
        }
    }
    for (int i = 0; i < n; ++i) cout << res[i] << endl;
    
    return 0;
}


Measured memory_bytes: 1200
import math
import bisect
from queue import Queue
from collections import deque

h,w = [int(i) for i in input().split()]
table = [list(input()) for i in range(h)]

count = 0
for i in range(h):
    for j in range(w):
        if(table[i][j] == "."):
            count += 1

q = deque()
q.append(0)
q.append(0)
table[0][0] = 1
flag = -1
while(len(q)):
    nowx = q.popleft()
    nowy = q.popleft()

    if((nowx == h-1) and (nowy == w-1)):
        flag = int(table[nowx][nowy])

    dx = [0,0,1,-1]
    dy = [1,-1,0,0]

    for i in range(4):
        tempx = nowx + dx[i]
        tempy = nowy + dy[i]
        if((0 <= tempx)and(tempx < h)and(0 <= tempy)and(tempy < w)):
            if(table[tempx][tempy] =="."):
                table[tempx][tempy] = table[nowx][nowy] + 1
                q.append(tempx)
                q.append(tempy)


if(flag == -1):
    print(flag)
else:
    print(count-flag)

Measured memory_bytes: 41196
from collections import Counter

n=int(input())
l=list(map(int,input().split()))
a=Counter(l)
c=a.most_common()
m=len(c)
ans=0
for i in range(m):
  x=c[i][0]
  y=c[i][1]
  if x>y:
    ans+=y
  elif x<y:
    ans+=y-x
print(ans)

Measured memory_bytes: 21232
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("no-stack-protector")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")

#include<bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

const ll inf = 1e18;
const ll mod1 = 1e9 + 7;
const ll mod2 = 228661337;
const ll N = (1 << 12) + 2;

#define int long long
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define F first
#define S second

void shift()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}
void include_file(bool a)
{
    if (!a) return;
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
}




int32_t main()
{
    shift();
    srand(time(0));
    include_file(false);
    int a, b;
    cin >> a >> b;
    int c = (a + b) / 2;
    if (abs(a - c) == abs(b - c))
        cout << c;
    else
        cout << "IMPOSSIBLE";

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		double money = 100000;
		final int c = 1000;
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		
		for(int i = 1; i <= n; i++) {
			money = money + money * 0.05;
			money = Math.ceil(money / c) * c; 
		}
		System.out.println((int)money);
		
	}	
}

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


public class Main {
	private	static	BufferedReader br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String		line  = null;
		String[]	token = null;
		int[]		aTrm  = null;
		int			nSum  = 0;
		int			nTrm  = 0;
		int			nCab  = 0;

		while((line = parseNum()) != null) {
			token = line.split(" ");
			nTrm  = Integer.parseInt(token[0]);
			nSum  = Integer.parseInt(token[1]);
			if (nTrm == 0 && nSum == 0) {
				break;
			}
			aTrm  = new int[nTrm];
			nCab  = calc(0, 1, 0, nSum, aTrm);
			System.out.println(nCab);
		}
	}

	private static String parseNum() {
		String	strNum = null;

		try {
			String line = br.readLine();
			if (line != null) {
				if (!line.isEmpty()) {
					strNum = line;
				}
			}
		}
		catch (IOException e) {}

		return strNum;
	}

	private static int calc(int nSumC, int nTrmC, int nCst, int nSumM, int[] aTrm) {
		int	nCnt = 0;

		for (int n = nCst; n <= 9; n++) {
			aTrm[nTrmC - 1] = n;
			if ((nTrmC == aTrm.length) && (nSumC + n == nSumM)) {
				// 最終項までの総和が指定した総和と一致した
				nCnt += 1;
			}
			else if ((nTrmC != aTrm.length) && (nSumC + n < nSumM)) {
				// 最終項より前までの総和が指定した総和より小さい
				nCnt += calc(nSumC + n, nTrmC + 1, n + 1, nSumM, aTrm);
			}
			else if (nSumC + n >= nSumM) {
				break;
			}
		}

		return nCnt;
	}
}

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

#define SEG_LEN (1 << 18)

int seg[SEG_LEN * 2];

// one point
long long int get(int ind){
    ind += SEG_LEN;
    long long int sum = 0;
    sum += seg[ind];
    while(true){
        ind /= 2;
        if(ind == 0)break;
        sum += seg[ind];
    }
    return sum;
}

// range
void add(int l, int r, int x){
    l += SEG_LEN;
    r += SEG_LEN;
    while(l < r){
        if(l % 2 == 1){
            seg[l] += x;
            l++;
        }
        l /= 2;
        if(r % 2 == 1){
            seg[r-1] += x;
            r--;
        }
        r /= 2;
    }
}

int main(){
    int n, q, com, ind, v, l, r;
    cin >> n >> q;
    for(int i = 0;i < q;i++){
        cin >> com;
        if(com == 0){//add
            cin >> l >> r >> v;
            add(l, r+1, v);
        }
        if(com == 1){//get
            cin >> ind;
            cout << get(ind) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3884