akhauriyash/Code-Regression huggingface dataset:
/**
DufauX-XuafuD
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define reset(x) memset(x,-1,sizeof(x))
#define CheckBit(a,b) (a&(1ll<<b))
#define SetBit(a,b) a=(a|(1ll<<b))
#define UnSetBit(a,b) a=(a&(~(1ll<<b)))
#define maxx 10000006
#define PI 2*acos(0.0)
const long long INF = 2000000000000000000LL;	// 2e18
const int inf = 0x3f3f3f3f;	// 1061109567
const long double EPS = 1e-9;
//bitset<maxx/2>vis;
//bitset<maxx>pr;
//int mobi[maxx+10];
//vector<ll>prime;
//void sieve(){
//    ll x=maxx/2, y=sqrt(maxx)/2;
//    for(ll i=1;i<=y;i++){
//        if(vis[i]==0){
//            for(ll j=(i*(i+1)*2);j<x;j+=(2*i)+1)
//                vis[j]=1;
//        }
//    }
//    prime.push_back(2);
//    for(ll i=3;i<maxx;i+=2)
//        if(vis[i/2]==0)
//        prime.push_back(i);
//}
//void generate_mobius()
//{
//    for(int i=0;i<maxx;i++)mobi[i]=1;
//    for(int i=2;i<maxx;i++){
//        if(!pr[i]){
//            mobi[i]*=-1;
//            for(int j=i+i;j<maxx;j+=i){
//                pr[j]=1;
//                mobi[j]*=(j%(i*i)?-1:0);
//            }
//        }
//    }
//}
//bool isprime(ll a)
//{
//    if(a==1)return false;
//    if(a==2)return true;
//    if(a%2==0)return false;
//    for(ll i=0;i<prime.size() && prime[i]*prime[i]<=a;i++)
//        if(a%prime[i]==0)return false;
//    return true;
//}
/*Used path compression technique*/
/*-------------------------------------*/
//ll finds(ll a)
//{
//    vector<ll>vec;
//    while(parent[a]>0){
//        vec.pb(a);
//        a=parent[a];
//    }
//    for(int i=0;i<vec.size();i++)parent[vec[i]]=a;
//    return a;
//}
//void unions(ll a,ll b)
//{
//    parent[a]+=parent[b];
//    parent[b]=a;
//}
/*------------------------------*/
/* Calculate ( a*b ) %c */
inline ll mulmod(ll a, ll b, ll c) {
    ll ret = 0 , cur = a % c ;
    while(b) { if(b%2) ret=(ret+cur)%c; cur=(cur<<1)%c; b=b>>1; }
    return ret%c;
}
//Calculate (b^p)%m || modular inverse: b^-1 = bigmod(b, m-2, m)
inline ll bigmod(ll b, ll p, ll m){
    ll ret = 1, cur = b % m;
    while(p) { if(p&1) ret=(ret*cur)%m; cur=(cur*cur)%m; p=p>>1; }
    return ret;
}
inline ll modulo(ll a,ll b,ll c) { //Same as big mod, use for numbers over 1e10
    ll ret = 1 , cur = a%c ;
    while(b) { if(b%2) ret=mulmod(ret,cur,c); cur=mulmod(cur,cur,c); b=b>>1; }
    return ret%c ;
}
inline ll power(ll b, ll p){
    ll ret = 1, cur = b;
    while(p) { if(p&1) ret=(ret*cur); cur=(cur*cur); p=p>>1; }
    return ret;
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
ll gcd(ll a,ll b)
{
    return __gcd(a,b);
}
ll arr[100];
void Dufaux()
{
    ll n,k,sum=0;
    cin>>n>>k;
    for(int i=0;i<n;i++)cin>>arr[i];
    sort(arr,arr+n,greater<ll>());
    for(int i=0;i<k;i++)sum+=arr[i];
    cout<<sum<<endl;
}
int main()
{
    FastIO;
	///sieve();
	///generate_mobius();
	int test=1;
	while(test--){
        Dufaux();
	}
	return 0;
}






Measured memory_bytes: 3612
#include <iostream> //cout
#include <cstring> //c
#include <vector> //vector
#include <string> //vector
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


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

    if(S.size() <= K){
        cout << S << endl;
    }
    else{
        cout << S.substr(0, K) + "..." << endl;
    }
}


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

using namespace std;
 
char bomb[8][8];
 
void printData(int i)
{
    cout << "Data " << i+1 << ':' << endl;
}
 
void dfs(int x, int y)
{
    bomb[y][x] = '0';
 
    for (int i = x-3; i <= x+3; i++) {
	if ((0 <= i && i <= 7) && bomb[y][i] == '1') dfs(i, y);
    }
    for (int j = y-3; j <= y+3; j++) {
	if ((0 <= j && j <= 7) && bomb[j][x] == '1') dfs(x, j);
    }
}
 
int main()
{
    int n, x, y;
    string str;
   
    cin >> n;
    for (int i = 0; i < n; i++) {
	string tmp;
	for (int j = 0; j < 8; j++) {
	    cin >> str;
	    tmp += str;
	}
 
	int t = 0;
	for (int j = 0; j < 8; j++) {
	    for (int k = 0; k < 8; k++) {
		bomb[j][k] = tmp[t++];
            }
        }
 
	cin >> x >> y;
 
	printData(i);
	dfs(x-1, y-1);
 
	for (int j = 0; j < 8; j++) {
	    for (int k = 0; k < 8; k++) {
		cout << bomb[j][k];
	    }
	    cout << endl;
	}
    }
    return 0;
}

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

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

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

    ll a[n];
    int flag = 0;
    ll max = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(max < a[i]){
            max = a[i];
        }
        if(a[i] == k){
            flag = 1;
        }
    }

    if(flag == 0){
        ll b = a[0];
        for(int i = 1; i < n; i++){
            b = gcd(b, a[i]);

            if(b == 1){
                break;
            }
        }

        if(k % b == 0 && k <= max){
            flag = 1;
        }
    }

    if(flag == 0){
        cout << "IMPOSSIBLE" << endl;
    }else{
        cout << "POSSIBLE" << endl;
    }
}

Measured memory_bytes: 4300
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  lint ans=0;
  REP(i,N){
    int a;
    cin>>a;
    ans+=a-1;
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(void){
	int N, M, Q;
	cin >> N >> M >> Q;
	vector<int> l(M), r(M);
	vector<vector<int>> c(N+10);
	for(int i = 0; i < N+10; ++i){
		c[i].resize(N+10);
	}
	for(int i = 0; i < M; ++i){
		cin >> l[i] >> r[i];
		c[l[i]][r[i]]++;
	}
	
	for(int i = 0; i < N; ++i){
		for(int j = 1; j <= N; ++j){
			c[i][j] += c[i][j-1];
		}
	}


	vector<int> p(Q), q(Q);
	for(int i = 0; i < Q; ++i){
		cin >> p[i] >> q[i];
	}
	for(int i = 0; i < Q; ++i){
		int ans = 0;
		for(int j = p[i]; j <= q[i]; ++j){
			ans += c[j][q[i]] - c[j][p[i]-1];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define int               long long
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define loop(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll
#define br                break
#define con               continue

template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.fr>>a.sc;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.fr<<" "<<a.sc;return out;}
template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}
 
const long long INF=1e18;
const int32_t M=1e9+7;
const int32_t MM=998244353;

priority_queue<pii, vector<pii>, greater<pii> >q;
const int mx= 1e7+7;
// vector<int>p;
// int mark[mx];
// void seive(){
// 	for(int i=2;i<=mx;i++){
// 		if(mark[i]==0){
// 			p.pb(i);
// 			for(int j=i+i;j<=mx;j+=i)mark[j]=1;
// 		}
// 	}
// }
signed main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output1.txt","w",stdout);
	#endif
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//seive();
	int n;
	cin>>n;
	int a[n+1];
	cin>>a[0];
	int g=a[0];
	int f=0;
	map<int,int>mp;
	for(int i=1;i<n;i++){
		cin>>a[i];
		g = __gcd(g,a[i]);
	}
	for(int i=0;i<n;i++){
		int x= a[i];
		//cout<<x;
		if(f==1)break;
		// if(mark[x]==0){
		// 	if(mp[x]==0)mp[x]++;
		// 	else{
		// 		f=1;
		// 		break;
		// 	}
		// }
		if(f==0){
			for(int i=1;i*i<=x;i++){
				if(x%i==0){
					int a = x/i;
					int b=i;
					if(a==b){
						b=1;
					}
					if(a>1){
						if(mp[a]){
							f=1;
							break;
						}
						mp[a]++;
					}
					if(b>1){
						if(mp[b]){
							f=1;
							break;
						}
						mp[b]++;
					}
				}
			}			
		}
	}
	if(f==0)cout<<"pairwise coprime"<<endl;
	else if(g==1)cout<<"setwise coprime"<<endl;
	else cout<<"not coprime"<<endl;
    
 
}

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

bool pmap[25][25]={0};
int n,m,now=0,x,y,nd;
int dy[4]={1,-1,0,0},dx[4]={0,0,1,-1};

int main(){
  int i,j,k;
  char d,dummy;
  while(1){
    cin >> n;
    if(n==0)break;
    now = 0;
    x = 10;
    y = 10;
    for(i=0;i<n;i++){
      cin >> k >> j;
      pmap[k][j]=1;
    }
    cin >> m;
    //cout << m << endl;
    for(i=0;i<m;i++){
      cin>> d >> j;
      //cout << d << " "<<j<<endl;
      if(d=='N')nd=0;
      if(d=='S')nd=1;
      if(d=='E')nd=2;
      if(d=='W')nd=3;
      for(k=0;k<j;k++){
	x+=dx[nd];
	y+=dy[nd];
	if(pmap[x][y]){
	  pmap[x][y]=0;
	  now++;
	}
      }
    }
    if(now==n)cout <<"Yes"<<endl;
    else cout <<"No"<<endl;
    for(i=0;i<21;i++)for(j=0;j<21;j++)pmap[i][j]=0;
  }
  return 0;
}



Measured memory_bytes: 3008
/*
coded by : Bissultanov Yedyge;
:)
¤
•
¦
§
*/
#include <bits/stdc++.h>
 
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
 
#define mp make_pair
#define np next_permutation
 
#define bg begin()
#define ed end()
 
#define int long long
#define ioi return 0;
 
#define sz size()
#define fix fixed<<setprecision
 
#define lb lower_bound
#define ub upper_bound
 
#define fr first
#define sc second
 
#define pb push_back
#define ppb pop_back
 
#define pf push_front
#define ppf pop_front
 
typedef long double ld;
typedef unsigned long long ull;
 
const int N = (int)5e5 + 7;
const int INF = (int)1e9 + 7;
 
using namespace std;
 
int ans, cnt;
int n , m , k;
int a[N];

main(){
	ios
		cin >> n >> m >> k;
		if ( k > m+n ){
			cout << "0 0";
			ioi
		}
		if ( n - k >= 0 ){
			cout << n-k << ' ' << m;
		}
		else{
			cout << 0 << ' ' << m-(k-n);
		}
	ioi	
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <cstdlib>
using namespace std;
#define Smax 200

class stack {
	int s[Smax] = { 0 };
	int top;
public:
	stack();
	bool isEmpty();
	bool isFull();
	void push(int x);
	int pop();
};

stack::stack()
{
	top = 0;
}

bool stack::isEmpty()
{
	return (top == 0);
}

bool stack::isFull()
{
	return (top >= Smax - 1);
}

void stack::push(int x)
{
	if (isFull()) {
		cout << "OverFlow!" << endl;
	}
	s[top++] = x;
}

int stack::pop()
{
	if (isEmpty()) {
		cout << "UnderFlow!" << endl;
	}
	return s[--top];
}

int main()
{
	stack s;
	char ch[100];
	int cnt = 0;

	while (cin >> ch) {
		if (strcmp(ch, "+") == 0) {
			int a = s.pop();
			int b = s.pop();
			s.push(a + b);
		}
		else if (strcmp(ch, "-") == 0) {
			int a = s.pop();
			int b = s.pop();
			s.push(b - a);
		}
		else if (strcmp(ch, "*") == 0) {
			int a = s.pop();
			int b = s.pop();
			s.push(a * b);
		}
		else {
			s.push(atoi(ch));
		}
	}

	cout << s.pop() << endl;

	return 0;
}


Measured memory_bytes: 3120
n = int(input())
par,rank = [i for i in range(n+1)],[0 for i in range(n+1)]
def root(x):
	if par[x]!=x: par[x] = root(par[x])
	return par[x]
def unite(x,y):
	x2,y2 = root(x),root(y)
	if x2!=y2:
		if rank[x2]<rank[y2]: par[x2] = y2
		else: par[y2] = x2
		if rank[x2]==rank[y2]: rank[x2]+=1
def same(x,y):
	return root(x)==root(y)
a,b = [],[]
for i in range(n):
	x,y = (int(_) for _ in input().split())
	a.append([x,i])
	b.append([y,i])
a,b,h,ans = sorted(a),sorted(b),[],0
from heapq import heappush,heappop
for i in range(n-1):
	heappush(h,(a[i+1][0]-a[i][0],a[i+1][1],a[i][1]))
	heappush(h,(b[i+1][0]-b[i][0],b[i+1][1],b[i][1]))
while h:
	i,j,k = heappop(h)
	if root(j)!=root(k):
		unite(j,k)
		ans += i
print(ans)

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

mod = 998244353

# segment tree
def init_max(init_max_val, n):
    #set_val
    for i in range(n):
        seg_max[i+num_max-1]=init_max_val[i]
    #built
    for i in range(num_max-2,-1,-1) :
        seg_max[i]=max(seg_max[2*i+1],seg_max[2*i+2])

def update_max(k,x):
    k += num_max-1
    seg_max[k] = x
    while k:
        k = (k-1)//2
        seg_max[k] = max(seg_max[k*2+1],seg_max[k*2+2])

def query_max(p,q):
    if q<=p:
        return ide_ele_max
    p += num_max-1
    q += num_max-2
    res=ide_ele_max
    while q-p>1:
        if p&1 == 0:
            res = max(res,seg_max[p])
        if q&1 == 1:
            res = max(res,seg_max[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = max(res,seg_max[p])
    else:
        res = max(max(res,seg_max[p]),seg_max[q])
    return res

#####単位元######
ide_ele_max = -1

#num_max:n以上の最小の2のべき乗
num_max = 1 << 18
seg_max=[ide_ele_max]*2*num_max



N = int(input())
tmpX = []
for i in range(N):
    x, d = list(map(int, input().split()))
    tmpX.append((x, d))
tmpX.sort()


X, D = [0] * N, [0] * N
for i in range(N):
    X[i] = tmpX[i][0]
    D[i] = tmpX[i][1]

to = [0] * N
for i in range(N):
    to[i] = i
init_max(to, N)

for i in range(N-1, -1, -1):
    ok = i
    ng = N
    while ng - ok > 1:
        mid = (ng + ok) // 2
        if X[i] + D[i] > X[mid]:
            ok = mid
        else :
            ng = mid
    to[i] = query_max(i, ok+1)
    update_max(i, to[i])

dp = [0] * (N+1)
dp[0] = 1
for i in range(N):
    dp[i+1] += dp[i]
    dp[i+1] %= mod
    dp[to[i]+1] += dp[i]
    dp[to[i]+1] %= mod
print(dp[N])


Measured memory_bytes: 90328
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){

  int n,a,b;
  string str;

  int x;
  cin >> x >> a >> b;
  if( a-b < 0){
    if(-(a-b) > x) cout <<"dangerous\n";
    else cout <<"safe\n";
  }else
    cout <<"delicious\n";

  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 256
N = int(input())
p = [int(x) for x in input().split()]

l = []

for i in range(len(p)):
    if p[i] == i + 1:
        l.append(p[i])
    else:
        l.append(0)

count = 0

for i in range(len(l) - 1):
    if l[i] > 0:
        l[i] = 0
        l[i + 1] = 0
        count += 1
if l[len(l) - 1] != 0:
    count += 1

print(count)


Measured memory_bytes: 13880
#include <iostream>
    #include <string>
    #include <set>  
    #include <stack>
    #include <algorithm>
    #include <vector>
    #include <cmath>
    #include <queue>
    #include <deque>
    #include <cstring>
    #include <cstdio>
    #include <map>
    #include <numeric>
    #include <cassert>
    #include <iomanip>
    #include <sstream>
    #include <ctime>
using namespace std;
#define for1(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,maxn) for1(i,0,maxn)
#define ford(i,b,a) for(int i=(int)(b)-1;i>=a;--i)
typedef long long ll;
typedef pair<int,int> pii;
#define st first
#define nd second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define dprintf(...) printf(__VA_ARGS__)
const int inf=0x3f3f3f3f;
const int maxn=5e5+10;
char c[maxn];
string d[maxn];
int cntd=0;
int n;
inline void sprt()
{
	string cur="";
	bool cmp=0;
	rep(i,n)
	{
	//	cout<<i<<" "<<cur<<" "<<cmp<<" "<<d.size()<<endl;
	//	system("pause");
		if(c[i]=='1')
		{
			cur.push_back(c[i]);
		}
		else if(c[i]=='0')
		{
			if(!cur.length())continue;
			if(i==n-1||c[i+1]!='1')
			{
				if(cmp)d[cntd++]=cur,cmp=0;
				cur="";
				continue;
			}
			cur.push_back(c[i]);
			cur.push_back(c[i+1]);
			i++; 
			cmp=1;
		}
	}
	if(cmp)d[cntd++]=cur;
//	rep(i,d.size())
//		cout<<d[i]<<endl;
}
inline void upd(int &x,int y)
{
	x=max(x,y);
}
int dp[maxn][2][3];
//第一维：0,无损；1,左端被取
//第二维：0,不取；1,向左取；2,向右取 
vector<int> con;
int main()
{
	scanf("%d",&n);
	scanf("%s",c);
	sprt();
	int ans=0;
	memset(dp,-1,sizeof(dp));
	int all=0;
	con.clear();
	rep(ii,cntd)
	{
		all=con.size();
		int cnt=0;
		string &s=d[ii];
//		cout<<s<<endl;
		rep(i,s.length())
		{
			if(s[i]=='1')cnt++;
			else con.push_back(cnt),cnt=0;
		}
		con.push_back(cnt),cnt=0;
		dp[all][0][0]=0;
		dp[all][0][2]=con[all];
		for1(i,all,con.size()-1)
		{
		//	cout<<i<<endl;
			if(dp[i][0][0]!=-1)//无损，不取 
			{
				upd(dp[i+1][0][0],dp[i][0][0]);
				upd(dp[i+1][0][1],dp[i][0][0]+con[i+1]);
				if(i+1<con.size()-1)upd(dp[i+1][0][2],dp[i][0][0]+con[i+1]); 
			}
			if(dp[i][0][1]!=-1)//无损，向左 
			{
				upd(dp[i+1][0][0],dp[i][0][1]);
				upd(dp[i+1][0][1],dp[i][0][1]-1+con[i+1]);
				if(i+1<con.size()-1)upd(dp[i+1][0][2],dp[i][0][1]+con[i+1]);
			}
			if(dp[i][0][2]!=-1)//无损，向右 
			{
				upd(dp[i+1][1][0],dp[i][0][2]);
				if(con[i+1]!=1&&i+1<con.size()-1)upd(dp[i+1][1][2],dp[i][0][2]+con[i+1]-1);
			}
			if(dp[i][1][0]!=-1)//取左，不取 
			{
				upd(dp[i+1][0][0],dp[i][1][0]);
				if(con[i]!=1)upd(dp[i+1][0][1],dp[i][1][0]+con[i+1]);
				if(i+1<con.size()-1)upd(dp[i+1][0][2],dp[i][1][0]+con[i+1]);
			}
			if(dp[i][1][2]!=-1)//取左，向右 
			{
				upd(dp[i+1][1][0],dp[i][1][2]);
				if(con[i]!=1&&i+1<con.size()-1)upd(dp[i+1][1][2],dp[i][1][2]+con[i+1]-1);
			}
		}
		int res=0;
		rep(j,2)rep(k,3)
		{
		//	cout<<j<<" "<<k<<" "<<dp[con.size()-1][j][k]<<endl; 
			res=max(res,dp[con.size()-1][j][k]);
		}
	//	cout<<res<<endl;
		//	system("pause");
		ans+=res;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 18684
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  vector<int> ant;
  for(int i=0; i<5; i++){
    int tmp;
    scanf("%d", &tmp);
    ant.push_back(tmp);
  }
  int k;
  scanf("%d",&k);
  if(ant[4]-ant[0] > k)printf(":(");
  else printf("Yay!");
  
  return 0;
}

Measured memory_bytes: 256
while True:
    try:
        n = [[0,"A"],[0,"B"],[0,"C"],[0,"D"],[0,"E"]]
        for i in range(5):
            n[i][0] = sum(list(map(int,input().split())))
        n.sort(reverse = True)
        print(n[0][1],n[0][0])
    except:
        break


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

int main()
{
	vector<int> S;

	int c;
	while(cin>>c)
	{
		if(c==0)
			cout<<S.back()<<endl,
			S.pop_back();
		else
			S.push_back(c);
	}
	return 0;
}

Measured memory_bytes: 0
fun main(args: Array<String>) {
    var a = "No"
    var t = "t"
    val (x, y) = readLine()!!.split(" ").map { it.toInt() }
    val l = (1..x).map{ readLine()!!}
    val o = (1..y).map{ readLine()!!}
    for(i in 0 until (x - y + 1)){
        for(j in 0 until (x - y + 1)){
            t = "t"
            o.forEachIndexed { ii, q ->
                for(jj in 0 until y){
                    if(l[i + ii][j + jj] != o[ii][jj]) t = "f"
                }
            }
            if (t == "t") a = "Yes"
        }
    }
    println(a)
}

Measured memory_bytes: 36700
from queue import Queue
k = int(input())
q = Queue()
for i in range(1,10):
    q.put(i)
for i in range(k):
    x = q.get()
    if x % 10 != 0:
        q.put(x*10+x%10-1)
    q.put(x*10+x%10)
    if x % 10 != 9:
        q.put(x*10+x%10+1)
print(x)

Measured memory_bytes: 12452
n=int(input())
h=list(map(int,input().split()))
if n==1:
  print('Yes')
else:
  if h[1]-h[0]==-1 or h[1]-h[0]==0:
    h[0]=h[0]-1
  elif h[1]-h[0]<=-2:
    print('No')
    exit()
  for i in range(n-1):
    sa=h[i+1]-h[i]
    if sa>=1:
      h[i+1]=h[i+1]-1
    elif sa<=-1:
      print('No')
      exit()
  print('Yes')

Measured memory_bytes: 14980
use petgraph::unionfind::UnionFind;
use proconio::input;
use proconio::marker::Usize1;
use std::collections::HashSet;

fn main() {
    input! {
        n: usize,
        m: usize,
        constraints: [(Usize1, Usize1, usize); m],
    }

    let mut uf = UnionFind::new(n);
    let mut set = HashSet::new();

    for constraint in &constraints {
        uf.union(constraint.0, constraint.1);
    }
    for i in 0..n {
        let n = uf.find(i);
        set.insert(n);
    }

    let ans = set.len();

    println!("{}", ans);
}


Measured memory_bytes: 8544
const input = require('fs').readFileSync('/dev/stdin', 'utf8').trim()
const lines = input.trim().split("\n")
while (lines.length > 1) {
    const [u, t] = lines.shift().trim().split(" ").map(Number)
    let cU = 0, cT = t, tArr = []
    while (tArr[cU] !== t) {
        if(cT > 0) {
            tArr[cU] = (tArr[cU] || 0) + 1
            cT--
        } else {
            cT = tArr[cU]
            tArr[cU] = 0
        }
        cU = (cU + 1)%u
    }
    console.log(cU)
}


Measured memory_bytes: 16112
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

string s;
ll k,n;

int main(){
	cin>>s>>k;
	n=s.size();
	for(int i=0;i<min(k,n);i++) if(s[i]!='1'){
		cout<<s[i]<<endl;
		return 0;
	}
	cout<<1<<endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			w = scanner.nextInt();
			h = scanner.nextInt();
			if ((w | h) == 0)
				break;
			map = new int[h][w + 2];
			for (int[] a : map)
				Arrays.fill(a, 1);
			for (int i = 0; i < h; i++) {
				for (int j = 1; j <= w; j++) {
					map[i][j] = scanner.nextInt();
				}
			}
			int[][] dp = new int[h][w + 2];
			for (int i = 1; i <= w; i++) {
				if (map[0][i] == 0)
					dp[0][i] = 1;
			}
			for (int i = 1; i < h; i++) {
				for (int j = 1; j <= w; j++) {
					if (map[i][j] == 1)
						continue;
					if (map[i][j] == 0) {
						for (int k = -1; k < 2; k++) {
							if (map[i - 1][j + k] == 0)
								dp[i][j] += dp[i - 1][j + k];
						}

					} else if (map[i][j] == 2) {
						if (map[i - 1][j] == 0)
							dp[i][j] += dp[i - 1][j];
					}
					if (i > 1 && map[i - 2][j] == 2)
						dp[i][j] += dp[i - 2][j];
				}
			}
			int sum = 0;
			for (int i = 1; i <= w; i++) {
				sum += dp[h - 1][i];
				if (h > 1 && map[h - 2][i] == 2)
					sum += dp[h - 2][i];
			}
			System.out.println(sum);
		}
	}

	int count;
	int w;
	int h;
	int[][] map;
}

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

int main() {
    int a, b, c, ans=0;
    cin >> a >> b >> c;
    for (int i=a; i<=b; i++) {
        if (c%i == 0) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
    int N,i,flag=0;
    cin>>N;
    for(i=1;i<=9;i++)
    {
    if(N/i<=9 && N%i==0)
    {
       flag++;
    }
    }
    if(flag>0)
        cout<<"Yes"<<endl;
    if(flag==0)
        cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>

int sum_gcd(int K);
int gcd(int a, int b);

int main(void) {
    int K;
    
    std::cin >> K;
    std::cout << sum_gcd(K) << std::endl;
    
    return 0;
}

int sum_gcd(int K) {
    /*
     1) (v,v,v); K
     2) (v1,v2,v2); P(K,2)*3 -> K*(K-1)*3, assume that K>1
     3) (v1,v2,v3); P(K,3) -> K*(K-1)*(K-2), assume that K>2
    */
    int a, b, c, sum = 0;
    
    for(a = 1; a <= K; a++) {
        for(b = 1; b <= K; b++) {
            for(c = 1; c <= K; c++) {
                sum += gcd(gcd(a,b),c);
            }
        }
    }
    
    return sum;
}

int gcd(int a, int b) {
    int r;

    while(b!=0) {
        r = a%b;
        a = b;
        b = r;
    }
    
    return a;
}




Measured memory_bytes: 3616
import sys

inf = sys.maxsize*1000000
V,e,r=(int (i)for i in input().split())
NC=False
#print(v)
#G=[[] for i in range(V)]#iごとに[]（式）を評価(実行)する。
G=[]
for j in range(e):
    f,t,cost=(int (i)for i in input().split())
    G.append((f,t,cost))
dist=[inf for _ in range(100000)]

dist[r]=0
max_=0
for i in range(V):
    for (u,v,cost) in G:#辺をひとつづつ追加していって最短距離の更新を試みる？

        if dist[u]!=inf and dist[u]+cost<dist[v]: 
            if i==V-1:
               
                NC=True
            else:
                dist[v]=dist[u]+cost

        
if not NC:
    for i in range(V):
        if dist[i]>=inf/2:
            print('INF')
        else:
            print(dist[i])
else:
     print("NEGATIVE CYCLE")


Measured memory_bytes: 7980
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    long long int n = s.length();
    long long int ans  = 0;
    long long int cnt = 0;
    for (long long int i=0; i<n; i++){
        if (s[i] == 'W'){
            ans += i-cnt;
            cnt++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3760
import java.util.Scanner;

class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		
		int i = 1;
		while (true) {
			int n = sc.nextInt();
			if (n == 0) return;
			System.out.println("Case "+i+": "+n);
			i++;
			
		}
		
	}
}


Measured memory_bytes: 40828
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

ll n, m;

ll solve() {
    ll res = 0;
    res += min(n, m/2);
    m -= 2 * min(n, m/2);
    res += m / 4;
    return res;
}

void input() {
    cin >> n >> m;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


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


#define vt vector
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
#define ll long long
#define ld long double
#define ar array
#define inf() ifstream cin("d.txt")
#define onf() ofstream cout("test.txt")
#define mod 1000000007
#define pb push_back
#define endl cout<<"\n";
#define prt1(a) cout<<a<<" "
#define prt2(a,b) cout<<a<<" "<<b<<" "
#define prt3(a,b,c) cout<<a<<" "<<b<<" "<<c<<" "
#define in(a) cin>>a
#define inn(a,b) cin>>a>>b
#define innn(a,b,c) cin>>a>>b>>c 
#define rep(i,st,end) for(int i=st;i<end;i++)
#define repv(i,st,end) for( i=st;i>=end;i--)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define TEST ll tc;cin>>tc;while(tc--)
#define EACH(x, a) for (auto& x: a)

template<class A> void read(vt<A>& v);
template<class A, size_t S> void read(ar<A, S>& a);
template<class T> void read(T& x) {
    cin >> x;
}
void read(double& d) {
    string t;
    read(t);
    d=stod(t);
}
void read(long double& d) {
    string t;
    read(t);
    d=stold(t);
}
template<class H, class... T> void read(H& h, T&... t) {
    read(h);
    read(t...);
}
template<class A> void read(vt<A>& x) {
    EACH(a, x)
        read(a);
}
template<class A, size_t S> void read(array<A, S>& x) {
    EACH(a, x)
        read(a);
}
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a <<"\n";
    err(++it, args...);
}


void solve()
{
    ll a,b,c,d;
    read(a,b,c,d);
    cout<<max({b*c,b*d,a*d,a*c});

  }

 int main()
 {
    fio;
    ll k = 1;
    ll tc = 1;
    // cin>>tc;
    while(tc--){
       // cout<<"Case #"<<k<<": ";k++;
        solve();
        endl;
    }
    
 }




Measured memory_bytes: 3640
L=list(map(int,list(input())))
n=len(L)
mod=10**9+7
table=[None]*n
table[0]=1
for i in range(1,n):
    table[i]=3*table[i-1]%mod
ans=0
k=1
for i in range(n):
    if L[i]==1:
        ans=(ans+k*table[n-i-1])%mod
        k=k*2%mod
ans+=k    
print(ans%mod)

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

int main(void){
    int n,a=4,b=7,c;
    cin>>n;
    string s="No";
    if(n%a==0||n%b==0){
        s="Yes";
    }
    c=(n-n%b)/b;
    for(int i =0;i<=c;i++){
        if((n-b*i)%a==0){
            s="Yes";
            i= c+1;
        }
    }
    cout<<s<<endl;
}


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

int main()
{
    int x,ans = 0;
    cin >> x;

    if(x == 1){
        cout << 1 << endl;
        return 0;
    }

    for(int i = 2; i <= sqrt(x); i++){
        for(int j = 2; pow(i,j) <= x; j++){
            ans = max((double)ans,pow(i,j)); 
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main(){

    ll N;
    cin >> N;
    ll tmp = 1;
    ll p = pow(10, 9) + 7;
    for(ll i=1;i<=N;i++)
    {
        tmp *= i;
        tmp %= p;
    }

    cout << tmp;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

template<class T>
class lpsg_tree {
private:
    vector<T> lazy;
    vector<T> seg;
    T def;
    lli num;
    void push(lli k){
        if(lazy[k] == def) return;
        set(k*2+1,lazy[k]);
        set(k*2+2,lazy[k]);
        lazy[k] = def;
    }
    void set(lli k,T x){
        lazy[k] = x;seg[k] = x;
    }
    void update(lli a,lli b,T x,lli k,lli l,lli r){
        if(r <= a || b <= l) return;
        if(a <= l && r <= b) set(k,x);
        else {
            push(k);
            update(a,b,x,k*2+1,l,(r+l)/2);
            update(a,b,x,k*2+2,(l+r)/2,r);
            seg[k] = func(seg[k*2+1],seg[k*2+2]);
        }
    }
    T func(T a,T b){
        return min(a,b);
    }
    T query(lli a,lli b,lli k,lli l,lli r){
        if(r <= a || b <= l) return def;
        if(a <= l && r <= b) return seg[k];
        push(k);
        T vl = query(a,b,k*2+1,l,(l+r)/2);
        T vr = query(a,b,k*2+2,(l+r)/2,r);
        return func(vl,vr);
    }
public:
    lpsg_tree(){}
    lpsg_tree(lli n,lli d = 2147483647):lazy(n*4,d),seg(n*4,d){
        def = d;
        num = 1;
        while(n > num) num <<= 1;
    }
    void update(lli a,lli b,lli x){
        update(a,b,x,0,0,num);
    }
    T query(lli a,lli b){
        return query(a,b,0,0,num);
    }

};


lpsg_tree<lli> sg;
lli n,q;
lli c,s,t,x;

int main(){
    cin >> n >> q;
    sg = lpsg_tree<lli> (n,2147483647);
    for(lli i = 0;i < q;i++){
        cin >> c;
        if(c){
            cin >> s >> t;
            cout << sg.query(s,t+1) << endl;
        }else{
            cin >> s >> t >> x;
            sg.update(s,t+1,x);
        }
    }
    return 0;
}

Measured memory_bytes: 9180
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1e18;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rnr(i,a,b) for(int i=int(a);i>=int(b);i--)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int d, t, s; cin >> d >> t >> s;
    if(s * t >= d) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;
const int mod = 1000000007;

int main() {
	int a, b;
	cin >> a >> b;
	cout << max(a + b, max(a - b, a * b)) << endl;
}


Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;

int main()
{
    int n, c, k;
    int i, j = 0, count = 0, first, ans = 0;
    
    cin >> n >> c >> k;
    
    int t[n];
    
    for(i = 0; i < n; i++) {
        cin >> t[i];
    }
    
    sort(t, t+n);
    
    while(j < n) {
        first = t[j];
        while((t[j] - first <= k) && (count < c)) {
            j++; count++;
        }
        ans++;
        count = 0;
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 640
N = int(input())
W = []
for _ in range(N):
  a,b = map(int,input().split())
  W.append((a,b))
W.sort(key=lambda x: x[1])

cur = 0
for a,b in W:
  if cur+a > b:
    print("No")
    exit()
  cur += a 

print("Yes")

Measured memory_bytes: 73048
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;

string solve(int a, int b, int c, int d){
    int n = a + b;
    // if (a > 1000 || b > 1000) return " ";
    if (a == b){
        string ret;
        FOR(i,c,d){
            if (i % 2 == 0) ret += 'A';
            else ret += 'B';
        }
        return ret;
    }
    if (a > b){
        ll x = (a + b) / (b + 1);
        int da = x * (b + 1) - a;
        int p = n;
        if (da > x){
            int s = x;
            da -= x;
            int bl = (da - 1) / (x * x - 1);
            s += bl * x * (x+1);
            da -= bl * (x * x - 1);
            bl = (da - 1) / x;
            s += bl * (x+1);
            da -= bl * x;
            s += da + 1;
            p = b + x * (b+1) - s;
        }
        string ret;
        FOR(i,c,d){
            if (i < p){
                if (i % (x+1) == x) ret += 'B';
                else ret += 'A';
            }else{
                int j = n - 1 - i;
                if (j % (x+1) == x) ret += 'A';
                else ret += 'B';
            }
        }
        return ret;
    }else{
        ll x = (a + b) / (a + 1);
        int db = x * (a + 1) - b;
        int q = n;
        if (db > x){
            int s = x;
            db -= x;
            int bl = (db - 1) / (x * x - 1);
            s += bl * x * (x+1);
            db -= bl * (x * x - 1);
            bl = (db - 1) / x;
            s += bl * (x+1);
            db -= bl * x;
            s += db + 1;
            q = a + x * (a+1) - s;
        }
        int p = n - q;
        string ret;
        FOR(i,c,d){
            if (i < p){
                if (i % (x+1) == x) ret += 'B';
                else ret += 'A';
            }else{
                int j = n - 1 - i;
                if (j % (x+1) == x) ret += 'A';
                else ret += 'B';
            }
        }
        return ret;
    }
}

int main() {
    int q;
    cin >> q;
    while (q--){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        c--;
        d--;
        cout << solve(a, b, c, d) << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(a) (a).begin(),(a).end()
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=10000000000000000;

int main() {
    ll n;
    cin >> n;
    vector<ll> s(n);
    rep(i,n) cin >> s[i];
    ll ans=0,o;
    rep(i,n-1){
        o=0;
        set<int> ss;
        rep(j,inf){
            if ((i+1)*(j+1)>n-1) break;
            if (ss.find((i+1)*(j+1))!=ss.end() || ss.find(n-1-(i+1)*(j+1))!=ss.end()) break;
            if (n-1-(i+1)*(j+1)==(i+1)*(j+1)) break;
            if (n-1-(i+1)*(j+1)<=i+1) break;
            o=o+s.at((i+1)*(j+1))+s.at(n-1-(i+1)*(j+1));
            ans=max(ans,o);
            ss.insert(n-1-(i+1)*(j+1));
            ss.insert((i+1)*(j+1));
        }
    }
    cout << ans << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<ll> a(n),b(n);
    for(int i = 0;i < n;i ++){
        cin >> a[i] >> b[i];
    }
    ll s=0;
    for (int i = n-1;i >= 0;i --){
        if((a[i]+s)%b[i]) s += b[i]-(a[i]+s)%b[i];
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int n, m;
int cnt[100005];

int main(void)
{
  cin >> n >> m;
  int u, v;
  for(int i =1; i <= m; i++){
    cin >> u >> v;
    cnt[u]++, cnt[v]++;
  }
  for(int i = 1; i <= n; i++){
    if(cnt[i]%2){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<cstring>
#include<cmath>
#include<set>
#include<queue>
#include<algorithm>
#include<climits>
#include<map>
#include<unordered_map>
#define ll long long

bool isPrime(ll n){
    if(n<=1)  return false;
    if(n<=3)  return true;
    if(n%2==0 || n%3==0) return false;
    for(ll i=5;i*i<=n;i=i+6)
        if(n%i==0||n%(i+2)==0)
           return false;
    return true;
}

#define w(t) ll t,tt=1;	cin>>t;		while(t--)
#define ps(x,y) fixed<<setprecision(y)<<x
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

#define vi vector<int>
#define vll vector<ll>
#define mii map<ll,ll>
#define umii unordered_map<ll,ll>
#define pi pair<int,int>
#define pll pair<ll,ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>

#define mod 1e9+7
#define inf 1e18

#define lln ll n; cin>>n
#define intn int n; cin>>n
#define YES cout<<"YES"
#define NO cout<<"NO"
#define strr    string str; cin>>str;
#define strn   n=str.length()
#define fr(a,n) for(ll i=a;i<n;i++)
#define loop for(ll i=0;i<n;i++)

using namespace std;

void solve (){
    intn;
    int ans=0;
    int num=0;
    fr(1,n+1){
        ++ans;
        num=(num*10+7)%n;
        if(!num){
            cout<<ans;
            return;
        }
    }
    cout<<-1;
}

int main(){
    IOS
    solve();
    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int a[3];
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&b==c&&c==a) cout<<'1';
	else if((a==b&&b!=c)||(c==b&&b!=a)||(a==c&&c!=b)) cout<<'2';
	else cout<<'3';
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

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

if sum(aa) >= 10:
	print('error')
else:
	print(sum(aa))

Measured memory_bytes: 3828
<?php
fscanf(STDIN, "%d%d", $n, $w);
for($i = 0; $i < $n; $i++){
    fscanf(STDIN, "%d%d", $W[], $V[]);
}
$offset = $W[0];
array_unshift($V,null);
for($i = 0; $i < $n; $i++){
    $W[$i] -= $offset;
}
array_unshift($W,null);

$dp[0][0] = array_fill(0, 301, 0);
for($i = 1; $i <= $n; $i++){
    $dp[$i] = $dp[$i-1];
    $dp[$i][$i] = $dp[$i][$i-1];
    for($j = 1; $j <= $i; $j++){
        for($k = 0; $k <= 3*$n; $k++){
            if($k-$W[$i] >= 0)$dp[$i][$j][$k] = max($dp[$i][$j][$k], $dp[$i-1][$j-1][$k-$W[$i]] + $V[$i]);
        }
    }
}
$max = 0;
for($i = 0; $i <= $n; $i++){
    if($w - $i*$offset >= 0){
        $max = max($max, $dp[$n][$i][min($w - $i*$offset, 3*$n)]);
    }
}
echo $max;

Measured memory_bytes: 107000
#include<iostream>
using namespace std;
int main(){
  int n,w,h,x,y,max,s,t,c;
  int ma[501][501];
  while(1){
    for(int i=0;i<501;i++){
      for(int j=0;j<501;j++){
	ma[i][j]=0;
      }
    }
    max=0;
    //in
    cin >> n;
    if(n==0)break;
    cin >> w >> h;
    for(int i=0;i<n;i++){
      cin >> x >> y;
      ma[y][x]=1;
    }
    cin >> s>>t;
    for(int i=1;i+t<=h+1;i++){
      for(int j=1;j+s<=w+1;j++){
	//
	c=0;
	for(int k=0;k<t;k++){
	  for(int l=0;l<s;l++){
	    if(ma[i+k][j+l]==1)c++;
	  }
	}
	if(max<c)max=c;
      }
    }
    cout << max << endl;
  }
  return 0;
}

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

#define ll long long

using namespace std;

ll a,b,c;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> a >> b >> c;

  if(c-a-b > 0 && 4*a*b < (c-a-b) * (c-a-b) ) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    vector<int> d(120);
    int ans = 0;
    for(int i = 0; i < N; i++) cin >> d[i];
    
    int num[120] = {0};

    for(int i = 0; i < N; i++){
        num[d[i]] += 1;
    }
    for(int i = 0; i < 101; i++){
        if(num[i]) ans += 1;
    }

    cout << ans;

    return 0;
}

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

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define endl '\n'
#define FASTIO std::ios::sync_with_stdio(false)

#define PRIME (1000000007)
#define oo (1 << 30)

#define debug(x) cerr << #x << " = " << x << endl
#define all(x) x.begin(), x.end()

#define loop(i, begin, end)                            \
  for (__typeof(end) i = (begin) - ((begin) > (end)); \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

template <class T>
std::vector<T> ReadVec(int n) {
    std::vector<T> answer(n);

    loop(i, 0, n) {
        std::cin >> answer[i];
    }
    return answer;
}

template <class T>
void PrintVec(std::vector<T> v) {
    loop(i, 0, v.size()) {
        std::cout << v[i] << " ";
    }
    std::cout << endl;
}

using namespace std;

int main() {
    FASTIO;

    string r, s;

    cin >> r;
    cin >> s;

    int ans = 0;
    loop(i, 0, 3) {
        ans += (r[i] == s[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define pb emplace_back
#define F first
#define S second
#define rep(i, st, ed) for(ll i=st; i<ed; ++i)
#define repn(i, st, ed) for(ll i=st; i<=ed; ++i)
#define repb(i, ed, st) for(ll i=ed; i>=st; --i)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define PI acosl(-1.0)
#define mp(a, b) make_pair(a, b)
#define eps 1e-9
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
const int N = 1e5 + 10;
const ll INF = 1LL << 60;
map<ll,ll> mp;

void solve()
{
	ll n;
	cin>>n;
	ll arr[n];
	for(int i=0; i<n; i++)
	{
		ll x;
		cin>>x;
		arr[i] =x;
		mp[x]++;
	}
	ll ans = 0;
	for(auto x: mp)
	{
		ans += (x.S*(x.S - 1)) / 2;
	}
	for(int i=0; i<n; i++)
	{
		ll tans = ans - (mp[arr[i]]-1); 
		cout<<tans<<endl;
	}
}


int main()
{
    FAST
    ll Tests = 1;
    //cin>>Tests;
    while(Tests--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <vector>

using namespace std;

int main() {
    
    const size_t M = 998244353;
    size_t N, S;
    cin >> N >> S;
    vector<size_t> a(N);
    for (auto& x : a) {
        cin >> x;
    }

    size_t res = 0;
    vector<size_t> dp(S + 1, 0);
    for (size_t i = 0; i < N; ++i) {
        dp[0] += 1;
        for (int s = S; s >= 0; --s) {
            if (a[i] + s <= S) {
                (dp[a[i] + s] += dp[s]) %= M;
            }
        }
        (res += dp[S]) %= M;
    }
    cout << res;

    return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define MP(a,b) make_pair(a,b)
typedef long long LL;
typedef pair<int, int> PI;
typedef vector<int> VI;
const LL MOD = 1000000007LL;
int A[100000];
int B[100000];
int main() {
	int N;
	cin >> N;
	rep(i, N) {
		cin >> A[i] >> B[i];
	}
	LL sum = 0;
	for (int i = N - 1; i >= 0; i--) {
		sum += (B[i] - (sum + A[i]) % B[i]) % B[i];
	}
	cout << sum << endl;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;
int r(int n)
{
    int v=1;
    for(int i=0;i<n;++i)v*=2;
    return v;
}
int main()
{
    int n;
    while(cin>>n)
    {
        bool flag=true,w[10]={false};
        int b=0;
        for(int i=9;i>=0;--i){
            if(n>=r(i)){
                w[i]=true;
                n-=r(i);
                if(flag){
                    b=i;
                    flag=false;
                }
            }
        }
        for(int i=0;i<10;++i){
            if(w[i]){
                cout<<r(i);
                if(i!=b)cout<<" ";
                else cout<<endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1160
import string
import sys

table = {c: 0 for c in string.ascii_lowercase}

for raw in sys.stdin.read():
    c = raw.lower()
    if c in string.ascii_lowercase:
        table[c] += 1

for key in string.ascii_lowercase:
    print('{:s} : {:d}'.format(key, table[key]))

Measured memory_bytes: 8104