akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,in[1010][1010] = {};
	cin >> n;
	vector<P> G[1010][1010];
	for(int i = 0;i < n;i++){
		int a[1010];
		for(int j = 0;j < n - 1;j++){
			cin >> a[j]; a[j]--;
			if(j){
				G[min(i,a[j - 1])][max(i,a[j - 1])].pb(P(min(i,a[j]),max(i,a[j])));
				in[min(i,a[j])][max(i,a[j])]++;
			}
		}
	}
	queue<P> que;
	for(int i = 0;i < n;i++){
		for(int j = i + 1;j < n;j++){
			if(!in[i][j]) que.push(P(i,j));
		}
	}
	int day = 0,match = 0;
	for(;;day++){
		int siz = que.size();
		if(!siz) break;
		for(int i = 0;i < siz;i++){
			P p = que.front();que.pop();
			match++;
			for(P to : G[p.first][p.second]){
				in[to.first][to.second]--;
				if(!in[to.first][to.second]) que.push(to);
			}
		}
	}
	if(match == n * (n - 1) / 2) cout << day << endl;
	else cout << -1 << endl;
}


Measured memory_bytes: 57344
using System;
using System.Collections.Generic;

namespace MyProgram{
    class AtCoder{
        static void Main(){
            int N = int.Parse(Console.ReadLine());
            int[] a = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
            int[] rate = new int[13];
            for(var i=0;i<N;i++){
                rate[a[i]/400]++;
            }
            int sum=0;
            for(var i=0;i<=7;i++){
                if(rate[i]>0)sum++;
            }
            int sum_min = sum;
            int sum_max = sum;
            for(var i=8;i<13;i++){
                sum_max += rate[i];
            }
            if(sum<sum_max&&sum==0){
                sum_min = sum+1;
            }
            Console.WriteLine("{0} {1}",sum_min,sum_max);
        }  
    } 
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
 #define rep(i,n) for(int i=0;i<n;i++)
 using namespace std;
  int main(){
      int a,b,c;
      cin >> a >> b >> c;
      if(a<=c && c<=b){
          cout << "Yes"  << endl;
      }
      else{
          cout << "No" << endl;
      }
      return 0;
  }

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

using namespace std;

/*

        Bismillahir Rahmanir Rahim
        Problem :
        Problem Link :
        Topics :
        Solver : Masud Parves
        I Love Code More than Sharks Love Blood <3
*/

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define SZ(a)           (int)a.size()
#define all(a)  a.begin(), a.end()
#define allr(a)  a.rbegin(), a.rend()


#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int zz=1 ; zz<=t ; zz++)
#define PRINT_CASE printf("Case %d: ",zz)
#define Debug(x)            cout<<#x " = "<<(x)<<endl
#define NOT_VISITED 0
#define IS_VISITED 1
#define WHITE 0
#define GRAY 1
#define BLACK 2

int fx[4]= {1,-1,0,0};
int fy[4]= {0,0,1,-1};

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N  (1<<pos);}
//int Reset(int N,int pos){return N= N & ~(1<<pos);}
//bool Check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/

const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)2e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<int, ll> pill;


int main() {
    CIN
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    //cout << "Fi Amanillah" << endl;


    int n;
    string s;

    cin >> n >> s;
    if(n<3200){
        cout << "red" << endl;
    }else cout << s << endl;

    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
ll MOD = 1e9 + 7;
int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    ll sum = 0;
    for(int i = 1; i < n; i++) sum += a[i];
    sum %= MOD;
    ll ans = 0;
    for(int i = 0; i < n-1; i++)
    {
        ans = (ans + (sum * a[i]) % MOD) % MOD;
        sum = (sum - a[i+1]) % MOD;
        sum = (sum + MOD) % MOD;
    }
    cout << (ans + MOD) % MOD << endl;
}



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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, y;
  cin >> n >> y;
  vector<int> a(n);
  for (auto&& e : a) {
    cin >> e;
  }
  long long sum = accumulate(begin(a), end(a), 0LL);
  long long res = 0;
  for (int s = 0; s < n; ++s) {
    vector<long long> c(n + 1);
    for (int i = n; i--; ) {
      c[i] = a[(s + i) % n] + c[i + 1];
    }
    vector< vector<long long> > dp(6, vector<long long>(n + 1));
    dp[0][0] = 1;
    for (int x = 0; x < 5; ++x) {
      for (int i = 0; i < n; ++i) {
        if (dp[x][i]) {
          for (int j = i + 1; j <= n; ++j) {
            if (c[i] - c[j] + y >= sum / 5) {
              dp[x + 1][j] += dp[x][i];
            }
          }
        }
      }
    }
    res += dp[5][n];
  }
  res /= 5;
  cout << res << '\n';
}



Measured memory_bytes: 3232
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int m,n;
	if (c%b==0) m=c/b;else m=c/b+1;
	if (a%d==0) n=a/d;else n=a/d+1;
	if (m<=n) cout<<"Yes";else cout<<"No";
}

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

int main(void){
    int n, ans = 0, tmp = 0;
    cin >> n;
    vector<int> buttons(n);
    for (int i=0; i<n; i++) cin >> buttons[i];
    for (int i=0; i<n; i++){
        if (buttons[tmp] == 2){
            ans++;
            cout << ans << endl;
            return 0;
        } else{
            ans++;
            tmp = buttons[tmp] - 1;
        }
    }
    cout << -1 << endl;
    return 0;
}

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

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

	string ch; cin >> ch;
	if (ch[0] == 'A' && ch[1] == 'B' && ch[2] == 'C')
		cout << "ARC";
	else
		cout << "ABC" << endl;
	return 0;
}

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

int main() {
  int n;cin>>n;
  int pn[n];rep(i,n)cin>>pn[i];
  int cnt=0;
  rep(i,n-1) {
    if (pn[i]==i+1) {
      cnt++;
      swap(pn[i], pn[i+1]);
    }
  }
  if (pn[n-1]==n) cnt++;
  cout << cnt;
}


Measured memory_bytes: 640
N = int(input())

ts = [0]
xs = [0]
ys = [0]

for _ in range(N):
    t,x,y = [ int(a) for a in input().split() ]
    ts.append(t)
    xs.append(x)
    ys.append(y)

good = True
for i in range(N):

    dist = abs(xs[i]-xs[i+1])+abs(ys[i]-ys[i+1]) 
    time = ts[i+1]-ts[i]
    # Parity
    if dist%2 != time%2:
        good = False

    # Distance
    if dist > time:
        good = False

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


Measured memory_bytes: 11736
A,B=[int(i) for i in input().split()]
def f(x):
	a=x%4
	if a==3:
		return bin(0)
	elif a==0:
		return bin(x)
	elif a==1:
		return bin(1)
	elif a==2:
		return bin(x+1)
res=[]
A=f(A-1)
B=f(B)
for i,j in zip(A[-1:1:-1],B[-1:1:-1]):
	if i==j:
		res.append('0')
	else:
		res.append('1')
if len(A)>len(B):
	p=A[0:2+abs(len(B)-len(A))]+"".join(res[::-1])
else:
	p=B[0:2+abs(len(B)-len(A))]+"".join(res[::-1])
print(int(p,0))

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


    long long n;
    cin >> n;
    long long a[n+1];
    for(int i=1; i<=n; i++) cin >> a[i];
    sort(a+1, a+n+1);
    for(int i=2; i<=n; i++)
    {
        if(a[i]==a[i-1])
        {
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
    return 0;
}


Measured memory_bytes: 1792
//--https://kenkoooo.com/atcoder/#/table/soma62jp


#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>

using namespace std;

int main(int argc, char* argv[])
{

	int A,B,C,D;

	cin >> A >> B >> C >> D;

	cout << ((A*B > C*D) ? A*B : C*D) << endl;

	return 0;

}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

vl bfs(vvl adj, ll s) {
	ll n = sz(adj);
	vl dist(n,oo);
	dist[s] = 0;
	queue<ll> q;
	q.push(s);
	while (sz(q)) {
		ll i = q.front(); q.pop();
		for (ll j: adj[i]) if (dist[j] == oo) {
			dist[j] = dist[i]+1;
			q.push(j);
		}
	}
	return dist;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	ll u, v;
	cin >> u >> v;
	u--, v--;
	
	vvl adj(n);
	FOR(i,1,n) {
		ll a, b;
		cin >> a >> b;
		a--, b--;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	
	vl du = bfs(adj,u);
	vl dv = bfs(adj,v);

	ll res = 0;
	FOR(i,0,n) if (du[i] < dv[i]) {
		res = max(res, dv[i]);
	}
	res--;
	cout << res << endl;


}



Measured memory_bytes: 13784
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define rep(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define irep(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define rrep(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

const int MOD = 1e9 + 7;

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    cout << (abs(x - a) < abs(x - b) ? "A" : "B") << endl;
    return 0;
}

Measured memory_bytes: 256
x = gets.to_i

if 400 <= x && x <= 599
  puts 8
elsif 600 <= x && x <= 799
  puts 7
elsif 800 <= x && x <= 999
  puts 6
elsif 1000 <= x && x <= 1199
  puts 5
elsif 1200 <= x && x <= 1399
  puts 4
elsif 1400 <= x && x <= 1599
  puts 3
elsif 1600 <= x && x <= 1799
  puts 2
elsif 1800 <= x && x <= 1999
  puts 1
end

Measured memory_bytes: 14396
#include<stdio.h>
int main(void){
  int N,M,L,R,x[100000]={},i,j,min=1,max;
  fscanf(stdin,"%d%d",&N,&M);
  max=N;
  for(i=0;i<M;i++){
  	fscanf(stdin,"%d%d",&L,&R);
    if(min<L)
      	min=L;
    if(R<max)
    	max=R;
  }
  printf("%d",min<=max?1+max-min:0);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pi=pair<ll,ll>;
using vi=vector<ll>;
using vstr=vector<string>;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
void yes(bool c) { if (c)print("Yes"); else print("No"); };

void solve() {
    int N; cin >> N;
    vi a(N);
    rep(i,N) {
        cin >> a[i];
        a[i]--;
    }
    ll ans = 0;
    rep(i,N) {
        ll j = a[i];
        if(a[j] == i) ans++;
    }
    print(ans/2);
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}


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

#define en "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fs first
#define sc second
#define size(a) (int) a.size()
#define deb(x) cerr << #x << " => " << x << en
#define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en;
#define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<<a.fs<<", "<<a.sc<<") "; cerr << en;
#define debm(x) cerr << #x << en; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << en;}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)
int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m;
while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;}
#define inv(a) fastpow(a, HELL - 2)

int32_t main() { fastio;
	string s; cin >> s;
	map<int, int> mods;
	mods[0]++;
	int last = 0, res = 0, inc = 1;
	reverse(s.begin(), s.end());
	for (auto x : s) {
		last = (last + (x - '0') * inc) % 2019;
		inc = (inc * 10) % 2019;
		res += mods[last];
		mods[last]++;
	}
	cout << res << endl;
	return 0; 
}


Measured memory_bytes: 3780
#include<bits/stdc++.h>
using namespace std;
 
double coin[3010][3010];
 
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
 
  coin[0][0] = 1;
  int n; cin >> n;
 
  for (int i = 0; i < n; ++i) {
    double p; cin >> p;
    for (int j = 0; j < 3000; ++j) {
      coin[i + 1][j + 1] += coin[i][j] * p;
      coin[i + 1][j] += coin[i][j] * (1 - p);
    }
  }
  double ans = 0;
  for (int i = 0; i <= n; ++i) if (i > n - i) ans += coin[n][i];
  cout << fixed << setprecision(20) << ans << '\n';
}

Measured memory_bytes: 70784
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=998244353;
//const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
  int n;
  cin>>n;
  V<P> a,b;
  for(int i=0;i<n;i++){
    ll h=0,mi=0;
    string s;cin>>s;
    for(int j=0;j<s.size();j++){
      if(s[j]=='(')h++;
      else h--;
      chmin(mi,h);
       }
       if(h>0)a.emplace_back(mi,h);
       else b.emplace_back(mi-h,-h);
  }
  sort(all(a),greater<P>());
  sort(all(b),greater<P>());
  int now=0;
  bool ok=true;
  for(int i=0;i<a.size();i++){
    if(now+a[i].fi<0)ok=false;
    now+=a[i].se;
  }
  int l=now;
  now=0;
  for(int i=0;i<b.size();i++){
    if(now+b[i].fi<0)ok=false;
    now+=b[i].se;
  }
cout<<(l==now&&ok?"Yes":"No")<<"\n";
}


Measured memory_bytes: 18976
import bisect
from collections import deque

N = int(input())
A = [int(input()) for _ in range(N)]
dq = deque([A[0]])

for i in range(1, len(A)):
    idx = bisect.bisect_left(dq, A[i])
    if idx == 0:
        dq.appendleft(A[i])
    else:
        dq[idx - 1] = A[i]

print(len(dq))


Measured memory_bytes: 81876
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 

using namespace std;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))


int main()
{
	int x, y, z, k;
	cin >> x >> y >> z >> k;
	vector <long long> a(x);
	vector <long long> b(y);
	vector <long long> c(z);
	vector <long long> ab;
	vector <long long> abc;
	rep(i, 0, x - 1)cin >> a[i];
	rep(i, 0, y - 1)cin >> b[i];
	rep(i, 0, z - 1)cin >> c[i];
	rep(i, 0, x - 1)rep(j, 0, y - 1)
	{
		ab.push_back(a[i] + b[j]);
	}
	sort(ab.begin(), ab.end(), greater<>());
	rep(i, 0, min((int)ab.size(), k) - 1)rep(j, 0, z - 1)
	{
		abc.push_back(ab[i] + c[j]);
	}
	sort(abc.begin(), abc.end(), greater<>());
	rep(i, 0, k - 1)cout << abc[i] << endl;
}



Measured memory_bytes: 43240
from collections import deque
N = int(input())
a = list(map(int, input().split()))
dp = [[0]*N for i in range(N+1)]
if N%2 == 1:
    f = 1
else:
    f = -1
for i in range(1,N+1):
    for j in range(N-i+1):
        if f > 0:
            if j+1 < N:
                dp[i][j] = max(dp[i-1][j]+a[j+i-1], dp[i-1][j+1]+a[j])
            else:
                dp[i][j] = dp[i-1][j]+a[j+i-1]
        else:
            if j+1 < N:
                dp[i][j] = min(dp[i-1][j]-a[j+i-1], dp[i-1][j+1]-a[j])
            else:
                dp[i][j] = dp[i-1][j]-a[j+i-1]
    f *= -1
print(dp[N][0])

Measured memory_bytes: 113244
#include<bits/stdc++.h>
#define ls(x) (x)<<1
#define rs(x) (x)<<1|1
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define Case(i,ans) cout<<"Case "<<i<<": "<<ans<<endl;
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) (x)%mo_num
#define vc vector
#define vct vector<int>
#define fa(i,V) for(auto i:V)
#define out(i) cout<<i<<endl;
#define fi first
#define sc second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
//#define P pair<int,int>
using namespace std;
const int INF=1e17+5;
const int maxn=2e5+5;
const int mo_num=1e9+7;
int n,m,a[maxn],b[maxn],ans;

int32_t main()
{
    IOS
    cin>>n;
    cout<<3*n*n;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define gcd __gcd
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
#define pr(n) printf("%d ",n)
#define out(n) printf("%d\n",n)
#define llin(a) cin >> a
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
#define DEBUG(x) cout << #x << " : " << x << endl;
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define ck printf("continue\n")
#define all(vec) vec.begin(),vec.end()
#define asc(vec) sort(vec.begin(),vec.end())
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define M 1000000007
//check the limits, man
// read the constraint properly (ll vs int)
const int N = 1e5+5;
typedef long long int ll;
int main()
{
    ll a,b,g;
    ll i,ans;
    llin(a);
    llin(b);
    g=gcd(a,b);
    ans=1;
    i=2;
    while(i*i<=g)
    {
        if(g%i==0)
        {
            ans++;
            while(g%i==0)
                g/=i;
        }
        i++;
    }
    if(g>1)
        ans++;
    llout(ans);
}





Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>

using namespace std;

int gcd(int n, int m) {
    if (n == 0)
        return m;
    return gcd(m % n, n);
}

int bit_count(int i) {
    i = i - ((i >> 1) & 0x55555555);
    i = (i & 0x33333333) + ((i >> 2) & 0x33333333);
    i = (i + (i >> 4)) & 0x0f0f0f0f;
    i = i + (i >> 8);
    i = i + (i >> 16);
    return i & 0x3f;
}

int main() {
    string s;
    cin >> s;
    int max_l = 0;
    for (size_t i = 0; i < s.length(); i++) {
        int l = 0;
        for (size_t j = 0; j < s.length() - i; j++) {
            if (s[i + j] != 'A' && s[i + j] != 'C' && s[i + j] != 'G' &&
                s[i + j] != 'T') {
                break;
            }
            l++;
        }
        max_l = max(max_l, l);
    }
    cout << max_l << endl;
}


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

public class Hello
{
    private const int MOD_N = 1000000000 + 7;

    public static void Main()
    {
        var list = Console.ReadLine().Split(' ');
        var n = int.Parse(list[0]);
        var m = int.Parse(list[1]);

        var list2 = Console.ReadLine().Split(' ');
        var ass = new uint[n];
        for (var i = 0; i < ass.Length; ++i)
            ass[i] = uint.Parse(list2[i]);

        var bcs = new KeyValuePair<int, uint>[m];
        for (var i = 0; i < bcs.Length; ++i)
        {
            var list3 = Console.ReadLine().Split(' ');
            var b = int.Parse(list3[0]);
            var c = uint.Parse(list3[1]);
            bcs[i] = new KeyValuePair<int, uint>(b, c);
        }

        Array.Sort(ass);
        Array.Sort(bcs, (l, r) => r.Value.CompareTo(l.Value));

        for (int i = 0, j = 0; i < bcs.Length; ++i)
        {
            var bc = bcs[i];
            for (int k = 0; k < bc.Key; ++k)
            {
                if (bc.Value > ass[j])
                {
                    ass[j] = bc.Value;
                    ++j;
                    if (j >= ass.Length)
                        goto Finish;
                }
                else
                    goto Finish;
            }
        }

        Finish:
        ulong sum = 0;
        for (int i = 0; i < ass.Length; ++i)
            sum += ass[i];

        Console.WriteLine(sum);
    }
}


Measured memory_bytes: 27968
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
#include <math.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;

ll last(vll& tar){
    return tar[tar.size() - 1];
}

int main()
{
    int n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    vll seiri;
    ll ans = 0;
    if (last(a)<n){
        cout << 0 << endl;
        return 0;
    }
    seiri.push_back(last(a));
    a.pop_back();
    rep(i,n-1)
    {
        /*cout << "a: ";
        for (auto x : a)
            cout << x << " ";
        cout << endl;
        cout << "seiri: ";
        for (auto x : seiri)
            cout << x << " ";
        cout << endl; */
        if (last(a)>last(seiri)-n){
            seiri.push_back(last(a));
            a.pop_back();
            sort(all(seiri));
        }
        else{
            ll x = (seiri[0] - last(a)) / (n + 1);
            //cout << x << endl;
            ans += x * seiri.size();
            rep(i,seiri.size()){
                seiri[i] += (-n + seiri.size() - 1) * x;
            }
            rep(i,a.size()){
                a[i] += x * seiri.size();
            }
            while (1){
                if (last(a)>last(seiri)-n){
                    break;
                }
                ans++;
                seiri[seiri.size() - 1] -= n;
                rep(i,seiri.size()-1){
                    seiri[i]++;
                }
                sort(all(seiri));
                rep(i,a.size()){
                    a[i]++;
                }
            }
            seiri.push_back(last(a));
            a.pop_back();
            sort(all(seiri));
        }
    }
    if (seiri[0]>n){
    ll x = seiri[0] - n + 1;
    ans += x * n;
    rep(i,n){
        seiri[i] -= x;
    }}
    while (1)
    {
        if (last(seiri)<n)
        {
            break;
        }
        ans++;
        seiri[seiri.size() - 1] -= n;
        rep(i, seiri.size() - 1)
        {
            seiri[i]++;
        }
        sort(all(seiri));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static class pair implements Comparator<pair>{
        int a,b;
        pair(int a,int b){
            this.a=a;
            this.b=b;
        }

        @Override
        public int compare(pair t1, pair t2) {
            if(t2.b==t1.b){
                return t2.a-t1.a;
            }
            return t2.b-t1.b;
        }
    }
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int h=sc.nextInt();
        int max=Integer.MIN_VALUE;
        pair[] pa=new pair[n];
        for(int i=0;i<n;i++){
            int a=sc.nextInt(),b=sc.nextInt();
            max=Math.max(max,a);
            pa[i]=new pair(a,b);
        }
        Arrays.sort(pa,new pair(0,0));
        int sum=0,ct=0;
        boolean cd=false;
        for(int i=0;i<n;i++){
            if(pa[i].b>=max){
                sum+=pa[i].b;
                ct++;
            }
            else{
                break;
            }
            if(sum>=h){
                cd=true;
                break;
            }
        }
        if(!cd){
            ct+=Math.ceil((h-sum)/(double)max);
        }
        System.out.println(ct);
    }
}


Measured memory_bytes: 85764
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <tuple>
#include <cstdio>
#include <cassert>
#include <functional>
#define _LIBCPP_DEBUG 0
using namespace std;

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

    vector<int> p(n),q(n),r(n);
    for (int i = 0; i < n; i++)
    {
        cin >> p.at(i);
    }
    for (int i = 0; i < n; i++)
    {
        cin >> q.at(i);
    }
    for (int i = 0; i < n; i++)
    {
        r.at(i)=i+1;
    }
    
    int count=1,a,b;
    do
    {
        if (p==r)
        {
            a=count;
        }
        if (q==r)
        {
            b=count;
        }
        count++;
    } while (next_permutation(r.begin(),r.end()));
    
    cout << abs(a-b) << endl;
}


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

int main() {
  int n;
  cin>>n;
  vector<int> w(n);
  int sum=0;
  for(int i=0;i<n;i++){
    cin>>w[i];
    sum+=w[i];
  }
  int cnt=0,ans=1e9;
  for(int i=0;i<n;i++){
    cnt+=w[i];
    int a=sum-cnt;
    int b=abs(a-cnt);
    ans=min(ans,b);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
X,N = list(map(int, input().split()))

if(N != 0):
    ps = list(map(int, input().split()))
else:
    ps = []



ans_list = []

for i in range(-10,110):
    if i not in ps:
        ans_list.append(i)

#print(ans_list)

initial = 10 ** 4
abs_sabun = abs(initial - X)

for ans in ans_list:
#    print(ans, abs_sabun)
    if(abs(ans - X) < abs_sabun):
        abs_sabun = abs(ans - X)
        initial = ans

print(initial)

Measured memory_bytes: 8848
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int main(){
  int N,A,B;
  cin>>N>>A>>B;
  if (abs(A-B)%2==0) cout << "Alice" << endl;
  else cout << "Borys" << endl;
  return 0;
}


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

int main(){
	int N;
	string S = "";
	cin >> N;
	int len = 0;
	while(len * (len + 1) / 2 < N){
		len++;
	}
	for(int i = 1; i <= len + 1; i++) S += ")";
	for(int i = 1; i <= len - 1; i++) S += "(";
	S[N - (len - 1) * len / 2] = '(';
	cout << S << endl;
	return 0;
}


Measured memory_bytes: 3320
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

const int INF = 1000000009;

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

  vector<int> coin;
  coin.push_back(1);

  int c = 6;
  while (c <= n) {
    coin.push_back(c);
    c *= 6;
  }
  c = 9;
  while (c <= n) {
    coin.push_back(c);
    c *= 9;
  }

  // dp[x] := ちょうどx円払うのに必要なコインの最小枚数
  vector<int> dp(n + 10, INF);
  dp[0] = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j < (int)coin.size(); j++) {
      int cc = coin[j];
      if (i + cc > n) {
        continue;
      }
      dp[i + cc] = min(dp[i + cc], dp[i] + 1);
    }
  }
  cout << dp[n] << endl;

  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int A,B,K;
  cin >> A >> B >> K;
  vector<int> vec(1,1);
  for(int i=2;i<=100;i++)
  {
    if(A%i==0&&B%i==0)
    {
      vec.push_back(i);
    }
  }
  sort(RALL(vec));
  cout << vec[K-1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i, v.size()){ cout << v[i] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

template<typename T> void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

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

int mod = 1000000007;
//int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod
#define AddMult(x, y, z) x = (x + (y) * (z)) % mod



signed main(){

    int N, K; cin >> N >> K;
    vec w(N), d(N);
    REP(i, N) cin >> w[i] >> d[i];

    int l = 0, r = bit(61);
    while(r - l > 1){
        int m = (r + l) / 2;
        int c = 0;
        REP(i, N) if(m >= w[i]) c += 1 + (m - w[i]) / d[i];
        if(c >= K) r = m;
        else l = m;
    }
    cout << r << endl;

    return 0;
}


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

int main(){
  int N,sum=0;
  cin >> N;
  vector<int> W(N);
  for(int i=0;i<N;i++){
    cin >> W.at(i);
    sum+=W.at(i);
  }
  int minA=10000;
  int sumB=0;
  for(int i=0;i<N;i++){
    sumB+=W.at(i);
    minA=min(minA,abs(sum-sumB-sumB));
  }
  cout << minA << endl;
}

Measured memory_bytes: 3596
#include <cstdio>

int n, k;

int main() {
	scanf("%d%d", &n, &k);
	if (k & 1) {
		int p = n / k;
		printf("%lld\n", 1LL * p * p * p);
	} else {
		int p = n / k, q = (n + k / 2) / k;
		printf("%lld\n", 1LL * p * p * p + 1LL * q * q * q);
	}
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
using VI = vector<int>;


int main()
{
  int N, M;
  cin >> N >> M;
  VI Hight(N);
  REP(n, N)
    cin >> Hight[n];
  
  vector<bool> Good(N, true);
  REP(m, M) {
    int a, b;
    cin >> a >> b;
    if(Hight[a-1] < Hight[b-1])
      Good[a-1] = false;
    else if(Hight[a-1] > Hight[b-1])
      Good[b-1] = false;
    else {
      Good[a-1] = false;
      Good[b-1] = false;
    }
  }
  int ans = 0;
  REP(n, N) {
    if(Good[n])
      ans++;
  }
  cout << ans; 
}

Measured memory_bytes: 3720
from sys import stdin

S = stdin.readline().rstrip()


ans = "Yes"
for i in range(len(S)):
    if i%2 == 0 and S[i] == "L":
        ans = "No"
        break
    if i%2 == 1 and S[i] == "R":
        ans = "No"
        break

print(ans)




Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>
 
using namespace std;
 
int main(){
int X,A,B;
 
  cin >> X;
  cin >> A;
  cin >> B;
  
  X = X -A;
  
  while(X >= B){
    X = X -B;
  
  
  }
 
  cout << X;
  
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<numeric>
#include<complex>
#define inf 0x3f3f3f3f3f3f3f3f
#define fi first
#define se second
#define pb push_back
#define ll long long
#define pii pair<int,int> 
const int N=4e6+10;
const int mod=998244353;
using namespace std;

int dp[110][110],s[110][110],n,m,vis[110][110];
char a[110][110];
int dir[2][2]={0,-1,-1,0};
void dfs(int x,int y,int cc){
	vis[x][y]=cc;
	for(int i=0;i<2;++i){
		int xx=x+dir[i][0];
		int yy=y+dir[i][1];
		if(xx<=n&&xx>=1&&yy<=m&&yy>=1&&vis[xx][yy]!=cc&&a[xx][yy]=='#')
			dfs(xx,yy,cc);
	}
}
int ok(int i,int j,int r,int c){
	if(r==0||c==0||i<r||j<c) return 0;
	return (vis[i][j]==vis[r][c])&&(vis[i][j]>0);
}
void solve(){
   scanf("%d%d",&n,&m);
   for(int i=1;i<=n;++i) scanf("%s",a[i]+1);
   int cc=0;
   memset(dp,0x3f,sizeof(dp)); 
   dp[0][0]=dp[0][1]=dp[1][0]=0;
   dp[1][1]=(a[1][1]=='#');
   for(int i=1;i<=n;++i){
   	  for(int j=1;j<=m;++j){
   	  	if(i==1&&j==1) continue;
   	  	dp[i][j]=min(dp[i-1][j],dp[i][j-1])+(a[i][j]=='#');
   	  	if(a[i][j]!='#') continue;
   	  	vis[i][j]=++cc;
   	  	dfs(i,j,cc);
   	  	for(int r=i;r>=0;r--){
   	  		for(int c=j;c>=0;c--){
   	  			if((r==i&&c==j)||dp[r][c]>=n*m) continue;
   	  			if(ok(i,j,r+1,c)||ok(i,j,r,c+1)) dp[i][j]=min(dp[i][j],dp[r][c]+1);
   	  		}
   	  	}
   	  	
   	  }
   } 
   printf("%d\n",dp[n][m]);
}
int main() 
{
    int _=1;  //scanf("%d",&_);
    while(_--) solve();
return 0;
}
/*
3 3
##.
###
.#.
*/





Measured memory_bytes: 384
ts, hs = 0, 0
n, *S = open(0).read().split()
for t, h in zip(*[iter(S)]*2):
    if t < h:
        hs += 3
    elif t > h:
        ts += 3
    else:
        hs += 1
        ts += 1
print(f'{ts} {hs}')


Measured memory_bytes: 5612
#include <stdio.h>


int main()
{
	int i, n;
	short a[101];

	scanf("%d", &n);
	for (i = 0; i < n; i++) scanf("%d", &a[i]);
	if (n >= 1) printf("%d", a[n - 1]);
	for (i = n - 2; i >= 0; i--) printf(" %d", a[i]);
	putchar('\n');
	return 0;
}



Measured memory_bytes: 2040
// #pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
#define MM " "
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}

main(){
    int n=in();
    set<pii> r,b;
    rep(i,n){
        int x=in(),y=in();
        r.emplace(x,y);
    }
    rep(i,n){
        int x=in(),y=in();
        b.emplace(x,y);
    }
    int ans=0;
    for(auto e:b){
        int x=e.first,y=e.se;
        int ma=-1;
        for(auto &t:r){
            if(t.first>=x)break;
            if(t.second<y)
            chmax(ma,t.second);
        }
        if(ma==-1)continue;
        for(auto it=r.begin();it!=r.end();it++){
            if((*it).second==ma){
                r.erase(it);break;
            }
        }
        ans++;
    }
    cout<<ans<<endl;
    
}

    

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

#define I_AM_SPEED ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
using ll = long long;

int32_t main() {
	int n;
	cin >> n;
	int ans = n % 1000;
	if(ans != 0){
		cout << 1000 - ans << endl;
	}
	else cout << 0 << endl;
}

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


int main() {
	int N, T;
	cin >> N >> T;
	vector<int> c(N);
	vector<int> t(N);
	int min;
	bool tle = true;
	for(int i = 0; i < N; i++){
		cin >> c.at(i) >> t.at(i);
	}
	for(int i = 0; i < N; i++){
		if(t.at(i) <= T){
			min = c.at(i);
			tle = false;
			break;
		}
		else{
			continue;
		}
	}
	for(int i = 0; i < N; i++){
		if(t.at(i) <= T){
			if(c.at(i) < min){
				min = c.at(i);
			}
		}
		else{
			continue;
		}
	}
	if(tle){
		cout << "TLE" << endl;
	}
	else{
		cout << min << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
d = {}
for i in range(n):
    s = input()
    if not s in d.keys():
        d[s] = 0
    d[s] += 1

m = max(d.values())

ans = []
for k, v in d.items():
    if m == v:
        ans.append(k)
    
ans.sort()

for a in ans:
    print(a)

Measured memory_bytes: 32224
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,k;
    cin>>n>>m>>k;
    vector<ll>a(n),b(m);
    for(ll i=0;i<n;i++)cin>>a[i];
    for(ll i=0;i<m;i++)cin>>b[i];
    ll ans=0;
    ll cur=0;
    ll t=0;
    while(cur<n && t+a[cur]<=k){
        ans++;
        t+=a[cur++];
    }
    ll Max=ans;
    if(cur)cur--;
    for(ll i=0;i<m;){
        if(t+b[i]<=k){
            ans++;
            Max=max(Max,ans);
            t+=b[i++];
            continue;
        }
        else{
            if(cur>=0)t=max(0ll,t-a[cur--]);
            else break;
            ans--;
        }
    }
    cout<<Max;
    return 0;
}



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

typedef long long ll;
typedef pair<int, int> P;

#define mod 1000000007
#define inf 1000000000
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)

const long double PI = acos(-1);

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}

int main(){
  ll a[3][3];
  for(ll i = 0; i < 3; i++){
    for(ll j = 0; j < 3; j++){
      cin >> a[i][j];
    }
  }

  ll n;
  cin >> n;
  ll b[n];
  for(ll i = 0; i < n; i++) cin >> b[i];

  bool ok[3][3] = {false};
  for(ll j = 0; j < 3; j++){
    for(ll k = 0; k < 3; k++){
      for(ll i = 0; i < n; i++){
        if(b[i] == a[j][k]){
          ok[j][k] = true;
        }
      }
    }
  }

  for(ll i = 0; i < 3; i++){
    if(ok[i][0] == true && ok[i][1] == true && ok[i][2] == true){
      cout << "Yes" << endl;
      return 0;
    }
  }

  for(ll i = 0; i < 3; i++){
    if(ok[0][i] == true && ok[1][i] == true && ok[2][i] == true){
      cout << "Yes" << endl;
      return 0;
    }
  }

  if(ok[0][0] == true && ok[1][1] == true && ok[2][2] == true){
    cout << "Yes" << endl;
    return 0;
  }

  if(ok[0][2] == true && ok[1][1] == true && ok[2][0] == true){
    cout << "Yes" << endl;
    return 0;
  }

  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int n, r[128], t[13]; bool used[22370000]; char com[8], s[14];
int main() {
	scanf("%d", &n); r[65] = 1, r[67] = 2, r[71] = 3;
	for(int i = 2; i < 12; i++) t[i] = t[i - 1] + (1 << (2 * i - 2));
	for(int i = 0; i < n; i++) {
		scanf("%s %s", com, s);
		int h = 0, l = strlen(s);
		for(int j = 0; j < l; j++) h = h * 4 + r[s[j]];
		if(com[0] == 105) used[h + t[l]] = true;
		else puts(used[h + t[l]] ? "yes" : "no");
	}
}

Measured memory_bytes: 3932
N,M = gets.chomp.split(' ').map{|p| p.to_i}

correct = Array.new(N,false)
_WA = Array.new(N,0)
result = [0,0]
M.times do
    array = gets.chomp.split(' ')
    
    if !correct[array[0].to_i - 1]
        if array[1] == "AC"
            correct[array[0].to_i - 1 ] = true
            result[0]+=1
        else
            _WA[array[0].to_i - 1 ] += 1
        end
    end
end

_WA.each_with_index do |val, index|
    result[1]+=val.to_i if correct[index]
end
puts result.join(' ')

Measured memory_bytes: 3324
def area(p,q,r):
    a = (q[0]-p[0], q[1]-p[1])
    b = (r[0]-p[0], r[1]-p[1])
    return (a[0]*b[1] - b[0]*a[1]) / 2

n = int(input())

v = []
for _ in range(n):
    v.append([float(x) for x in input().split()])

v = list(reversed(v))

s = 0

for i in range(1,n-1):
    s += area(v[0],v[i],v[i+1])

print(-1 * round(s,1))


Measured memory_bytes: 5624
#include<bits/stdc++.h>
//#include <boost/math/common_factor.hpp>
using namespace std;
#define ll long long
int main()
{
  ll a;
  cin>>a;
  ll b[a];
  for(ll i=0;i<a;i++)
  {
    cin>>b[i];
  }
  ll m=b[0],count=0;
  for(ll i=1;i<a;i++)
  {
    if(m<b[i])count++;
    m=min(b[i],m);
  }
  cout<<a-count;
}


Measured memory_bytes: 1792
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::Integer;
#[allow(unused_imports)]
use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp;

fn solve(x: i32, y: i32) -> bool {
    for i in 0..=x {
        if 2 * i + 4 * (x - i) == y {
            return true;
        }
    }
    false
}

#[fastout]
fn main() {
    input! {
      x: i32,
      y: i32,
    }

    println!("{}", if solve(x, y) { "Yes" } else { "No" });
}


Measured memory_bytes: 2116
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
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 (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

string X,Y;
cin >> X >> Y;

if(X<Y) puts("<");
else if(X>Y) puts(">");
else puts("=");

return 0;
}

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

using namespace std;

int main(){
   int N,L;
   cin >> N >> L;
   int ans=0;
   int mi = INT_MAX;
   for(int i = 1; i <=N; i++){
      ans += L+i-1;
      if(abs(mi)>abs(L+i-1)){
         mi = L+i-1;
      }
   }
   cout << ans-mi << endl;

   return 0;
}


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

using namespace std;

void doc()
{
    freopen("solve.inp","r",stdin);
    freopen("solve.out","w",stdout);
}

void solve() {
    int n, K, Q;
    cin >> n >> K >> Q;
    int D[n];
    memset(D, 0, sizeof(D));
    for (int i = 0; i < Q; i++) {
        int x;
        cin >> x;
        x--;
        D[x]++;
    }
    for (int i = 0; i < n; i++) {
        if ((Q - D[i]) >= K) {
            cout << "No" << '\n';
        }
        else cout << "Yes" << '\n';
    }
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    //doc();
    solve();
}


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

int main () {
  int a, b, c, d;
  int n;
  cin >> n;
  a = n/1000;
  b = (n%1000)/100;
  c = (n%100)/10;
  d = (n%10);
  string res;
  for(int i = 0; i <= 1; ++i){
    for(int j = 0; j <= 1; ++j) {
      for(int k = 0; k <= 1; ++k) {
        int sum = a;
        string ans = "";
        ans = ans + char(a + '0');
        if (i == 0) {
          sum += b;
          ans = ans + "+" + char(b + '0');
        }
        else {
          sum -= b;
          ans = ans + "-" + char(b + '0');
        }

        if (k == 0) {
          sum += c;
          ans = ans + "+" + char(c + '0');
        }
        else {
          sum -= c;
          ans = ans + "-" + char(c + '0');
        }

        if (j == 0) {
          sum += d;
          ans = ans + "+" + char(d + '0');
        }
        else {
          sum -= d;
          ans = ans + "-" + char(d + '0');
        }
        ans = ans + "=7";
        if (sum == 7) res = ans;
      }
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 256