akhauriyash/Code-Regression huggingface dataset:
/*
Date: 2017/01/22 19:44:40 Sunday
*/
#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define rep(i,a,n) for(int i=(a);i<=(n);++i)
#define dep(i,a,n) for(int i=(a);i>=(n);--i)
#define eps 1e-8
#define pi 3.1415926535897
#define sqr(x) ((x)*(x))
#define MAX(a,b) a=max(a,b)
#define MIN(a,b) a=min(a,b)
#define SZ(x) ((int)(x).size())
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define POSIN(x,y) (1<=(x)&&(x)<=n&&1<=(y)&&(y)<=m)
#define all(x) (x).begin(),(x).end()
#define COUT(S,x) cout<<fixed<<setprecision(x)<<S<<endl
#define buli(x) (__builtin_popcountll(x))
#define bur0(x) (__builtin_ctzll(x))
#define bul2(x) (63-__builtin_clzll(x))
#define pw(x) ((ll(1))<<(x))
#define upmo(a,b) (((a)=((a)+(b))%mo)<0?(a)+=mo:(a))
#define mmo(a,b) (((a)=1ll*(a)*(b)%mo)<0?(a)+=mo:(a))
#define y0 y0z
#define y1 y1z
#define yn ynz
#define j0 j0z
#define j1 j1z
#define jn jnz
#define tm tmz
#ifdef LOCAL
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...) 
#endif
typedef long long ll;
typedef double lf;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<lf,lf> pff;
typedef complex<double> CD;
const int inf=0x3f3f3f3f;
const int mo=1000000007;
inline void gn(long long&x){
	int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');
	while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;
}
inline void gn(int&x){long long t;gn(t);x=t;}
inline void gn(unsigned long long&x){long long t;gn(t);x=t;}
inline void gn(double&x){double t;scanf("%lf",&t);x=t;}
inline void gn(long double&x){double t;scanf("%lf",&t);x=t;}
template<class T1,class T2>inline void gn(T1&r,T2&s){gn(r),gn(s);}
template<class T1,class T2,class T3>inline void gn(T1&r,T2&s,T3&t){gn(r),gn(s),gn(t);}
template<class T1,class T2,class T3,class T4>inline void gn(T1&r,T2&s,T3&t,T4&u){gn(r),gn(s),gn(t),gn(u);}
inline void gs(char *s){scanf("%s",s);}
inline void gc(char &c){while((c=getchar())>126 || c<33);}
inline void pc(char c){putchar(c);}
const int DX[]={1,0,-1,0},DY[]={0,1,0,-1};
ll powmod(ll a,ll b) {ll res=1;a%=mo;for(;b;b>>=1){if(b&1)res=res*a%mo;a=a*a%mo;}return res;}
ll powmod(ll a,ll b,ll mo) {ll res=1;a%=mo;for(;b;b>>=1){if(b&1)res=res*a%mo;a=a*a%mo;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//*******************************************

const int N=111111,M=111111;
int l,m,n,t,C;
ll a[N],b[N];
int main(){
#ifdef LOCAL
	freopen("A.in","r",stdin);//freopen("A.out","w",stdout);
#endif
	scanf("%d",&n);
	rep(i,1,n)scanf("%lld%lld",&a[i],&b[i]); 
	ll sum=0,ans=0;
	dep(i,n,1){
		a[i]+=sum;
		ll p=b[i]-a[i]%b[i];if(p==b[i])p=0;
		sum+=p;
		ans+=p;
	}printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1920
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e8;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
	string s;cin>>s;
	int co=0;
	rep(i,26){
		int c=0;
		rep(j,s.size())if(s[j]=='a'+i)c++;
		if(c%2)co++;
	}
	cout<<co/2<<endl;
}

Measured memory_bytes: 3140
open Printf;;

let rec f x y =
  if x = 9 && y = 9 then printf "%dx%d=%d\n" x y (x*y)
  else if y = 9 then
  begin
    printf "%dx%d=%d\n" x y (x*y) ;
    f (x+1) 1
  end
  else 
  begin
    printf "%dx%d=%d\n" x y (x*y) ;
    f x (y+1)
  end;;

f 1 1;;

Measured memory_bytes: 2144
# coding: utf-8
# Your code here!

#n = int(input())
n,l = [int(i) for i in input().split()]

ans = sum([l+i for i in range(n)])

if l>=0:
    print(ans - l)
elif l+n-1 <= 0:
    print(ans-(l+n-1))
else:
    print(ans)















Measured memory_bytes: 2940
/*  ex7_1
    Y_Aizaki  */

#include <stdio.h>

typedef struct point
{
    int x_elem; // x座標
    int y_elem; // y座標
}point;

point shift_point(point pointP, point pointQ){
    point pointR;

    pointR.x_elem = pointQ.x_elem + (-1)*(pointQ.y_elem - pointP.y_elem);
    // qとrのx座標の差の大きさは、pとqのy座標の差の大きさに等しい
    pointR.y_elem = pointQ.y_elem + (pointQ.x_elem - pointP.x_elem);
    // qとrのy座標の差の大きさは、pとqのx座標の差の大きさに等しい

    return pointR;
}

int main(void){
    point pointA,pointB,pointC,pointD;
    scanf("%d%d%d%d", &pointA.x_elem, &pointA.y_elem, &pointB.x_elem, &pointB.y_elem);

    pointC = shift_point(pointA, pointB);
    pointD = shift_point(pointB, pointC);

    printf("%d %d %d %d\n", pointC.x_elem, pointC.y_elem, pointD.x_elem, pointD.y_elem);

    return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

char ba[12][6];

typedef pair<int, int> pii;
bool visited[2][12][6];
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int rec(int y, int x, char c, bool f) {
//  cout << y << " " << x << endl;
  if (f) ba[y][x] = '*';
  int res = 1;
  visited[f][y][x] = 1;
  REP(k,4) {
    int yy = y+dy[k];
    int xx = x+dx[k];
    if (yy<0||yy>=12||xx<0||xx>=6) continue;
    if (visited[f][yy][xx]) continue;
    if (ba[yy][xx] == c) {
      res += rec(yy,xx,c,f);
    }
    if (f&&ba[yy][xx] == 'O')
      ba[yy][xx] = '*';
  }
  return res;
}

int solve() {
  bool del = 0;

  memset(visited,0,sizeof(visited));
  REP(i, 12) {
    REP(j, 6) {
      if (ba[i][j] != '.' && ba[i][j] != 'O' && !visited[0][i][j]) {
        if (rec(i, j, ba[i][j], 0) >= 4) {
          rec(i, j, ba[i][j], 1);
          del = 1;
        }
      }
    }
  }
  if (!del) return 0;

  REP(j, 6) {
    vector<char> v;
    for (int i=11; i>=0; --i) {
      if (ba[i][j] == '.') break;
      if (ba[i][j] != '*')
        v.push_back(ba[i][j]);
    }
    for (int i=11; i>=0; --i) {
      if (11-i < v.size())
        ba[i][j] = v[11-i];
      else
        ba[i][j] = '.';
    }
  }
  // REP(i,12) {
  //   REP(j,6) {
  //     cout << ba[i][j];
  //   }
  //   cout << endl;
  // }cout << endl;

  return 1 + solve();
}

int main() {
  int n;
  cin >> n;
  while(n--) {
    REP(i, 12) {
      REP(j, 6) {
        cin >> ba[i][j];
      }
    }
    cout << solve() << endl;
  }
}

Measured memory_bytes: 0
# coding:utf-8

INF = float('inf')


def inpl(): return list(map(int, input().split()))


S = input()
S_li = list(S)
direction = ('N', 'W', 'S', 'E')
judge = []
for di in direction:
    if di in S_li:
        judge.append(1)
    else:
        judge.append(0)


if judge[0] ^ judge[2] == 1:
    print('No')
elif judge[1] ^ judge[3] == 1:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 3060
n = gets.to_i
w = gets.split.map {|x| x.to_i}

sum = 0
w.each { |v|
  sum += v
}

psum = 0
mind = sum
w.each { |v|
  d = (sum - psum) - psum
  if d.abs < mind
    mind = d.abs
  end
  psum += v
}

puts mind


Measured memory_bytes: 1788
n, w = map(int, input().split())
elems = []
for _ in range(n):
    elems.append(list(map(int, input().split())))
res = [0] * (w + 1)
for item in elems:
    for j in range(w, item[0] - 1, -1):
        res[j] = max(res[j], res[j - item[0]] + item[1])

print(res[-1])

Measured memory_bytes: 41836
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

#define int long long

int a,b,c;

signed main(){
  cin >> a >> b >> c;
  int k;
  cin >> k;
  vector<int> vec = {a,b,c};
  sort(vec.begin(),vec.end());
  vec.back() <<= k;
  cout << vec[0] + vec[1] + vec[2] << endl;
}


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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
	string s;
	cin>>s;
	rep(i,7){
		if(day[i]==s){
			cout<<7-i<<endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    int a, b, t; cin>> a >>b>>t;
    double now = 0;
    int ans=0;
    for(double i=a; i<= t+0.5; i+=a){
        ans += b;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include <vector>
#include<string>
#include<cmath>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define max(x,y) (((x)>(y)) ? x:y)
#define min(x,y) (((x)<(y)) ? x:y)
#define FOR(a,b,c) for(b=(c);b<(a);b++)
#define ender {return 0;}
#define tosasuretu(a) (a*(a+1)/2)
inline ll kaizyo(ll);
ll combination(ll, ll);
int main() {
	int n;
	cin >> n;
	vector<string> s;
	string in;
	char c;
	bool b = true;
	for (int i = 0; i < n; i++) {
		cin >> in;
		s.push_back(in);
		if (i == 0) {
			
		}
		else if (s[i][0] == c) {

		}
		else {
			b = false;
		}
		c = s[i].back();
	}
	sort(s.begin(), s.end());
	for (int i = 1; i < n; i++) {
		if (s[i] == s[i - 1]) {
			b = false;
		}
	}
	if (b) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}


inline ll kaizyo(ll x) {
	long ans = 1;
	for (int z = 0; z < x; z++) {
		ans *= (x - z);
	}
	return ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll long long

using pi = pair<int, int>;

typedef tree< pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update>Order_Set;

Order_Set X;

const int mxn = 2e5+100;
const int Mod = 1e9+7;

int arr[mxn], qs[mxn];
int bitOn[55];
map<int,int>Mp, cnt, op;
vector<int>Pi, Ans;
vector<int>G[mxn];
set<int>seet[mxn];

int main()
{
     ios::sync_with_stdio(false);
     int x, y, z, k;
     cin>>x>>y>>z>>k;
     vector<long long>v1(x), v2(y), v3(z);
     vector<long long>tmp, Ans;
     for(int i=0 ; i<x ; i++) cin>>v1[i];
     for(int i=0 ; i<y ; i++) cin>>v2[i];
     for(int i=0 ; i<z ; i++) cin>>v3[i];

     sort(v1.rbegin(), v1.rend());
     sort(v2.rbegin(), v2.rend());

     for(int i=0 ; i<x ; i++){
        for(int j=0 ; j<y ; j++){
            tmp.push_back(v1[i]+v2[j]);
        }
     }

     sort(tmp.rbegin(), tmp.rend());
     sort(v3.rbegin(), v3.rend());

     int sz1 = tmp.size();
     int sz = min(3000, sz1);
     for(int i=0 ; i<z ; i++){
        for(int j=0 ; j<sz ; j++){
            Ans.push_back(tmp[j]+v3[i]);
        }
     }
     sort(Ans.rbegin(), Ans.rend());
     for(int i=0 ; i<k ; i++) cout<<Ans[i]<<endl;

     return 0;
}




Measured memory_bytes: 57320
#include<bits/stdc++.h>
using namespace std;	
long long l[87];
int n;
int main(){

	l[0]=2;
	l[1]=1;
	cin>>n;
	for(int i=2;i<=n;++i)
	l[i]=l[i-1]+l[i-2] ;
	cout<<l[n];
	return 0;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int WWW = 0;WWW < (n);WWW++)cerr << v[WWW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007


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

int main(){
	ll n;cin >> n;
	vector<ll> v(n);
	
	REP(i,n)cin >> v[i];
	
	ll ans = 0;
	
	REP(i,n){
		ll tmp = v[i] - n*n;
		ll pla = max(0LL,tmp / (n + 1));
		ans += pla * (n+1);
		v[i] -= pla * (n + 1);
	}
	DBG(SHOW1d(v,n);)
	while(1){
		sort(ALL(v),greater<ll>());
		if(v[0] < n)break;
		v[0] -= n+1;
		REP(i,n)v[i]++;
		ans++;
	}
	
	cout << ans << endl;
		
		
	return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int a, b;
    cin >> a >> b;
    if(a+b >= 24){
        cout << a+b-24;
    }
    else
    {
        cout << a+b;
    }
    
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
using namespace std;
int main(){
    int n;
    cin >> n;
    bool ans = true;
    vector<int> x(n+1);
    vector<int> y(n+1);
    vector<int> t(n+1);
    x[0]=0;
    y[0]=0;
    t[0]=0;
    for(int i=0; i<n; i++){
        cin >> t[i+1] >> x[i+1] >> y[i+1];
    }
    for(int i=0; i<n; i++){
        int a = t[i+1]-t[i];
        int x1 = abs(x[i]-x[i+1]);
        int y1 =abs(y[i]-y[i+1]);
        if(a<(x1+y1)){
            ans = false;
            break;
        }
        else if((a%2) != ((x1+y1)%2)){
            ans = false;
            break;
        }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
using namespace std;

int n,m,p,f[100010],a,b;
bool ok[100010];
string s;

int main()
{

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

    cin >> n >> m;

    for(int i=0; i<m; i++){
        cin >> p >> s;
        if( !ok[p] && s=="WA" ) f[p]++;

        if( s=="AC" && !ok[p] ) ok[p] = true , a++,b+=f[p];
    }

    cout << a << " " << b;

    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=100005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int D,T,S;cin>>D>>T>>S;
    if(T*S>=D) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}




Measured memory_bytes: 3616
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int x[252521];
int ne[252521][20],rne[252521][20];
int dp[(1<<20)+10],rdp[(1<<20)+10];
vector<int> v;
int main()
{
	int n,V;
	cin>>n>>V;
	rep(i,n) cin>>x[i];
	while(V>0){
		v.pb(V);V/=2;
	}
	v.pb(0);int m=v.size();
	rep(i,n) rep(j,m){
		rne[i][j]=i;
		if(i>0 && x[i]-x[i-1]<=v[j]) rne[i][j]=rne[i-1][j];
	}
	for(int i=n-1;i>=0;i--) rep(j,m){
		ne[i][j]=i;
		if(i<n-1 && x[i+1]-x[i]<=v[j]) ne[i][j]=ne[i+1][j];
	}
	memset(dp,0,sizeof(dp));
	rep(i,(1<<20)+5) rdp[i]=n-1;
	rep(i,(1<<m)) rep(j,m){
		if((i&(1<<j))>0) continue;
		dp[i+(1<<j)]=max(dp[i+(1<<j)],dp[i]>=n?n:ne[dp[i]][j]+1);
		rdp[i+(1<<j)]=min(rdp[i+(1<<j)],rdp[i]<0?-1:rne[rdp[i]][j]-1);
	}
	//rep(i,(1<<m)) cout<<i<<' '<<dp[i]<<' '<<rdp[i]<<endl;
	if(dp[(1<<m)-1]<n){
		//assert(dp[(1<<m)-1]<n && rdp[(1<<m)-1]>=0);
		rep(i,n) cout<<"Impossible"<<endl;
		return 0;
	}
	int now=0;
	while(now<n){
		int f=0;
		rep(i,(1<<(m-1))){
			if(dp[(1<<m)-2-(i<<1)]>=now && rdp[(i<<1)]<=ne[now][0]) f=1;
		}
		REP(i,now,ne[now][0]+1){
			if(f>0) cout<<"Possible"<<endl;
			else cout<<"Impossible"<<endl;
		}
		now=ne[now][0]+1;
	}
}


Measured memory_bytes: 46208
import java.util.Scanner;
public class Main{
		 
			public static void main(String[] args) {
		        Scanner sc = new Scanner(System.in);
				int n = sc.nextInt(),m= sc.nextInt();
				int sum=0;
				for(int i=n; i<=m; i++) {
					int a1=i%10,a2=i/10000; 
					int a3=(i%100-a1)/10,a4=i/1000-a2*10;
					if(a1==a2 && a3==a4) {
						sum++;
					}
				}
				System.out.println(sum);
			}
		 
		}


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

using namespace std;

int main(){

	int n, x, y, tmp, nearx, neary;
	int d[2020];

	cin>> n >> x >> y;

	for (int i = 0;i < 2020;i++) d[i] = 0;

	for (int i = 1;i <= n - 1;i++) {
		for (int j = i + 1;j <= n;j++) {
			nearx = min(abs(x - i), abs(y - i));
			neary = min(abs(x - j), abs(y - j));
			tmp = min(j - i, nearx + neary + 1);
			d[tmp]++;
		}
	}

	for (int i = 1;i < n;i++) cout << d[i] << endl;;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n)repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
typedef pair<int,int> P;
typedef pair<int, P> PP;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define fi first
#define se second
const int inf = 1e9+7;
const int INF = 1e18+7;
int mod = 1e9+7;

string str, str2;
int mp[100];
signed main(){
	rep(i,'z'-'a'+1)str2.push_back((char)('z'-i));
	cin >> str;
	int n = str.size();
	
	rep(i,n)mp[str[i]-'a']++;
	rep(i,'z'-'a'+1){
		if(mp[i] == 0){
			cout << str << (char)(i+'a') << endl;
			return 0;
		}
	}
	
	drep(i,n-1,0){
		char c = str[i];
		repi(j,c-'a','z'-'a'+1){
			if(mp[j] == 0){
				cout << str.substr(0, i) << (char)('a'+j) << endl;
				return 0;
			}
		}
		mp[c-'a'] = 0;
	}
	cout << -1 << endl;
	return 0;
}


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

int mycmp(const void *a, const void *b) {
    // return (*(string*)a > *(string*)b);
    // if(*(string*)a > *(string*)b) return -1;
    // else if(*(string*)a < *(string*)b) return 1;

    // return 0;
    char *left_char = (char *)a;
    char *right_char = (char *)b;

    return strcmp( left_char, right_char );
}

int main() {
    int n;
    cin>>n;
    char poll[n][11];
    for(int i=0; i<n; i++) cin>>poll[i];

    qsort(poll, n, sizeof(poll[0]), mycmp);

    // for(int i=0; i<n; i++) {
    //     cout<<poll[i]<<endl;
    // }

    int answer[n];
    int ansnum = 0;

    int max = 0;
    int posi = 0;
    while(posi<n) {
        int start = posi;
        //while(poll[posi]==poll[start]) {
        while(strcmp(poll[posi], poll[start]) == 0) {
            posi++;
        }
        if(posi-start == max) {
            answer[ansnum] = start;
            ansnum++;
        }
        else if(posi-start > max) {
            max = posi-start;
            ansnum = 0;
            answer[ansnum] = start;
            ansnum++;
        }
    }

    for(int i=0; i<ansnum; i++) {
        cout<<poll[answer[i]]<<endl;
    }
    

    return 0;
}

Measured memory_bytes: 4936
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
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; }
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;

#define MAX_E 100000
#define MAX_V 100000

int V, E, r;

struct edge {
	int from, to, cost;
};
int d[MAX_V];

edge es[MAX_E];

void shortest_path(int s) {
	rep(i, 0, V) d[i] = INF;
	d[s] = 0;
	while(true) {
		bool update = false;
		rep(i, 0, E) {
			edge e = es[i];
			if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				update = true;
			}
		}
		if(!update) break;
	}
}

bool find_negative_loop(int s) {
	//memset(d, 0, sizeof(d));
	fill(d, d + V, INF);
	d[s] = 0;
	rep(i, 0, V) {
		rep(j, 0, E) {
			edge e = es[j];
			if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				if(i == V - 1) return true;
			}
		}
	}
	return false;
}

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

  cin >> V >> E >> r;
  rep(i, 0, E) {
    int s, t, d;
    cin >> s >> t >> d;
    edge e = {s, t, d};
    es[i] = e;
  }

  if(find_negative_loop(r)) {
    cout << "NEGATIVE CYCLE" << endl;
    return 0;
  }

  shortest_path(r);
  rep(i, 0, V) {
    if(d[i] == INF) cout << "INF" << endl;
    else cout << d[i] << endl;
  }
}




Measured memory_bytes: 3228
#include<queue>
#include<cstdio>

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

using namespace std;

typedef	pair<int,int>	pii;

const int INF=1<<29;

int main(){
	for(int n;scanf("%d",&n),n;){
		int adj[20][20],deg[20]={};
		rep(u,n)rep(v,n)	adj[u][v]=INF;
		rep(i,n-1){
			int a,b,t;	scanf("%d%d%d",&a,&b,&t);
			a--,b--;
			adj[a][b]=adj[b][a]=t;
			deg[a]++,deg[b]++;
		}

		for(int u=1;u<n;u++)if(deg[u]==1){	// delete leaves
			rep(v,n)	adj[u][v]=adj[v][u]=INF;
		}

		int lmax=0;
		bool visited[20]={};
		queue<pii> qu;	qu.push(mp(0,0));
		while(!qu.empty()){
			pii a=qu.front();	qu.pop();
			int u=a.first,len=a.second;
			visited[u]=true;

			bool enqued=false;
			rep(v,n)if(!visited[v] && adj[u][v]<INF){
				qu.push(mp(v,len+adj[u][v]));
				enqued=true;
			}
			if(!enqued)	lmax=max(lmax,len);
		}

		int lsum=0;
		rep(u,n)rep(v,u) if(adj[u][v]<INF) lsum+=adj[u][v];
		printf("%d\n",2*lsum-lmax);
	}

	return 0;
}

Measured memory_bytes: 0
H, W, K = map(int, input().split())

s = [input() for _ in range(H)]

lst = [[] for _ in range(H)]
for i, ss in enumerate(s):
    lst[i] = ss.count('#')

ans = [[0]*W for _ in range(H)]
cnt = 1
pre = [0]*W
for i in range(H):
    if lst[i] != 0:
        s[0], s[i] = s[i], s[0]
        lst[i], lst[0] = lst[0], lst[i]
        break

cnt = 1        

for i in range(H):
    if lst[i] == 0:
        ans[i] = pre[:]
        continue
    jdg = False
    for j in range(W):
        if s[i][j] == '.':
            ans[i][j] = cnt
        else:
            if jdg: cnt += 1
            else: jdg = True
            ans[i][j] = cnt
    cnt += 1
    pre = ans[i][:]

for a in ans:
    print(*a)

Measured memory_bytes: 7552
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;

char ch[3][3];
char ch1[3][3];

int main()
{
    int flag=0,i,j;
    for(i=0; i<2; i++)
        scanf("%s",ch[i]);
    for(i=0; i<2; i++)
        for(j=0; j<3; j++)
            ch1[i][j] = ch[2-i-1][3-j-1];
    for(i=0; i<2; i++)
        for(j=0; j<3; j++)
//            cout << ch1[i][j];
            if(ch[i][j] != ch1[i][j])
                flag = 1;
    if(flag == 1)
        cout << "NO" << endl;
    else if(flag == 0)
        cout <<"YES"<<endl;
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    set<int> s;
    for(int _ = 0; _ < n; _++){
        int d;
        cin >> d;
        s.insert(d);
    }
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e4+7;
int dp[maxn] = {1};
int Wight[10] = {0,2,5,5,4,5,6,3,7,6},A[10];
int n,m;
signed main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)scanf("%d",&A[i]);
    for(int i=1;i<=m;i++)
        for(int j=Wight[A[i]];j<=n;j++)
            dp[j] = max(dp[j],dp[j-Wight[A[i]]]+1);
    sort(A+1,A+1+m);
    while(n)
        {
        if(dp[n] == dp[n-Wight[A[m]]]+1)
            printf("%d",A[m]),n -= Wight[A[m]];
        else m--;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long[] ab = new long[2];
		long a,b;
		long gcd = 0;
		long lcm = 0;

		while ((scan.hasNext())) {
			a = Integer.parseInt(scan.next());
			b = Integer.parseInt(scan.next());

			ab[0] = a;
			ab[1] = b;

			java.util.Arrays.sort(ab);

			while(ab[0] != 0){
				long pool = ab[0];
				ab[0] = ab[1] % ab[0];
				ab[1] = pool;
			}
			gcd = ab[1];


			// Å¬ö{
			lcm = a * b / gcd;
			System.out.println(gcd+" "+lcm);
		}
	}
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	998244353;

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, q, x, K;
string s,t;

// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>n;
	map<ll,ll,greater<ll>> cnt;
	for(ll i=0;i<n;i++) {
		cin>>x;
		cnt[x]++;
	}

	ll len = -1, bre = -1;

	for(auto it : cnt) {
		if(it.s > 1) {
			if(len == -1) {
				len = it.f;
				it.s -=2;
			}
			else if(bre == -1) {
				bre = it.f;
				it.s -=2;
				break;
			}

			if(it.s > 1 && bre == -1) {
				bre = it.f;
				break;
			}
		}
	}
	if(len == -1 || bre == -1) cout<<0;
	else cout<<len*bre;
}


int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 9736
import java.util.*;
public class Main {
	
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int K = sc.nextInt();
		
		List<String> ng = new ArrayList<>();
		for (int i = 0; i < K; i++) {
			ng.add(sc.next());
		}
		
		int min = Integer.MAX_VALUE;
		for (int i = N; i <= 100_000; i++) {
			String val = String.valueOf(i);
			
			if (!ng.stream().anyMatch(ngChar -> val.contains(ngChar))) {
				min = Math.min(i, min);
			}
		}
		
		System.out.println(min);
	}
}


Measured memory_bytes: 41528
n = int(input())
h = list(map(int, input().split()))
h.append(h[-1])
mini = h[0] - 1
flag = 0
for i in range(n):
    if h[i+1] > mini:
        mini = h[i+1] - 1
    elif h[i+1] == mini:
        mini = mini
    else:
        flag = 1
print("Yes") if flag == 0 else print("No")

Measured memory_bytes: 14396
package main

import (
        "fmt"
)

func solution(a, b int) int {
        out := 0
        for i := 0; i < 2; i++ {
                if a > b {
                        out += a
                        a--
                } else {
                        out += b
                        b--
                }
        }
        return out
}

func main() {
        var a, b int
        fmt.Scan(&a, &b)
        fmt.Println(solution(a, b))
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		String result = a%2 == 0 || b%2 == 0 ? "Even" : "Odd";

		System.out.println(result);
	}
}


Measured memory_bytes: 21716
import sys
def input(): return sys.stdin.readline().rstrip()
from bisect import bisect_left,bisect
def main():
    n=int(input())
    S=list(input())
    q=int(input())
    set_s={chr(ord('a')+i):[] for i in range(26)}
    for i,s in enumerate(S):
        set_s[s].append(i)
    for _ in range(q):
        query=input().split()
        if query[0]=="1":
            i,c=int(query[1])-1,query[2]
            if S[i]==c:continue
            set_s[S[i]].remove(i)
            set_s[c].insert(bisect_left(set_s[c],i),i)
            S[i]=c
        else:
            l,r=int(query[1])-1,int(query[2])-1
            ans=0
            for i in range(26):
                ss=chr(ord('a')+i)
                if bisect(set_s[ss],r)>bisect_left(set_s[ss],l):
                    ans+=1
            print(ans)


if __name__=='__main__':
    main()

Measured memory_bytes: 104448
def main():
    S = input()
    odd_list=['R', 'U', 'D']
    eve_list=['L', 'U', 'D']
    odd = S[0::2]
    eve = S[1::2]
    for i in odd:
        if i not in odd_list:
            print('No')
            return
    for i in eve:
        if i not in eve_list:
            print('No')
            return
    print('Yes')

main()

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

const int MOD = 1000000007;
const int INF = 1000000000;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}

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; }

int main(){
    int N;
    cin >> N;
    map<int, int>A;
    REP(i, N) {
        int x;
        cin >> x;
        A[x]++;
    }
    bool flag = true;
    for(auto a : A){
        if(a.second > 1) flag = false;
    }
flag ? YES : NO;
}

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

int main(){
    string S;
    string U[3];
    int num = 1;
    getline(cin, S);
    int length = S.size();

    transform(S.begin(), S.end(), S.begin(), ::toupper);


    for(int i=0; i < length; i++){
        if(i == 0){
            U[0] = S[0];
        }

        if(S[i] == ' '){
            U[num] = S[i+1];
            num++;
        }

    }

    cout << U[0];
    cout << U[1];
    cout << U[2] << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)

n, m = map(int, input().split())

g = [[] for _ in range(n)]

for _ in range(m):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    g[x].append(y)

dp = [-1] * n

def dfs(i):
    if dp[i] != -1:
        return dp[i]

    tmp = 0
    for j in g[i]:
        tmp = max(tmp, dfs(j) + 1)

    dp[i] = tmp
    return tmp

for i in range(n):
    dfs(i)

print(max(dp))



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

int main() {
  string S;
  cin >> S;
  int N = S.size();
  int X = 1;
  long ans = 0;
  for (int i = 0; i < N-1; i++) X *= 2;
  for (int i = 0; i < X; i++) {
    int st = 0;
    for (int j = 0; j < N-1; j++) {
      if (i >> j & 1) {
        ans += stol(S.substr(st, j-st+1));
        st = j+1;
      }
    }
    ans += stol(S.substr(st, N-st));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;
class Main
{
	public static void main(String[] args)throws IOException
	{
	BufferedReader br=
	new BufferedReader(new InputStreamReader(System.in));

	String str=br.readLine();
	int x=Integer.parseInt(str);	
	
	System.out.println(x*x*x);
	}
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=(n)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

ll sol(ll a, ll b){

    if(a<b)swap(a,b);
    if(a%b==0)return 2*a-b;

    ll t;
    t = a/b;
    return sol(b,a-b*t) + t*2*b;

}

int main(){
   
    ll n,x;
    cin >> n >> x;
    // ll ans=n;

    // ll a=n-x,b=x;
    // if(a<b)swap(a,b);

    // ll tmp;
    // while(a%b != 0){
    //     tmp = a/b;
    //     ans += 2*b*tmp;
    //     a -= b*tmp;
    //     swap(a,b);
    // }
    // ans += b*((a/b)*2-1);

    // cout << ans << endl;

    cout << sol(n-x,x) + n << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
vector<int>G[1<<17];
int used[1<<17];
long n,m;
bool dfs(int u,int col)
{
	used[u]=col;
	int next=-col;
	bool ans=true;
	for(int i=0;i<G[u].size();i++)
	{
		if(used[G[u][i]]){if(used[G[u][i]]!=next)ans=false;}
		else ans&=dfs(G[u][i],next);
	}
	return ans;
}
main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int a,b;cin>>a>>b;
		G[a].push_back(b);G[b].push_back(a);
	}
	if(dfs(1,1))
	{
		long cnt=0;
		for(int i=0;i++<n;)cnt+=used[i]==1;
		cout<<cnt*(n-cnt)-m<<endl;
	}
	else cout<<n*~-n/2-m<<endl;
}

Measured memory_bytes: 7680
class AtCoder {
  // 入力系
  input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);
  input_i=-1;

  n(){
    this.input_i++;
    return Number(this.input[this.input_i]);
  }
  nn(n:number):number[]{
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.n());
    }
    return a;
  }
  s(){
    this.input_i++;
    return String(this.input[this.input_i]);
  }
  ss(n:number):string[]{
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.s());
    }
    return a;
  }

  // コンソール
  o(...a:any){
    console.log(...a);
  }

  // Math
  abs(a:number){
    return Math.abs(a);
  }
  min(...a:number[]){
    return Math.min(...a);
  }
  max(...a:number[]){
    return Math.max(...a);
  }
  floor(a:number){
    return Math.floor(a);
  }
  ceil(a:number){
    return Math.ceil(a);
  }
  round(a:number){
    return Math.round(a);
  }

  // ソート
  asc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return a-b});
  }
  desc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return b-a});
  }

  // 自作
  gcd(...arr:number[]):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=x;
    }
    return arr[arr.length-1];
  };
  lcm(...arr:number[]):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=arr[i]*arr[i+1]/x;
    }
    return arr[arr.length-1];
  };
  isPrime(n:number):boolean{
    if(n < 2) return false;
    const suq=Math.sqrt(n);
    for(let i=2;i<=suq;i++){
      if(n%i==0){
        return false;
      }
    }return true;
  };
  deduplicate(a:any[]):any[]{
    return Array.from(new Set(a));
  };
  f(roop:number, callback:any){
    for(let i=0;i<roop;i++){
      callback(i);
    }
  };
  Yes(){
    console.log('Yes');
  }
  No(){
    console.log('No');
  }
  YES(){
    console.log('YES');
  }
  NO(){
    console.log('NO');
  }
}
const m = () => {
  const o = new AtCoder();
  let [n,k] = o.nn(2);
  o.o(n.toString(k).length)
}
m();

Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

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

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; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

bool is_prime[1000010];


int main() {
    int n,cnt = 0;
    cin >> n;
    while(cnt < n){
        cnt += 1000;
        if(cnt >= n){
            cout << cnt - n << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){
	int n;
	vi v(2001);
	rer(i,0,1000){
		rer(j,0,1000){
			v[i+j]++;
		}
	}
	while(cin>>n){
		int ans=0;
		/*sort(all(v));
		rep(i,0,v.size()){
			ans+=upper_bound(all(v),n-v[i])-lower_bound(all(v),n-v[i]);
		}*/
		/*rer(i,0,min(1000,n)){
			rer(j,0,min(1000,n)){
				if((n-i-j)<0) continue;
				ans+=upper_bound(all(v),n-i-j)-lower_bound(all(v),n-i-j);
			}
		}*/
		rer(i,0,v.size()){
			rer(j,0,v.size()){
				if(i+j==n) ans+=(v[i]*v[j]);
			}
		}
		o(ans);
	}
}

Measured memory_bytes: 1204
n = gets.to_i
h = Array.new(10){Array.new(10,0)}

(n+1).times do |i|
    next if i % 10 == 0
    x = i.to_s
    h[x[0].to_i][x[-1].to_i] += 1
end

ans = 0
1.upto(9) do |i|
    1.upto(9) do |j|
        ans += h[i][j] * h[j][i]
    end
end

puts ans

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

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

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl

int main(){
    int w,h,n;
    cin>>w>>h>>n;
    int xi=0,xa=w,yi=0,ya=h;
    REP(i,n){
        int x,y,a;
        cin>>x>>y>>a;
        switch(a){
            case 1:
                chmax(xi,x);
                break;
            case 2:
                chmin(xa,x);
                break;
            case 3:
                chmax(yi,y);
                break;
            case 4:
                chmin(ya,y);
                break;
        }
    }
    cerr<<xa<<xi<<ya<<yi<<endl;
    if(xa<xi || ya<yi){
        cout<<0<<endl;
    }else{
        cout<<max(0,(xa-xi)*(ya-yi))<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
from sys import stdin
from heapq import heappop, heappush
readline = stdin.readline

heap = []
while True:
    line = readline()
    if line[1] == 'x':
        print(-heappop(heap))
    elif line[0] == 'i':
        heappush(heap, -int(line.split()[1]))
    else:
        break


'''
def insert(heap, key):
    heap.append(-1000000)
    heapIncreaseKey(heap, key)

def parent(i):
    return (i - 1) // 2

def heapIncreaseKey(heap, key):
    heap[len(heap) - 1] = key
    i = len(heap) - 1
    while i > 0 and heap[parent(i)] < heap[i]:
        heap[i], heap[parent(i)] = heap[parent(i)], heap[i]
        i = parent(i)

def heapExtractMax(heap):
    if len(heap) < 1:
        return None
    else:
        MAX = heap[0]
        heap[0] = heap.pop()
        maxHeapify(heap, 0)

        return MAX

def maxHeapify(heap, i):
    left = (i + 1) * 2 - 1
    right = (i + 1) * 2
    largest = left if left < len(heap) and heap[left] > heap[i] else i
    largest = right if right < len(heap) and heap[right] > heap[largest] else largest
    if largest != i:
        heap[i], heap[largest] = heap[largest], heap[i]
        maxHeapify(heap, largest)


heap = []
while True:
    line = sys.stdin.readline()
    if line[0] == 'i':
        insert(heap, int(line.split()[1]))
    elif line[0:2] == 'ex':
        print(str(heapExtractMax(heap)))
    else:
        break
'''

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

int main(){
  int word=0;
  string W, T;
  
  cin >> W;
  for(int i=0; i<W.size(); i++) W[i] = toupper(W[i]);
  
  cin >> T;
  while(T != "END_OF_TEXT"){
    for(int i=0; i<T.size(); i++) T[i] = toupper(T[i]);
    if(W == T) word++;
    cin >> T;
  }
  cout << word << endl;
  return 0;
}



Measured memory_bytes: 3200
import java.util.Scanner;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int acN = 0;
    int waN = 0;
    int tleN = 0;
    int reN = 0;
    int n = sc.nextInt();
    for (int cnt = 0; cnt < n; cnt++) {
      String s = sc.next();
      switch (s) {
        case "AC":
          acN++;
          break;
        case "WA":
          waN++;
          break;
        case "TLE":
          tleN++;
          break;
        case "RE":
          reN++;
          break;
      }
    }
    System.out.println("AC x " + acN);
    System.out.println("WA x " + waN);
    System.out.println("TLE x " + tleN);
    System.out.println("RE x " + reN);
    sc.close();
  }
}

Measured memory_bytes: 58096
N = int(input())
arr = list(map(int,input().split()))

max_seq = 0
seq = 0
for i in range(len(arr)-1):
	if arr[i]>=arr[i+1]:
		seq+=1
	else:
		max_seq = max(seq,max_seq)
		seq = 0
print(max(max_seq,seq))


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

#define ll long long
#define pb push_back
#define F first
#define S second

using namespace std;

const int N = 100005;
const int MOD = 1e9 + 7;

int arr[55];
int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
    }
    int res = 0;
    for (int x = 0; x <= n; x++) {
        for (int y = 0; x + y <= min(n, k); y++) {
            multiset <int> ms;
            int sum = 0;
            for (int i = 1; i <= x; i++) {
                ms.insert(arr[i]); sum += arr[i];
            }
            for (int i = n - y + 1; i <= n; i++) {
                ms.insert(arr[i]); sum += arr[i];
            }
            int rem = k - (x + y);
            while(rem > 0 && ms.size() > 0) {
                auto it = ms.begin();
                if (*it < 0) ms.erase(it);
                else break;
                sum -= *it;
                rem--;
            }
            res = max(res, sum);
        }
    }
    cout << res << endl;
    return 0;
}


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

using namespace std;

int main() {
    int n, cnt = 0;
    string s;
    cin >> n >> s;
    for (int i = 0; i < n - 2; ++i) if (s.substr(i, 3) == "ABC") ++cnt;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		System.out.println(r * r * 3);
		sc.close();
	}

}


Measured memory_bytes: 23124
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();

        if((a * b) % 2 == 0) {
            System.out.println("Even");
        } else {
            System.out.println("Odd");
        }
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <deque>

std::deque<std::pair<int, int>> dq;

int main() {
  dq.clear();
  int n, l;
  std::cin >> n >> l;
  bool f = true;
  for (int i = 0; i < n; ++i) {
    int x;
    std::cin >> x;
    while (!dq.empty() && (i - dq.front().second >= l)) dq.pop_front();
    while (!dq.empty() && (dq.back().first > x)) dq.pop_back();
    dq.push_back({x, i});
    if (i >= l - 1) {
      if (!f) std::cout << " ";
      f = false;
      std::cout << dq.front().first;
    }
  }
  std::cout << std::endl;
  return 0;
}


Measured memory_bytes: 3228
'use strict';
function Main(stdin){
  const input = stdin.trim().split(/\r?\n/g);
  const A_V= input[0].split(' ').map(str => BigInt(str));
  const A = A_V[0], V = A_V[1];
  const B_W= input[1].split(' ').map(str => BigInt(str));
  const B = B_W[0], W = B_W[1];
  const T = BigInt(input[2]);
  let result = 'NO';
  let kyori;
  const tidimu = V - W;
  
  if(tidimu > 0){
    if(A > 0 && B < 0){
        kyori = A + BigInt(String(B).slice(1));
      } else if(A < 0 && B > 0){
        kyori = B + BigInt(String(A).slice(1));
      } else {
        kyori = A - B;
        if(kyori < 0) kyori = BigInt(String(kyori).slice(1));
      }
      if(tidimu * T >= kyori) result = 'YES';
  }
  console.log(result);
}

// 固定
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29636
import java.util.Scanner;

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

		int a = sc.nextInt();
		int b = sc.nextInt();

		int c = a + b;
		if (c < a - b) c = a - b;
		if (c < a * b) c = a * b;
		System.out.println(c);
	}
}

Measured memory_bytes: 22100