akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define int long long int
#define MOD 1000000007
#define mkp make_pair
#define maxn 100005
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,a,b) for(int i=a;i<b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define mp map<int,int>
#define ump unordered_map<int,int>
#define  vi vector<int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define in cin>>
#define out cout<<
using namespace std;
const int infi=1e9+7;
void printVector(vector<int> v){
    for(int i=0;i<(int)v.size();i++)
        cout<<v[i]<<" ";
    out endl;
}

void printArray(int arr[],int n)
{
   for(int i=0;i<n;i++)cout<<arr[i]<<' ';
cout<<endl;
}
 set<pair<int,int>> primeset;
 vi prime_number;
void SieveOfEratosthenes(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
        for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
           primeset.insert(mkp(p,1));
}
ll modExp(ll base, ll power) {
    if (power == 0) {
        return 1;
    } else {
        ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
        if (power % 2 == 1) cur = cur * base;
        cur = cur % MOD;
        return cur;
    }
}
//for making unordered_map with pair
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
bool check(string s){
    string t=s;
    reverse(t.begin(),t.end());
    return (s==t)?true:false;
}
int32_t main()
{
fastio;
int tt=1;
int t=1;
//in t;
while(t--){
string s;in s;
int n=s.size();
if(check(s) && check(s.substr(0,(n-1)/2)) && check(s.substr((n+1)/2)))
    cout<<"Yes";
else cout<<"No";
}
    return 0;
}

/*
google kick start
  cout << "Case #" << tt << ": "<<ans<<endl;
*/


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iX = int.Parse(sS[0]);
            int iY = int.Parse(sS[1]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sOut = "No";
            for (int i = 0; i <= iX; i++)
            {
                if (iY == i * 2 + (iX - i) * 4) { sOut = "Yes"; break; }
            }

            // 出力
            System.Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 27476
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<P> vp;
typedef vector<bool> vb;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;
 
int n,k,ans=0;
vi a(26);
 
int main(){
	cin>>n>>k;
	string s;
	for(int i=0;i<n;i++){
		cin>>s;
		a[s[0]-'A']--;
	}
	while(1){
		sort(a.begin(),a.end());
		if(a[k-1]==0) break;
		for(auto i=a.begin();i!=a.begin()+k;i++) (*i)++;
		ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int dx[] = {0,1,0,-1,0};
const int dy[] = {0,0,1,0,-1};

int tile[10][10];
int tmp[10][10];
int correct(int x,int y){
	return x < 10 && x >= 0 && y < 10 && y >= 0;
}
int getColor(int x,int y){
	int ret = tile[y][x];
	rep(i,5){
		int sx = x + dx[i] , sy = y + dy[i];
		if(!correct(sx,sy))continue;
		if(tmp[sy][sx])ret++;
	}
	return ret%2;
}

int solve(int upperMost){
	rep(i,10)rep(j,10)tmp[i][j] = 0;
	rep(i,10)tmp[0][10-i-1] = (upperMost>>i) & 1;
	//rep(i,10)cout << tmp[0][i] << endl;
	
	for(int i = 1 ; i < 10 ; i++){
		rep(j,10){
			if(getColor(j,i-1) == 1){
				tmp[i][j] = 1;
			}
		}
	}
	
	rep(i,10)rep(j,10)
		if(getColor(j,i))return 0;
	return 1;
}
int main(){
	int N; cin >> N;
	while(N--){
		rep(i,10)rep(j,10)cin >> tile[i][j];
		rep(bit,1<<10){
			if( solve(bit) ){
				rep(i,10){
					rep(j,10)cout << (j?" ":"") << tmp[i][j];
					cout << endl;
				}
				break;
			}
		}
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define N 100010
int n,K,a[N],mx;
int gcd(int x,int y){
	if(!y) return x;
	return gcd(y,x%y);
}
int main(){
	scanf("%d%d",&n,&K);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]),mx=max(mx,a[i]);
	if(K>mx){puts("IMPOSSIBLE");return 0;}
	int now=a[1];
	for(int i=2;i<=n;++i) now=gcd(now,a[i]);
	if(K%now==0) puts("POSSIBLE");
	else puts("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main()
{
  int x[100][100],r,c,k[100]={0};
  int i,j,n=0,m=0;
  scanf("%d%d",&r,&c);
  for(i=0;i<r;i++)
    {
      for(j=0;j<c;j++)
	{
	  scanf("%d",&x[i][j]);
	}
    }
  for(i=0;i<r;i++)
    {
      for(j=0;j<c;j++)
	{
	  printf("%d ",x[i][j]);
	  n+=x[i][j];
	  m+=x[i][j];
	}
      printf("%d\n",n);
      n=0;
    }
  for(j=0;j<c;j++)
    {
      for(i=0;i<r;i++)
	{
	  k[j]+=x[i][j];
	}
      printf("%d ",k[j]);
      k[j+1]=0;
    }
  printf("%d\n",m);
  return 0;
}


  

Measured memory_bytes: 636
s =map(str,(raw_input()))
a = 0
z = 0
for i in range(len(s)):
  if s[i]=='A':
    a = i
    break
for i in range(len(s)):
  if s[-i-1]=='Z':
    z=len(s)-i-1
    break
print z-a+1

Measured memory_bytes: 10556
MOD = 1000000007


def solve(n, s1, s2, allowed):
    if n == 0:
        return 1

    if s1[0] == s2[0]:
        return (allowed * solve(n - 1, s1[1:], s2[1:], 2)) % MOD
    else:
        if allowed == 3:
            mul = 6
        elif allowed == 2:
            mul = 2
        else:
            mul = 3
        return (mul * solve(n - 2, s1[2:], s2[2:], 1)) % MOD


def main():
    n = int(input())
    s1, s2 = input(), input()
    print(solve(n, s1, s2, 3))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
const string tr="abcdefghijklmnopqrstuvwxyz";
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}
ll llpow(ll n,ll i){ll cnt=n;  for(ll j=0;j<i-1;j++){n*=cnt;}return n;}
bool ip/*is_prime*/(long long N) {if (N == 1) return false;for (long long i = 2; i * i <= N; ++i) {if (N % i == 0) return false;}return true;}
int digit(ll N) {int ans = 0;while (N) {++ans;N /= 10;}return ans;}
vector<pair<ll,ll>> pf/*prime_factorize*/(ll n){vector<pair<ll,ll>> res;for(ll a=2;a*a<=n;a++){if(n%a!=0) continue;ll ex=0;while(n%a==0){ex++;n/=a;}res.pb({a,ex});}if(n!=1) res.pb({n,1});return res;}
vector<ll> div/*divisor*/(ll n){  vector<ll> res={1};for(ll a=2;a*a<=n;a++){if(n%a!=0) continue;ll b=n/a;res.pb(b);if(b!=a) res.pb(a);}sort(all(res));return res;}

int main(){
  ll n;
  cin>>n;
  v(ll) a(n);
  ll m=1000;
  rep(i,n) cin>>a[i];
  rep(i,n-1){
    if(a[i+1]>a[i]){
      ll mc=m;
      m-=mc/a[i]*a[i];
      m+=mc/a[i]*a[i+1];
    }
  }
  cout<<m<<endl;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>

using namespace std;

typedef pair<int, int> P;
#define FOR(i, a, b) for(ll (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define _1 first
#define _2 second
#define pb push_back
#define bigmod 1000000007
#define INF 1050000000

const int maxn = 1e5 + 10;
vi G[maxn];
int n, m, u, v;
int a,b;

int main() {
	string s;
	cin >> s;
	bool check = true;
	rep(i,26) {
		rep(j, s.length()) {
			if ((int)i == (int)(s[j] - 'a')) {
				check = false;
				break;
			}
		}
		if (check) {
			cout << (char)(i + (int)'a') << endl;
			return 0;
		}
		check = true;
	}
	cout << "None" << endl;
	return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
#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++)
typedef int64_t llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define ld PRId64


int main(){
    int n;
    cin >> n;
    int bai=0,kisuu=0;
    int tmp;
    REP(i,n){
        cin >> tmp;
        if(tmp%4==0) bai+=1;
        else if(tmp%2 == 1) kisuu+=1;
    }
    if(kisuu <= bai or (kisuu + bai == n and kisuu == bai+1)) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
int main() 
{
	int n,l;
	scanf("%d%d",&n,&l);
	string ch[105];
	for(int i=1;i<=n;i++)
		cin>>ch[i];
	sort(ch+1,ch+n+1);
	for(int i=1;i<=n;i++)
		cout<<ch[i];
	puts("");
    return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef unsigned long long u64;
typedef signed long long l64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  string out = "";
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == 'B') {
      if (out.size() != 0) {
        out = out.substr(0, out.size()-1);
      }
    } else {
      out += s[i];
    }
  }
  cout << out << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import Counter
n = int(input())
ball = list(map(int,input().split()))

num = [0] * (n + 1)
for i in ball:
    num[i] += 1

data = [0] * (n + 1)
sentaku = [0] * (n + 1)

for i in range(n+1):
        data[i] = num[i] * (num[i] - 1) // 2
        sentaku[i] = (num[i] - 1) * (num[i] - 2) // 2
x = sum(data)

for i in ball:
    print(x - data[i] + sentaku[i])


Measured memory_bytes: 26780
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;
const int MAXN = 505;

int n;
char a[MAXN][MAXN];
int cnt1[MAXN], cnt2[MAXN];

int main(){
	cin >> n;
	for(int i=0; i<n; i++) cin >> a[i];
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			if(a[i][j] == '#'){
				cnt1[i]++;
				cnt2[j]++;
			}
		}
	}
	int ans = 1e9;
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			if(a[i][j] == '#'){
				ans = min(ans, n - cnt1[j]);
				ans = min(ans, n + 1 - cnt1[i]);
			}
		}
	}
	if(ans > 1e8){
		puts("-1");
		return 0;
	}
	ans += n - count(cnt2, cnt2 + n, n);
	cout << ans << endl;
}


Measured memory_bytes: 512
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

C = []
D = []
for n in range(N+1):
    if n == 0:
        C.append(min(A[0], B[0]))
        D.append(max(0, B[0] - A[0]))
    elif n == N:
        C.append(min(A[N], D[N-1]))
    else:
        C.append(min(A[n], B[n] + D[n-1]))
        D.append(max(0, B[n] - max(0, A[n] - D[n-1])))

print(sum(C))



Measured memory_bytes: 92772
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll H, W;
    cin >> H >> W;

    char a;
    rep(i, W + 2){
        cout << '#';
    }
    cout << endl;
    rep(i, H){
        cout << '#';
        rep(j, W){
            cin >> a;
            cout << a;
        }
        cout << '#' << endl;
    }
    rep(i, W + 2){
        cout << '#';
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>

#define rep(p,q) for(int i = p;i < q;i++)

using namespace std;

const int cons = 1e9 + 7;

//B

int main(void) {
	int n[5];
	cin >> n[0] >> n[1] >> n[2] >> n[3] >>n[4];
	int mini = 10;
	int index = -1;
	int iti[5];
	rep(0, 5) {
		iti[i] = n[i] - (n[i] / 10) * 10;
		if (n[i] % 10 != 0 && mini > iti[i]) {
			mini = iti[i];
			index = i;
		}
	}
	int ans = 0;
	rep(0, 5) {
		if (i == index) ans += n[i];
		else {
			if (n[i] % 10 == 0)ans += n[i];
			else ans += n[i] - iti[i] + 10;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

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

  ll n, m, x;
  cin >> n >> m >> x;

  vll cs(n);
  vvll as(n, vll(m));
  rep(i, n) {
    cin >> cs[i];
    rep(j, m) { cin >> as[i][j]; }
  }

  ll ans = LONG_LONG_MAX;
  rep(s, 1 << n) {
    ll cost = 0;
    vll ris(m, 0);
    rep(i, n) {
      if (s >> i & 1) {
        cost += cs[i];
        rep(j, m) ris[j] += as[i][j];
      }
    }
    bool ok = true;
    rep(j, m) {
      if (ris[j] < x) ok = false;
    }
    if (ok) chmin(ans, cost);
  }

  if(ans == LONG_LONG_MAX){
    puts("-1");
    return 0;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 2147483647
#include <math.h> /* M_PI */
int main()
{
    ll n, k;
    cin >> n >> k;
    ll count = 0;
    for (int i = k + 1; i <= n; i++) //iは割る数。
    {
        ll p_min = k;     //あまりの最小値
        ll p_max = i - 1; //あまりの最大値
        ll o = n % i;     //値の分岐点
        //p_minからo含むまでは、n/iと等しい。
        //oからp_maxまでは、n_i-1と等しい。
        if (p_min != 0)
        {
            if (o < p_min)
            {
                count += (p_max - p_min + 1) * ((n - o - 1) / i + 1);
            }
            else
            {
                count += (p_max - o) * ((n - o - 1) / i + 1);
                count += (o - p_min + 1) * (n / i + 1);
            }
        }
        if (p_min == 0)
        {

            if (o < p_min)
            {
                count += (p_max - p_min + 1) * ((n - o - 1) / i + 1);
                count -= 1;
            }
            else
            {
                count += (p_max - o) * ((n - o - 1) / i + 1);
                count += (o - p_min + 1) * (n / i + 1);
                count -= 1;
            }
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int[] h = new int[10];
	for(int i = 0 ; i < 10 ; i++){
	    h[i] = sc.nextInt();
	}
	Arrays.sort(h);
	for(int i = 9 ; i > 6 ; i--){
	    System.out.println(h[i]);
	}
    }
}

Measured memory_bytes: 12000
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define MAX(a,b) (a>b?a:b)

int main()
{
    long long int i, n, h, w;
    long long int a[1000], b[1000];
    long long int count = 0;

    scanf("%lld %lld %lld",&n, &h, &w);
    for(i=0; i<n; i++) {
        scanf("%lld %lld", &a[i], &b[i]);
        if(a[i]>=h && b[i]>=w)count++;
    }
    printf("%lld", count);

    return 0;
}

Measured memory_bytes: 128
//G++/Gcc
#include<bits/stdc++.h>
 using namespace std;
  int f[5][5],i,j,x;
  int main()
  {
      cin>>f[1][1]>>f[1][2]>>f[2][2];
      x=f[2][2]*3;
      f[1][3]=x-f[1][1]-f[1][2];
      f[3][1]=x-f[1][3]-f[2][2];
      f[3][3]=x-f[1][1]-f[2][2];
      f[2][1]=x-f[1][1]-f[3][1];
      f[2][3]=x-f[2][1]-f[2][2];
      f[3][2]=x-f[1][2]-f[2][2];
      for(i=1;i<=3;++i)
      {
          for(j=1;j<=3;++j) cout<<f[i][j]<<" ";
          cout<<endl;
      }
      return 0;
  }
  
  
  
  
  
  /*
   QTR,U KICW TIY!!!
   ;EV,UPIT STR HPPF!!!
   KJK,UPIT STR HPPF!!!
   YKX,UPIT STR HPPF!!!
   KUL,UPIT STR HPPF!!!
  */

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int n,a,b,c;
  for(;;){
    scanf("%d",&n); if(!n)break;
    while(n--){
      scanf("%d%d%d",&a,&b,&c);
      if(a==100||b==100||c==100||(a+b)/2>=90||(a+b+c)/3>=80){
        puts("A"); continue;
      }
      if((a+b+c)/3>=70||(a+b+c)/3>=50&&(a>=80||b>=80)){
        puts("B"); continue;
      }
      puts("C");
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main(void)
{
    int a,b;
    char op;
    while(1){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='+') printf("%d\n",a+b);
        else if(op=='-') printf("%d\n",a-b);
        else if(op=='*') printf("%d\n",a*b);
        else if(op=='/') printf("%d\n",a/b);
        else break;
    }
    return 0;
}

Measured memory_bytes: 600
/*

Author: @karngyan
Team: BlundersPride

*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef std::vector<ll> vll;
typedef std::pair<ll,ll> pll;
typedef std::vector<vll> vvll;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define max3( a, b, c ) max( a , max(b , c))
#define cres(c,n) (c).clear(),(c).resize(n)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define ff first
#define ss second
#define mk make_pair
const ll N = 410;
const ll INF = 9999999999999;
ll a[N+1];
ll dp[N+1][N+1];

ll pref[N];
ll go(ll i , ll j)
{
	if(i == j)
		return 0;

	ll &ans = dp[i][j];
	if(ans != INF)
		return ans;

	for(ll k = i ; k <= j ; ++k)
		ans = min(ans ,
			go(i , k) + go(k+1 , j) + pref[j] - pref[i-1]);

	return ans;

}

signed main()
{

	fast;

	rep(i,0,N)
		rep(j,0,N)
			dp[i][j] = INF;
////////////////////////////////////////////////////////////////////////////////////////////
	
	pref[0] = 0;
	ll n;
	cin >> n;

	rep(i,1,n+1)
		cin >> a[i] , pref[i] = a[i] + pref[i-1];


	cout<<go(1 , n)<<endl;













////////////////////////////////////////////////////////////////////////////////////////////

	
	return 0;
}


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

const int DIM = 5e2 + 5;

int cnt[DIM];

int main( void ) {
    
    int n, m;
    cin >> n >> m;
    
    for( int i = 1; i <= m; i ++ ) {
        int x, y;
        cin >> x >> y;
        
        cnt[x] ++; cnt[y] ++;
    }
    
    for( int i = 1; i <= n; i ++ )
        cout << cnt[i] << "\n";
    
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	n := r.nextInt()
	a := fact(n)
	ans := 0
	for _, ai := range a {
		w := ai.count
		for j := 1; ; j++ {
			w -= j
			if w < 0 {
				break
			}
			ans++
		}
	}
	fmt.Fprintln(stdout, ans)
}


Measured memory_bytes: 1752
import sys
N = int(input())
if N == 1:
    print(1)
    sys.exit()

# 数列の和
def re(x):
    return x*(x+1)//2

# 二分探索
l, r = 0, N+1
exact = -1
while abs(l - r) > 1:
    mid = (l + r) // 2
    if re(mid) > N:
        r = mid
    elif re(mid) == N:
        exact = mid
        break
    else:
        l = mid

# 途中抜けしない場合
if exact != -1:
    for i in range(1, exact + 1):
        print(i)

# する場合
else:
    temp = re(r) - N
    for i in range(1, r+1):
        if i != temp:
            print(i)

Measured memory_bytes: 80328
/*
  AUTHOR:SOURABH
  CREATED:01:05:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<pll , null_type, less< pll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 1000000007
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

ll ans,n,m,q;
vector<pair<pll,pll> > qq;
vll A(10);

void solve(ll id,ll val)
{
    if(id==n)
    {
        ll i,sum=0;
        fn(i,q)
        {
            if(A[qq[i].fi.se]-A[qq[i].fi.fi]==qq[i].se.fi)
                sum+=qq[i].se.se;
        }
        ans=max(ans,sum);
        return;
    }
    ll i;
    fs(i,val,m+1)
    {
        A[id]=i;
        solve(id+1,i);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    ll t,a,b,c,d,i;
    t=1;
    //cin>>t;
    W(t--)
    {
        cin>>n>>m>>q;
        fn(i,q)
        {
            cin>>a>>b>>c>>d;
            a--,b--;
            qq.pb({{a,b},{c,d}});
        }
        ans=0;
        solve(0,1);
        cout<<ans;
    }
    return 0;
}














Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
const long long INF = 1LL << 60;
int main() 
{
    int n,cnt=0,rep=0;
    cin >> n;
    int A[n+10];

    rep(i,n){
        cin >> A[i];
    }

    sort(A,A+n);

    rep(i,n-1){
        if(A[i]){
            if(A[i] == A[i+1])
                cnt++;
                else
                {
                    if(!cnt)
                        rep++;
                    else 
                        rep += (cnt+1)%2;
                    cnt = 0;
                }
                
        }
    }

    rep += (cnt+1)%2;

    cout << rep << endl;
}

Measured memory_bytes: 640
s = input()
l = []
for i in range(len(s)):
    if s[i] == '0':
        l.append('0')
    elif s[i] == '1':
        l.append('1')
    else:
        if l == []:
            continue
        else:
            del l[-1]
print(''.join(l))
        

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

int main() {
    int n, k;
    cin >> n >> k;
    int arr[n];
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    sort(arr, arr + n);
    int ans = 0;
    for (int i = 0; i < k; i++)
        ans += arr[i];
    cout << ans;
    return 0;
}

Measured memory_bytes: 3584
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};
vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n);
  auto f=[&](bool x){
    if(x)cout<<"First"<<endl;
    else cout<<"Second"<<endl;
  };
  rep(i,0,n)cin>>a[i];
  if(n==1){
    f(a[0]%2==0);
    return 0;
  }
  sort(ALLR(a));
  rep(i,0,n){
    if(i==n-2||a[i+2]<=i){
      ll p=max(0LL,a[i]-i);
      ll q=max(0LL,a[i+1]-i);
      //cout<<p spa q<<endl;
      if(p==0){
        ll cnt=0;
        rep(j,i,n)if(a[j]==a[i])cnt^=1;
        if(a[i-1]==a[i]){
          f(cnt);
        }
        else{
          f(cnt||(a[i-1]-a[i])%2==1);
        }
      }
      else if(q==0)f(!(p%2));
      else f(q%2);
      return 0;
    }
  }
  return 0;
}

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

int main()
{
    int N, M;
    cin >> N;
    string s;
    map <string, int> S;
    for (int i = 0; i < N; i++)
    {
        cin >> s;
        S[s] += 1;
    }
    cin >> M;
    string t;
    map <string, int> T;
    for (int i = 0; i < M; i++)
    {
        cin >> t;
        T[t] -= 1;
    }

    int max_val = 0;

    for (auto itr = S.begin(); itr != S.end(); itr++)
    {
        int val = S[itr->first];
        if (T.count(itr->first))
        {
            val += T[itr->first];
        }

        if (val > max_val)
        {
            max_val = val;
        }
    }

    cout << max_val << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a_b_c = []
for i in range(n):
  a_b_c_ = list(map(int,input().split()))
  a_b_c.append(a_b_c_)
dp = [[0,0,0] for i in range(n+2)]
dp[1][0] = a_b_c[0][0]
dp[1][1] = a_b_c[0][1]
dp[1][2] = a_b_c[0][2]
for i in range(2,n+1):
  dp[i][0] = max(dp[i-1][1] + a_b_c[i-1][0],dp[i-1][2] + a_b_c[i-1][0])
  dp[i][1] = max(dp[i-1][0] + a_b_c[i-1][1],dp[i-1][2] + a_b_c[i-1][1])
  dp[i][2] = max(dp[i-1][0] + a_b_c[i-1][2],dp[i-1][1] + a_b_c[i-1][2])

print(max(dp[n]))

Measured memory_bytes: 47336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

const int maxs = 4e6+1;
bitset<maxs> s;


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

  int n;
  cin >> n;
  s[0] = 1;
  ll sum = 0;
  rep(i,n){
    int x;
    cin >> x;
    sum += x;
    s |= s<<x;
  }
  ll mid = sum/2;
  for(ll i = (sum+1)/2;i<=sum; i++){
    if(s[i]){
      cout << i << endl;
      break;
    }
  }


  return 0;
    

}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define endl '\n'
#define debug(X) cout << #X << " = " << X << endl

using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	#ifdef UTP
	freopen("input.txt", "r", stdin);
	#endif
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	int ans = 0;
	int l = 0, r = 0;
	while (l < n) {
		while (r < n && a[r] == a[l]) r++;
		ans += (r - l) / 2;
		l = r;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <utility>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <sstream>
#include <cstring>
#include <bitset>
#include <stack>
using namespace std;
#define MP make_pair
#define PB push_back
const int INF=1e9;
const int mod=1e9+7LL;

long long n,a[55];

int main()
{
	cin>>n;
	if (n<50) 
	{
		cout<<50<<endl;
		cout<<49+50*n<<" ";
		for (int i=1;i<=49;i++) cout<<0<<" ";
		return 0;
	}
	else
	{
		long long l=n/50LL;
		long long t=n%50LL;
		long long ans=49LL+l;
		for (int i=1;i<=50;i++) a[i]=ans;
		int pos=1;
		while (t--)
		{
			if (a[pos]+50LL>=1e16+1000LL) pos++;
			a[pos]+=50LL;
			for (int i=1;i<=50;i++)
			{
				if (i!=pos) a[i]--;
			}
		}
		cout<<50<<endl;
		for (int i=1;i<=50;i++) cout<<a[i]<<" ";
		return 0;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pb push_back
int main()
{
  string s,t;
  cin>>s>>t;
  t.erase(t.length()-1,1);
  if(s==t)
    cout<<"Yes\n";
  else
  cout<<"No\n";
  return 0;
}

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

int main() {
  int N,i=0,sum=0;
  cin >> N;
  vector<int> a(N);
  
  for(i=0;i<N;i++){
    cin >> a[i];
  }
  sort (a.begin(),a.end(),greater<int>());
  for(i=0;i<N;i+=2){
    sum += a[i];
  }
  for(i=1;i<N;i+=2){
    sum -= a[i];
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
object Main extends App{
  import scala.io.StdIn._
  val Array(n,m)=readLine().split(" ").map(_.toInt)
  val a=readLine().split(" ").map(_.toInt)
  val ans=a.filter(_>=a.sum.toDouble/(4*m))
  println(if(ans.length >=m ) "Yes" else "No")
}


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

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define MOD 1000000007
const double PI=3.14159265358979323846;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> T Ceil(T a, T b){return (a+b-1)/b;}

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

void printv(vint &v){
    for(auto e:v) cout<<e<<" ";
        cout<<endl;
    }

int main() {
    cout<<fixed<<setprecision(10);

    ll n; cin>>n;
    vint a(n);
    rep(i,n) cin>>a[i];

    vint b(n),c(n);

    rep(i,n){
        b[i] = i - a[i];
        c[i] = i + a[i];
    }

    map<ll,ll> m;
    ll ans = 0;
    repr(i,n){
        ans += m[c[i]];
        m[b[i]]++;
    }
    cout<<ans<<endl;


    return 0;

}

Measured memory_bytes: 30624
import sys
input=sys.stdin.readline
S=input()
S1=S[::2]
S2=S[1::2]
for i in S1:
    if i == "L":
        print("No")
        exit(0)
for i in S2:
    if i =="R":
        print("No")
        exit(0)
print("Yes")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}    //最大公約数
ll lcm(ll a, ll b) {return a * b / gcd(a, b);}   //最小公倍数

int main()
{
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll ca = a / c;
	ll cb = b / c;
	ll cc = cb - ca;
	if(a%c==0)
		cc++;

	ll da = a / d;
	ll db = b / d;
	ll cd = db - da;
	if(a%d==0)
		cd++;

	ll cd2 = lcm(c,d);
	ll cda = a / cd2;
	ll cdb = b / cd2;
	ll ccd = cdb - cda;
	if(a%cd2==0)
		ccd++;
	
	ll ans = b - a + 1;
	ans = ans - (cc + cd - ccd);
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>
#include <set>

const int INT_INF = 1e9;
const long long LONG_INF = 1e18;
const long long MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

using namespace std;

int main()
{
    int k, x;
    cin >> k >> x;
    int start, end;
    start = max(x - k + 1, -1000000);
    end = min(x + k - 1, 1000000);
    cout << start;
    for (int i = start + 1; i <= end; i++)
    {
        cout << " " << i;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3632
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n,k;
    cin >>n;
    cin>>k;
    int sum=0;
    forn(i,n){
        int x;
        cin>>x;
        sum += (2*min(x, k-x));
    }
    cout<<sum<<endl;
    return 0;
}



Measured memory_bytes: 256
n,m = map(int,raw_input().strip().split(' '))
graph = [[] for i in range(n)]
for i in range(m):
    s,t = map(int,raw_input().strip().split(' '))
    graph[s].append(t)
    graph[t].append(s)
color = {}
c = 0
for i in range(n):
    if not i in color:
        que = [i]
        color[i] = c
        while len(que) > 0:
            u = que[0]
            for v in graph[u]:
                if not v in color:
                    color[v] = c
                    que.append(v)
            del que[0]
        c += 1
q = int(raw_input())
for i in range(q):
    s,t = map(int,raw_input().strip().split(' '))
    if color[s] == color[t]:
        print 'yes'
    else:
        print 'no'

Measured memory_bytes: 32024
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int main(){
    string s;
    cin >> s;
    if (s.substr(0,7) == "keyence" ) cout << "YES" << endl;
    else if (s.substr(0,6) == "keyenc" && s.substr(s.size()-1,1) == "e") cout << "YES" << endl;
    else if (s.substr(0,5) == "keyen" && s.substr(s.size()-2,2) == "ce") cout << "YES" << endl;
    else if (s.substr(0,4) == "keye" && s.substr(s.size()-3,3) == "nce") cout << "YES" << endl;
    else if (s.substr(0,3) == "key" && s.substr(s.size()-4,4) == "ence") cout << "YES" << endl;
    else if (s.substr(0,2) == "ke" && s.substr(s.size()-5,5) == "yence") cout << "YES" << endl;
    else if (s.substr(0,1) == "k" && s.substr(s.size()-6,6) == "eyence") cout << "YES" << endl;
    else if(s.substr(s.size()-7,7) == "keyence") cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
num = int(input())

a = num -(num%100) ## 百のくらい
b = (num - a)%10 ## 1のくらい
c = (num - b)%100 ## 10のくらい

a = a/100
c = c/10

if a == 7 or b == 7 or c == 7:
    print("Yes")
else:
    print("No")


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

		long[] arr = new long[2019] ;
		long t = 0 ;
		while ( true ) {
			int v = s.read();
			if (  ! (v >= 49 && v <=57 ))
				break ;
			v = v -49 +1 ;

			long[] arr2 = new long[2019] ;
			arr2[v] += 1 ;
			for ( int k=0 ; k<arr.length ; k++ ) {
				if ( arr[k] == 0 ) continue ;
				arr2[ ( k * 10 + v ) % 2019 ] += arr[k] ;
			}
			
			arr = arr2 ;
			t += arr[0] ;

		}
		System.out.println ( t ) ;

	 }
}

Measured memory_bytes: 45044
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n, val, ans = 0;
    cin >> n;
    map<int, int> cnt;
    for(int i =0; i < n; i++) {
        cin >> val;
        cnt[val] += 1;
    }
    int m = cnt.rbegin()->first;
    int target = 1;
    while (target <= m) {
        target *= 2;
    }

    while (target > 1) {
        int half = target/2;
        auto it = cnt.lower_bound(half);
        if (it->first == half) {
            ans += it->second / 2;
            it->second %= 2;
            ++it;
        }
        //cout << "target: " <<target << endl;
        while (it != cnt.end()) {
            if (cnt.count(target - it->first) > 0) {
                int valid = min(it->second, cnt[target - it->first]);
                ans += valid;
                it->second -= valid;
                cnt[target - it->first] -= valid;
                //cout << "pair " << it->first << ", " << target-it->first << endl;
            }
            // cout << it->first << endl;
            ++it;
        }
        cnt.erase(cnt.lower_bound(half), cnt.end());
        target /= 2;
    }
    cout << ans << endl;
    return 0;
}




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

int main() {
  int n,m;
  long long ll = 1000000000+7;
  cin >> n >> m;
  vector<bool>ana(n,false);
  vector<long long>dp(n+1);
  for(int i = 0;i < m;i++){
    int a;
    cin >> a;
    ana[a] = true;
  }
  if(ana[0]) dp[0] = 0;
  else dp[0] = 1;
  if(ana[1]) dp[1] = 0;
  else dp[1] = 1;
  for(int i = 2;i <= n;i++){
    dp[i] = dp[i-2]+dp[i-1];
    dp[i] %= ll;
    if(ana[i]) dp[i] = 0;
  }
  cout << dp[n] << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void){

  int N,M,T[100],P[100],X[100];
  int time_x = 0;
  int time_e = 0;
  scanf("%d",&N);
  for(int i=0;i<N;i++){
  	scanf("%d",&T[i]);
    time_x += T[i];
  }
  
  scanf("%d",&M);
  for(int i = 0;i<M;i++){
  	scanf("%d%d",&P[i],&X[i]);
  }
  
  for(int i=0;i<M;i++){
  	time_e = time_x + X[i] - T[P[i]-1];
    printf("%d\n",time_e);
    time_e = 0;
  }
  
  return 0;
}

Measured memory_bytes: 1704
#include<bits/stdc++.h>
#define ll long long
#define PI acos(-1)
#define INF 0x7f3f3f3f
#define L first
#define R second
#define pii  pair<int ,int>
#define pll  pair<long,long>
#define pb push_back
#define lowbit(x)  (x&-x)
#define fr(i,m,n) for( int i=m;i<n;++i)
#define fo(i,m,n) for(int i=m;i<=n;++i)
#define MM(a,b) memset(a,b,sizeof(a));
#define fin freopen("C:\\Users\\w\\Desktop\\ACM\\in.txt","r",stdin)
#define fot freopen("C:\\Users\\w\\Desktop\\ACM\\out.txt","w",stdout)
#define fcs fclose(stdin);fclose(stdout);


using namespace std;

inline void read(int&a){char ch;while(!(((ch=getchar())>='0')&&(ch<='9')));a=ch-'0';while(((ch=getchar())>='0')&&(ch<='9'))(a*=10)+=ch-'0';}

int main()
{
   char a,b;
   cin>>a>>b;
   if(a==b) cout<<"H"<<endl;
   else cout<<"D"<<endl;

}













Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n,min,max;
    scanf("%d", &n);
    int a[n];

    scanf("%d", a);
    min=a[0];max=a[0];
    for(int i = 1; i < n; i++){
        scanf("%d", a+i);
        if(min>a[i]){
            min=a[i];
        }
        if(max<a[i]){
            max=a[i];
        }
    }
    printf("%d\n", max-min);
    return 0;
}


Measured memory_bytes: 128
N,K=map(int,input().split())
AB=[]
for i in range(N):
    a,b=map(int,input().split())
    AB.append([a,b])
ans=sum([b for a,b in AB if K|a==K])

for i in range(int.bit_length(K)-1,0,-1):
    if not K &(1<<i):
        continue
    m=K & ~(1<<i)|(1<<i)-1
    s=sum([b for a,b in AB if m | a ==m])
    ans=max(s,ans)
print(ans)


Measured memory_bytes: 74500
#include <iostream>
 
int main() {
  int x;
  int rank1 = 0;
  int rank2 = 0;
  int rank3 = 0;
  for (int i = 0; i < 10; i++) {
    std::cin >> x;
    if (x > rank1) {
      rank3 = rank2;
      rank2 = rank1;
      rank1 = x;
    } else if (x > rank2) {
      rank3 = rank2;
      rank2 = x;
    } else if (x > rank3) {
      rank3 = x;
    }
  }
  std::cout << rank1 << std::endl <<  rank2 << std::endl << rank3 << std::endl;
  return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<stdlib.h>

int main(){
    int n;
    int a[100+5];
    int b[100+5];
    int sum=0;
    scanf("%d", &n);
    for(int i=0; i<n-1; i++){
        scanf("%d", &b[i]);
    }
    a[0]=b[0];
    for(int i=1; i<n; i++){
        if(b[i-1]<b[i]){
            a[i]=b[i-1];
        }else{
            a[i]=b[i];
        }
    }
    a[n-1]=b[n-2];
    for (int i = 0; i < n; i++){
        // printf("%d: %d\n", i, a[i]);
        sum+=a[i];
    }
    
    printf("%d\n", sum);
    return 0;
}

Measured memory_bytes: 128