akhauriyash/Code-Regression huggingface dataset:
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    string s;
    cin>>s;
    vector<vector<ll>> mx1(s.size()+2,vector<ll>(26,s.size()+1));
    vector<vector<ll>> mx2(s.size()+2,vector<ll>(26,s.size()+1));
    vector<ll> mx(26,s.size()+1);
    for(ll i=s.size()-1;i>=0;i--){
        mx[s[i]-'a']=i+1;
        mx1[i]=mx;
    }
    reverse(s.begin(),s.end());
    for(int i=0;i<26;i++){mx[i]=s.size()+1;}
    for(ll i=s.size()-1;i>=0;i--){
        mx[s[i]-'a']=i+1;
        mx2[i]=mx;
    }
    vector<vector<ll>> dp(s.size()+2,vector<ll>(s.size()+2,0));
    ll ans=0;
    dp[0][0]=1;
    for(int i=0;i<=s.size();i++){
        for(int t=0;t<=s.size();t++){
            dp[i][t]%=MOD;
            for(int h=0;h<26;h++){
                if(mx1[i][h]+mx2[t][h]<=s.size()){ans+=dp[i][t]; ans%=MOD;}
                dp[mx1[i][h]][mx2[t][h]]+=dp[i][t];
            }
        }
    }
    for(int i=1;i<=s.size();i++){
        for(int t=1;i+t<=s.size()+1;t++){
            //cout<<i<<" "<<t<<" "<<dp[i][t]<<endl;
            ans+=dp[i][t];
            ans%=MOD;
        }
    }
    cout<<ans<<endl;
    
    
    return 0;
}



Measured memory_bytes: 35428
program sequence_sum
  implicit none
  integer(8) :: n, num, k, tmp, a(0:100000) = 0
  integer :: x, m, b(0:100000) = 0, period, offset, rem, i
  read(*,*) n, x, m
  tmp = m
  if (n <= 2 * m) then
    num = x
    do k = 2, n
      x = mod(int(x, 8) * x, tmp)
      if (x == 0) exit
      num = num + x
    end do
    write(*,'(i0)') num
    stop
  end if
  a(1) = x
  b(x) = 1
  do i = 2, m + 1
    x = int(mod(int(x, 8) * x, tmp))
    a(i) = a(i - 1) + x
    if (b(x) > 0) then
      offset = b(x) - 1
      period = i - offset - 1
      exit
    end if
    b(x) = i
  end do
  num = (n - offset) / period
  rem = int(n - offset - num * period)
  write(*,'(i0)') (a(offset + period) - a(offset)) * num + a(offset + rem)
end program sequence_sum

Measured memory_bytes: 3512
#include <stdio.h>
#include <string.h>

int main()
{
  int a[5],k,i;

  for(i=0;i<5;i++)
    scanf("%d",&a[i]);
  scanf("%d",&k);

  int min =a[0],max = a[0];
  
  for(i=1;i<5;i++)
    {
      if(max < a[i])
	max = a[i];
      if(min > a[i])
	min = a[i];
    }
  
  if(k < max - min)
    printf(":(\n");
  else
    printf("Yay!\n");
  
  return 0;
  
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
vector <int> vec(N+100);
cin >> N;
for (int i=0; i<N; ++i){
    cin >> vec.at(i);
}
// 入力終わり
int sum_a=0, sum_b=0;
sort(vec.begin(), vec.end());
reverse(vec.begin(), vec.end());

for(int i=0; i<N; i+=2){
    sum_a+=vec.at(i);
}
for(int i=1; i<N; i+=2){
    sum_b+=vec.at(i);
}
cout << sum_a - sum_b << endl;

/*
for(int i=0; i<N+10; i++){
    cout << vec.at(i) << endl;
}
*/
}

Measured memory_bytes: 256
# 踏み台！？ うぅ...ももこ

N = int(input())
heights = [int(x) for x in input().split(" ")]

step = 0 # 踏み台高さの合計

for i in range(len(heights)-1):

    if(heights[i] >= heights[i+1]):
        diff = heights[i] - heights[i+1]
        heights[i+1] = heights[i+1] + diff
        step += diff

print(step)


Measured memory_bytes: 32204
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n, q = map(int, input().split())
T = [[] for _ in range(n+1)]
for _ in range(n-1):
  a, b = map(int, input().split())
  T[a].append(b)
  T[b].append(a)
dp = [0]*(n+1)
for _ in range(q):
  p, x = map(int, input().split())
  dp[p] += x

seen = [False]*(n+1)
def dfs(v):
  seen[v] = True
  for nv in T[v]:
    if seen[nv]:
      continue
    dp[nv] += dp[v]
    dfs(nv)
dfs(1)
print(*dp[1:])

Measured memory_bytes: 232468
#!python3.8
# -*- coding: utf-8 -*-
# abc177/abc177_a
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    D, T, S = i2nn()
    if D / S <= T:
        print('Yes')
    else:
        print('No')
    return

main()


Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define pb push_back
#define xx first
#define yy second
#define FOR(i,a,b) for (ll i=(a); i<(b); i++)
#define FORD(i,a,b) for (ll i=ll(b)-1; i>=(a); i--)

void self_min(ll &a, ll b) {
	a = min (a,b);
}
template <class T>
void self_max(T &a, T b) {
	a = max(a,b);
}

int main() {
	ios::sync_with_stdio(false);

	ll n; cin >> n;
	vvl h(3, vl(n));
	FOR(j,0,n) FOR(i,0,3) cin >> h[i][j];

	vvl dp(3,vl(n,0));
	dp[0][0] = h[0][0];
	dp[1][0] = h[1][0];
	dp[2][0] = h[2][0];

	FOR(i,0,n-1) {
		FOR(j,0,3) {
			ll nex1 = (j+1) % 3;
			ll nex2 = (j+2) % 3;
			self_max(dp[nex1][i+1], dp[j][i] + h[nex1][i+1]);
			self_max(dp[nex2][i+1], dp[j][i] + h[nex2][i+1]);
		}
	}
	cout << max (dp[0][n-1], max(dp[1][n-1], dp[2][n-1])) << endl;
	return 0;
}


Measured memory_bytes: 5752
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a;
	char b;
	cin >> a;
	int ans=0,sum=0;
	for (int i=1;i<=a;i++){
		cin >> b;
		if (b=='I') sum++,ans=max(sum,ans);
		if (b=='D') sum--,ans=max(sum,ans);
	}
	cout << ans << endl;
} 

Measured memory_bytes: 256
n= int(input())
s= sorted([input() for i in range(n)])
s.append("END")
ans=[]
max=-1
past=s[0]
c=1
for i in range(1,n+1):
	if past==s[i]:
		c+=1
	else:
		if c>max:
			max=c
			ans=[]
			ans.append(s[i-1])
		elif c==max:
			ans.append(s[i-1])
		c=1
	past=s[i]
for i in range(len(ans)):
	print(ans[i])

Measured memory_bytes: 22012
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s; cin >> s;
  if(s.size()==3) reverse(ALL(s));
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 3532
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A,B;
  cin >> A >> B;
  if(A == 1 && B == 13) {
    cout << "Alice" << endl;
  }else if(A == 13 && B == 1) {
    cout << "Bob" << endl;
  }else if(A > B) {
    cout << "Alice" << endl;
  }else if(A < B) {
    cout << "Bob" << endl;
  }else {
    cout << "Draw" << endl;
  }
}

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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

int main(){
   string s;
   cin>>s;
   if (s=="ABC") cout << "ARC" << endl;
   if (s=="ARC") cout << "ABC" << endl;
   return 0;
}


Measured memory_bytes: 3572
#include <iostream>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define lli long long int
using namespace std;
#define S second
#define F first
#define pb push_back 
#define M1 1000000007
#define M2 998244353
#define plli pair<lli,lli>
#define setit set<lli>::iterator seti
#define mapit map<lli,lli> ::iterator mapi
#define MP make_pair
#define MT make_tuple
// map      iterator->first 
// map      mp[key]=value
// set      *s.begin()
// vector   v[j]=value
// pair     p.first p.second
// vector of pairs v[j].first v[j].second
// tuple    get<index>(tuple_name)
// vector of tuples get<index>(v[j])  sort(v.begin(),v.end())
//priority queue .top() .pop() .push()
// __gcd(x,y)
#define fr(j,a,b) for(j=a;j<b;j++)

int power(int x, unsigned int y, int p)  
{    int res = 1;    
     x = x % p;
     if (x == 0) return 0;
     while (y > 0)  
     {  if (y & 1)  
        res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
     }  
    return res;  
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	lli t,i,j,n,x,a,b,c,d;
	cin>>n;string s;
    set<string> se;
    fr(j,0,n){
        cin>>s;
        se.insert(s);
    }
    cout<<se.size();
}



Measured memory_bytes: 19240
<?php
$stdins = array();
    while(true)
    {
        $stdin = trim(fgets(STDIN));
        if ($stdin === '0')
        {
          foreach($return as $value) {
            echo $value . PHP_EOL;
          }
           return;
 
        } else {
          $n = $stdin;
          $y = trim(fgets(STDIN));
          $max = 0;
          $num = null;
          for ($n ; 0 < $n; $n--) {
            list($b, $r, $t) = explode(' ', trim(fgets(STDIN)));
            if ($t == 1) {
              $money = 1+$y*($r/100);
            } else {
              $money = pow(1+($r/100), $y);
            }
            if ($max < $money) {
              $max = $money;
              $num = $b;
            }
          }
 
          $return[] = $num;
 
        }
        $stdins[] = $stdin;
    }
?>

Measured memory_bytes: 15720
n = int(input())
a_list = [int(i) for i in input().split()]

flag = True
for a in a_list:
    if a %2 == 0:
        if a%6 == 0 or a%10 == 0:
            pass
        else:
            flag = False
            break
        
if flag:
    print('APPROVED')
else:
    print('DENIED')

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

int main(){
  int n, m;
  while(cin >> n >> m, n, m){
    int pn[1000];
    for(int i = 0; i < n; i++) cin >> pn[i];
    sort(pn, pn+n);
    int nowm = 0, ans = 0;
    for(int i = n-1; i >= 0; i--){
      nowm++;
      if(nowm == m) nowm = 0;
      else{
	ans += pn[i];
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1176
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, readline().split())
sc = [list(map(int, readline().split())) for _ in range(m)]
max_dig = 10 ** n
min_dig = 10 ** (n - 1)
if n == 1:
    min_dig -= 1
for dig in range(min_dig, max_dig):
    dig = str(dig)
    for s, c in sc:
        if dig[s - 1] != str(c):
            break
    else:
        print(dig)
        exit()
print(-1)


Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
using namespace std;
/*
int main(){
	int n;
	int count=0;
	string name;
	cin >> n >> name;
	vector<string> signs(n);
	for(int i=0; i<n; ++i){
		cin >> signs[i];
		cout << signs[i].size() << "\n";
	}
	for(int m=0; m<n; ++n){

		for(unsigned int i=0; i<signs[m].size(); ++i){
			for(unsigned int j=1; i+(name.size()-1)*j<signs[m].size(); ++j){
				for(unsigned int k=0; k<name.size(); ++k){
					if(signs[m][i+k*j]!=name[k]){
						goto fail;
					}
				}
				count++;
				goto naxtk;
fail:;
			}
		}
naxtk:;
	}
	cout << count << "\n";
	return 0;
}
*/
/*
int calc(vector<int> array){
	queue<int> cntR,cntB,cntY;
	for(int i=0; i<array.size(); ++i){
		switch(array[i]){
		case 1:
			cntR.push(array[i]);
			if(i>3)cntR.pop();
			break;
		case 2:
			cntB.push(array[i]);
			if(i>3)cntB.pop();
			break;
		case 3:
			cntY.push(array[i]);
			if(i>3)cntY.pop();
			break;
		}
		if()
	}
	return array.size();
}

int main(){
	int n;
	while(cin >> n&&n!=0){
		vector<int> chars(n);
		for(int i=0; i<n; ++i){
			cin >> chars[i];
		}
		cout << calc(chars) << "\n";
	}
	return 0;
}*/

void lifl(vector<int>& a){
	vector<int> b;
	for(unsigned int i=1; i<a.size()/2+1; ++i){
		b.push_back(a[i]);
		b.push_back(a[a.size()/2+i]);
	}

	/*for(int i=1; i<a.size(); ++i){
		a[i]=b[i];
	}*/
	copy(b.begin(),b.end(),a.begin()+1);
	/*for(unsigned int i=1; i<a.size(); ++i){
		cout << a[i] << "\n";
	}*/
}

void cut(vector<int>& c,int d){
	vector<int> e;
	for(unsigned int i=d+1; i<c.size(); ++i){
		e.push_back(c[i]);
	}
	for(int i=1; i<d+1; ++i){
		e.push_back(c[i]);
	}

	/*for(int i=1; i<c.size(); ++i){
		c[i]=e[i];
	}*/
	copy(e.begin(),e.end(),c.begin()+1);
	/*for(unsigned int i=1; i<c.size(); ++i){
		cout << c[i] << "\n";
	}*/
}

int main(){
	int n,m;
	cin >> n >> m;
	vector<int> card(2*n+1);
	for(int i=0; i<2*n+1; ++i){
		card[i]=i;
	}
	for(int i=0; i<m; ++i){
		int k;
		cin >> k;
		if(k==0) lifl(card);
		else {
			cut(card,k);
		}
		/*for(int i=1; i<2*n+1; ++i){
			cout << card[i] <<"\n";
		}*/
	}
	for(int i=1; i<2*n+1; ++i){
		cout << card[i] <<"\n";
	}
	return 0;
}

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

typedef long long ll;
using namespace std;
const int MAXN = 1e5 +1;
const ll mod = 998244353;
ll dem[MAXN];

ll lt(ll x, ll y)
{
    ll res =1;
    x=x%mod;
    while (y>0)
    {
        if (y&1) res=(res*x)%mod;
        x=(x*x)%mod;
        y=y>>1;
    }
    return res;
}

int main()
{
#ifndef RICARDO
    //freopen("input.inp", "r", stdin);
#endif // RICARDO
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    //vector<int> dem(n+1,0
    int maxx=0;
    bool flag = true;
    for(int i=0; i<n; i++)
    {
        int k;
        cin >> k;
        if (k==0 && i!=0)
        {
            flag=false;
            continue;
        }
        dem[k]++;
        maxx = max(maxx,k);
    }
    ll ans=1;
    if (dem[0]==0) ans=0;
    else
    if (!flag) ans=0;
    else
    for(int i=1 ; i<=maxx; ++i)
        if (dem[i]==0)
        {
            ans =0;
            break;
        }else
        {
            ans=(ans*lt(dem[i-1],dem[i]))%mod;
            while (ans<0) ans+=mod;
        }
    while (ans<0) ans+=mod;
    cout << ans;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
            #include<iostream>
            #include<cstdio>
            #include<vector>
            #include<queue>
            #include<map>
            #include<cstring>
            #include<string>
            #include <math.h>
            #include<algorithm>
        //    #include <boost/multiprecision/cpp_int.hpp>
            #include<functional>
          #define int long long
            #define inf  1000000007
            #define pa pair<int,int>
    #define ll long long
            #define pal pair<ll,ll>
            #define ppa pair<int,pa>
             #define ssa pair<string,int>
            #define  mp make_pair
            #define  pb push_back
            #define EPS (1e-10)
            #define equals(a,b) (fabs((a)-(b))<EPS)
     
            using namespace std;
     
            class Point{
            	public:
            	double x,y;
            	Point(double x=0,double y=0):x(x),y(y) {}
            	Point operator + (Point p) {return Point(x+p.x,y+p.y);}
            	Point operator - (Point p) {return Point(x-p.x,y-p.y);}
            	Point operator * (double a) {return Point(x*a,y*a);}
            	Point operator / (double a) {return Point(x/a,y/a);}
            	double absv() {return sqrt(norm());}
            	double norm() {return x*x+y*y;}
            	bool operator < (const Point &p) const{
            		return x != p.x ? x<p.x: y<p.y;
            	}
            	bool operator == (const Point &p) const{
            		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
            	}
            };
            typedef Point Vector;
     
            struct Segment{
            Point p1,p2;
            };
     
        double hen(Vector a){
        if(fabs(a.x)<EPS && a.y>0) return acos(0);
        else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0);
        else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0);
        else if(fabs(a.y)<EPS && a.x>0) return 0.0;
        else if(a.y>0) return acos(a.x/a.absv());
        else return 2*acos(0)+acos(-a.x/a.absv());
     
        }
     
int gcd(int v,int b){
	if(v>b) return gcd(b,v);
	if(v==b) return b;
	if(b%v==0) return v;
	return gcd(v,b%v);
}
            double dot(Vector a,Vector b){
            	return a.x*b.x+a.y*b.y;
            }
            double cross(Vector a,Vector b){
            	return a.x*b.y-a.y*b.x;
            }
        
            //----------------kokomade tenpure------------

    signed  main(){
 int n,x;
    	int ans=0;
    	int a[100002];
    	cin>>n>>x;
    	for(int i=0;i<n;i++) cin>>a[i];
    	
    	if(a[0]>x){
    		ans += (a[0]-x);
    		a[0]=x;
    	}
    	for(int i=0;i<n-1;i++){
    		if(a[i]+a[i+1]<=x) continue;
    		ans += a[i+1]-(x-a[i]);
    		a[i+1]=x-a[i];
    		
    	}
    	cout<<ans<<endl;
    	
    //	printf("%.10f\n",ans);
    	return 0;
    }

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;} 


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

i64 N, D, A; cin>> N >> D >> A;
VP XH(N); rep(i, 0, N) cin >> XH[i].first >> XH[i].second;
sort(ALL(XH));
VI X, H; 
rep(i, 0, N){
    X.push_back(XH[i].first);
    H.push_back(XH[i].second);
}

VI d(N+1, 0); // imosでダメージ記録
i64 ans = 0;
rep(i, 0, N){
    if (H[i] - d[i] > 0){
        int att = ((H[i] - d[i]) + A - 1) / A;//iを倒す攻撃回数
        ans += att;
        d[i] += A * att;
        d[upper_bound(RANGE(X, i, N), X[i] + 2*D) - X.begin()] -= A * att;
    }
    d[i+1] += d[i];
}

cout << ans << "\n";



return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 8292
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ll;
#define pi 3.1415926535
#define doubl long double
int main(){
    
	cin.tie(NULL);
	cout.tie(NULL);
	ios_base::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    map<int,vector<int> >mp;
    int a,b;
    while(m--)
    {
    	cin>>a>>b;
		mp[a].push_back(b);
		mp[b].push_back(a);	
	}
	bool vis[n+1]={0};
	queue<int> q;
	vector<int> ans(n+1,-1);
	for(int i=0;i<mp[1].size();i++)
	{
		q.push(mp[1][i]);
		vis[mp[1][i]]=true;
		vis[1]=true;
		ans[mp[1][i]]=1;
	}
	while(!q.empty())
	{
		int x=q.front();
		q.pop();
		for(int i=0;i<mp[x].size();i++)
		{
			if(!vis[mp[x][i]])
			{
				q.push(mp[x][i]);
				vis[mp[x][i]]=1;
				ans[mp[x][i]]=x;
			}
		}
	}
	int f=0;
	for(int i=1;i<=n;i++)
	{
		if(vis[i]==0)
		{
			f=1;
			break;
		}
	}
	if(f==1)
	{
		cout<<"No\n";
	}
	else
	{
		cout<<"Yes\n";
		for(int i=2;i<=n;i++)
			cout<<ans[i]<<"\n";
		//cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 15776
package main
 
import(
  "fmt"
	"bufio"
	"os"
	"strings"
)
 
var sc = bufio.NewScanner(os.Stdin)
 
func Rr() []string {
  sc.Scan()
  slice := strings.Split(sc.Text(), " ")
  return slice
}
 
func abc147b(S string){
	l := len([]rune(S))
	a := S[0:l/2]
	b := S[l-l/2:l]
	cnt := 0
	for i := 0; i<l/2; i++{
		if a[i] != b[l/2-i-1]{
			cnt++
		}
	}
	fmt.Println(cnt)
}
 
func main(){
	S := ""
	fmt.Scan(&S)
	abc147b(S)
}

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

#define int long long
#define vi vector <int>
#define endl "\n"
#define vvi vector <vector<int> >
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>=b;i--)
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define init(i,k) memset(i,k,sizeof i)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
const int N=1e5+5 , MOD=1e9+7;

int dp[N]={0}, a[N];

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


void solve()
{
    int n;
    cin >> n;
    rep(i,0,n)
    {
    	cin >> a[i];
    }
    dp[0]=0;
    dp[1] = abs(a[1]-a[0]);

    rep(i,2,n)
    {
    	dp[i] = min(dp[i-2]+abs(a[i]-a[i-2]), dp[i-1]+abs(a[i]-a[i-1]));
    }

    cout << dp[n-1] << endl;

}

signed main()
{
    speed;
    
 //    int t; cin >> t;
 //    rep(tt,1,t+1)
 //    {
	// cout <<"Case #"<<tt<<": ";
	solve();
 //    }
    return 0;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1e9 + 7;  

int main(){
    int N;
    cin >> N;
    map<string,int> m;
    int maxi = 0;
    for(int i = 0; i < N; i++){
        string a;
        cin >> a;
        m[a]++;
        maxi = max(maxi,m[a]);
    }
    for(auto ite = m.begin(); ite != m.end(); ++ite){
        if(ite -> second == maxi) cout << ite -> first << endl;
    }
    return 0;
}



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

[A, B] = [int(i) for i in input().split()]
A = A * 100
B = B * 100

na = int(A / 8)
if A % 8 > 0:
    na +=1
npa = int((A + 100) / 8)
if (A + 100) % 8 == 0:
    npa -= 1

nb = int(B / 10)
if B % 10 > 0:
    nb +=1
npb = int((B + 100) / 10)
if (B + 100) % 10 == 0:
    npb -= 1

if na <= npb and nb <= npa:
    print(max(na, nb))
else:
    print(-1)

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

using namespace std;
typedef long long ll;

int main(){
    int N;
    string s;
    int k;
    cin >> N >> s >> k;
    char tmp=s[k-1];
    rep(i, N){
        if(s[i]!=tmp){
            s[i]='*';
        }
    }
    cout << s << endl;
}


Measured memory_bytes: 256
{-# OPTIONS_GHC -O #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns #-}

import Control.Monad
import Data.Bits
import qualified Data.Vector.Unboxed as UV
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Sequence as Sq
import Data.Sequence ((|>), ViewL(..))

data Shaku = Shaku (Sq.Seq Int) Int Int (UV.Vector Int) (Shaku -> Maybe(Int, Shaku))

solve as = (t-) $ UV.sum $ UV.unfoldr (\sh@(Shaku _ _ _ _ f) -> f sh) $ Shaku Sq.empty 0 0 as ext
    where
        n = UV.length as
        t = (n * (n-1)) `div` 2 + n

ext (Shaku _ _ _ v _) | UV.length v == 0 = Nothing
ext (Shaku sq su xo aa _) =
    if su' == xo' then  Just(0, Shaku sq' su' xo' as ext)
                  else  Just(UV.length aa, Shaku sq' su' xo' as shr)
    where
        a = UV.head aa
        as = UV.tail aa
        su' = su + a
        xo' = xo `xor` a
        sq' = sq |> a

shr (Shaku (Sq.viewl -> Sq.EmptyL) _ _ as _) = Just(0, Shaku Sq.empty 0 0 as ext)
shr (Shaku (Sq.viewl -> d :< sq') su xo as _) =
    if su' == xo' then  Just(0, Shaku sq' su' xo' as ext)
                  else  Just(UV.length as + 1, Shaku sq' su' xo' as shr)
    where
        su' = su - d
        xo' = xo `xor` d

main = do
    _ <- getLine
    as <- UV.unfoldr (B.readInt.B.dropWhile (==' ')) <$> B.getLine
    print $ solve as

Measured memory_bytes: 16764
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<locale.h>
#include<math.h>
#include<set>
#include<stack>
#include<queue>
using namespace std;
int main()
{
 long long int x,k,d,ans;
 scanf("%lld %lld %lld",&x,&k,&d);
 if(x<0){x=x*-1;}//反転してxを正の位置に
 long long int mim=x/d; //正の最近傍へ移動するための必要移動回数
 if(k<=mim){ans=x-d*k;}
else
 {
	long long int mmp=x-d*mim,mmm=x-d*mim-d;
	k=k-mim;
	if(k%2==0){ans=mmp;}
	else{ans=mmm;}
 }
 if(ans<0){ans=ans*-1;}
 printf("%lld",ans);
}



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

int main(){
  int N,Q;
  string S;
  cin >> N >> Q >> S;
  int r,l;
  vector<int> cnt(S.size()+1,0);
  //累積和
  for(int i=1; i<S.size(); i++){
    cnt.at(i+1) = cnt.at(i);
    if(S.at(i-1)=='A' && S.at(i)=='C') cnt.at(i+1)++;
  }

  for(int i=0; i<Q; i++){
    cin >> r >> l;
    cout << cnt.at(l)-cnt.at(r) << endl;
  }
  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
ll a, b, k;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);


  cin >> a >> b >> k;

  ll aa = min(a, k);
  ll bb = min(b, k - aa);

  cout << a - aa << " " << b - bb << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9+7;
const int maxn = 250005;

void go() {
   	int n, w;
   	cin >> n >> w;
   	ll dp[w + 5] = {};
   	f(n) {
   		int x, v;
   		cin >> x >> v;
   		for (int j = w ; j >= x ; j--) {
   			dp[j] = max(dp[j], dp[j - x] + v); 
   		}
   	}
   	cout << dp[w] << '\n';
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int c = 0;
    int t;
    if (!c) {
        t = 1;
    }
    else {
        cin >> t;
    }
    while (t--) {
        go();
    }
    
}

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

int h[100010];
int dp[100010];
int n;

int main() {
    cin >> n;
    for(int i = 0; i < n; ++i) {
        cin >> h[i];
    }

    dp[0] = 0;

    for(int i = 1; i < n; ++i) {
        if(i == 1) {
            dp[1] = dp[0] + abs(h[1]-h[0]);
        }else {
            dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]));
        }
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
#define mod 1000000007

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    int n,l,total=0,now,minv=1000;
    cin >> n >> l;
    vector<ll> a(n);
    rep(i,n){
        a[i]=i+l;
        total+=a[i];
        if(abs(a[i])<minv){
            now=i;
            minv=abs(a[i]);
        }
    } 
    cout << total-a[now] << endl;

    return 0;
}











Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
  
};
typedef struct node * Node;
Node root, NIL;
int maxh;
void insert(int t){
  int H;
  Node y = NIL;
  Node x = root;
  Node z;
  z = malloc(sizeof(struct node));
  z->key = t;
  z->left = NIL;
  z->right = NIL;
  while( x != NIL ){
    y = x;
    if ( z->key < x->key ){
      x = x->left;
    } else {
      x = x->right;
   }
  }
  z->parent = y;
  if ( y == NIL ){
    root = z;
  } else {
    if (z->key < y->key) {
      y->left = z;
    } else {
     y->right = z;
    }
  }
}
void inorder(Node z){
  if (z==NIL) return;
  inorder(z->left);
  
  printf(" %d",z->key);
  inorder(z->right);
}
void preorder(Node z){
  if ( z == NIL ) return;
  printf(" %d", z->key);
  preorder(z->left);
  preorder(z->right);
}
int main(){
  int l, i, r;
  char C[20];
  scanf("%d", &l);
  maxh = 0;
  for (i=0;i<l;i++){
    scanf("%s",C);
    if (strcmp(C,"insert")==0){
      scanf("%d",&r);
      insert(r);
    } else if ( strcmp(C,"print") == 0 ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}




Measured memory_bytes: 25204
#include <bits/stdc++.h>
using namespace std ;
const int N = 1e6 + 10 ;
vector<int> v[N] ;
typedef long long ll ;
int a[N] ;
int main()
{
  ll x ;
  int k , n ;
  cin >> k >> n ;
  for(int i = 1 ; i <= n ;i ++) cin >> a[i] ;
  int ans = 0 ;
  if(a[1] == 0)
  a[n + 1] = k ;
  int res = a[n] - a[1] ;
  for(int i = 1; i <= n ;i ++)
   {
     if(ans < a[i + 1] - a[i] )
      ans = a[i + 1] - a[i] ;
   }
  cout << min(k - ans , res) << endl ;
  return 0 ;
}


Measured memory_bytes: 26368
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            long N = cin.ReadLong;

            long a=1,b=1,c=1;
            for(int i=0;i<N;i++){
                a = 10*a % 1000000007;
                b = 9*b % 1000000007;
                c = 8*c % 1000000007;
            }


            long ans=0;
            if(a-2*b+c >= 0) ans = (a-2*b+c) % 1000000007;
            else {ans = ((a-2*b+c)+ 2*1000000007)  % 1000000007;}
            Console.WriteLine( ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


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

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

    for (int i = 1; i <= 50000; ++i)
    {
        double value = (double)i * 1.08;
        if((int)value == n) {
            cout << i << endl;
            return 0;
        }
    }

    cout << ":(" << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
void Yes() {
    cout << "Yes" << endl;
}
void No() {
    cout << "No" << endl;
}
int main(void) {
    int n, a; cin >> n >> a;
    n %= 500;
    if(a >= n) Yes();
    else No();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, l; cin >> n >> l;
	vi w(n), v(n);
	rep(i, n) cin>> w[i] >> v[i];
	
	map<ll, ll> dp;
	dp[0] = 0;
	
	rep(i, n){
		map<ll, ll> nxt = dp;
		for(const auto &p : dp) if(p.first + w[i] <= l){
			if(!nxt.count(p.first + w[i])) nxt[p.first + w[i]] = p.second + v[i];
			else nxt[p.first + w[i]] = max(nxt[p.first + w[i]], p.second + v[i]);
		}
		dp = nxt;
	}
	ll ans = 0;
	for(const auto &p : dp) ans = max(ans, p.second);
	cout << ans << endl;
	
	return 0;
}

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

public class Main {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;

	static final int[] DX = { 1, 0, -1, 0 };
	static final int[] DY = { 0, 1, 0, -1 };

	void solve() throws IOException {
		int h = nextInt();
		int w = nextInt();

		char[][] f = new char[h][];
		for (int i = 0; i < h; i++) {
			f[i] = nextToken().toCharArray();
		}

		int[][] a = new int[h][w];
		int x0 = 0, y0 = 0, x1 = h - 1, y1 = w - 1;
		int dir = 0;
		
		int freeCells = h * w;
		
		while (freeCells >= 3) {
			
//			System.err.println(x0 + " " + y0 + " " + freeCells);
			
			a[x0][y0] = 1;
			a[x1][y1] = 2;
			freeCells -= 2;
			while (true) {
				int nx0 = x0 + DX[dir];
				int ny0 = y0 + DY[dir];
				if (nx0 < 0 || nx0 >= h || ny0 < 0 || ny0 >= w || a[nx0][ny0] != 0) {
					dir = (dir + 1) % 4;
					continue;
				}
				x0 = nx0;
				y0 = ny0;
				
				x1 += DX[dir ^ 2];
				y1 += DY[dir ^ 2];
				break;
			}
		}
		
		a[x0][y0] = 1;
		a[x1][y1] = 2;
		
//		for (int[] row : a) {
//			System.err.println(Arrays.toString(row));
//		}
		
		
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (a[i][j] == 1 || f[i][j] == '#') {
					out.print('#');
				} else {
					out.print('.');
				}
			}
			out.println();
		}
		out.println();
		
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (a[i][j] == 2 || f[i][j] == '#') {
					out.print('#');
				} else {
					out.print('.');
				}
			}
			out.println();
		}
	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

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

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return null;
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 14820
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <deque>

#define AS(a) (sizeof(a)/sizeof(a[0]))
using namespace std;
long long int MOD = 1000000007;

int main() {
  int N;
  cin >> N;
  int a[N];
  for(int i = 0; i < N; i++) {
    cin >> a[i];
  }
  int a_0 = 0;
  int a_2 = 0;
  int a_4 = 0;
  for(int i = 0; i < N; i++) {
    if(a[i] % 4 == 0) a_4++;
    else if(a[i] % 2 == 0) a_2++;
    else a_0++;
  }
  if(a_2 > 0) {
    a_0++;
  }
  if(a_4+1 >= a_0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }




}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <stack>

using namespace std;

struct Counter
{
    int radix;
    vector<int> value;
    vector<int> index;

    Counter(int radix)
    {
        this->radix = radix;
        value.push_back(0);
        index.push_back(0);
    }

    void add(int b)
    {
        if (b > index.back())
        {
            index.push_back(b);
            value.push_back(0);
            return;
        }
        while (b < index.back())
        {
            index.pop_back();
            value.pop_back();
        }
        if (index.back() != b)
        {
            index.push_back(b);
            value.push_back(0);
        }
        inc();
    }

    void inc()
    {
        if (radix == 1)
        {
            value[0]++;
            return;
        }

        while (++value.back() == radix && value.size() > 1)
        {
            int carried_base = index.back();
            index.pop_back();
            value.pop_back();

            if (carried_base - 1 != index.back())
            {
                index.push_back(carried_base - 1);
                value.push_back(0);
            }
        }
    }

    bool is_valid() const
    {
        return value[0] == 0;
    }
};

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

    vector<int> a(n);
    for (int &v : a)
    {
        cin >> v;
    }

    auto ok = [&a](int mid) {
        Counter counter(mid);
        for (int v : a)
        {
            counter.add(v);
        }
        return counter.is_valid();
    };

    int low = 0, high = n;
    while (high - low > 1)
    {
        int mid = (low + high) / 2;

        (ok(mid) ? high : low) = mid;
    }

    cout << high << endl;

    return 0;
}


Measured memory_bytes: 4020
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

int main() {
   int k;
   cin >> k;
   cout << (k/2)*(k-k/2) << endl;
}

Measured memory_bytes: 256
N = int(input())
list = [int(a) for a in input().split()]
dict = dict()
for i in range(N):
    if list[i] in dict:
        dict[list[i]] += 1
    else:
        dict[list[i]] = 1
count = 0
for i, j in dict.items():
#    print(i, j) 
    if i <= j:
        count += j - i
    else:
        count += j
              
print(count)

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

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

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

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end(),greater<int>());
    long long w =0,h=0;
    bool flag = true;
    for(int i=0;i<N-1;i++){
        if(a[i] == a[i+1]){
            if(flag){
                w = a[i];
                i++;
                flag ^= 1;
            }else{
                h = a[i];
                break;
            }
        }
    }

    cout << h * w;
    return 0;
}

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

int main() {
    int64_t N, ans = 0;
    cin >> N;
    for (int64_t i = 1; i <= N; i++) {
        if (i % 3 != 0 && i % 5 != 0) {
            ans += i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define sz(x) (int)(x).size()
typedef vector<int> vi;
// #define ll long long 
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=2e5+2;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int x,y;
      cin>>x>>y;
      int gcd=__gcd(x,y);
      int ans=x*y/gcd;
      cout<<ans;
} 
// I never lose. I either win or I learn

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

int main() {
  vector<vector<int> > A(3,vector<int>(3));
  for(int i =0; i<3; i++){
    for(int j=0; j<3; j++){
      cin>>A.at(i).at(j);
    }
  }
  int N;
  cin>>N;
  vector<int> B(N);
  for(int i=0; i<N; i++){
    cin>>B.at(i);
  }
   for(int i =0; i<3; i++){
     for(int j=0; j<3; j++){
       for(int k=0; k<N; k++){
         if(A.at(i).at(j) == B.at(k)){
           A.at(i).at(j) = 'o';
         }
       }
     }
   }
  string ans = "No";
  for(int i=0; i<3; i++){
    if(A.at(i).at(0)==A.at(i).at(1)&&A.at(i).at(1)==A.at(i).at(2)){
      ans = "Yes";
    }
    else if(A.at(0).at(i)==A.at(1).at(i)&&A.at(1).at(i)==A.at(2).at(i)){
      ans = "Yes";
    }
  }
  if(A.at(0).at(0) == A.at(1).at(1)&&A.at(1).at(1)==A.at(2).at(2)){
    ans = "Yes";
  }
  else if(A.at(2).at(0) == A.at(1).at(1)&&A.at(1).at(1)==A.at(0).at(2)){
       ans = "Yes";
  }
  cout<<ans<<endl;
}

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

int main(){
  long long K;
  cin >> K;
  
  long long A[50];
  for(int i=0;i<50;i++) A[i]=50+K/50;
  int l=50-K%50;
  
  for(int i=0;i<l;i++){
    sort(A,A+50);
    for(int i=0;i<49;i++) A[i]++;
    A[49]-=50;
  }
  cout << "50" << endl;
  for(int i=0;i<49;i++)
    cout << A[i] << ' ';
  cout << A[49] << endl;
  
  return 0;
}

Measured memory_bytes: 384
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, R = MAP()

print( R if N >= 10  else R+100*(10-N) )

Measured memory_bytes: 5156
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int N = Integer.parseInt(str[0]);
		int M = Integer.parseInt(str[1]);

		int value[] = new int[N];
		Arrays.fill(value, 1);

		boolean dp[] = new boolean[100100];
		dp[0] = true;

		for (int i = 0; i < M; i++) {
			str = br.readLine().split(" ");
			int x = Integer.parseInt(str[0]) - 1;
			int y = Integer.parseInt(str[1]) - 1;

			value[x]--;
			value[y]++;

			if (dp[x])
				dp[y] = true;
			if (value[x] == 0) {
				dp[x] = false;
			}
		}

		int count = 0;
		for (int i = 0; i < N; i++) {
			if (dp[i]) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 44988
//CODING ME ACCHHA KARNEKA HAI TERKO TO BAS PRACTICE KARTE REH
#include <bits/stdc++.h>
#define pragma
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define aisort sort(a,a+n)
#define adsort sort(a,a+n,greater<ll>())
#define PI 2 * acos(0)

typedef pair<ll, ll> pii;
typedef pair<ll, pii> piii;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef set<ll> Set;

const ll maxs = 1e5+3;
const ll maxs1 = 1e3+4;
const ll mod = 1e9 + 7;

//MODULO OPEARTIONS
    inline ll add(ll a, ll b) { return (mod + a + b) % mod; }
    inline ll sub(ll a, ll b) { return (a - b + mod) % mod; }
    inline ll mul(ll a, ll b) { return (1ll * a * b) % mod; }

//POWER
    ll fastpow(ll x,ll y)
    {ll res = 1;x = x % mod;while (y > 0){ if (y & 1)res = (res * x) % mod; y = y >> 1 ; x = (x * x) % mod; } return res;}

//MODULAR INVERSE
    ll inv(ll x){ return fastpow(x , mod - 2);}
    
//PRIME
    bool isPrime(ll n) { if (n <= 1)  return false; if (n <= 3)  return true;if (n%2 == 0 || n%3 == 0) return false; for (int i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0) return false; return true; } 

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   long long N,K;
  cin>>N>>K;
  cout<<min(N%K,K-N%K);
   
}




Measured memory_bytes: 3604
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<String> x = new ArrayList<String>();
        String tempx;
        int count;

        while (true) {
            tempx = sc.next();

            if (tempx.equals("0"))
                break;

            x.add(tempx);
        }

        for (int i = 0; i < x.size(); i++) {
            count = 0;
            for(int j = 0; j < x.get(i).length(); j++){
                count += Character.getNumericValue(x.get(i).charAt(j));
            }
            System.out.println(count);
        }

        sc.close();
    }
}


Measured memory_bytes: 26328
#pragma GCC optimize("O3")
    #include<iostream>
    #include<algorithm>
    #include<string>
    #include<cmath>
    #include<set>
    #include<vector>
    #include<sstream>
    #include<queue>
    #include <iomanip>
    #include <fstream>
    #include<unordered_set>
    #include<stack>
    #include <unordered_map>
    #include<time.h>
    #include <chrono>
    constexpr auto INF = 9223372036854775807;
    typedef long long int ll;
    typedef unsigned long long int ull;
    typedef unsigned long int ul;
    typedef long int l;
    #define f(i,a,b) for(l i=(l)a;i<(l)b;i+=1)
    #define rf(i,a,b) for(l i=(l)a;i>=(l)b;i-=1)
    #define endl '\n'
    #define N 1000000007 // prime modulo value 
    #define all(x) x.begin(),x.end()
    #define FAST ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0)
    using namespace std;
    #define MAX 1000001 
    l spf[MAX];
    void precompute()
    {
    	spf[1] = 1;
    	for (l i = 2; i < MAX; i++)
    		spf[i] = i;
     
    	for (l i = 4; i < MAX; i += 2)
    		spf[i] = 2;
     
    	for (l i = 3; i * i < MAX; i++)
    	{
    		if (spf[i] == i)
    		{
    			for (l j = i * i; j < MAX; j += i)
    				if (spf[j] == j)
    					spf[j] = i;
    		}
    	}
    }
     
    int main()
    {
    	FAST;
    	string s;
    	cin >> s;
    	string ans = "No";
    	f(i, 0, 3)
    	{
    		if (s[i] == '7')
    			ans = "Yes";
    	}
    	cout << ans;
    	return 0;
    }

Measured memory_bytes: 3640