akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<tuple>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
	int n;
	cin >> n;
	vector<ll>a(n);
	rep(i, n)cin >> a[i];
	ll ans = 0;
	rep(i, n) {
		ans += a[i] - 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int n;

	cin>>n;

	vll a(n);

	ll count=0, min_a=1e18, ans=0;
	rep(i, n){
		cin>>a[i];
		if(a[i]<=0) count++;
		min_a=min(min_a, llabs(a[i]));
		ans+=llabs(a[i]);
	}
	if(count%2!=0){
		cout<<ans-min_a*2<<endl;
	}else{
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
 
const int N = 1e5 + 10 , M = 5e5+10 ,  MOD = 1e9+7;
const int OO = 0x3f3f3f3f;
const double EPS = 1e-3;
 
#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define ALL(v) ((v).begin()) , ((v).end())
#define SZ(v)  ((int)((v).size()))
typedef pair <int,int> pii ;
typedef vector < pii > vii ;
typedef vector < int > vi;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
 

int n , m;
char s[2005][2005];
int l[2005][2005] , r[2005][2005] , up[2005][2005] , down[2005][2005];



int main()
{
    
   // ios_base::sync_with_stdio(0);
   // cin.tie(0);cout.tie(0);

    

    scanf("%d %d",&n,&m);

    for(int i = 0 ; i < n ; ++i)
        scanf("%s",s[i]);

    for(int i = 1 ; i < n+1 ; ++i){
        for(int j = 1 ; j < m+1 ; ++j){

            if (s[i-1][j-1] == '.') {
                l[i][j] = l[i][j-1] + 1;
                up[i][j] = up[i-1][j] + 1;
            }

        }
    }

    for(int i = n ; i >= 1 ; --i){
        for(int j = m ; j >= 1 ; --j){
             if (s[i-1][j-1] == '.') {
                r[i][j] = r[i][j+1] + 1;
                down[i][j] = down[i+1][j] + 1;
            }
        }   

    }

    int mx = 0;

    for(int i = 1 ; i < n+1 ; ++i){
        for(int j = 1 ; j < m+1 ; ++j){
            mx = max(mx , l[i][j] + up[i][j] + down[i][j] + r[i][j] - 3);
        }

    }

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

    
    return 0;
}


Measured memory_bytes: 66944
#include<bits/stdc++.h>
using namespace std;
 
typedef long long LL;
 
int main()
{
    LL n,ans=1LL<<62;
    cin>>n;
    vector<LL>arr(n+1);
 
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
        arr[i]+=arr[i-1];
    }
    
    for(int i=1;i<n;i++)
        ans=min(ans,abs(arr[n]-2*arr[i]));
 
    cout<<ans<<endl;
}

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

int main(){
  string s;
  cin >> s;

  for(int i = 0; i < s.size(); i++){
    int x = s[i] - 'A';
    x = (x + 26 - 3) % 26;
    s[i] = (char)('A' + x);
  }

  cout << s << endl;
}

Measured memory_bytes: 1180
n,k=map(int,input().split())
l=[]
for i in range(n):
    a,b=[int(j) for j in input().split()]
    l.append([a,b])
l.sort()
p=0
i=0
while True:
    if p+l[i][1]>=k:
        print(l[i][0])
        break
    else:
        p+=l[i][1]
        i+=1



Measured memory_bytes: 20064
#include <iostream>

int main() {
  int n;
  std::cin >> n;
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    int a;
    std::cin >> a;
    while (true) {
      if (a % 2 == 1) {
        break;
      }
      cnt++;
      if (a % 2==0) a /= 2;
    }
    
  }
  std::cout << cnt << std::endl;
}


Measured memory_bytes: 888
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define rep(i,n) for(i=0;i<n;i++)
#define PI 3.14159265358979323846264338327950L
int main(){
    int n,i,j,sum;
    long int L=1000000000;
    scanf("%d",&n);
    int x[n];
    rep(i,n) scanf("%d",&x[i]);
    for(j=1;j<=100;j++){
        sum=0;
        rep(i,n){
            sum=sum+(x[i]-j)*(x[i]-j);
        }
        if(sum<L) L=sum;
    }
    printf("%ld",L);
    return 0;
}

Measured memory_bytes: 1724
# import math
# import statistics
#a=input()
#b,c=int(input()),int(input())
# c=[]
# for i in a:
#    c.append(i)
e1,e2 = map(str,input().split())
#K = input()
# f = list(map(int,input().split()))
#g = [input() for _ in range(a)]
count=0
a=e1+e2
for i in range(1,int(a)):
	if int(a)/int(i)==int(i):
		count+=1
if count>0:
	print('Yes')
else:
	print('No')


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

int N,K,x;
int main(){
    cin >> N >> K;
    REP(i,N) cin >> x;
    int ans = (N-1)/(K-1);
    ans += (N-1)%(K-1) > 0;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long LL;
typedef unsigned int uint;
typedef pair<int,int> pii;
//-------------------------------------------------------------------LYYY↓
namespace LYYY{
	int rd()
	{
		int s=0;char c=getchar();int f=1;
		while(c<48||c>57)
		{
			if(c==45) f=-1;
			c=getchar();
		}
		while(c>=48&&c<=57) s=(s<<3)+(s<<1)+(c^48),c=getchar();
		return s*f;
	}
	LL rdl()
	{
		LL s=0;char c=getchar();int f=1;
		while(c<48||c>57)
		{
			if(c==45) f=-1;
			c=getchar();
		}
		while(c>=48&&c<=57) s=(s<<3)+(s<<1)+(c^48),c=getchar();
		return s*f;
	}
	void wt(int x)
	{
		if(x>=10) wt(x/10);
		putchar(x%10+48);
	}
	void WT(int x)
	{
		if(x<0) x=-x,putchar(45);
		wt(x);
	}
	void wtl(LL x)
	{
		if(x>=10) wtl(x/10);
		putchar(x%10+48);
	}
	void WTL(LL x)
	{
		if(x<0) x=-x,putchar(45);
		wtl(x);
	}
}using namespace LYYY;
//-------------------------------------------------------------------bianliang↓
const int maxn=333;
const int maxm=99999;
int tot,N,M,L,fir[maxn],nxt[maxm],to[maxm],D[maxm];
pii dis[maxn][maxn];
bool vis[maxn];
priority_queue<pair<pii,int> > Q;
//-------------------------------------------------------------------hanshu↓
void Dij(int x)//朴素dij应该更快！！！
{
	memset(vis,0,sizeof(vis));
	for(int i=1;i<=N;++i) dis[x][i]=mp(N*2,0);
	Q.push(mp(dis[x][x]=mp(0,0),x));
	while(!Q.empty())
	{
		int q=Q.top().second;vis[q]=true,Q.pop();
		for(int i=fir[q],v=to[i];i;i=nxt[i],v=to[i])if(!vis[v])
		{
			pii uuu=dis[x][q];
			uuu.second+=D[i];
			if(uuu.second>L) ++uuu.first,uuu.second=D[i];
			if(uuu<dis[x][v]) dis[x][v]=uuu,Q.push(mp(mp(-uuu.first,-uuu.second),v));
		}
		while(!Q.empty()&&vis[Q.top().second]) Q.pop();
	}
}
void add_edge(int x,int y,int z)
{
	nxt[++tot]=fir[x],to[fir[x]=tot]=y,D[tot]=z;
}
//-------------------------------------------------------------------main()↓
int main()
{
	N=rd(),M=rd(),L=rd();
	for(int i=1;i<=M;++i)
	{
		int a=rd(),b=rd(),c=rd();
		if(c>L) continue;
		add_edge(a,b,c);
		add_edge(b,a,c);
	}
	for(int i=1;i<=N;++i) Dij(i);
	int Q=rd();
	while(Q--)
	{
		int a=rd(),b=rd();
		if(dis[a][b].first==N*2) puts("-1");
		else WT(dis[a][b].first),puts("");
	}
	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e18;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    int P[N], Q[N];
    rep(i, N) cin >> P[i];
    rep(i, N) cin >> Q[i];
    ll fac[N+1];
    fac[0] = 1;
    rep2(i, 1, N) fac[i] = fac[i-1]*i;
    ll a = 0, b = 0;
    rep(i, N){
        int p = 0, q = 0;
        rep2(j, i+1, N-1) if(P[j] > P[i]) p++;
        a += (N-1-i-p)*fac[N-1-i];
        rep2(j, i+1, N-1) if(Q[j] > Q[i]) q++;
        b += (N-1-i-q)*fac[N-1-i];
    }
    cout << abs(a-b) << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    from bisect import bisect_left

    s = input()
    t = input()
    n = len(s)
    m = len(t)
    alpha = [[] for _ in range(26)]

    # KeyInsight
    # 部分列判定：場所i以降で文字Cが最初に現れる位置を高速に求める
    # アルファベットの出現位置をリストで記録

    # sで各文字が出現する位置を2周分記録
    for index, si in enumerate(s):
        alpha[(ord(si) - ord('a'))].append(index)

    for index, si in enumerate(s):
        alpha[(ord(si) - ord('a'))].append(index + n)

    ans = 0
    p = 0

    for ti in t:
        c = ord(ti) - ord('a')

        if len(alpha[c]) == 0:
            print('-1')
            exit()

        pi = bisect_left(alpha[c], p)
        p = alpha[c][pi]
        p += 1

        if p >= n:
            p -= n
            ans += n

    ans += p

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 11764
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    bool ans = false;
    ll x, y; cin >> x >> y;
    for(ll i=0; i<=x; i++){
        ll j = x-i;
        if(2*i + 4*j == y) ans = true; 
    }
    ans ? Yes() : No();
}

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

#define ll          long long
#define pb          push_back
#define int       ll
#define ppb         pop_back
#define eb          emplace_back
#define	endl		'\n' 
#define max(a,b)	((a)>(b)?(a):(b))
#define min(a,b)	((a)<(b)?(a):(b))
#define vi          vector<int>
#define vii         vector<pair<int, int> >
#define mp          make_pair
#define mem1(a)     memset((a),-1,sizeof(a))
#define all(a)      (a).begin(),(a).end()
#define vs          vector<string>
#define F           first
#define S           second
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    (a)*((b)/gcd((a),(b)))
#define DECIMAL(n)  cout << fixed ; cout << setprecision(n);
#define FAST        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mi          map<int,int>
#define sz(x)       (ll)(x).size()
#define rep(i,a,b)  for(int i=(a);i<(b);i++)
#define pii         pair<int,int>
#define MOD         (1000000007)

int solve()
{
	int n,m;
	cin>>n>>m;
	string arr[n];
	rep(i,0,n)
		cin>>arr[i];
	// dp[i][j] = no of ways to get there
	//vector<vector<int> > dp ( n+1 ,vector<int> (m+1,0));
	int dp[n+1][m+1];
	rep(i,0,n+1)
	{
		rep(j,0,m+1)
		dp[i][j]=0;
	}
	dp[1][1]=1;
	rep(i,1,n+1)
	{
		rep(j,1,m+1)
		{
			if(i==1 && i==j)
				continue;
			if(arr[i-1][j-1]=='.')
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
			else
				dp[i][j]=0;
		}
	}
	cout<<dp[n][m];
    return 0;
}
signed main()
{
    FAST
    #ifndef ONLINE_JUDGE 
        freopen("input.txt", "r", stdin); 
        freopen("output.txt", "w", stdout); 
    #endif 
    int t=1;
   // cin>>t;
    while(t)
    {
        solve();
        t--;
    }
    cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
    return 0;
}

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

int main(){
    int N;
    cin>>N;
    double v[N];
    for(int i=0;i<N;i++){
        cin>>v[i];
    }
    sort(v,v+N,greater<int>());
    for(int j=N-2;j>=0;j--){
        v[j]=(double)(v[j]+v[j+1])/2;

    }
cout<<v[0]<<endl;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
int main()
{
	ll n;
	cin>>n;
    string s;
    cin>>s;
    ll p = s.size();
    if(p>n){
    	string b;
    	for(ll i=0; i<n; i++){
    		b+=s[i];
		}
		b+="...";
		cout<<b<<endl;
	}
	else{
		cout<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 3532
#include <stdio.h>
#include <math.h>

int main(void) {
	int n,i;
	
	while( scanf("%d", &n) != EOF ) {
		
		int a[10]={0};
		int count=0;
		
		for(i=9; i>=0; i--){
			if(n/(int)pow(2,i)>0) {
				a[i] = 1;
				n = n-(int)pow(2,i);
				count++;
			}
		}
		
		for(i=0; i<=9; i++) {
			if(count==1) break;
		
			if(a[i] == 1) {
				printf("%d ", (int)pow(2, i) );
				count--;
			}
		
		}
		while(i<=9){
			if(a[i] ==1) 
				printf("%d",(int)pow(2,i));
			i++;		
		}
				
		printf("\n");
				
	}

	return 0;
}

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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)

int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int Q; cin >> Q;
  for (int i = 0; i < Q; i++) {
    ll a, b; cin >> a >> b;
    ll n = sqrt((long double)(a * b - 1));
    if (a * b <= n * (n+1)) {
      cout << 2 * (n-1) << "\n";
    }else if (a == n+1 && b == n+1) {
      cout << 2*n << "\n";
    }else {
      cout << 2*n - 1 << "\n";
    }
  }
  return 0;
}



Measured memory_bytes: 256
/*****************************************************
 				*	Logged in : HABIBUR RAHMAN						 *
				*	Dept	  : COMPUTER SCIENCE AND ENGINEERING	 *
				*													 *
				*	KHULNA UNIVERSITY OF ENGINEERING AND TECHNOLOGY  *
				******************************************************/


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<string> vs;
typedef pair<ll,ll> pll;
#define fast_io 			ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) 				v.begin(),v.end()
#define allr(v) 			v.rbegin(),v.rend()
#define rep(i,a,b) 			for(ll i=a;i<=b;i++)
#define rep0(i,n)			for(ll i=0;i<n;i++)
#define rrep0(i, n) 		for(ll i=(ll)(n);i>0;--i)
#define rrep(i, a, b) 		for(ll i=(ll)(a);i>=(ll)(b);--i)
#define pb(z) 				push_back(z)
#define ff					/first
#define ss 					second
#define caset 				int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define sz(X) 				((ll)(X).size())
#define scan(X) 			scanf("%s", (X))
#define ms(v,val)			memset((v),(val),sizeof((v)))
#define ms0(X) 				memset((X), 0, sizeof((X)))
#define ms1(X) 				memset((X), -1, sizeof((X)))
#define m_p(a,b)            make_pair(a,b)
#define get_pos(c,x) 		(lower_bound(c.begin(),c.end(),x)-c.begin())
#define lcm(a,b)            (a*b)/__gcd(a,b)
#define INF9                1000000010
#define INF18               4000000000000000010
#define bpll(a)             __builtin_popcountll(a)
#define sqr(a)              ((a)*(a))
#define nl					"\n"
//#define mod					1e9+7;
#define mx_el(v)			*max_element(all(v));
#define mn_el(v)			*min_element(all(v));
#define pcase(z,x)    		cout<<"Case "<<z<<": "<<x<<"\n"
const double pi = 2*acos(0) ;
#define display(v)			vi :: iterator it;for(it=(v).begin();it!=(v).end();it++){cout << *it << " " ;}cout << endl;
#define taking(n,v) 		for(ll i=0;i<(n);i++){ll inp;cin>>inp;(v).push_back(inp);}

void start(){
      #ifndef ONLINE_JUDGE 
      freopen("input.txt" , "r" , stdin) ;
      freopen("output.txt" , "w" , stdout) ;
      #endif
}

void solve()
{
 	 char ch;cin>>ch;
 	 if(ch>='a'&&ch<='z')cout << "a";
 	 else cout << "A";
}

int main(){
	fast_io
	//start();
   // caset{
    	//cout << "Case " << tt << ": ";

		  solve();
	//}
	
	return 0;
}


Measured memory_bytes: 3472
#include <iostream>

using namespace std;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==5&&b==5&&c==7 || a==7&&b==5&&c==5 || a==5&&b==7&&c==5)
        cout<<"YES";
    else cout<<"NO";
    return 0;
}


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

int main(){

  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n);
  int ans;
  ans = a[n-1]/2 + accumulate(a,a+n-1,0);
  cout << ans << endl;


}


Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::{
   fastout, input,
   marker::{Bytes, Chars, Isize1, Usize1},
};

use std::io::{stdout, BufWriter, Write};

fn main() {
   let out = stdout();
   let mut out = BufWriter::new(out.lock());
   input! {
      n:usize,
      a:[Usize1;n-1]
   }
   let mut v = vec![0_usize; n];
   for i in a {
      v[i] += 1;
   }

   for i in v {
      writeln!(out, "{}", i).unwrap();
   }
}


Measured memory_bytes: 6396
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int N;
  cin >> N;
  map<string,int> A;
  rep(i,N) {
    string c;
    cin >> c;
    if (A[c] != 0) {
      cout << "NO" << endl;
      return 0;
    }
    else {
      A[c] = 1;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 18604
#include<stdio.h>
int main()
{
	int N,i;
	int count=0;
	scanf("%d",&N);
	for(i=1;i<=N;i++){
		if(i%2!=0){
			count++;
		}
	} 
	double y;
	y=1.0*count/N;
	printf("%f",y);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner stdIn = new Scanner(System.in);
		
		int X = stdIn.nextInt();
		int t = stdIn.nextInt();
		
		if(X-t >= 0)
		{
			System.out.println(X-t);
		}
		else
		{
			System.out.println(0);
		}

	}

}


Measured memory_bytes: 35556
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int sum=0;
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++)
  {
    sum=sum+(s[i]-'0');
  }
  if(sum%9==0)
    cout<<"Yes";
  else
    cout<<"No";
}


Measured memory_bytes: 3732
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<ctime>
using namespace std;

const int N=370;
const int M=30;

int D,ans,T,d,q,start;
int s[N][M],lst[M],c[M],t[N],cnt[N][M];

bool time_out(){
	return clock()-start>1930;
}

int calc(){
	int sum=0;
	for (int i=1;i<=26;i++) lst[i]=0;
	for (int i=1;i<=D;i++){
		sum+=s[i][t[i]];
		lst[t[i]]=i;
		for (int j=1;j<=26;j++) sum-=c[j]*(i-lst[j]);
	}
	return sum;
}

int argmx(int d){
	int id=1;
	for (int i=2;i<=26;i++)
		if (s[d][i]>s[d][id]) id=i;
	return id;
}

int main(){
	scanf("%d",&D);
	for (int i=1;i<=26;i++) scanf("%d",&c[i]);
	for (int i=1;i<=D;i++)
		for (int j=1;j<=26;j++) scanf("%d",&s[i][j]);
	for (int i=1;i<=D;i++) t[i]=argmx(i);
	ans=calc();
  srand(time(0));
	start=clock();
	while (!time_out()){
		int sum,tmp;
		d=rand()%D+1; q=rand()%26+1;
		tmp=t[d];
		t[d]=q; sum=calc();
		if (sum>ans) ans=sum;
		else t[d]=tmp;
	}
	for (int i=1;i<=D;i++) printf("%d\n",t[i]);
	return 0;
}

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

int main(){
  ll k;
  cin >> k;
  ll a[k+10];
  a[1] = 7%k;
  rep(i,k){
    a[i+1] = (a[i]*10+7)%k;
    if(a[i] == 0){
      cout << i << endl;
      return 0;
    }
  }
  
  cout << -1 << endl;
  
  return 0;
}


Measured memory_bytes: 11360
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let m: u8 = read(&mut stdin_lock, &mut buf, b'\n');
    let ans = 24 + 24 - m;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;


// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//組み合わせ計算用
const int MAX = 500000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void)

{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << ketasitei;

	ll n, k;
	cin >> n >> k;
	ll ans = 0;

	for (ll i = k; i <= n + 1; i++)
	{
		ll tmp = 0;
		tmp = i * (1LL + i);
		tmp /= 2;
		tmp %= MOD;
		ll tmp2 = 0;
		tmp2 = i * (n + 1 + (n + 1 - i + 1));
		tmp2 /= 2;
		tmp2 %= MOD;
		ans += tmp2 - tmp + 1;
		ans %= MOD;
		if (ans < 0)
			ans += MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
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 int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<pair<ll, ll>> ab(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> ab[i].first >> ab[i].second;
    }
    sort(ALL(ab), [](const auto &a, const auto &b) { return a.second < b.second; });
    ll rec = 0;
    for (ll i = 0; i < n; i++)
    {
        rec += ab[i].first;
        if (rec > ab[i].second)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3456
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	    String w=sc.next();
	    
	    char[] alpha = new char[26];//アルファベットの配列のオブジェクトを生成
	    
	    String str = "abcdefghijklmnopqrstuvwxyz";
	    for(int i = 0; i < 26; i++){
			alpha[i] = str.charAt(i);//alphaにアルファベットを格納
	    }
	    
	    int [] count = new int[26];//カウント回数を保存する配列オブジェクトを生成
	    
	    for(int i=0;i<w.length();i++){
	    	for(int j=0;j<26;j++){
	    		if(w.charAt(i) == alpha[j])//一致したら＋１する
					count[j]++;
	    	}
	    }
	    for(int i=0; i<26; i++){//判定を行う
	    	if(count[i]%2!=0){//偶数でないのが現れたら終わり
	    		System.out.println("No");
	    		System.exit(0);
	    	}
	    }
	    System.out.println("Yes");//前の判定を全てくぐり抜けたらyes
	}
}

Measured memory_bytes: 24788
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T> void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T> void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U> bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U> bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T> bool even(T n) { return ! (n & 1); }
template<class T> bool odd(T n) { return n & 1; }
template<class T> ll rup(T a, T b) { return a % b ? a / b + 1 : a / b; }
template<class T> ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T> ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;
ll intpow(ll a, ll n, ll _mod=numeric_limits<ll>::max()) { ll p=1; while (n) { if (n&1) p=p*a%_mod; a=a*a%_mod; n>>=1; } return p; } 
ll modc(ll a, char op, ll b, ll _mod=mod)
{
        a %= _mod; b %= _mod; ll res = 1;
        switch (op) {
        case '+': res = (a + b) % _mod; break;
        case '-': res = (a - b) % _mod; break;
        case '*': res = a * b % _mod; break;
        case '/': res = modc(a, '*', modc(b, '^', _mod-2, _mod), _mod); break;
        case '^': res = intpow(a, b, _mod); break;
        case 'P': rep(i, a-b+1, a+1) res = modc(res, '*', i, _mod); break;
        case 'C': res = modc(modc(a, 'P', b, _mod), '/', modc(b, 'P', b, _mod)); break;
        } 
        if (res < 0) { res += _mod; } return res;
}



int main()
{
        string S;
        cin >> S;

        ll N = len(S);
        reverse(all(S));

        vll dp(N+2);
        dp[0] = 0;

        rep(i, 0, N) {
            ll num = S[i] - '0';
            //cout << num << endl;
            dp[i+1] =  modc(dp[i], '+',  num*intpow(10, i, 2019), 2019);
        }

        //print1d(dp);

        vll cnt(2019);
        rep(i, 0, N+1) {
            cnt[dp[i]]++;
        }

        ll ans = 0;
        rep(i, 0, 2019) {
            ll x = cnt[i];
            ans += x * (x-1) / 2;
        }

        cout << ans << endl;
}


Measured memory_bytes: 5196
<?php
$n = intval(fgets(STDIN));
for($i = 0; $i < $n; $i++){
  $a[$i] = intval(fgets(STDIN));
  for($j = 0; $j < $a[$i]; $j++){
    list($b, $c) = array_map("intval", explode(" ", trim(fgets(STDIN))));
    $map[$i][$b-1] = $c; 
  }
}
$max = 0;
for($i = 0, $I = 2**$n; $i < $I; $i++){
  $bits = sprintf("%0".$n."b", $i);
  foreach($map as $from => $row){
    if($bits[$from] == "1"){ 
      foreach($row as $to => $v){
        if($bits[$to] != $v){ 
          continue 3;
        }
      }
    }
  }
  $sum = 0;
  for($j = 0; $j < $n; $j++){
    $sum+=$bits[$j];
  }
  $max = max($max, $sum);
}
echo $max;

Measured memory_bytes: 4856
const main = (input) => {
  let n = BigInt(input.trim())
  const alpha = 'zabcdefghijklmnopqrstuvwxyz'
  let ans = []

  while (n > 0n) {
    const r = n % 26n || 26n
    ans.unshift(alpha[`${r}`])
    n = (n-r) / 26n
  }

  return console.log(ans.join(''))
}

process.env.MYTEST
  ? (process.env.MYTEST === 'test' ? test() : main(require('fs').readFileSync('dev/stdin', 'utf8')))
  : main(require('fs').readFileSync('/dev/stdin', 'utf8'))

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define eb emplace_back

typedef unsigned long long ll;
typedef long double ld;

const ll MOD = 1e9+7;
		

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	string S; cin >> S;
	
	vector<ll> rem(13, 0);
	rem[0] = 1;
	for (char e : S) {
		vector<ll> n_rem(13, 0);
		if (e == '?') {
			for (int dig = 0; dig<10; dig++) {
				for (int i=0; i<13; i++) {
					int idx = (10*i+dig)%13;
					n_rem[idx] += rem[i];
					n_rem[idx] %= MOD;
				}
			}
		} else {
			int dig = e-'0';
			for (int i=0; i<13; i++) {
				n_rem[(10*i+dig)%13] = rem[i];
			}
		}
		rem = n_rem;
	}
	cout << rem[5] << endl;
				
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,K; cin>>N>>K;
    vint l(N); REP(i,N) cin>>l[i];
    sort(ALL(l),greater<int>());

    int ans=0;
    REP(i,K) ans+=l[i];
    cout<<ans<<endl;

}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C044
{
    class C105
    {
        static void Main(string[] args)
        {
            long N =int.Parse( Console.ReadLine());
            long x = N;
            char[] c = null;
            while (x != 0)
            {

                int i = 0;
                long s = 0, t = 0;
                while (true)
                {
                    long k = (long)Math.Pow(-2, i);
                    if (k < 0) s += k;
                    else t += k;
                    i++;

                    if(s <= x && x <= t)
                    {
                        x -= k;
                        if (c == null)
                        {
                            c = Enumerable.Repeat('0', i).ToArray();
                        }
                        c[c.Length-i] = '1';
                        break;
                    }
                }
            }
            if (c == null) c = new char[] { '0' };
            string str = new string(c);
            Console.WriteLine(str);
        }

    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
auto fl = [](auto a, auto b) { assert(b != 0); return a / b - (a % b != 0 && ((a >= 0) != (b >= 0)) ? 1 : 0); };
auto ce = [](auto a, auto b) { assert(b != 0); return a / b + (a % b != 0 && ((a >= 0) == (b >= 0)) ? 1 : 0); };
auto mo = [](auto a, auto b) { assert(b != 0); a %= b; if(a < 0) { a += abs(b); } return a; };
LL gcd(LL a, LL b) { return (b == 0 ? a : gcd(b, a % b)); }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)

// ---- ----

using str = vector<int>;

vector<int> rotation_array(str const & s) {
	int n = SI(s);
	vector<int> r(n), a(n);
	inc(i, n) {
		r[i] = s[i];
		a[i] = i;
	}
	for(int k = 1; k < n; k <<= 1) {
		auto comp = [&](int x, int y) -> bool {
			int x1 = r[x], x2 = r[x + k - (x + k < n ? 0 : n)];
			int y1 = r[y], y2 = r[y + k - (y + k < n ? 0 : n)];
			return (MP(x1, x2) < MP(y1, y2));
		};
		stable_sort(ALL(a), comp);
		vector<int> rr(n);
		inc(i, n - 1) { rr[a[i + 1]] = rr[a[i]] + (comp(a[i], a[i + 1]) ? 1 : 0); }
		r = rr;
	}
	return a;
}

vector<int> rotation_lcp_array(str const & s, vector<int> const & RA) {
	int n = SI(s);
	vector<int> r(n), l(n); // l.back() == 0
	inc(i, n) { r[RA[i]] = i; }
	int c = 0;
	inc(i, n) {
		if(c > 0) { c--; }
		if(r[i] + 1 == n) { continue; }
		int j = RA[r[i] + 1];
		while(c < n && s[(i + c) % n] == s[(j + c) % n]) { c++; }
		l[r[i]] = c;
		if(j + 1 == n) { c = 0; }
	}
	return l;
}

int main() {
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	inc(i, n) { cin >> a[i]; }
	inc(i, n) { cin >> b[i]; }
	
	auto RA   = rotation_array(a);
	auto RLCP = rotation_lcp_array(a, RA);
	
	vector<pair<int, int>> ans;
	int s = 0;
	dec(i, n) {
		setmin(s, RLCP[i]);
		int x = a[RA[i]] ^ b[0];
		incID(j, s, n) {
			if((a[mo(j + RA[i], n)] ^ b[j]) == x) { setmax(s, j + 1); } else { break; }
		}
		if(s == n) { ans.EB(RA[i], x); }
	}
	sort(ALL(ans));
	
	RF(e, ans) { cout << e.FI << " " << e.SE << "\n"; }
	
	return 0;
}


Measured memory_bytes: 9444
import sys
sys.setrecursionlimit(10**6)

def dfs(heights: int, a_index:int, a_n_1, a_n_2):
    if n < heights:
        return
    
    if m != 0 and a_index <= len(a) -1 and a[a_index] == heights:
        memo[2] = 0
        a_index += 1
        #print("10",heights)
    else:
        memo[2] = a_n_1 + a_n_2 #memo[1] + memo[0]
        #print("13",heights)
    dfs(heights+1,a_index,memo[2],a_n_1)
    return
    

n,m = list(map(int, input().split()))
memo = [1]*(3)
a = []
a_index = 0
if m != 0:
    for i in range(m):
        tmp = int(input())
        if i >= 1 and tmp -1 == a[len(a)-1]:
            print(0)
            sys.exit()
        else:
            a.append(tmp)
            #print(i,a)

    if a[0] == 1:
        memo[1] = 0
        a_index += 1
#a = list(set(a))
#a.sort()
dfs(2,a_index,memo[1],memo[0])
#print(memo)
print(memo[2] % (10**9+7))


Measured memory_bytes: 545140
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back
#define FF first
#define SS second

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

const int N = 55;

int A[N],B[N],C[N],D[N];

int main() {
  int n,m;
  S2(n,m);
  rep(i,0,n) S2(A[i],B[i]);
  rep(i,0,m) S2(C[i],D[i]);
  rep(i,0,n) {
    int ans = 0, mx = 1000000000;
    rep(j,0,m) {
      int cur = abs(C[j] - A[i]) + abs(D[j] - B[i]);
      if(cur < mx) {
        mx = cur;
        ans = j;
      }
    }
    P(ans+1);
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s; 
    cin >> s;
    vector <long long int> freq(2019,0);
    long long int i,u=1,sum=0,ans=0;
    freq[0]=1;
    for(i=s.length()-1;i>=0;i--)
    {
        sum+=(s[i]-'0')*u;
        sum%=2019;
        //cout << sum << " ";
        u*=10;
        u%=2019;
        freq[sum]++;
    }
    for(i=0;i<freq.size();i++)
    ans+=freq[i]*(freq[i]-1)/2;
    cout << ans;
    return 0;
}

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

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

    ll N;
    cin >> N;
    vector<int> p(N);
    rep(i,N){
        cin >> p[i];
        p[i]--;
    }
    ll d = N;
    vector<ll> a(N),b(N);
    a[0] = 1;
    rep(i,N-1)a[i+1] = a[i] + d;
    b.back() = 1;
    int start = 0;
    rep(i,N)if(p[i] == N - 1)start = i;
    for(int i = start; i+1 < N; i++){
        ll y = p[i];
        ll x = p[i+1];
        ll delta_a = abs(a[y] - a[x]);
        if(x < y) b[x] = b[y] + delta_a + 1;
        else b[x] = b[y] - delta_a + 1;
    }
    for(int i = start; i - 1 >= 0; i--){
        ll y = p[i-1];
        ll x = p[i];
        ll delta_a = abs(a[x] - a[y]);
        if(x < y)b[y] = b[x] - delta_a - 1;
        else b[y] = b[x] + delta_a - 1;
    }
    rep(i,N)cout << a[i] << " ";
    cout << endl;
    rep(i,N)cout << b[i] << " ";
    cout << endl;
}


Measured memory_bytes: 3708
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>



using namespace std;




int main() {
	
	int n,k;
	cin>>n>>k;
	for(int i=0;i<k;i++){
		int x;
		cin>>x;
		if(2*x>n+1){
			cout<<2*x-n-1<<endl;
			return 0;
		}
	}
	cout<<0<<endl;

	return 0;
}


	

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

#define int ll

signed main(){
    int n,a,b;
    cin>>n>>a>>b;
    
    if(b<a)cout<<0<<endl;
    else if(n<=1 && a!=b)cout<<0<<endl;
    else{
        cout<<(b-a)*(n-2)+1<<endl;
    }
}

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

int main() {
	int64_t n, mod = 1e9 + 7;
	cin >> n;
	map<int64_t, int64_t> mp;
	function<int64_t(int64_t)> f = [&](int64_t a) {
		if (a < 0) {
			return int64_t(0);
		}
		if (mp[a]) {
			return mp[a];
		}
		return mp[a] = (f(a / 2) + f((a - 1) / 2) + f(a / 2 - 1)) % mod;
	};
	mp[0] = 1;
	cout << f(n) << endl;
	return 0;
}

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

int main() {
  int l[11],v1,v2;
  double time1[11],time2[11];
  while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9],&l[10],&v1,&v2) == 12) {
    //for(int i=1;i<11;i++) {
    //cout << l[i] << endl;}
    double time1[11] = {0};
    double time2[11] = {0};
    for(int i=1;i<11;i++) {
      for(int j=0;j<i;j++) {
        time1[i] += ((double)l[j+1]) / v1;
        time2[10-i] += ((double)l[10-j]) / v2;
      }
      //  cout << time1[i] << " " << time2[10-i] << endl;
    }


        for(int i=0;i<10;i++) {
    if((time1[i] < time2[i]) && (time1[i+1] > time2[i+1]))
        cout << i+1 << endl;
    else if(time1[i] == time2[i])
      cout << i << endl;
    }
  }
}

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



int main() {
	int a,b;
	cin >> a >> b;
  	if(a == b){
          cout << "Draw";
          return 0;
	}
  if(a == 1){
    a = 14;
  }
  if(b == 1){
   b = 14;
  }
  if(a > b){
	cout << "Alice";
  }else{
    cout << "Bob";
  }
  	
}


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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define MOD_1_000_000_007 (1000000007)
#define IINF (1<<28)
#define LINF (1LL<<60)
#define rep(i, n)      REP(i, 0, (n))
#define repc(i, n)     REPC(i, 0, (n))
#define REP(i, n, m)   for (int i = (int)(n); i <  (int)(m); i++)
#define REPC(i, n, m)  for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define yesno(cond)       YESNO((cond), "Yes", "No")
#define YESNO(cond, a, b) cout << ((cond) ? (a) : (b)) << "\n"

namespace solver {
  using namespace std;
  typedef long long ll;

  static const int MAX = 100010;
  int N, as[MAX], bs[MAX], cs[MAX];

  void init() {
    cin >> N;
    rep(i, N) {
      cin >> as[i] >> bs[i];
      cs[i] = as[i] + bs[i];
    }
  }

  void solve() {
    sort(cs, cs + N, greater<int>());
    ll ans = 0;
    rep(i, N) if(i%2==0) ans += cs[i];
    rep(i, N) ans -= bs[i];
    cout << ans << "\n";
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 1408
/**
 *      ABC 81 C
 *      author  : kyomukyomupurin
 *      created : 2018-09-03 03:03:21
**/

#include <bits/stdc++.h>
using namespace std;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N, K; cin >> N >> K;
    vector<int> A;

    for (int i = 0; i < N; ++i) {
        int x; cin >> x;
        A.push_back(x);
    }
    sort(A.begin(), A.end());
 
    int cnt[200003] = {};//vector は遅い！！
    for (int i = 0; i < N; ++i) {//うまいやり方：個数分布を作る
        ++cnt[A[i]];
    }
    sort(cnt, cnt + N + 1 , greater<int>());

    int sum = 0;

    for (int i = 0; i < K; ++i) {        
        sum += cnt[i];
    }

    cout << N - sum << endl;
    return 0;
}

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

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
int main() {
    int a[3];
    int count[110] = {0};
    int ans = 0;
    for(int i = 0; i < 3; i++){
        cin >> a[i];
        ++count[a[i]];
    }
    for(int i = 0; i < 110; i++)
        if(count[i] != 0) ans++;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3588
#include<cmath>
    #include<cstdio>
    #include<cstring>
    using namespace std;
    int n,k,f[100010],g[100010];
    int min(int a,int b)
    {
    	return (a<b?a:b);
    }
    int abs(int x)
    {
    	return (x>0?x:(-x));
    }
    int main()
    {
    	scanf("%d %d",&n,&k);
    	memset(g,0x3f,sizeof(g));
    	for(int i=1;i<=n;i++)
    	{
    		scanf("%d",&f[i]);
    	}
    	g[1]=0;
    	for(int i=1;i<=n;i++)
    	{
    		for(int j=1;j<=k&&i+j<=n;j++)
			{
				g[i+j]=min(g[i+j],(g[i]+abs(f[i]-f[i+j])));
			}
    	}
    	printf("%d",g[n]);
    } 

Measured memory_bytes: 896
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;

namespace AtCoderBC137
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var matches = Regex.Matches(input, "-?[0-9]+");
            var K = int.Parse(matches[0].Value);
            var X = int.Parse(matches[1].Value);
            var min = Math.Max(X - K + 1, -1000000);
            var max = Math.Min(X + K - 1, 1000000);
            var res = Enumerable.Range(min, max-min+1);

            Console.WriteLine(string.Join(" ",res));
        }
    }
}


Measured memory_bytes: 15960
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cassert>
using namespace std;
char s[1000005];
int cnt[3],num[2],val[3];
char nw[1000005];int len,l,p,q;
void init(){
	len=0;
	memset(cnt,0,sizeof(cnt));
	for(int i=1;i<=l;i++)if(s[i]!=s[i-1]){
		nw[++len]=s[i];
		cnt[s[i]-'A']++;
	}
	swap(s,nw); l=len;
	p=q=0;
	for(int i=1;i<=2;i++){
		if(cnt[i]<cnt[p])p=i;
		if(cnt[i]>cnt[q])q=i;
	}
	if(p==q)q=(q+1)%3;
	memset(num,0,sizeof(num));
	memset(val,0,sizeof(val));
	s[l+1]=p+'A';
	for(int i=1,lst=0;i<=l+1;i++)
		if(s[i]-'A'==p){
			if(i-lst==2){
				if(lst!=0&&i!=l+1)num[s[i-1]-'A'==q]++;
				else val[(s[i-1]-'A')==q]++;
			}else if(i-lst>2){
				if(s[lst+1]!=s[i-1])val[2]++;
				else val[(s[i-1]-'A')==q]+=2;
			}
			lst=i;
		}
}
int main(){
	scanf("%s",s+1);
	l=strlen(s+1);
	init();
	// s[l+1]=0; puts(s+1);
	if((cnt[q]-cnt[3^p^q])>(val[1]+val[2])){
		len=0;
		int k=(cnt[q]-cnt[3^p^q])-(val[1]+val[2]);
		s[l+1]=p+'A';
		for(int i=1,lst=0;i<=l+1;i++){
			if(s[i]-'A'==p){
				if(k&&i-lst==2&&lst!=0&&i!=l+1&&s[i-1]-'A'==q){lst=i; k--;continue;}
				lst=i;
			}
			if(i!=l+1)nw[++len]=s[i];
		}
		swap(nw,s);
		l=len;
		init();
	}
	// s[l+1]=0; puts(s+1);
	assert((cnt[q]-cnt[3^p^q])<=(val[1]+val[2]));
	if(cnt[q]>cnt[3^p^q]){
		int w=cnt[q]-cnt[3^p^q];
		len=0;
		s[l+1]=p+'A';
		for(int i=1,lst=0;i<=l+1;i++)
			if(s[i]-'A'==p){
				if(i-lst==2){
					if(!w||((lst>0&&i<=l)||s[i-1]-'A'!=q))nw[++len]=s[i-1];
					else w--;
				}else if(i-lst>2){
					if(s[lst+1]!=s[i-1]){
						for(int j=lst+1+(w&&s[lst+1]-'A'==q);j<=i-1-(w&&s[i-1]-'A'==q);j++)nw[++len]=s[j];
						if(w)w--; 
					}else{
						if(s[i-1]-'A'==q){
							for(int j=lst+1+(w>0);j<=i-1-(w>1);j++)nw[++len]=s[j];
							if(w)w--;
							if(w)w--;
						}else{
							for(int j=lst+1;j<=i-1;j++)nw[++len]=s[j];
						}
					}
				}
				if(i!=l+1)nw[++len]=s[i];
				lst=i;
			}
		swap(nw,s);
		l=len;
		init();
	}
	// s[l+1]=0; puts(s+1);
	assert(cnt[q]==cnt[3^p^q]);
	int e=cnt[3^p^q]-cnt[p];
	s[l+1]=p+'A';
	for(int i=1,lst=0;i<=l+1;i++)
		if(s[i]-'A'==p){
			if(i-lst==2)putchar(s[i-1]);
			else if(i-lst>2){		
				int t=min(e,(i-lst-1)/2-(s[lst+1]!=s[i-1]&&lst!=0&&i!=l+1));
				for(int j=lst+1+t*2;j<=i-1;j++)putchar(s[j]);
				e-=t;
			}
			if(i!=l+1)putchar(s[i]);
			lst=i;
		}
	return 0;
}

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

#define INF 1e9

int main(void){
  int v, e;
  cin >> v >> e;

  int s, t, d;
  vector<vector<int> > adjmatrix(v, vector<int>(v, INF));
  for(int i = 0; i < e; i++){
    cin >> s >> t >> d;
    adjmatrix[s][t] = d;
  }

  // dp[i][j] = ??????i?????????????????????????????????????????????j????????????????????´??????????°??????????
  vector<vector<int> > dp(1 << v, vector<int>(v, INF));
  dp[0][0] = 0;
  
  // ??????????????????????????????
  for(int i = 0; i < (1 << v); i++){
    for(int j = 0; j < v; j++){
      // ?????????????????????k????????????????????¨????????????
      for(int k = 0; k < v; k++){
        // ?????§?????????k?????°??????????????£???????£???°???
        if((i & (1 << k)) != 0){ continue; }

        // ????£????: ????????¶????????? + ??????j????????????k???????§?????????????
        int cost = dp[i][j] + adjmatrix[j][k];

        // ?????¨???????????????????£?????????????????°????????????°?????????????????´??°
        if(cost < dp[i | (1 << k)][k]){ dp[i | (1 << k)][k] = cost; }
      }
    }
  }

  // ??????
  if(dp[(1 << v) - 1][0] == INF){ cout << -1 << endl; }
  else{ cout << dp[(1 << v) - 1][0] << endl; }
  
  return 0;
}

Measured memory_bytes: 6248