akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

typedef struct Word{
	char	word[31];
	int		page;
}	WORD;
WORD wordArray[100];

typedef int		BOOL;
#define TRUE	1;
#define FALSE	0;
BOOL is_smaller(WORD, int);

int main()
{
	int 	word_index, insert_index;
	WORD	tempWORD;
	char	last_print_word[31] = "";
	
	/*Input with order*/
	while(scanf("%s %d", tempWORD.word, &tempWORD.page) != EOF)
		for(word_index = 0; word_index < 100; word_index++){
			/*Put at last*/
			if(wordArray[word_index].page == 0){
				strcpy(wordArray[word_index].word, tempWORD.word);
				wordArray[word_index].page = tempWORD.page;
				break;
			}
			/*Insert*/
			else if(is_smaller(tempWORD, word_index)){
				for(insert_index = 98; insert_index >= word_index; insert_index--){
					strcpy(wordArray[insert_index + 1].word, wordArray[insert_index].word);
					wordArray[insert_index + 1].page = wordArray[insert_index].page;
				}
				strcpy(wordArray[word_index].word, tempWORD.word);
				wordArray[word_index].page = tempWORD.page;
				break;
			}
		}
	
	/*Output*/
	word_index = 0;
	while(wordArray[word_index].page != 0){
		if(strcmp(last_print_word, "") == 0){
			printf("%s\n", wordArray[word_index].word);
			strcpy(last_print_word, wordArray[word_index].word);
		}
		else if(strcmp(wordArray[word_index].word, last_print_word) != 0){
			printf("\n%s\n", wordArray[word_index].word);
			strcpy(last_print_word, wordArray[word_index].word);
		}
		else{
			printf(" ");
		}
		printf("%d", wordArray[word_index].page);
		word_index++;
	}
	printf("\n");
	
	return 0;
}

BOOL is_smaller(WORD tempWORD, int cnt)
{
	if(strcmp(tempWORD.word, wordArray[cnt].word) < 0){
		return TRUE;
	}
	else if(strcmp(tempWORD.word, wordArray[cnt].word) == 0){
		if(tempWORD.page < wordArray[cnt].page){
			return TRUE;
		}
		else{
			return FALSE;
		}
	}
	else{
		return FALSE;
	}
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define dbg(n) cout<<#n<<' '<<n<<endl;
int main(){ 
	ll n;
	cin>>n;
	ll x=100,count=0;
	while(x<n){
		x=(x+x/100);
		count++;
	}
	cout<<count<<endl;
}



Measured memory_bytes: 3588
n,k=map(int,input().split())
l=list(map(int,input().split()))
l.sort()
mod=10**9+7
n_max=2*10**5
F,FI=[0]*(n_max+1),[0]*(n_max+1)
F[0],FI[0]=1,1
for i in range(n_max):
  F[i+1]=(F[i]*(i+1))%mod
  FI[i+1]=pow(F[i+1],mod-2,mod)
def comb(x,y):
  return (F[x]*FI[x-y]*FI[y])%mod
total=0
for i in range(n-k+1):
   f=comb(n-i-1,k-1)%mod
   total+=int((l[n-i-1]-l[i])*f)
   total%=mod
print(total)

Measured memory_bytes: 63344
#include <stdio.h>
int main(void)
{
	int A, B, C, X;
	int count = 0;
	scanf("%d", &A); scanf("%d", &B); scanf("%d", &C); scanf("%d", &X);
	
	for(int i = 0; i <= A; i++) {
		for (int j = 0;j <= B; j++) {
			for (int k = 0; k <= C; k++) {
				if (500 * i + 100 * j + 50 *k == X)
					count++;
			}
		}
	}
	printf("%d", count);

	return 0;
	
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
 
void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}
 
int main(){
  ll N;
  cin>>N;
  ll A[N+10];
  ll B[N+10];
  rep1(i,N){
    cin>>A[i];
  }
  
  ll ori=N/2+1;
  ll count=0;
  
  for(int i=ori; i<=N; i++){
    if(A[i]==1){
      count++;
      B[i]=1;
    }
    else B[i]=0;
  }
  
  if(N>=2){
    for(int i=N/2; i>0; i--){
      ll ad=0;
      for(int j=2; j<=N/i; j++){
        ll k=i*j;
        ad+=B[k];
        ad%=2;
      }
      if(A[i]==ad) B[i]=0;
      else{
        B[i]=1;
        count++;
      }
    }
  }
  
  cout<<count<<endl;
  if (count!=0){
    rep1(i,N){
      if(B[i]==1){
        cout<<i<<" ";
      }
      else continue;
    }
  }
}
      
    
  

Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
struct gg{
	int a,b,id;
}node[100010],nw[100010];
struct hh{
	int u,v,w;
}mp[200010];
int n,num,fa[100010];
int find(int x)
{return fa[x]==x?x:fa[x]=find(fa[x]);}
bool cmp(gg mo,gg ha)
{return mo.a<ha.a;}
bool cmpp(gg mo,gg ha)
{return mo.b<ha.b;}
bool cmppp(hh mo,hh ha)
{return mo.w<ha.w;}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&node[i].a,&node[i].b);
		node[i].id=i;nw[i]=node[i];
	}
	sort(nw+1,nw+n+1,cmp);
	sort(node+1,node+n+1,cmpp);
	for(int i=2;i<=n;i++)
	{
		mp[++num].u=nw[i-1].id;
		mp[num].v=nw[i].id;
		mp[num].w=nw[i].a-nw[i-1].a;
		mp[++num].u=node[i-1].id;
		mp[num].v=node[i].id;
		mp[num].w=node[i].b-node[i-1].b;
	}
	int ans=0,cnt=n-1;
	sort(mp+1,mp+num+1,cmppp);
	for(int i=1;i<=n;i++)fa[i]=i;
	for(int i=1;i<=num&&cnt>=1;i++)
	{
		if(find(mp[i].u)==find(mp[i].v))continue;
		else ans+=mp[i].w,fa[find(mp[i].u)]=find(mp[i].v),cnt--;
	}
	cout<<ans;
}

Measured memory_bytes: 5376
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)
#include <string>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl
#define rep(i,n) for(ll i = 0;i < n;++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0)

const ll INF = 1e9+7;

// 各桁の和
template<typename T>T digit(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;}
template<typename T>T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}

int main(){
  int x,k;cin>>x>>k;
  
  for(int i = k-x+1;i <= k + x-1;++i){
    cout<<i<<' ';
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int h,m,s,T;
    cin >>T;
    h=T/3600;
    m=(T%3600)/60;
    s=(T%3600)%60;
    cout <<h<<":"<<m<<":"<<s<<endl;
    
}


Measured memory_bytes: 3096
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  if n==1:
    return 0
  else:
    return 1

# main()
print(main())


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int h,w,n,a,c[100][100];
queue<int> q;


signed main() {
    cin >> h >> w >> n;
    rep(i,n) {
        cin >> a;
        rep(j,a) q.push(i+1);
    }
    rep(i,h) {
        if (i%2) repm(j,w) {
            c[i][j] = q.front();
            q.pop();
        }
        else rep(j,w) {
            c[i][j] = q.front();
            q.pop();
        }
    }
    rep(i,h) {
        rep(j,w-1) cout << c[i][j] << " ";
        cout << c[i][w-1] << endl;
    }
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#define INF 1000000000;
#define dis first
#define mati second.first
#define sta  second.second
using namespace std;
typedef pair <int ,pair <int,int> > P;
vector <P> mp[102];
int c,n,m,start,goal;

int dijkstra() {
  int flg[12][102] = {},dis[12][102];
  for(int j=0;j<=c;j++)
    for(int i=0;i<=n;i++) dis[j][i] = -INF;

  for(int j=1;j<=c;j++)flg[j][start] = 1;

  priority_queue <P> Q;
  P t;
  t.dis = 0, t.mati = start, t.sta = 0;
  Q.push(t);

  while(!Q.empty()) {
    t = Q.top(),Q.pop();
    if(flg[t.sta][t.mati] == 1) continue;
    flg[t.sta][t.mati] = 1;
    for(int i=0;i<mp[t.mati].size();i++){
      int ndis = mp[t.mati][i].dis;
      int nmati = mp[t.mati][i].mati;
      int nsta = t.sta+1;
      P tt;
      if(dis[t.sta][nmati] < t.dis-ndis && flg[t.sta][nmati] == 0) {
	tt.dis = t.dis-ndis,tt.mati = nmati,tt.sta = t.sta;
	dis[t.sta][nmati] = t.dis-ndis;
	Q.push(tt);
      }
      if(nsta<= c&&dis[nsta][nmati]<t.dis-ndis/2 && flg[nsta][nmati]==0){
	tt.dis = t.dis - ndis/2 , tt.mati = nmati, tt.sta = nsta;
	dis[nsta][nmati] = t.dis-ndis/2;
	Q.push(tt);
      }
    }
  }

  int ans = -INF;
  for(int j=0;j<=c;j++)ans = max(ans,dis[j][goal]);
   
  return -ans;
}


int main() {
  while(1) {
    cin >> c >> n >> m >> start >> goal;
    if(c==0&&n==0&&m==0&&start==0&&goal==0) break;

    for(int i=0;i<=n;i++) mp[i].clear();
    for(int i=0;i<m;i++) {
      int a,b,f;
      cin >> a >> b >> f;
      P t;
      t.dis = f,  t.mati = b , t.sta = 0;
      mp[a].push_back(t);
      t.mati = a;
      mp[b].push_back(t);
    }

    cout << dijkstra() << endl;
  }

  return 0;
}

Measured memory_bytes: 1252
#include<bits/stdc++.h>
using namespace std;
#define Mod(n) n % 1000000007
int main()
{
    int N,M,X;
    cin >> N >> M >> X;
    vector<int> v,l;
    int tmp;
    for(int i = 0;i < M;i++)
    {
        cin >> tmp;
        if(tmp > X)
            v.push_back(tmp);
        else
            l.push_back(tmp);
    }
    cout << min(v.size(),l.size()) << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<math.h>
#include<algorithm>
using namespace std;
#include<string>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
 
 
 
int main(void)
{
	int x;
 
	cin >> x;
	int n =1;
	bool f = false;
	while (n<10000)
	{
		if (100*n<=x && 105 * n>=x)
		{
 
			f = true;
		}
 
		n++;
	}
 
 
	if (f == false)cout << 0 << endl;
	else cout << 1 << endl;
}



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

#define ll long long int

void test(vector<int> &a){
	ll dp[a.size()][a.size()];
	memset(dp, 0, sizeof(dp));
	for(int i = 0; i < a.size(); i++){
		dp[i][i] = a[i];
	}
	for(int i = a.size()-2; i >= 0; i--){
		for(int j = i + 1; j < a.size(); j++){
			dp[i][j] = max(a[i] - dp[i+1][j] , a[j] - dp[i][j-1]);
		}
	}
	cout << dp[0][a.size()-1] << endl;
}

int main(){
	#ifndef ONLINE_JUDGE
	freopen("/home/afzalrao/Desktop/Academics/2nd Year/3rd Sem/ESO207/CP/Text Files/input.txt", "r", stdin);
	freopen("/home/afzalrao/Desktop/Academics/2nd Year/3rd Sem/ESO207/CP/Text Files/output.txt", "w", stdout);
	#endif
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	test(a);
	return 0;
}

Measured memory_bytes: 73920
#include<bits/stdc++.h>
#define int long long
using namespace std;

int fx(int n,int k){
	int cnt =0;

	while(n!=0){
		//cout<<n%k<<" ";
		n = n/k;
		cnt++;
	}

	return cnt;
}

signed main(){

	int n,k;
	cin>>n>>k;

	int ans = fx(n,k);
	cout<<ans<<endl;
    

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	long long n, a, b, x, y, ans;

	cin >> n >> a >> b;
	x = n / (a + b);
	y = n % (a + b);

	ans = x * a + min(a, y);

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from pprint import pprint
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, T, A):
    ma = [-1] * N
    ma[-1] = A[-1]
    for i in range(N-2, -1, -1):
        ma[i] = max(ma[i+1], A[i])

    c = Counter()
    for i in range(N):
        c[ma[i]-A[i]] += 1

    return c[max(c.keys())]


def main():
    N, T = read_int_n()
    A = read_int_n()

    print(slv(N, T, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 94972
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SORT(a) sort((a).begin(), (a).end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
    { cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}

Vec fac, finv;

ll PowMod(ll a, ll n){
    if(n == 1) return a;
    if(n%2 == 0) return PowMod(a*a%MOD, n/2);
    return a*PowMod(a*a%MOD, n/2)%MOD;
}

ll combi(ll n, ll k){
    if(k>n) return 0;
    return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}

int main(){
    int a, b;
    R a >> b;
    if((a % 2) && (b % 2)){
        co("Yes");
    }else{
        co("No");
    }
}


Measured memory_bytes: 256
import collections as cl
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

sum = 0
for i in range(N):
    sum += A[i]
dic = cl.Counter(A)

l = []
for _ in range(Q):
    b, c = map(int, input().split())
    x = dic.get(b)
    if x == None:
        l.append(sum)
        continue
    if b < c:
        sum += (c - b) * x
    else:
        sum -= (b - c) * x
    l.append(sum)
    if c not in dic:
        dic[c] = dic.pop(b)
    else:
        dic[c] = dic.pop(b) + dic[c]

for s in l:
    print(s)


Measured memory_bytes: 21504
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 605;

int sm1[MAX_N][MAX_N], sm2[MAX_N][MAX_N];
int f[MAX_N][MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    rep(i,h){
        string s;
        cin >> s;
        rep(j,w){
            f[i+j][h-1-i+j] = (s[j] == '#');
        }
    }
    rep(i,h+w-1){
        rep(j,h+w-1){
            sm1[i][j+1] = sm1[i][j] + f[i][j];
        }
    }
    rep(j,h+w-1){
        rep(i,h+w-1){
            sm2[i+1][j] = sm2[i][j] + f[i][j];
        }
    }
    int one = 0, two = 0;
    rep(i,h+w-1){
        rep(j,h+w-2){
            if(f[i][j] == 0) continue;
            srep(k,j+1,h+w-1){
                if(f[i][k] == 0) continue;
                if(i-k+j >= 0) one += sm1[i-k+j][k] - sm1[i-k+j][j+1], two += f[i-k+j][k] + f[i-k+j][j];
                if(i+k-j < h+w-1) one += sm1[i+k-j][k] - sm1[i+k-j][j+1], two += f[i+k-j][k] + f[i+k-j][j];
            }
        }
    }
    rep(j,h+w-1){
        rep(i,h+w-2){
            if(f[i][j] == 0) continue;
            srep(k,i+1,h+w-1){
                if(f[k][j] == 0) continue;
                if(j-k+i >= 0) one += sm2[k][j-k+i] - sm2[i+1][j-k+i], two += f[k][j-k+i] + f[i][j-k+i];
                if(j+k-i < h+w-1) one += sm2[k][j+k-i] - sm2[i+1][j+k-i], two += f[k][j+k-i] + f[i][j+k-i];
            }
        }
    }
    cout << one + two/2 << "\n";
    return 0;
}


Measured memory_bytes: 4608
#include <stdio.h>

int main() {
  int N, K;
  int num = 1;
  int i;
  
  scanf("%d %d", &N, &K);
  for(i = 0; i < N; i++) {
    if(num < K) {
      num = num + num;
    } else {
      num = num + K;
    }
  }
  printf("%d\n", num);
  return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}
template<typename T,typename U>
ll FindErase(T &v,U tar){
  ll cnt = 0;
  for(auto it = v.begin(); it != v.end();){
    if(*it == tar){
      it = v.erase(it);
      ++cnt;
    }
    else{
      ++it;
    }
  }
  return cnt;
}

template<typename T>
bool SuffixErase(T &v,size_t suf){
  if(suf > v.size()) return false;
  for(auto it = v.begin(); it != v.end();){
    if(distance(v.begin(),it) == suf){
      v.erase(it);
      return true;
    }
    else{
      ++it;
    }
  }
  return false;
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll h,w;
  cin >> h >> w;
  vector<vector<ll>> v(w,vector<ll>(h,0));
  vector<vector<ll>> dp(w+1,vector<ll>(h+1,0));
  rep(i,h){
    rep(j,w){
      cin >> v[j][i];
    }
  }
  ll ans = 0;
  rep(i,h){
    dp[0][i] = !v[0][i];
    ans = max(ans,dp[0][i]);
  }
  rep(i,w){
    dp[i][0] = !v[i][0];
    ans = max(ans,dp[i][0]);
  }
  REP(i,1,h){
    REP(j,1,w){
      if(v[j][i] == 0){
        ll mi = min(dp[j-1][i],min(dp[j-1][i-1],dp[j][i-1]));
        dp[j][i] = mi+1;
      }
      ans = max(ans,dp[j][i]);
    }
  }
  cout << ans * ans << endl;
  return 0;
}

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

using namespace std;

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

  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int mx = max({a, b, c});

  cout << a + b + c - mx + (mx<<k) << endl;

  return 0;
}



Measured memory_bytes: 256
#include <cstdio>

int main()
{
	int N, M, X, Y, tx, ty, i;
	std::scanf("%d %d %d %d", &N, &M, &X, &Y);

	for (i = 0; i < N; i++) {
		std::scanf("%d", &tx);
		if (tx > X)
			X = tx;
	}
	for (i = 0; i < M; i++) {
		std::scanf("%d", &ty);
		if (ty < Y)
			Y = ty;
	}

	if ((Y - X) > 0)
		std::printf("No War\n");
	else
		std::printf("War\n");

	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
const int M = 100010;
int n,p,s,a[M],b[M];
int main()
{
    scanf("%d",&n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d%d",&a[i],&b[i]);
        if(a[i] > p)
        {
            p = a[i];
            s = b[i];
        }
    }
    printf("%d\n",p+s);
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int swap(int *a,int *b);

int main(){
	int w,n,line[30],i,a,b;
	
	scanf("%d",&w);
	for(i=0;i<w;i++){
		line[i]=i+1;
	}
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d,%d",&a,&b);
		swap(&line[a-1],&line[b-1]);
	}
	
	for(i=0;i<w;i++){
		printf("%d\n",line[i]);
	}
	
	return 0;
}


int swap(int *a,int *b){
	int temp;
	temp=*a;
	*a=*b;
	*b=temp;
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main()
{ int a,b ;
    cin>>a>>b;
   if(a==b)
   cout <<"a == b"<<endl;
   else if(a>b)
   cout <<"a > b"<<endl;
   else
   cout <<"a < b"<<endl;

return 0;
}



Measured memory_bytes: 3004
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    h,w,k = map(int,ipt().split())
    c = [input() for i in range(h)]
    ans = 0
    for i in range(2**h):
        for j in range(2**w):
            num = 0
            for hi in range(h):
                for ji in range(w):
                    if (i >> hi)&1 and (j>>ji)&1 and c[hi][ji] == "#":
                        num += 1
            if num == k:
                ans += 1
    print(ans)        

    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 70568
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int P[100001];
int m[100001];
vector<int> sonota;
int Find(int A) {
	if (P[A] < 0) return A;
	return P[A] = Find(P[A]);
}

bool Unite(int A, int B) {
	int a = Find(A);
	int b = Find(B);
	if (a == b) return false;
	if (P[a] > P[b]) swap(a, b);
	P[a] += P[b];
	P[b] = a;
	sonota.pb(max(m[a], m[b]));
	m[a] = min(m[a], m[b]);
	return true;
}

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


	int N = getint(), M = getint();
	rep(i, N) m[i] = getint();;

	rep(i, N) P[i] = -1;
	rep(i, M) {
		int x = getint(), y = getint();
		Unite(x, y);
	}

	ll kotae = 0;
	int kazu = 0;
	rep(i, N) {
		if (P[i] < 0) {
			kazu++;
			kotae += m[i];
		}
	}
	if (kazu == 1) co(0);
	else {
		kazu -= 2;
		if (kazu > sonota.size()) co("Impossible");
		else {
			sort(sonota.begin(), sonota.end());
			rep(i, kazu) {
				kotae += sonota[i];
			}
			co(kotae);
		}
	}

	Would you please return 0;
}

Measured memory_bytes: 1788
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int main() {
  int N, M;
  while (cin >> N >> M) {
    vec<int, 2> G(N);
    vector<int> indeg(N, 0);
    for (int i = 0; i < M; i++) {
      int x, y;
      cin >> x >> y;
      --x;
      --y;
      G[x].push_back(y);
      ++indeg[y];
    }
    stack<int> stk;
    for (int i = 0; i < N; i++)
      if (indeg[i] == 0) stk.push(i);
    vector<int> dp(N, 0);
    while (!stk.empty()) {
      int v = stk.top();
      stk.pop();
      for (int u : G[v]) {
        dp[u] = max(dp[u], dp[v] + 1);
        if (--indeg[u] == 0) {
          stk.push(u);
        }
      }
    }
    int res = *max_element(dp.begin(), dp.end());
    cout << res << endl;
  }
  return 0;
}


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

int n;


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

    scanf("%d",&n);
    vector < int > v(n) ;
    for(auto &x : v)
        scanf("%d",&x);

    int mx = 0 , e = n-1;
    

    rloop(i,n-1){ 
        if(v[i] < v[i+1])
             e = i;
       // cout << e << "\n";
        mx = max(mx , e-i);
    }
    printf("%d\n",mx);
    




    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int f(int a,int b)
{
	return a>b;
}
int main()
{
	int n,m;
	cin>>n>>m;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	 } 
	 sort(a,a+n,f);
	 int sum=0;
	 for(int i=0;i<m;i++)
	 sum+=a[i];
	 cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
//#include <stdlib.h>
//#include <stdio.h>
//#include <string>
using namespace std;

int a[200000],b[200000];

int main()
{
	int i,n;
	cin>>n;
	
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		b[a[i]-1]=i+1;
	}
	for(i=0;i<n;i++)
		cout<<b[i]<<" ";
	return 0;
}


Measured memory_bytes: 1664
from collections import Counter
N = int(input())
l=[input() for i in range(N)]
count=Counter(l).most_common()
d = []
most = count[0][1]
for si,c in count:
  if c==most:
    d.append(si)
d.sort()
for i in d:
  print(i)



# # O(N)
# max_word_list = [kv[0] for kv in word_count.items() if kv[1] == max(word_count.values())]

# # 辞書順にソートして出力
# max_word_list = sorted(max_word_list)
# for word in max_word_list:
#   print(word)


Measured memory_bytes: 45040
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9 + 7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

string S;

signed main() {
	cin >> S;
	bool flg = true;
	rep(i, S.size()) {
		if (i % 2 == 0) {
			if (S[i] == 'L') flg = false;
		}
		if (i % 2 == 1) {
			if (S[i] == 'R') flg = false;
		}
	}
	if (flg) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
	int n;
	int a, v;
	int i;
	int max_num, max;
	
	scanf("%d", &n);
	
	scanf("%d %d", &a, &v);
	max_num = a;
	max = v;
	
	for (i = 1; i < n; i++){
		scanf("%d %d", &a, &v);
		
		if (max < v){
			max_num = a;
			max = v;
		}
		else if (max == v && max_num > a){
			max_num = a;
		}
		
	}
	printf("%d %d\n", max_num, max);
	
	return (0);
}

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

#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()  
{ 
    FAST_INP;
    int t; 
    string s;
    cin >> t;
    map<int,int> m;
    while(t--){
        cin >> s;
        if(s=="AC") m[0]++;
        else if(s=="WA") m[1]++;
        else if(s=="TLE") m[2]++;
		else m[3]++; 
    }
    
    printf("AC x %d\n", m[0]);
    printf("WA x %d\n", m[1]);
    printf("TLE x %d\n", m[2]);
    printf("RE x %d\n", m[3]);
    
    return 0;
} 

Measured memory_bytes: 3752
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
using namespace std;


int main()
{
	long long int r, r1, r2, i, j, x = 2019;
    long long int a, b;
	cin >> a >> b;
	r1 = a % 2019;
	r2 = b % 2019;
	if (b - a > 2019) {
		cout << 0 << endl;
	}
	else if (r2 < r1)
		cout << 0 << endl;
	else {
		for (i = r1; i < r2; i++) {
			for (j = i+1; j <= r2; j++) {
				if ((i * j) % 2019 < x) {
					x = (i * j) % 2019;
				}
			}
		}
		cout << x << endl;
	}

}


Measured memory_bytes: 892
#include <iostream>

using namespace std;

int main()
{
	int N, d[100] = { 0 }, t[100] = { 0 }, i, j, k=0;
	cin >> N;
	for (i = 0; i < N; i++) {
		cin >> d[i];
		t[i] = d[i];
	}

	for (i = 0; i < N-1; i++) {
		for (j = i + 1; j < N; j++) {
			if (d[i] == d[j])
				t[j] = 0;
		}
		
	}

	for (i = 0; i < N; i++) {
		if (t[i])
			k++;
	}

	cout << k << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int q = sc.nextInt();
		String str = sc.next();

		int leftAC[] = new int[n];

		for(int i = n - 2; i >= 0; i--){
			leftAC[i] = leftAC[i + 1];
			if(str.substring(i, i + 2).equals("AC")){
				leftAC[i]++;
			}
		}

		for(int i = 0; i < q; i++){
			int l = sc.nextInt() - 1;
			int r = sc.nextInt() - 1;

			System.out.println(leftAC[l] - leftAC[r]);
		}
	}
}

Measured memory_bytes: 70484
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#define FUP(i,x,y) for(int i=(x);i<=(y);i++)
#define FDW(i,x,y) for(int i=(x);i>=(y);i--)
#define MAXN 100010
#define INF 0x7fffffff
#define MOD 1000000007
#define ll long long
#define db double
using namespace std;
int read(){
    int w=0,flg=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')flg=-1;ch=getchar();}
    while(ch<='9'&&ch>='0'){w=w*10-'0'+ch,ch=getchar();}
    return w*flg;
}
int a,b;
int main(){
	a=read(),b=read();
	if(a>=10)
	{
		printf("%d",b);
		return 0;
	}
	printf("%d",b+100*(10-a));
    return 0;
}

Measured memory_bytes: 256
object Main extends App {
  import scala.io.StdIn._

  val d = readInt
  val numbers = readLine.trim.split(' ').map(_.toInt)
  val segTree = SegTree(numbers)
  for (_ ← 0 until readInt){
    val Array(l, r, e) = readLine.trim.split(' ').map(_.toInt)
    val a = math.min(numbers(l - 1), numbers(r - 1))
    val b = math.max(numbers(l - 1), numbers(r - 1))
    println(r - l + 1 - segTree.countInRange(l - 1, r, a - e, b + e))
  }
  object SegTree{
    sealed trait Tree extends SegTree
    private class Node(private val mFrom: Int, private val mUntil: Int, private val mLeft: Tree, private val mRight: Tree, private[this] val mArray: Array[Int]) extends Tree {
      override def countInRange(from: Int, until: Int, lower: Int, upper: Int): Int = {
        if (from <= mFrom && mUntil <= until) upperBound(mArray, upper) - lowerBound(mArray, lower)
        else if (mUntil <= from || until <= mFrom) 0
        else mLeft.countInRange(from, until, lower, upper) + mRight.countInRange(from, until, lower, upper)
      }
    }
    private class Leaf(private val mFrom: Int, private val mUntil: Int, private[this] val mArray: Array[Int]) extends Tree {
      override def countInRange(from: Int, until: Int, lower: Int, upper: Int): Int = {
        (math.max(from, mFrom) until math.min(until, mUntil)).count(i ⇒ lower <= mArray(i - mFrom) && mArray(i - mFrom) <= upper)
      }
    }
    private[this] def lowerBound(array: Array[Int], target: Int): Int = {
      var left = 0
      var right = array.length
      while (left < right){
        val mid = (left + right) / 2
        if (array(mid) < target){
          left = mid + 1
        }else {
          right = mid
        }
      }
      right
    }
    private[this] def upperBound(array: Array[Int], target: Int): Int = {
      var left = 0
      var right = array.length
      while(left < right){
        val mid = (left + right) / 2
        if (array(mid) <= target){
          left = mid + 1
        }else {
          right = mid
        }
      }
      right
    }
    def apply(numbers: Array[Int]): Tree = {
      makeTree(numbers, 0, numbers.length)
    }
    private[this] def makeTree(array: Array[Int], from: Int, until: Int): Tree = {
      if (until - from >= 16) new Node(from, until, makeTree(array, from, (from + until) / 2), makeTree(array, (from + until) / 2, until), (from until until).map(array).sorted.toArray)
      else new Leaf(from, until, (from until until).map(array).toArray)
    }
  }
  trait SegTree {
    def countInRange(from: Int, until: Int, lower: Int, upper: Int): Int
  }
  implicit class Scope[T](val value: T) extends AnyVal {
    @inline
    def also(@inline func: T ⇒ Unit): T = {
      func(value)
      value
    }
    @inline
    def let[A](@inline func: T ⇒ A): A = func(value)
  }
}


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

using namespace std;
typedef long long ll;
const ll INF = -1e15;
struct edge{int from, to; ll cost;

  edge (int f, int t, ll c) : from(f), to(t), cost(c) {}

};

int N,M;
vector<edge> e;
ll dist[1001];

int main() {
  cin >> N >> M;

  for(int i = 0; i < M; i++) {
    int a,b;
    ll c;
    cin >> a >> b >> c;
    a--; b--;
    e.push_back(edge(a,b,c));
  }

 
  fill(dist,dist+N,INF);
  dist[0] = 0;
  for(int j = 0; j < N; j++) {
    for(int i = 0; i < e.size(); i++) {
      if(dist[e[i].from] == INF) continue;

      if(dist[e[i].to] < dist[e[i].from] + e[i].cost){
	dist[e[i].to] = dist[e[i].from] + e[i].cost;
	//	cout <<dist[e[i].to]<<endl;

      }
    }
  }

  ll heiro = dist[N-1];
  for(int j = 0; j < N; j++) {
    for(int i = 0; i < e.size(); i++) {
      if(dist[e[i].from] == INF) continue;

      if(dist[e[i].to] < dist[e[i].from] + e[i].cost){
	dist[e[i].to] = dist[e[i].from] + e[i].cost;
	//	cout <<dist[e[i].to]<<endl;

      }
    }
 
  }
   if(heiro >= dist[N-1]) {
     cout << dist[N-1] << endl;
   }
   else cout <<"inf"<<endl;
}
      

  
  
  


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

int main() {
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<P> d;
  rep(i, a) {
    int p;
    cin >> p;
    d.push_back(make_pair(-p, 1));
  }
  rep(i, b) {
    int q;
    cin >> q;
    d.push_back(make_pair(-q, 2));
  }
  rep(i, c) {
    int r;
    cin >> r;
    d.push_back(make_pair(-r, 3));
  }
  sort(d.begin(), d.end());

  ll ans = 0;
  int a0 = 0, b0 = 0, c0 = 0;
  rep(i, d.size()) {
    if (a0 + b0 + c0 == x + y) break;
    int clr = d[i].second;
    if (clr == 1 && a0 == x) continue;
    if (clr == 2 && b0 == y) continue;
    ans -= d[i].first;
    if (clr == 1) ++a0;
    if (clr == 2) ++b0;
    if (clr == 3) ++c0;
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
    int N, P; string S;
    cin >> N >> P >> S;
    ll ans = 0LL;
    if (P == 2 || P == 5) {
        for (int i = 0; i < S.size(); ++i) {
            if ((S[i] - '0') % P == 0) ans += i + 1;
        }
    }
    else {
        unordered_map<int, int> mp;
        mp[0]++;
        int rem = 0, factor = 1;
        for (int i = S.size() - 1; i >= 0; --i) {
            rem = (rem + (S[i] - '0') * factor) % P;
            ans += mp[rem];
            mp[rem]++;
            factor = (factor * 10) % P;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long X, P; 
	cin >> X >> P; 
	double ans; 
	if(X % 2 == 0) ans = 50.0 * X / P; 
	else ans = 50.0 * (X + 1.0) / P; 
	cout.precision(15); 
	cout << ans << endl; 
}

Measured memory_bytes: 256
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//																				NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define mod 100000007
#define testcases() ll t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
 
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	fast;
	string str;
	cin>>str;
	bool flag = true;
	for(int i=0;i<(int)str.size();i++)
	{
		if(i%2==0 && str[i]=='L')
		{
			flag = false;
			break;
		}
        if(i%2==1 && str[i]=='R')
		{
			flag = false;
			break;
		}
	}
	flag?cout<<"Yes":cout<<"No";
	return 0;
}


Measured memory_bytes: 256
s_list = list()

while True:
    h,w = map(int,input().split())
    s_pair = [h,w]
    if s_pair == [0,0]:
        break
    s_list.append(s_pair)

for pair in s_list:
    for h in range(pair[0]):
        if h == 0 or h == pair[0]-1:
            for w in range(pair[1]):
                print('#', end='')
        else:
            print('#', end='')
            for w in range(1,pair[1]-1):
                print('.', end='')
            print('#', end='')
        print('')
    print('')



Measured memory_bytes: 7020
package main

import(
	"fmt"
)

func main() {
	var b string
	fmt.Scan(&b)
	
	switch b {
		case "A":
			fmt.Println("T")
		case "T":
			fmt.Println("A")
		case "C":
			fmt.Println("G")
		case "G":
			fmt.Println("C")
	}
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main (int argc, char * const argv[]) {
    // insert code here...
    
	for(int i=1;i<10;i++){
		for(int j=1;j<10;j++){
			cout<<i<<"x"<<j<<"="<<i*j<<endl;
		}
	}
    return 0;
}

Measured memory_bytes: 1116
#include<iostream>

using namespace std;

long long int A[112345];
long long int N,K;
int main () {
    cin >> N >> K;
    for(int i=0; i<N; i++) cin >> A[i];
    long long int mask = 0;
    long long int ans = 0;
    for(int j=40; j>=0;j--){
        int cnt = 0;
        for(int k=0; k<N; k++) if((A[k]>>j) & 1) cnt++;
        if(2*cnt < N && (mask|(1L<<j)) <= K) mask |= (1L<<j);
    }
    for(int i=0; i<N; i++) ans += mask ^ A[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long a[100100],n,k,mn=100000000000000;

long long dp[100100];
/*long long DP(long long ind,long long cnt){
    if(ind==0)return cnt;
    if(ind<0)return 1000000000;
    if(dp[ind]!=-1)return dp[ind];
    return dp[ind]=min(DP(ind-1,cnt+abs(a[ind]-a[ind-1])),DP(ind-2,cnt+abs(a[ind]-a[ind-2])));

}*/

int main(){

    cin>>n>>k;
   // memset(dp,-1,sizeof dp);
    for (long long i=0;i<n;i++)cin>>a[i];
    //cout<<DP(n-1,0);
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(long long i=2;i<n;i++){
            mn=1000000000;
            for(int j=1;j<=k;j++)if(i-j>=0)mn=min(dp[i-j]+abs(a[i]-a[i-j]),mn);
            dp[i]=mn;

    }
    cout<<dp[n-1];
    return 0;
}

/*
10
1 10 2 10 10 10 2 10 2 2
*/


Measured memory_bytes: 1792
S = input()
t = int(S[-1])
if t == 2 or t == 4 or t == 5 or t == 7 or t == 9:
    print("hon")
elif t == 0 or t == 1 or t == 6 or t == 8:
    print("pon")
else:
    print("bon")


Measured memory_bytes: 61608
#include <bits/stdc++.h>
#include<algorithm>	
using namespace std;
#define ll long long 
long long n;
vector<long long> so_a;//素数を格納
int main(){
  long double a,b,x;
  cin >> a >> b >> x;
  long double res;
  if(x > a*a*b/2){
    
    res = atan(2*(a*a*b-x)/(a*a*a));
  }else{
    res = atan((a*b*b)/(2*x)) ;
  }
  cout << fixed << setprecision(10);
  cout << 360*res/(2*M_PI) << endl;

}


Measured memory_bytes: 3788
import sys
# sys.stdin = open('input.txt')

nCr = {}
def cmb2(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


n = int(input())
a = [i for i in map(int, input().split())]

cnt = {}
for i in a:
    if i not in cnt.keys():
        cnt[i] = 1
    else:
        cnt[i] += 1

total = 0

for i in cnt.values():
    if i >= 2:
        total += cmb(i, 2)

ansDic = {}

for i in range(n):
    if a[i] in ansDic.keys():
        print(ansDic[a[i]])
    else:
        x = cnt[a[i]]
        ans = total
        if x >= 2:
            ans = total - cmb(x, 2)
        if x-1 >= 2:
            ans += cmb(x-1, 2)
        ansDic[a[i]] = ans
        print(ans)

Measured memory_bytes: 33812
#include<iostream>
#include<map>


int c{};

template<class K,class U>
auto rec(std::map<const K,U>*mpp,int &c,const K k) {
	auto it = mpp->find(k);
	
	if (mpp->end() == it)
		mpp->insert(std::make_pair(k, 1));
	else 
		return c;
	
	return rec(mpp, ++c, k%2==0?k/2:3*k+1);
}

int main() {
	std::map<const int, int> mp;

	int s;
	std::cin >> s;


	auto ans = rec(&mp, c, s);
	std::cout << ans+1 << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    
    int n, m; cin >> n >> m;
    vector<int> c(m);
    rep(i, m) cin >> c[i];

    // コインをi枚目までつかって j円払うときの値が最小枚数
    int INF = 1e5+1;
    vector<vector<int>> dp(m+1, vector<int>(n+1, INF));
    rep(i, m+1) {
        dp[i][0] = 0;
    }
    rep(i, m) {
        rep(j, n) {
            if (j+1 - c[i] >= 0) {
                dp[i+1][j+1] = min(dp[i][j+1], dp[i+1][j+1-c[i]]+1);
            } else {
                dp[i+1][j+1] = dp[i][j+1];
            }
        }
    }
    /*
    rep(i, m+1) {
        rep(j, n+1) {
            cout << dp[i][j] << " "; 
        }
        cout << endl;
    }
    */
    cout << dp[m][n] << endl;
    return 0;
}


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

int main(int argc, char const *argv[]) {
  int n;
  std::cin >> n;

  std::vector<int> h;

  for (size_t i = 0; i < n; i++) {
    int tmp;
    std::cin >> tmp;
    h.push_back(tmp);
  }

  bool is_ok = true;
  bool is_checked = false;
  int count = 1;
  
  for (size_t i = 0; i < n; i++) {
    for (size_t j = 0; j < i; j++) {
      is_checked = true;
      if (h.at(i) < h.at(j)) {
        is_ok = false;
        break;
      }
    }

    if (is_ok == true && is_checked == true) {
      count++;
    }

    is_ok = true;
    is_checked = false;
  }
  
  std::cout << count << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
  vector<int> A(3);
  cin >> A[0] >> A[1] >> A[2];
  sort(A.rbegin(), A.rend());
  cout << A[0] * 10 + A[1] + A[2] << endl;

  return 0;
}


Measured memory_bytes: 256