akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  string s;
  cin >> s;
  int n = s.size();
  vector<vector<int>>vec(n+1,vector<int>(26,0));
  rep(i,n){
    rep(j,26){
      int add=0;
      if(s[i]-'a'==j)add++;
      vec[i+1][j]+=vec[i][j]+add;
    }
  }
  int l=-1,r=-1;
  if(n == 2){
    if(s[0]==s[1]){
      l=1;
      r=2;
    }
  }
  else{
    for(int i=0;i+3<=n;i++){
      rep(j,26){
        if(vec[i+3][j]-vec[i][j]>=2){
          l=i+1;
          r=i+3;
          break;
        }
      }
      if(l>0 && r>0)break;
    }
  }
  
  cout << l << " " << r << endl;
  return 0;
}


Measured memory_bytes: 13648
c = []

for i in range(3):
    c.append(list(map(int,input().split())))

ok = False

if c[0][1] == c[1][1] + c[0][0] - c[1][0] and c[0][1] == c[2][1] + c[0][0] -c[2][0]:
    if c[0][2] == c[1][2] + c[0][0] - c[1][0] and c[0][2] == c[2][2] + c[0][0] -c[2][0]:
        ok = True

if ok:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define repl(i, l, r) for (ll i = l; i < r; ++i)
#define rep(i, n) repl(i, 0, n)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
const int MOD = 1000000007;
const int INF = 1001001001;
const int dy[] = {-1, 0, 1, 0};
const int dx[] = {0, -1, 0, 1};

struct mint {
  ll x;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

ll sum(ll l, ll r) { 
    return (l + r) * (r - l + 1) / 2;
}

int main()
{
    int n, k;
    cin >> n >> k;
    mint ans;
    for (int i = k; i <= n + 1; ++i) {
        ll l = sum(0, i - 1), r = sum(n - i + 1, n);
        ans += r - l + 1;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int n; cin >> n;
  int org=n;
  int sum=0;
  int ten = 1;
  for(int i=0;n>0;i++){
    ten = 10;
    sum += n%ten;
    n=n/ten;
    //cout << "sum: " << sum << " n: " << n << endl;
  }
  //cout << sum << " " << org << endl;
  if(org%sum==0)
    cout << "Yes" << endl;
  else 
    cout << "No" << endl;
}

Measured memory_bytes: 256
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

if v <= w:
    ans = 'NO'
else:
    if abs(a - b) <= (v - w) * t:
        ans = 'YES'
    else:
        ans = 'NO'

print(ans)


Measured memory_bytes: 9176
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <iomanip>
using ll = long long;
#define rep(i, n) for(ll i = 0; i < n; i++)
using namespace std;
using P = pair<ll, ll>;

int main(){
  ll n;
  cin >> n;
  vector<vector<P>> G(n);
  rep(i, n-1){
    ll u, v, w;
    cin >> u >> v >> w;
    u--, v--;
    w %= 2;
    G[u].push_back(P(v, w));
    G[v].push_back(P(u, w));
  }
  vector<ll> dist(n, -1);
  rep(i, n){
    if (dist[i] != -1) continue;
    queue<ll> que;
    que.push(i);
    dist[i] = 0;
    while(!que.empty()){
      ll x = que.front();
      que.pop();
      for(P nx : G[x]){
        if (dist[nx.first] != -1) continue;
        dist[nx.first] = dist[x] + nx.second;
        que.push(nx.first);
      }
    }
  }
  rep(i, n){
    if (dist[i] % 2 == 0) cout << 0 << endl;
    else cout << 1 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 11448
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define bpc(x) __builtin_parityll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

ll powa(ll a, ll b, ll c)
{
    a%=c;
    if(a<0)
	a+=c;
    ll res = 1;
    while(b>0)
    {
        if(b&1)
            res*=a, res%=c;
        a*=a, a%=c;
        b>>=1;
    }
    return res;
}
 
#define N 200005
 
ll fact[N];
ll ifact[N];
 
ll ncr(ll n, ll r)
{
    if(r>n)
        return 0;
    ll ans = fact[n];
    ans*=ifact[r];
    ans%=mod;
    ans*=ifact[n-r];
    ans%=mod;
    return ans;
}

int main()
{
   FAST/**/
   
   fact[0] = 1;
   for(ll i=1;i<N;i++)
        fact[i] = fact[i-1]*i, fact[i]%=mod;
   for(ll i=0;i<N;i++)
        ifact[i] = powa(fact[i],mod-2,mod);
   
   ll n,k;
   cin>>n>>k;
   
   ll hold[k+1];
   memset(hold,0,sizeof(hold));
   for(ll i=1;i<=k;i++)
        hold[i] = k/i;
   ll dp[k+1];
   memset(dp,0,sizeof(dp));
   for(ll i=k;i>0;i--)
   {
        dp[i] = powa(hold[i],n,mod);
        for(ll j = 2*i;j<=k;j+=i)
            dp[i] = (dp[i]+mod-dp[j])%mod;
   }
   
   ll ans = 0;
   for(ll i=1;i<=k;i++)
   {
       ans+=(i*dp[i])%mod;
       ans%=mod;
   }
   cout<<ans;
   
   return 0;        
}  
   


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

int main() {
  int n,k;
  cin>>n>>k;
  double p=0;

  for(int i=1;i<=n;i++){
    double d = i;
    double pi = 1/double(n);
    while(d<k){
      pi *=0.5;
      d *=2;
    }
    p += pi;
  }

 // cout<<p<<endl;
printf("%.9f\n", p);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int a,b;
  cin >> a >> b;
  for (int i = 0; i <= a; i++) {
    if (i * 2 + (a - i) * 4 == b) {
      cout << "Yes\n";
      return 0;
    }
  }
  cout << "No\n";
  return 0;
}

Measured memory_bytes: 3620
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

count = 0
for i in range(n-1,-1,-1):
    k1 = min(a[i+1],b[i])
    b[i] = b[i]-k1
    k2 = min(a[i],b[i])
    a[i] = a[i]-k2
    count += (k1 + k2)
print(count)

Measured memory_bytes: 18468
#include <bits/stdc++.h>
using namespace std;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

typedef long long ll;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define DBGV(v,n) forn(i,n) cout << v[i] << " "; cout << endl
#define esta(x,c) ((c).find(x) != (c).end())
#define RAYA cerr << "===============================" << endl

int main()
{
	FIN;
	
	int n;
	cin >> n;
	cout << (1000-n%1000)%1000 << "\n";
	
    return 0;
}


Measured memory_bytes: 3648
x = int(input())

if 400 <= x < 600:
    print('8')
elif 600 <= x < 800:
    print('7')
elif 800 <= x < 1000:
    print('6')
elif 1000 <= x < 1200:
    print('5')
elif 1200 <= x < 1400:
    print('4')
elif 1400 <= x < 1600:
    print('3')
elif 1600 <= x < 1800:
    print('2')
elif 1800 <= x < 2000:
    print('1')


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

using namespace std;
 
#define int1(a) scanf("%d",&a)
#define int2(a,b) scanf("%d %d",&a,&b)
#define int3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define int4(a,b,c,d) scanf("%d %d %d %d",&a,&b,&c,&d)
 
#define lint1(a) scanf("%lld",&a)
#define lint2(a,b) scanf("%lld %lld",&a,&b)
#define lint3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define lint4(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define lli long long int
 
#define pint(x) printf("%d",x)
#define plint(x) printf("%lld",x)
#define endl '\n'
#define nl printf("\n");
#define ps printf(" "); 
 
#define all(x) x.begin(),x.end()
#define pb push_back
#define Set(a, s) memset(a, s, sizeof (a))
#define mod1 (lli)(1e9 + 7)
#define mod2 (lli)(1e9 + 9)
#define EPS 1e-9

#define fore(i,n) for(int i=n; i>=0; i--)
#define fors(i,a,n) for(int i=a; i<n; i++)
#define fora(i,ele) for(auto i: ele)
 
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<lli> vli;
 
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
 
double tick(){static clock_t oldt,newt=clock();double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;oldt=newt;return diff;}
float roundoff(float val, float p){ return floor(val*pow(10.0,p)+0.5)/pow(10.0,p);}
lli power(lli a, lli b, lli mod){lli x=1,y=a; while(b > 0){if(b&1){x=(x*y)%mod;}y = (y*y)%mod; b /= 2;}return x;}
 
const int INF = 0x3f3f3f3f;
const float pi = 3.14159265;
 
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};
//int dx[]={1,-1,0,0}; int dy[]={0,0,1,-1};
 lli n;
 vli arr;
 
 lli go(int idx, vli &dp){
	 if(idx == n-1) return 0;
	 if (dp[idx] != -1) return dp[idx];
	 
	 else if(idx==n-2) return dp[n-2] = abs(arr[n-1]-arr[n-2]);
	 
	 else{
		 return dp[idx] = min(abs(arr[idx]-arr[idx+1])+go(idx+1,dp), abs(arr[idx]-arr[idx+2])+go(idx+2,dp));
	 }
	 
 }
 
int main(void) {
    ios_base::sync_with_stdio(true);
    cin.tie(NULL);
    cout.tie(NULL);
	//srand (time(NULL));
	/*
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	*/
    // cout<<"Execution time : "<<tick()<<"\n";
    
    lint1(n);
    vli dp(n,-1);
    
   // vi arr;
    fors(i,0,n){
		lli temp;
		lint1(temp);
		arr.pb(temp);
	}
	cout<<go(0,dp);
	
    return 0;
}


Measured memory_bytes: 5108
from collections import defaultdict


N, K = map(int, input().split())
A = list(map(int, input().split()))

dictNum = defaultdict(int)
for a in A:
    dictNum[a] += 1

listNum = sorted(list(dictNum.values()))
if len(listNum) <= K:
    print(0)
else:
    print(sum(listNum[:len(listNum)-K]))

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

int main() {
	string s;
	cin >> s;
	int cnt = 0;
	for(int i = 0; i < s.size(); i++) {
		if(s[i] == 'S') {
			cnt += 1;
		} else {
			if(cnt) cnt -= 1;
		}
	}
	cout << (2 * cnt) << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

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

    int n, m, v, p;
    cin >> n >> m >> v >> p;
    vi a(n);
    rep(i, n) cin >> a[i];
    sort(a.rbegin(), a.rend());

    int ok = p-1;
    int ng = n;
    while (ng - ok > 1) {
        int mid = (ok + ng) / 2;
        ll total = 0;
        rep(i, n) {
            if (i < p-1 || i >= mid+1) {
                total += m;
            } else {
                if (a[i] > a[mid] + m) {
                    total = -1;
                    break;
                }
                total += max(a[mid] + m - a[i], 0);
            }
        }
        if (total >= (ll)m*v) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    cout << ok + 1 << endl;
}

Measured memory_bytes: 640
n,q = map(int, input().split())
s = input()

ac_cnts = [0]*(n)
curr_cnt = 0
for i, (s1,s2) in enumerate(zip(s[:-1],s[1:])):
    if s1 == 'A' and s2 == 'C':
        curr_cnt += 1
    ac_cnts[i+1] = curr_cnt

ans = []
for _ in range(q):
    l,r = map(int, input().split())
    l-=1
    r-=1
    ans.append(ac_cnts[r]-ac_cnts[l])

# print(ac_cnts)
# print(ans)

for a in ans:
    print(a)

Measured memory_bytes: 83144
#include<iostream>

using namespace std;


class DICE {
	enum {
		Top,
		Front,
		Right,
		Left,
		Rear,
		Bottom
	};

	void Roll(const char*Directions) {
		for (int i = 0; Directions[i] != '\0'; i++) {
			Roll(Directions[i]);
		}
	}

	void Roll(const char Direction) {
		int tmpTop = Num[Top];

		switch (Direction) {
		case'E':
			Num[Top] = Num[Left];
			Num[Left] = Num[Bottom];
			Num[Bottom] = Num[Right];
			Num[Right] = Num[tmpTop];
			break;
		case'N':
			Num[Top] = Num[Front];
			Num[Front] = Num[Bottom];
			Num[Bottom] = Num[Rear];
			Num[Rear] = tmpTop;
			break;
		case'S':
			Num[Top] = Num[Rear];
			Num[Rear] = Num[Bottom];
			Num[Bottom] = Num[Front];
			Num[Front] = tmpTop;
			break;
		case'W':
			Num[Top] = Num[Right];
			Num[Right] = Num[Bottom];
			Num[Bottom] = Num[Left];
			Num[Left] = tmpTop;
			break;
		}
	}

	bool SameDiceDirectionFlag(DICE Dice) {
		for (int i = 0; i < 6; i++) {
			if (Num[i] != Dice.Num[i])return false;
		}
		return true;
	}

public:
	int Num[6];

	bool SameDiceNoneDirectionFlag(DICE Dice) {
		const char Directions[][3] = { "N","N","N","NW","WW","\0" };

		for (int i = 0; i < 6; i++) {
			if (Num[Top] == Dice.Num[Top]) {
				for (int j = 0; j < 4; j++) {
					if (SameDiceDirectionFlag(Dice))return true;

					int tmpFront = Dice.Num[Front];
					Dice.Num[Front] = Dice.Num[Right];
					Dice.Num[Right] = Dice.Num[Rear];
					Dice.Num[Rear] = Dice.Num[Left];
					Dice.Num[Left] = tmpFront;
				}
			}

			Dice.Roll(Directions[i]);
		}

		return false;
	}

};

int main() {
	DICE Dice[101];
	int n;

	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 6; j++)cin >> Dice[i].Num[j];
	}

	for (int i = 1; i < n; i++) {
		if (Dice[0].SameDiceNoneDirectionFlag(Dice[i])) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 1160
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  int n=sc.nextInt(),count=0;
	  for(int i=1;i<=n;i+=2) {
		  if(divisorEnum(i).size()==8)count++;
	  }

	  System.out.println(count);
  }
	public static List<Long> divisorEnum(long n) {
		List<Long> l=new ArrayList<>();
		for(long i=1;i<=Math.sqrt(n);i++) {
			if(n%i==0) {
				l.add(i);
				if(i!=Math.sqrt(n))l.add(n/i);
			}
		}
		l.sort(null);
		return l;
	}
}


Measured memory_bytes: 35712
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <limits>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, a, n) for (int i = a; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eps 1e-15

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef tuple<int, int, int> ti3;

int main()
{
    int n;
    scanf("%d", &n);
    if (n % 2 == 1)
        n *= 2;
    printf("%d\n", n);
    return 0;
}


Measured memory_bytes: 256
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))
# map(int, input().split())
# int(input())
# input().split()
# mojiretu = ','.join(str_list)
# sorted(input())
n, a, b = map(int, input().split())
print(min(n*a, b))

Measured memory_bytes: 5048
n=gets.to_i
v=gets.split.map(&:to_i)
he,ho={},{}
n.times do |i|
  if i.even?
    if !he.has_key?(v[i])
      he[v[i]]=1
    else
      he[v[i]]+=1
    end
  else
    if !ho.has_key?(v[i])
      ho[v[i]]=1
    else
      ho[v[i]]+=1
    end
  end
end
hemk, hemv = he.max{|x,y| x[1] <=> y[1]}
homk, homv = ho.max{|x,y| x[1] <=> y[1]}
if hemk == homk
  he.delete(hemk)
  ho.delete(homk)
  if he=={}
    hhemv=0
  else
    hhemk, hhemv = he.max{|x,y| x[1] <=> y[1]}
  end
  if ho=={}
    hhomv=0
  else
    hhomk, hhomv = ho.max{|x,y| x[1] <=> y[1]}
  end
  puts n-[hemv+hhomv,homv+hhemv].max
else
  puts n-hemv-homv
end


Measured memory_bytes: 17164
A,B,M=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
x=[]
y=[]
c=[]

for i in range(M):
    x1,y1,c1=list(map(int,input().split()))
    x.append(x1)
    y.append(y1)
    c.append(c1)

sum=min(a)+min(b)
for i in range(0,M):
    sum1=a[x[i]-1]+b[y[i]-1]-c[i]
    if sum>sum1:
        sum=sum1

print(sum)





Measured memory_bytes: 24676
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    int b,c=0,k=0,n,h,w,m,ans=0,max=-10;
    string s,s2;
    cin >> s; 
    for(int i=1;i<s.size()-1;i++){
        c++;
    }
    cout << s[0] << c << s[s.size()-1] << endl;
    return 0;
}

Measured memory_bytes: 256
N,_=gets.chomp.split(" ").map{|n| n.to_i}
A = Array.new(N)
B = Array.new(N)
0.upto(N-1){|d|
	A[d],B[d]=gets.chomp.split(' ').map{|n| n.to_i}
}
i = N-1
sum = 0
while(i>=0)
	sum += -(A[i]+sum) % B[i]
	i -= 1
end
puts sum




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

int main(){
  char c11, c12, c13;
  char c21, c22, c23;
  char c31, c32, c33;
  cin >> c11 >> c12 >> c13;
  cin >> c21 >> c22 >> c23;
  cin >> c31 >> c32 >> c33;
  cout << c11 << c22 << c33 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;

int main(){
    int n;    
    cin>>n;
    while(n!=0){
        double s[1000]={},sum=0,a=0;
        for(int i=0; i<n; i++){
        	cin>>s[i];
        	sum+=s[i];
    	}        
        for(int i=0; i<n; i++){
        	a+=((sum/n)-s[i])*((sum/n)-s[i])/n;
    	}
        printf("%.5f\n",sqrt(a));
    	cin >> n;
    }
	return 0;
}


Measured memory_bytes: 3184
#include<stdio.h>
int cmp(const void *a,const void *b)
{
    return(*(int*)a-*(int*)b);
}
int main()
{
    int n,i=0,c=0,temp,count=0,j;
    int ary[50];
    int bry[50];

    scanf("%d",&n);
    while(i<n)
    {
       scanf("%d",&ary[i]);;
       i++;
    }

    for(i=0;i<n;i++)
        bry[i]=ary[i];

qsort(ary,n,sizeof(int),cmp);

   for(i=0;i<n;i++)
        if(bry[i]!=ary[i])
            count++;



if(count<=2)
    printf("YES");
    else
        printf("NO");



}




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

int main(){
  int64_t N;
  cin>>N;
  vector<int64_t> A(N);
  for(int64_t i=0;i<N;i++){
    int64_t j;
    cin>>j;
    A.at(i)=j-(i+1);
  }
  sort(A.begin(),A.end());
  int64_t l=A.at(N/2),k=0;
  for(int64_t &i:A)
    k+=max(i-l,l-i);
  cout<<k<<endl;
}

Measured memory_bytes: 1792
x,y = map(int,input().split())
c = 0
if x==1:
    c+=300000
elif x == 2:
    c+=200000
elif x == 3:
    c+=100000
    
if y==1:
    c+=300000
elif y == 2:
    c+=200000
elif y == 3:
    c+=100000

if x == 1 and y == 1:
    c+=400000
    
print(c)

Measured memory_bytes: 9184
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
const int MAX = (int)1e5 + 5;

signed main() {
	ll n;
	while (cin >> n) {
		int cnt = 0;
		rep(i, 10) rep(j, 10) rep(k, 10) rep(l, 10) {
			if (i + j + k + l == n) cnt++;
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define maxn 200005
#define mod 998244353
#define ll long long
using namespace std;

typedef pair<int, int> P;

int n, m;
int f[maxn];
int getf(int x)
{
    return (f[x] == x) ? x : f[x] = getf(f[x]);
}
int unite(int x, int y)
{
    x = getf(x);
    y = getf(y);
    f[y] = x;
}

int g[maxn];
int ans = 0;

int main()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        f[i] = i;
    for (int i = 0; i < m; i++)
    {
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        unite(x, y);
    }
    for (int i = 1; i <= n; i++)
        g[getf(i)]++;
    for (int i = 1; i <= n; i++)
        if (g[i] > 0)
            ans++;
    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace codeTester.contest190727
{
    class ProblemC
    {
        static int n = 0;
        static List<long> aList = new List<long>();
        static List<long> bList = new List<long>();
        static long answer = 0;

        public static void Main(string[] args)
        {
            Input();
            Logic();
            Output();
        }

        static void Input()
        {
            n = int.Parse(Console.ReadLine());
            aList = ReadSpaceSeparatedValues();
            bList = ReadSpaceSeparatedValues();
        }

        public static List<long> ReadSpaceSeparatedValues()
        {
            List<long> values = new List<long>();
            string[] inputs = Console.ReadLine().Split(' ');
            foreach (string input in inputs)
            {
                values.Add(long.Parse(input));
            }

            return values;
        }

        static void Logic()
        {
            // 0 番目の街からグリーディーにやっていく。
            long remainPower = 0;
            long defeatedMonsterNum = 0;
            
            // TODO Linq にする
            for(int i = 0; i < n; i++)
            {
                long remainMonsters = Math.Max(aList[i] - remainPower, 0); // １つ前の勇者の余力で今回の街のモンスターが倒される。
                long battleResult = bList[i] - remainMonsters; // 今回の勇者の力と残ったモンスターの力の差
                DebugPrint("remainMonsters = " + remainMonsters + " / battleResult = " + battleResult);
                if (battleResult >= 0)
                {
                    // モンスターを全滅させた
                    defeatedMonsterNum += aList[i];

                    // 次の街のモンスターを倒すのに使える余力
                    remainPower = battleResult;
                }
                else
                {
                    // 前の勇者の余力と今の勇者の力の合計だけモンスターを倒した
                    defeatedMonsterNum += (remainPower + bList[i]);

                    // 次への余力は残ってない
                    remainPower = 0;
                }
            }

            answer = defeatedMonsterNum + Math.Min(remainPower, aList[n]);
        }

        static void Output()
        {
            Console.WriteLine(answer.ToString());
        }

        static void DebugPrint(string msg)
        {
            // 提出時に消す
            // Console.WriteLine(msg);
        }
    }
}


Measured memory_bytes: 34908
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <cmath>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n;
  cin >> n;
  vector<vector<int>> coordinate(n, vector<int>(2));
  rep(i, n) {
    cin >> coordinate[i][0] >> coordinate[i][1];
  }
  vector<int> order(n);
  rep(i, n) {
    order[i] = i;
  }
  double sum = 0;
  int n_factorial = 1;
  for(int i = 1; i <= n; i++) {
    n_factorial *= i;
  }
  do {
    double distance = 0;
    int x_now = coordinate[order[0]][0];
    int y_now = coordinate[order[0]][1];
    for(int i = 1; i < n; i++) {
      double dis = sqrt((coordinate[order[i]][0]-x_now)*(coordinate[order[i]][0]-x_now)+
      (coordinate[order[i]][1]-y_now)*(coordinate[order[i]][1]-y_now));
      //printf("x,y:%d %d\n", x_now, y_now);
      distance += dis;
      x_now = coordinate[order[i]][0];
      y_now = coordinate[order[i]][1];
    }
    sum += distance;
  } while(next_permutation(order.begin(), order.end()));
  double mean = sum / n_factorial;
  printf("%.7lf\n",mean);
}

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

int main() {
  string str, mf, ml;
  map<string, int> mp;
  while (cin >> str) {
    mp[str]++;
    if (mp[str] > mp[mf]) mf = str;
    if (str.length() > ml.length()) ml = str;
  }
  cout << mf << " " << ml << endl;
}


Measured memory_bytes: 3116
class dice():
    def __init__(self,number):
        self.number = number

    def korokoro(self,com):
        if com == 'E':
            self.number = [self.number[i] for i in [3,1,0,5,4,2]]
        if com == 'S':
            self.number = [self.number[i] for i in [4,0,2,3,5,1]]
        if com == 'N':
            self.number = [self.number[i] for i in [1,5,2,3,0,4]]
        if com == 'W':
            self.number = [self.number[i] for i in [2,1,5,0,4,3]]
d1 = dice([int(x) for x in input().split()])
d2 = dice([int(x) for x in input().split()])
for com in 'EEEENEEEENEEEENEEEENWSEEEENNEEEE':
    d1.korokoro(com)
    if d1.number == d2.number:
        ans = 'Yes'
        break
    else:
        ans = 'No'
print(ans)



Measured memory_bytes: 5604
program main;
var n,g,count : integer;
var s : string;
begin

readln (n);
readln (s);
count:=0;

for g:=1 to (n+2) do
if s[g]+s[g+1]+s[g+2]='ABC'
then count:=count+1;

writeln (count);
end.

Measured memory_bytes: 1380
n,a,b = map(int,input().split())

sa = b-a

goal = 0

if n-b > a-1:
    goal = 1
else:
    goal = n
    

if sa % 2 == 0:
    print(sa//2)
else:
    if goal == 1:
        print(a-1+1+sa//2)
    else:
        print(n-b+1+sa//2)

Measured memory_bytes: 3060
#include <cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;

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() {
    ll n;
    cin >> n;
    vector<P>p = prime_factorize(n);
    ll count = 0;
    for (auto id : p) {
        int index = 1;
        while (id.second > 0) {
            count++;
            id.second -= index;
            index++;
        }
        if (id.second != 0) {
            count--;
        }
        
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3588
// 2020-09-04 23:13:00
// clang-format off
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

// clang-format on
void answer() {
  int n;
  string s;
  cin >> n >> s;
  deque<char> que;
  int x = 0;
  rep(i, n) {
    if (s[i] == '(') {
      x++;
      que.push_back('(');
    } else if (x > 0) {
      x--;
      que.push_back(')');
    } else {
      que.push_front('(');
      que.push_back(')');
    }
  }
  rep(i, x) que.push_back(')');
  for (char c : que) cout << c;
  cout << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3640
def neighbor(i, j):
    dxy4 = [(0, 1), (-1, 0), (0, -1), (1, 0)]
    neighL = []
    for dxy in dxy4:
        ni, nj = i+dxy[0], j+dxy[1]
        if 0<= ni < H and 0<= nj < W:
            if map_[ni][nj] =='.':
                neighL.append((ni, nj))
    return neighL
            
def bfs(start, goal):
    from collections import deque
    WHITE, GRAY, BLACK, INF = 0, 1, 2, float('inf')
    
    color = [[WHITE]*W for _ in range(H)]
    d = [[INF]*W for _ in range(H)]
    
    i0, j0 = start
    i1, j1 = goal
    depth = 0
    color[i0][j0] = GRAY
    d[i0][j0] = depth + 1
    Q = deque([(i0, j0)])
    while Q:
        i, j = Q.popleft()
        depth = d[i][j]
        for ni, nj in neighbor(i, j):
            if color[ni][nj] == WHITE:
                color[ni][nj] = GRAY
                d[ni][nj] = depth + 1
                Q.append((ni, nj))
        color[i][j] = BLACK
    return d[i1][j1]


H, W = map(int, input().split())
map_ =  [list(input().strip()) for _ in range(H)]   #; print(map_)
n_open = sum([map_[i].count('.') for i in range(H)])
start, goal = (0, 0), (H-1, W-1)
min_d = bfs(start, goal)
if min_d == float('inf'):
    print(-1)
else:
    print(n_open - min_d)


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

int main() {
    unsigned int n, q;
    unsigned long long int k;
    cin >> n >> k >> q;
    //cout << n << ',' << k << ',' << q << endl;

    vector<unsigned int> a(q);
    for (unsigned int i = 0; i < q; ++i) {
        cin >> a.at(i);
    }

    //cout << n << ',' << k << ',' << q << endl;
    vector<int> score(n, k-q);

    for (unsigned int i = 0; i < q; ++i) {
        score.at(a.at(i)-1)++;
    }

    for (unsigned int i = 0; i < n; ++i) {
        //cout << "i: " << i << ", score[" << i << "]: " << score.at(i) << endl;
        if(score.at(i) <= 0) {
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    }
}


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

int n,a[100010],b[100010];
vector<pair<pair<int,int>,int> > v;
bool vis[100010][2];

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	int sum1=0,sum2=0;
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i];
		sum1+=a[i];
		sum2+=b[i];
		v.push_back(make_pair(make_pair(a[i],i),0));
		v.push_back(make_pair(make_pair(b[i],i),1));
	}
	sort(v.begin(),v.end());
	int sum=0;
	for(int i=0;i<n;i++){vis[v[i].first.second][v[i].second]=1;sum+=v[i].first.first;}
	int cnt1=0,cnt2=0,cnt3=0,cnt4=0;
	for(int i=1;i<=n;i++){
		if(!vis[i][0]&&!vis[i][1]) cnt1++;
		if(vis[i][0]&&!vis[i][1]) cnt3++;
		if(!vis[i][0]&&vis[i][1]) cnt2++;
		if(vis[i][0]&&vis[i][1]) cnt4++;
	}
	if(cnt1>0&&cnt4>0) cout<<sum<<endl;
	else if(cnt2==0||cnt3==0) cout<<sum<<endl;
	else{
		int mn=min(sum1,sum2);
		multiset<int> s;
		for(int i=1;i<=n;i++){
			if(vis[i][0]) s.insert(b[i]);
			else s.insert(a[i]);
		} 
		for(int i=1;i<=n;i++){
			if(vis[i][0]){
				int now=sum-a[i];
				s.erase(b[i]);
				now+=*s.begin();
				mn=min(mn,now);
				s.insert(b[i]);
			}
			else{
				int now=sum-b[i];
				s.erase(a[i]);
				now+=*s.begin();
				mn=min(mn,now);
				s.insert(a[i]);
			}
		}
		cout<<mn<<endl;
	}
	return 0;
}

Measured memory_bytes: 12524
import java.util.*;

public class Main  {
   public static void main(String[] args)  {
      Scanner sc = new Scanner(System.in);
          
      int n = sc.nextInt();
      
      if (10 <= n && n <100) {
         n = n % 10;
      } else if (100 <= n) {
         n = n % 10 % 10;
      }
         
      if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
         System.out.println("hon");
      } else if (n == 0 || n == 1 || n == 6 || n == 8) {
         System.out.println("pon");
      } else if (n == 3) {
         System.out.println("bon");
      }
   }
}

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

#define int long long
using ll = long long;
using ld = long double;
using intpair = pair<int, int>;
const int MOD = 1e9 + 7;
inline int mod (ll a, int m = MOD) { return (a % m + m) % m; }
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((ll)((a) + (b) - 1)/(ll)(b))

signed main(){
    int a; cin >> a;
    cout << a + a*a + a*a*a << endl;
}

Measured memory_bytes: 3684
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>

using namespace std;

#define Whats(x) cout<<#x<<" is "<<x<<endl

const int N=5000;

int MOD;

int Mul(int a,int b)
{
	unsigned long long x=(long long)a*b;
	unsigned xh=(unsigned)(x>>32),xl=(unsigned)x,d,m;
	asm
		(
		 "divl %4;\n\t"
		 :"=a"(d),"=d"(m)
		 :"d"(xh),"a"(xl),"r"(MOD)
		);
	return m;
}

int U(int x,int y)
{
	return ((x+=y)>=MOD)?(x-MOD):x;
}

void SU(int& x,int y)
{
	((x+=y)>=MOD)?(x-=MOD):0;
}

int Qpow(int x,int y=MOD-2)
{
	int res=1;
	for(;y;y>>=1,x=Mul(x,x))if(y&1)
		res=Mul(res,x);
	return res;
}

int n,C[N][N],S[N][N],ppw[N],pw[N];

void Prework()
{
	for(int i=0;i<=n;++i)
	{
		C[i][0]=1;
		for(int j=1;j<=i;++j)
			C[i][j]=U(C[i-1][j-1],C[i-1][j]);
	}
	S[0][0]=1;
	for(int i=1;i<=n+1;++i)
		for(int j=1;j<=i;++j)
			S[i][j]=U(S[i-1][j-1],Mul(j,S[i-1][j]));
	pw[0]=1;
	for(int i=1;i<=n;++i)
		pw[i]=U(pw[i-1],pw[i-1]);
	ppw[0]=2;
	for(int i=1;i<=n;++i)
		ppw[i]=Mul(ppw[i-1],ppw[i-1]);
}

int main()
{
	scanf("%d%d",&n,&MOD);
	Prework();
	int ans=0;
	for(int i=0,sum;i<=n;++i)
	{
		sum=0;
		for(int k=0;k<=i;++k)
			SU(sum,Mul(Qpow(pw[n-i],k),S[i+1][k+1]));
		if(i&1)
			SU(ans,MOD-Mul(C[n][i],Mul(ppw[n-i],sum)));
		else
			SU(ans,Mul(C[n][i],Mul(ppw[n-i],sum)));
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 119552
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	cout << (N-2)*180 << "\n";

	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        String s = in.next();

        long t = 0;
        for (int i = 0; i < 1 << (s.length() - 1); i++) {
            int p = 0;
            for (int j = 0; j < s.length() - 1; j++) {
                if ((1 & i >> j) == 1) {
                    t += Long.parseLong(s.substring(p, j + 1));
                    p = j + 1;
                }
            }
            t += Long.parseLong(s.substring(p));
        }

        out.println(t);
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

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

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

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

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}

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

const ll MOD = 1000000007;
int n, bitsum[70];
ll a[303030];

int main(){
  cin >> n;
  rep(i, n) cin >> a[i];
  rep(i, n) rep(j, 60) bitsum[j] += ((a[i] >> j) & 1LL);
  
  //rep(i, 60) cout << bitsum[59 - i] << " ";
  ll res = 0;
  rep(i, n - 1){
    rep(j, 60) bitsum[j] -= ((a[i] >> j) & 1LL);
    rep(j, 60){
      ll tmp;
      if((a[i] >> j) & 1){
        tmp = n - i - bitsum[j] - 1;
      }else{
        tmp = bitsum[j];
      }
      tmp *= ((long)pow(2, j) % MOD);
      res += tmp;
      res %= MOD;
    }
  }
  cout << res << endl;

  return 0;
}

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

#define FOR(i,a,b) for(int i = (a);i < (b);++i)
typedef long long ll;

int main(){
   vector<int> c(3);
   cin >> c[0] >> c[1] >> c[2];
   sort(c.begin(),c.end());
   cout << c[2] - c[0] << endl;
   return 0;
 } 

Measured memory_bytes: 256
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
// #define MOD  998244353
#define ll long long
const double PI = atan(1.0) * 4;
// const ll INF = (int)1e9 ;
const int di[4] = { -1, 0, 1, 0} ;
const int dj[4] = {0, -1, 0, 1} ;
const ll INF = (ll)2e18 + 50;
const int maximum  = numeric_limits<int>::min();
const int minimum  = numeric_limits<int>::max();

ll power(ll a , ll e) {
	ll res = 1LL ;
	while (e > 0) {
		if (e % 2 == 1) res = res * a;
		a =  a * a  ;
		e /= 2 ;
	}
	return res ;
}
bool isBalanced(const string &exp)
{
	// Initialising Variables
	bool flag = true;
	int count = 0;

	// Traversing the Expression
	for (int i = 0; i < exp.length(); i++) {

		if (exp[i] == '(') {
			count++;
		}
		else {
			count--;
		}
		if (count < 0) {
			flag = false;
			break;
		}
	}
	if (count != 0) {
		flag = false;
	}

	return flag;
}
bool sortbysec(const pair<pair<int, int>, int> &a,
               const pair<pair<int, int>, int> &b)
{
	return (a.second < b.second);
}

void uniformly_distribute_k_numbers_in_a_square_grid(int n , int k ) {
	int p = 0 , q = 0 ;
	vector<vector<int>> a(n, vector<int>(n)) ;
	for (int i = 1 ; i <= k ; ++i ) {
		a[p][q] = 1 ;
		p = p + 1 ;
		q = (q + 1) % n ;
		if (p == n) {
			p = 0  ;
			q = (q + 1) % n ;

		}
	}
}




int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	// int t ;
	// cin >> t ;
	// while (t--) {
	int n ;
	cin >> n ;
	if (n % 1000 > 0) cout << 1000 - n % 1000 << "\n";
	else cout << 0 << "\n";


	// }







	return 0 ;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
const int maxx = 1e5 + 7;
typedef long long ll;
const int Inf = 1 << 30;
const ll INF = 1ll << 60;
int n, r;

int main() {
	cin >> n >> r;
	if(n >= 10) cout << r << endl;
	else {
		int ans = 100 * (10 - n) + r;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] town = new int[n];
		for(int i = 0; i < m; i++) {
			town[sc.nextInt() - 1] ++;
			town[sc.nextInt() - 1] ++;
		}
		for(int i : town) {
			System.out.println(i);
		}
	}

}


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

#pragma region Macro
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define vvi vector<vector<int>>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

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

void solve(){
	#define int ll
	// ここに処理を記述
	// コンパイル時はエイリアス「gpp」--> c++17でコンパイル
	int x,y;
	cin >> x >> y;

	rep(i,x+1){
		int j = x - i;
		if(i*2 + j*4 == y){
			cout << "Yes" << endl;
			return;
		}
	}

	cout << "No" << endl;
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	
	solve();
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define contests_de_diya_kar 0
#define PB push_back
#define MP make_pair
#define int long long
#define MOD ((long long) (1000*1000*1000 + 7))
#define maxn 5000
#define inf (int) 2e15
#define exit(a, b) return cout << a, b;
#define eps (double)1e-8
#define forn(a, b, i) for (int i = a; i < b; i += 1)
#define vi vector<int>
#define vb vector<bool>
#define all(v) v.begin(), v.end() 
#define pii pair<int, int>
#define mii map<int, int> 
#define print(stuff) cout << stuff << endl
#define len(stuff) stuff.size()

signed main () {
	start_routine;
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	#endif

	int n;
	cin >> n;

	if (n % 2 == 0) cout << n;
	else cout << 2 * n;

	end_routine;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);

	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt" , "r" , stdin);
	// freopen("output.txt" , "w" , stdout);
	// #endif

	ll n,ans=0;
	cin>>n;
	map<ll,ll>m1,m2;
	for(ll i=1;i<=n;i++)
	{
		ll a;
		cin>>a;
		m1[i+a]++;
		m2[i-a]++;
	}
	for(auto i:m1)
	{
		ans+=(i.second)*(m2[i.first]);
	}

	
	cout<<ans<<endl;
}


Measured memory_bytes: 37808
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;

int main(){
   int n,k;
   cin>>n>>k;
   int ans=n-k;
   if(k==1)ans=0;
   cout<<ans<<endl;
}

   


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a,b,c;
	int sum=700;
	cin>>a>>b>>c;
	if(a=='o')sum+=100;
	if(b=='o')sum+=100;
	if(c=='o')sum+=100;
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
S = input()

S = set(S)

if 'N' in S and 'S' in S:
    pass
elif 'N' not in S and 'S' not in S:
    pass
else:
    print('No')
    exit()
if 'E' in S and 'W' in S:
    pass
elif 'E' not in S and 'W' not in S:
    pass
else:
    print('No')
    exit()

print('Yes')



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

using namespace std;

int main() {
	int K, X;
	cin >> K >> X;
	if (500 * K >= X) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 3636
import java.io.*;
import java.util.*;

public class Main {

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

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

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

        public float nextFloat() {
            return Float.parseFloat(next());
        }

    }

    static InputReader r = new InputReader(System.in);
    static PrintWriter pw = new PrintWriter(System.out);

    /** CHECKLIST:
     * LIMITS (DOES BRUTE FORCE WORK?)
     * CHECK ALL PARAMETERS
     * INT VS LONG
     */
    public static void main(String[] args) {
        int n = r.nextInt();
        int[] arr = new int[n+1];
        for(int i = 1; i <= n; i++){
            arr[i] = r.nextInt();
        }
        int[] dp = new int[n+1];
        dp[1] = 0; // frog starts here
        dp[2] = Math.abs(arr[2] - arr[1]);
        for(int i = 3; i <= n; i++){
            dp[i] = Math.min(dp[i-1] + Math.abs(arr[i] - arr[i-1]), dp[i-2] + Math.abs(arr[i] - arr[i-2]));
        }
        pw.println(dp[n]);

        pw.close();
    }
}

/**
                _        _                 _                                                
               | |      | |               | |                                               
   ___ ___   __| | ___  | |__  _   _    __| | __ _ _ __ _ __ ___ _ __     _   _  __ _  ___  
  / __/ _ \ / _` |/ _ \ | '_ \| | | |  / _` |/ _` | '__| '__/ _ \ '_ \   | | | |/ _` |/ _ \ 
 | (_| (_) | (_| |  __/ | |_) | |_| | | (_| | (_| | |  | | |  __/ | | |  | |_| | (_| | (_) |
  \___\___/ \__,_|\___| |_.__/ \__, |  \__,_|\__,_|_|  |_|  \___|_| |_|   \__, |\__,_|\___/ 
                                __/ |                               ______ __/ |            
                               |___/                               |______|___/             
 */

Measured memory_bytes: 33664