akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <fstream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <assert.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define ALL(s) begin(s),end(s)
#define VIEW(dat) for(auto v : dat){cout<<v<<endl;}
#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizeof(a))
#define pb push_back
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define MP(a,b) make_pair((a),(b))


const int INF=1<<24;

using namespace std;

string valOf(int n){ stringstream ss;ss<<n;return ss.str();}
int    valOf(string s){return atoi(s.c_str());}
int    valOf(char s){return (unsigned int)(s - '0');}

int gt(int h,int w){return h*h+w*w;}

int main(){
	
	//ifstream cin("in.txt");
	
	int h,w, t;
	while(cin>>h>>w,h||w){
		int r=INF, H=0, W=0;
		t=gt(h,w);
		for(int i=150;i>0;--i){
			for(int j=150;j>0;--j){
				if(t==gt(i,j)&&i>h&&i<j){
					r=gt(i,j);
					H=i;W=j;
				}else if(t<gt(i,j)&&i<j){
					if(r==gt(i,j)){
						H=min(H,i);W=j;
					}else if(r>gt(i,j)){
						r=gt(i,j);
						H=i;W=j;
					}
				}
			}
		}
		cout<<H<<" "<<W<<endl;
	}
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll n;
	cin>>n;
	ll arr[n];
	ll s=0;
	for(ll i=0;i<n;i++)
	{
		cin>>arr[i];
		s+=arr[i];
	}
	ll c=ceil(abs(s)/(1.0*n));
	ll c1=floor(abs(s)/(1.0*n));
	if(s<0)
	{
		c=c*-1;
		c1=c1*-1;
	}
	ll ans=0,ans1=0;
	for(ll i=0;i<n;i++)
	{
		ans+=(arr[i]-c)*(arr[i]-c);
		ans1+=(arr[i]-c1)*(arr[i]-c1);
	}
	cout<<min(ans,ans1)<<endl;
}

Measured memory_bytes: 256
S = input()
N = len(S)
dp = [[0] * 13 for _ in range(N + 1)]
dp[0][0] = 1
mod = 10 ** 9 + 7

for i in range(N):
    c = S[i]
    c = [int(c)] if c != '?' else range(10)

    for k in c:
        for j in range(13):
            dp[i + 1][(j * 10 + k) % 13] += dp[i][j]

    for j in range(13):
        dp[i + 1][j] %= mod

print(dp[N][5])


Measured memory_bytes: 61916
# from pprint import pprint
# import math
# import collections

# n = int(input())
s = input()
t = input()
# n, k = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))

cnt = 0
for _s, _t in zip(s, t):
    if _s != _t:
        cnt += 1

print(cnt)


Measured memory_bytes: 9392
#include <iostream>
#include<vector>
#include<string.h>
using namespace std;
long long dp[100005];
int N, W;
struct Item{
    int weight;
    int value;
};
vector <Item> item;
int main(int argc, char const *argv[])
{
    int temp1, temp2;
    cin >> N >> W;
    for(int i = 0 ; i<N ; i++){
        cin >> temp1 >> temp2;
        item.push_back({temp1, temp2});
    }
    memset(dp, 0, sizeof(dp));
    for(int i = 0 ; i<N ; i++){
        int temp_w = item[i].weight;
        int temp_v = item[i].value;
        for(int j = W ; j>=temp_w ; j--){
            dp[j] = max(dp[j], dp[j - temp_w] + temp_v);
            
        }
    }
    cout << dp[W] << endl;
}

Measured memory_bytes: 3964
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define N 200005
char s[N];
int d[N];

int main(int argc, const char * argv[]) {
    
    scanf("%s", s + 1);
    int len = (int)strlen(s + 1);
    int *dp = &d[1];
    dp[-1] = -1;
    dp[0] = 0;
    dp[1] = 1;
    int i;
    for (i = 2; i <= len; i++) {
        if (s[i] == s[i - 1]) {
            dp[i] = dp[i - 3] + 2;
        }
        else {
            dp[i] = dp[i - 1] + 1;
        }
    }
    printf("%d\n", d[len + 1]);
    
    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm> // sort
#include <map> // pair
using namespace std;
#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


//後ろから求める
//最短時間だから
int main() {
    int N;
    cin >> N;

    int c[N],s[N],f[N];

    REP(i,N-1)
    {
      cin >> c[i] >> s[i] >> f[i];
    }

    //res[N-1]からもとめる
    ll res[N+1] = {};

    for(int i = 0; i <= N-1; ++i)
    {
      ll cnt = 0;

      for(int j = i; j < N-1; ++j)
      {

        if(cnt < s[j])
        {
          cnt = s[j];
        }
        else
        {
          int tmp;
          //s%f == 0なので
          tmp = cnt % f[j];
          if(tmp != 0)
          {
            tmp = f[j] - tmp;
          }
          //乗れる電車を探す
          cnt += tmp;
        }
        cnt += c[j];
      }

      res[i] = cnt;
    }
    REP(i,N)
    {
      cout << res[i] << endl;
    }




    return 0;
}


Measured memory_bytes: 256
S = input()

i = 0
for i in range(len(S)):
    s1 = S[i:i+1]
    if (s1 == 'A'):
        break

for j in range(len(S)):
    k = len(S) - j
    s2 = S[k-1:k]
    if (s2 == 'Z'):
        break

print(k-1-i+1)

Measured memory_bytes: 3516
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  int N,M,Q;
  cin >> N >> M >> Q;
  vector<P> A(M);
  REP(i,M){
    cin >> A[i].first >> A[i].second;
    A[i].first--;
    A[i].second--;
  }
  vector<P> B(Q);
  REP(i,Q){
    cin >> B[i].first >> B[i].second;
    B[i].first--;
    B[i].second--;
  }
  
  vector<vector<int>> vec(N+1,vector<int> (N+1,0));
  REP(i,M){
    vec[0][A[i].second]++;
    vec[A[i].first+1][A[i].second]--;
    vec[0][N]--;
    vec[A[i].first+1][N]++;
  }

  REP(i,N+1){
    int sum=0;
    REP(j,N+1){
      sum+=vec[i][j];
      vec[i][j]=sum;
    }
  }
  REP(j,N+1){
    int sum=0;
    REP(i,N+1){
      sum+=vec[i][j];
      vec[i][j]=sum;
    }
  }

  REP(i,Q){
    cout << vec[B[i].first][B[i].second] << endl;
  }
}

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

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

    for (auto s : N) {
        if (s == '9') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
inline bool read(ll &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
int cnt[999];
int main(){
string a;cin>>a;
for (char c:a) cnt[c]++;
for (int i=1;i<=990;++i) if (cnt[i]&1) return puts("No"),0;
puts("Yes");
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int n;
    scanf("%d",&n);
    if(n<10) printf("%d",n);
    if(n>=10 && n<100) printf("%d",9);
    if(n>=100 && n<1000){
        int left1 = n-100+1;
        printf("%d",9+left1);
    }
    if(n>=1000 && n < 10000) printf("%d",909);
    if(n>=10000 && n < 100000){
        int left2 = n-10000+1;
        printf("%d",left2+909);
    }
    if(n==100000)printf("%d",90909);
    return 0;
}

Measured memory_bytes: 128
n=int(input())
r=[tuple(map(int,input().split())) for _ in range(n)]
b=[tuple(map(int,input().split())) for _ in range(n)]
r=sorted(r)
b=sorted(b)
for x,y in b:
  p,q=-1,-1
  for i,j in r:
    if i<x and j<y and j>q:p,q=i,j
  if (p,q) in r:r.remove((p,q))
print(n-len(r))

Measured memory_bytes: 66260
#include <cmath>
#include <iostream>

using namespace std;

int main() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int xx = -(x1 - x2);
  int yy = -(y1 - y2);
  int x3 = x2 - yy;
  int y3 = y2 + xx;
  int x4 = x1 - yy;
  int y4 = y1 + xx;
  cout << x3 << " " << y3 << " ";
  cout << x4 << " " << y4 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
const lli mod=1e9+7;
const lli pINF=100000000000000000;
const lli nINF=-LLONG_MAX;
void fast() {std::ios::sync_with_stdio(false);cin.tie(NULL);}
lli power(lli a,lli b){lli ans=1;while(b!=0){ if(b%2==1){ans*=a;}b/=2;a*=a;} return ans;}
lli invmod(lli a) {return pow(a,mod-2);}
#define vi vector<int>
#define vlli vector<lli>
#define pb push_back
#define mp make_pair
#define F first
const int INF = 0x3f3f3f3f ;
#define PII pair<int,int>
#define S second
#define si(n) scanf("%d",&n)
#define sli(n) scanf("%lld",&n)
#define printi(n) printf("%d\n",n)
#define printli(n) printf("%lld\n",n)
#define all(v) v.begin(),v.end()
#define forn(i,n) for(int i=0;i<n;i++)
void print(int a[],int n){for(int i=0;i<n;i++) cout<<a[i]<<" ";}
char a[55][55];

int main() {
    int n,m;
    si(n);si(m);
    
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++) cin>>a[i][j];
    }
    
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(a[i][j]=='#'){
                if(a[i-1][j]!='#' && a[i][j-1]!='#' && a[i+1][j]!='#' && a[i][j+1]!='#'){
                    cout<<"No\n";
                    return 0;
                }
            }
        }
    }
    
    cout<<"Yes\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define mod 1000000007
#define bitcount __builtin_popcountll
#define ll long long
#define pb push_back
#define pi pair<int,int>
#define pii pair<pi,int>
#define mp make_pair
int main()
{
	int i,j,k;
	ll n,a,b;
	slld(n);
	slld(a);
	slld(b);
	if(n==1)
	{
		if(a==b)
			printf("1\n");
		else
			printf("0\n");
		return 0;
	}
	if(a>b)
	{
		printf("0\n");
		return 0;
	}
	if(n==2)
	{
		printf("1\n");
		return 0;
	}
	ll mini = (n-1)*a + b;
	ll maxi = (n-1)*b + a;
	printf("%lld\n", max(0ll,maxi-mini+1));
	return 0;
}

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

int main(void){
	char s[11],t[11];
	int n=0;
	do{
		scanf("%c",&s[n]);
		n++;
	}while(s[n-1]!='\n');
	for(int i;i<n;i++){
		scanf("%c",&t[i]);
		//printf("%c",t[i]);
	}
	for(int i=0;i<n-1;i++){
		//printf("%c,%c\n",s[i],t[i]);
		if(s[i]!=t[i]){
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 1652
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);

	long A, B;

	A = sc.nextLong();
	B = sc.nextLong();

        if ((A - B) % 2 == 0) {
	    long C = A - B;
	    if (C < 0) {
		C *= -1;
		System.out.println((C / 2) + A);
	    } else {
		System.out.println((C / 2) + B);
	    }
	} else {
	    System.out.println("IMPOSSIBLE");
	}
    }
}

Measured memory_bytes: 20820
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class ConnectNodeInfo{
	vector<vector<pair<ll,ll>>> graph;
public:
	ConnectNodeInfo(int node_num){
		graph.resize(node_num);
	}
	void AddNonDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
		graph[v].emplace_back(u,w);
	}
	void AddDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
	}
	vector<pair<ll,ll>>& operator[](ll index){
		return graph[index];
	}
	size_t size(){return graph.size();}
};

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

	int N=in(),X=in()-1,Y=in()-1;
	ConnectNodeInfo connect(N);
	REP(i,N-1){
		connect.AddNonDirectionalConnection(i,i+1,1);
	}
	connect.AddNonDirectionalConnection(X,Y,1);

	vector<vector<int>> D(N,vector<int>(N,0));
	vector<int> S(N,0);
	REP(i,N){
		for(int j=i+1;j<N;j++){
			if(j<=X) D[i][j] = j-i;
			else if(j>X && j<=Y){
				if(i<=X){
					D[i][j] = min({j-i,X-i+1+Y-j});
				}
				else{
					D[i][j] = min({j-i,i-X+1+Y-j,Y-i+1+j-X});
				}
			}
			else if(j>Y){
				if(i<Y){
					D[i][j] = min(j-i,abs(i-X)+1+j-Y);
				}
				else D[i][j] = j-i;
			}
			S[D[i][j]]++;
		}
	}
	REP(i,N-1){
		out(S[i+1]);
	}
	return 0;
}


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

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		int w=in.nextInt();
		int h=in.nextInt();
		int x=in.nextInt();
		int y=in.nextInt();
		double ans=(double)w*(double)h/2;
		int a=0;
		if(x+x==w&&y+y==h)
			a=1;
		System.out.println(ans+" "+a);
	}
}
	

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


int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    int sum=0;
    for(int i=0; i<N; i++){
        cin >> a[i];
        sum += a[i];
    }
    double ave = (double)sum/N;

    double mi=1e9;
    for(int i=0; i<N; i++){
        mi = min(mi,abs(a[i]-ave));
    }
    vector<int> s;
    for(int i=0; i<N; i++){
        if(mi == abs(a[i]-ave)){
            s.push_back(i);
        }
    }
    sort(s.begin(),s.end());
    cout << s[0] << endl;
}

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

int main()
{
    vector<int> cards = {0,0,0} ;
    cin >> cards[0] >> cards[1] >> cards[2];
    
    sort(cards.begin(), cards.end());

    cout << cards[0] + cards[1] + cards[2] * 10 << "\n";

	return 0;
}


Measured memory_bytes: 256
class fenwick_tree():
    n=1
    data=[0 for i in range(n)]
    def __init__(self,N):
        self.n=N
        self.data=[0 for i in range(N)]
    def add(self,p,x):
        assert 0<=p<self.n,"0<=p<n,p={0},n={1}".format(p,self.n)
        p+=1
        while(p<=self.n):
            self.data[p-1]+=x
            p+=p& -p
    def sum(self,l,r):
        assert (0<=l and l<=r and r<=self.n),"0<=l<=r<=n,l={0},r={1},n={2}".format(l,r,self.n)
        return self.sum0(r)-self.sum0(l)
    def sum0(self,r):
        s=0
        while(r>0):
            s+=self.data[r-1]
            r-=r&-r
        return s

N,Q=map(int,input().split())
a=[int(i) for i in input().split()]
FT=fenwick_tree(N)
for i in range(N):
    FT.add(i,a[i])
for i in range(Q):
    t,a,b=map(int,input().split())
    if t==0:
        FT.add(a,b)
    else:
        print(FT.sum(a,b))


Measured memory_bytes: 154588
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n = II()
    if n % 2:
        print(2 * n)
    else:
        print(n)
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


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

using namespace std;

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

  vector<int> a;

  for (int i = 0; i < n; ++i) {
    int m;
    cin >> m;
    a.push_back(m);
  }

  vector<int> sorted;
  copy(a.begin(), a.end(), back_inserter(sorted));
  sort(sorted.begin(), sorted.end());
  int max = sorted[n - 1];
  int smax = sorted[n - 2];

  for (int i = 0; i < n; ++i) {
    int pre = a[i];

    if (pre == max) {
      cout << smax << endl;
    } else {
      cout << max << endl;
    }
  }
}

Measured memory_bytes: 3316
#include<stdio.h>
int main(void)
{
	char s[12];
	scanf("%s",s);
	int i,max;
	int count = 0;
	max =0;
	for(i=0;i<11;i++){
		if('A'==s[i] || 'C'==s[i] || 'G'==s[i] || 'T'==s[i]){
			count++;
		}else{
			if(count > max)max = count;
			count = 0;
		}
	}
	printf("%d",max);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define sz(a) signed(a.size())
using namespace std;

void solve(){
	ll m,n;
	cin>>n>>m;
	ll sum = 0;
	vector<ll> ar(n+1,0);
	for(ll i=1;i<=n;i++){
	cin>>ar[i];
	sum +=ar[i];
	}
	sort(ar.begin(),ar.end());
	ll idx = lower_bound(ar.begin()+1,ar.end(),ceil(sum*1.0/(4*m))) - (ar.begin()+1);
	if(n-idx>=m)
	cout<<"Yes";
	else
	cout<<"No";
	
}

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

	


Measured memory_bytes: 256
#include <stdio.h>
#define N -1000000000
 
int main()
{
  int i, n, k, max=N, min;
  scanf("%d%d", &n, &min);
  for(i = 1; i < n; i++){
    scanf("%d", &k);
    if(max < k-min) max = k - min; 
    if(k < min) min = k;
  }
  printf("%d\n", max);
  return 0;
}

Measured memory_bytes: 596
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	@SuppressWarnings("unchecked")
	private void run() {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			int m = scanner.nextInt();
			if ((n | m) == 0)
				break;
			List<Edge>[] lists = new ArrayList[n];
			for (int i = 0; i < n; i++) {
				lists[i] = new ArrayList<Edge>();
			}
			for (int i = 0; i < m; i++) {
				int from = scanner.nextInt() - 1;
				int to = scanner.nextInt() - 1;
				int cost = scanner.nextInt();
				lists[from].add(new Edge(to, cost));
				lists[to].add(new Edge(from, cost));
			}
			int g = n - 1;
			PriorityQueue<Edge> pq = new PriorityQueue<Edge>();
			pq.offer(new Edge(0, 0, 2));
			int[][] cost = new int[3][n];
			for (int i = 0; i < 3; i++)
				Arrays.fill(cost[i], 1 << 20);
			cost[2][0] = 0;
			while (!pq.isEmpty()) {
				Edge edge = pq.poll();
				if (edge.to == g && edge.ticket != 1) {
					System.out.println(edge.cost);
					break;
				}

				for (Edge e : lists[edge.to]) {
					if (edge.ticket == 1) {
						pq.offer(new Edge(e.to, edge.cost, 0));
					} else {
						if (edge.ticket == 2) {
							pq.offer(new Edge(e.to, edge.cost, 1));
						}
						if (cost[edge.ticket][e.to] > edge.cost + e.cost) {
							cost[edge.ticket][e.to] = e.cost + edge.cost;
							pq.offer(new Edge(e.to, edge.cost + e.cost,
									edge.ticket));
						}
					}
				}
			}
		}
	}

	class Edge implements Comparable<Edge> {
		int to, cost, ticket;

		public Edge(int to, int cost, int ticket) {
			super();
			this.to = to;
			this.cost = cost;
			this.ticket = ticket;
		}

		public Edge(int to, int cost) {
			super();
			this.to = to;
			this.cost = cost;
		}

		@Override
		public String toString() {
			return "Edge [to=" + to + ", cost=" + cost + ", ticket=" + ticket
					+ "]";
		}

		@Override
		public int compareTo(Edge o) {
			if (this.cost == o.cost)
				return o.to - this.to;
			return this.cost - o.cost;
		}

	}
}

Measured memory_bytes: 33652
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,b,a) for (ll i = b - 1; i >= a; i--)
#define all(v) v.begin(), v.end()
#define maxe(v) *max_element(v.begin(), v.end())
#define mine(v) *min_element(v.begin(), v.end())
#define pb push_back
#define pf push_front
//#define rem 1000000007
#define cont continue
#define PI 3.141592653589793238462643383279502
#define debug(n1) cout<<"debug... "<<n1<<"\n"
const ll INF=(1ll<<60)-1;//ll ans = 3e18 + 5;
/////////////////////////

int main() {
	//code
	int tc=1;
	//cin>>tc;
	while(tc--)
	{
	    int n;
        cin>>n; // multiple of n of form 7777...
        int states[n]={};
        queue<pair<int,int>> q; // initial number is 7
        q.push({1,7%n}); // 1 is term number and 7%n is remainder 
        while( !q.empty() )
        {
            pair<int,int> temp=q.front();
            q.pop();
            int rem = temp.second;
            int num = temp.first;
            states[rem]=num; // getting this state in numth number
            // next number will be 7*10+7 ... but we only store % here
            rem = ( (rem*10)%n + 7 )%n;
            if( states[rem] == 0 )
            q.push({num+1,rem});
        }
        if( states[0] )
        cout<<states[0]<<'\n';
        else 
        cout<<-1<<'\n';
	}
	return 0;
}


Measured memory_bytes: 7492
#include <bits/stdc++.h>
using namespace std;
 
#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vl(p) vector<p>
#define W while
#define For(i,s,x) for(i=s;i<x;i++)
#define Fore(i,s,x) for(i=s;i<=x;i++)
#define FOR(i,x) for(i=0;i<x;i++)
#define Rof(i,s,x) for(i=s;i>=x;i--)
#define all(v) v.begin(),v.end()
#define it(r,v) for(auto r=v.begin();r!=v.end();r++)
#define pb push_back
#define in insert
#define sz size()
#define F first
#define S second
#define nl cout<<"\n"
#define pr(a) cout<<a<<" "
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define pr3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define mod 1000000007
#define mp make_pair

  int main()
  {
    ll n,k;
    cin>>n>>k;
    ll a[n+1]={0},i;
    while(k--)
    {
        ll d,c;
        cin>>d;
        for(i=0;i<d;i++)
        {
           cin>>c;
           a[c]=1;
        }
    }
    ll count=0;
    for(i=1;i<n+1;i++)
    {
        if(a[i]==0)
        count++;
    }
    cout<<count;
     }

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//FUNCTION

void solve(void)
{
  string str;
  cin>>str;
  string str2;
  for (int i = 0; i < str.size()-1; i++)
  {
    if(str[i] == 'A')
    {
      str2+='A';
    }
    else if(str[i] =='B' && str[i+1] =='C')
    {
      str2+='X';
      i++;
    }
    else
    {
      str2 += str[i];
    }
  }
  str2 += str[str.size()-1];
  // DEBUG(str2);
  int ANS = 0;
  for (int i = str2.size()-1; i >= 0; i--) {
      static int Xcnt = 0;
      if(str2[i] == 'X')
      {
        Xcnt++;
      }
      else if(str2[i] =='A')
      {
        ANS += Xcnt;
        str2.erase(i);
      }
      else
      {
        Xcnt = 0;
      }
  }
  cout<<ANS<<endl;
  
  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 100001
const ll mod = 1e9+7;


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int ans = c-(a-b);
    if (ans<0) ans = 0;
    cout << ans << endl;

}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int w, d, hw[11], hd[11], s, t;
	bool f, vis[11];
	
	while(1){
		cin >> w >> d;
		if(w == 0 && d == 0){
			break;
		}
		
		for(int i = 0; i < w; i++){
			cin >> hw[i];
		}
		for(int i = 0; i < d; i++){
			cin >> hd[i];
		}
		fill(vis, vis+11, true);
		s = 0;
		for(int i = 0; i < w; i++){
			for(int j = 0; j < d; j++){
				if(hd[j] == hw[i]){
					if(vis[j]){
						vis[j] = false;
					} else {
						j++;
						for(; j < d; j++){
							if(hd[j] == hw[i] && vis[j]){
								vis[j] = false;
								break;
							}
						}
					}
					break;
				}
			}
			s += hw[i];
		}
		
		for(int i = 0; i < d; i++){
			if(vis[i]){
				s += hd[i];
			}
		}
		
		cout << s << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int x, a, b;
	cin >> x >> a >> b;
	if (abs(x-a)>abs(x-b)) {
		cout << "B" << endl;
	}
	else {
		cout << "A" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n;
vector<i64> a, b;
int main() {
  cin >> n;
  read_n(a, n);
  read_n(b, n);

  queue<i64> que;
  for (i64 i = 0; i < n; ++i) {
    que.push(i);
  }

  i64 ans = 0;
  while (!que.empty()) {
    i64 i = que.front();
    que.pop();
    i64 l = (i - 1 + n) % n,
        r = (i + 1) % n,
        x = b[i] - a[i],
        y = b[l] + b[r];
    if (x >= y) {
      b[i] = x % y + a[i];
      ans += x / y;
      que.push(l);
      que.push(r);
    }
  }

  for (i64 i = 0; i < n; ++i) {
    if (a[i] != b[i]) ans = -1;
  }
  
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,a,b;
	cin>>n>>a>>b;
	long long s=0;
	for(int i=a;i<=b;i++)
	{
		for(int j=i;j<=n;j++)
		{
			int l=0;
			for(int k=j;k>0;k/=10)
			l+=k%10;
			if(l==i)
			s+=j;
		}
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int main()
{
	ll p=1,n;
	cin >> n;
	for(int i=1;i<=n;i++){
		p=i*p%1000000007;
	}
	cout << p << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <cctype>

using namespace std;
// for loop
#define F(i, L, R) for(int i = L; i < R; i++)
#define FE(i, L, R) for(int i = L; i <= R; i++)
// for (reversed)
#define FR(i, L, R) for(int i = L; i > R; i--)
#define FRE(i, L, R) for(int i = L; i >= R; i--)

// data types
#define ul unsigned long
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned shoft

// vectors
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define ALL(c) (c).begin(),(c).end()
#define last(vec) vec.size()-1
#define lastEle(vec) vec[last(vec)]
#define pb push_back
#define InputV(a, n) F(i,0,n){long l; cin >> l; a.pb(l);}

// debug
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i==R?'\n':' ')
#define printAF(a, L) printA(a, 0, L-1)
#define printV(a) printA(a, 0, a.size()-1)

// utils
#define char2int(c) (c-'0')
#define bit(x, i) (x&(1<<i))
#define space ' '
#define PI 3.14159265358979323

int gcd(int a, int b) {
    if(a < b)swap(a,b);
    while(1) {
        int r = a % b;
        if(r == 0)break;
        a = b;
        b = r;
    }
    return b;
}

int main() {
    int k;
    cin >> k;
    long ans = 0;
    FE(i, 1, k){
        FE(j, 1, k){
            FE(l, 1, k){
                int gcd_1 = gcd(j, l);
                ans += gcd(gcd_1 , i);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3596
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n,m;
    cin >> n >> m;
    cout << (n-1)*(m-1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  ll n;
  cin >> n;
  ll tmp = n/15LL;
  ll ans = (60LL+60LL+120LL*(tmp-1))/2*tmp;
  ll m = n%15;
  if(m==0){
    cout << ans << endl; return 0;
  } else if(m==1){
    cout << ans+1+15*tmp << endl; return 0;
  } else if(m<=3){
    cout << ans+3+30*tmp << endl; return 0;
  } else if(m<=6){
    cout << ans+7+45*tmp << endl; return 0;
  } else if(m<=7){
    cout << ans+14+60*tmp << endl; return 0;
  } else if(m<=10){
    cout << ans+22+75*tmp << endl; return 0;
  } else if(m<=12){
    cout << ans+33+90*tmp << endl; return 0;
  } else if(m<=13){
    cout << ans+46+105*tmp << endl; return 0;
  } else if(m<=15){
    cout << ans+60+120*tmp << endl; return 0;
  } 
  return 0;
}


Measured memory_bytes: 3596
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
un = 0
ov = []
ans = 0
for i in range(n):
    if a[i] < b[i]:
        un += b[i] - a[i]
        ans += 1
    elif a[i] > b[i]:
        ov.append(a[i] - b[i])
if un == 0:
    print(0)
    exit()
ov.sort(reverse = True)
for i in ov:
    un -= i
    ans += 1
    if un <= 0:
        print(ans)
        exit()
print(-1)

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

using namespace std;



int main(){

    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout.precision(20);
    //freopen("intput.txt", "r", stdin);

    int n;
    cin >> n;
    if(n<1000) cout << "ABC" << endl;
    else cout << "ABD" << endl; 

}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main() {
    long n;
    int k;
    cin >> n >> k;
    
    vector <bool> disliked (10);
    for (int i = 0; i < k; i++) {
        int digit;
        cin >> digit;
        disliked[digit] = true;
    }
    
    bool found = false;
    
    while(!found) {
        found = true;
        string str = to_string(n);
        for (int i = 0; i < str.length(); i++) {
            if (disliked[stoi(str.substr(i,1))]) {
                found = false;
                break;
            }
        }
        n++;
    }
    cout << n-1 << endl;    
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {
	int n, x;
	while (1) {
		scanf("%d %d", &n, &x);
		if (n == 0 && x == 0)break;
		int count = 0;
		for (int j = 1; j <= n; j++) {
			for (int k = 1; k <= n; k++) {
				for (int l = 1; l <= n; l++) {
					if (j + k + l == x && j != k && k != l && l != j)count++;
				}
			}
		}
		printf("%d\n", count / 6);
	}
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

bool dp[90][90][14000];

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    long long N,M;cin >> N >> M;
    if(N == 1 && M == 1){
        cout << 1 << endl;
    }
    else if(N == 1 || M == 1){
        cout << max(0LL,max(N,M)-2) << endl;
    }
    else if(N == 2 || M == 2){
        cout << N*M - max(N,M)*2 << endl;
    }
    else{
        cout << N*M - 2*(N-2)-2*M << endl;
    }
}

Measured memory_bytes: 256
import itertools
import math
N = int(input())
A = []
for i in range(N):
    B = [int(i) for i in input().split()]
    A.append(B)
C = []
for i in range(N):
    C.append(i)
X = list(itertools.combinations(C,2))
LENGEs = []
for i in X:
    Y = A[i[0]]
    Z = A[i[1]]
    lenge = math.sqrt((Y[0] - Z[0]) ** 2 + (Y[1] - Z[1]) ** 2)
    LENGEs.append(lenge)
M = 0
for i in LENGEs:
    M += i
ans = (N-1 ) * (M / len(LENGEs))

print(ans)

Measured memory_bytes: 3064
// 1_6_B
#include<stdio.h>

int main(void)
{
	int foundCards[4][13] = {};
	int n, i, rank;
	char suit;

	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf("%s %d", &suit, &rank);
		if(suit == 'S'){
			foundCards[0][rank-1] = 1;
		}else if(suit == 'H'){
			foundCards[1][rank-1] = 1;
		}else if(suit == 'C'){
			foundCards[2][rank-1] = 1;
		}else if(suit == 'D'){
			foundCards[3][rank-1] = 1;
		}
	}

	for(i = 0; i < 13; i++){
		if(!foundCards[0][i]){
			printf("S %d\n", i+1);
		}
	}

	for(i = 0; i < 13; i++){
		if(!foundCards[1][i]){
			printf("H %d\n", i+1);
		}
	}

	for(i = 0; i < 13; i++){
		if(!foundCards[2][i]){
			printf("C %d\n", i+1);
		}
	}

	for(i = 0; i < 13; i++){
		if(!foundCards[3][i]){
			printf("D %d\n", i+1);
		}
	}
	return 0;
}

Measured memory_bytes: 596
n = int(input())
s = input()
A = [0 for i in range(n+2)]
A2 = [0 for i in range(n+2)]
for i in range(0,n):
  ndA = i +1
  ndA2 = n-i
  A[ndA] = A[ndA-1] + 1 if s[i]=="W" else A[ndA-1]
  A2[ndA2] = A2[ndA2+1] + 1 if s[n-i-1]=="E" else A2[ndA2+1]
A[n+1]=A[n]
A2[0]=A2[1]
#print(A)
#print(A2)
print(min([A[i-1]+A2[i+1] for i in range(1,n+1)]))

Measured memory_bytes: 29728
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    if (input[2] === input[3] && input[4] === input[5]) {
        console.log("Yes");
    } else {
        console.log("No");   
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int main(){
    int a, b, c, d, e, f;
    scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);
    int t[2][f+1];
    rep(i, 0, f+1){
        t[0][i] = 0;
        t[1][i] = 0;
    }
    t[0][0] = 1;
    t[1][0] = 1;
    rep(i, 0, f+1){
        if(t[0][i]){
            if(i+100*a <= f){
                t[0][i+100*a] = 1;
            }
            if(i+100*b <= f){
                t[0][i+100*b] = 1;
            }
        }
        if(t[1][i]){
            if(i+c <= f){
                t[1][i+c] = 1;
            }
            if(i+d <= f){
                t[1][i+d] = 1;
            }
        }
    }
    double ans = 0;
    int ans_i = 100*a, ans_j = 0;
    rep(i, a, f){
        rep(j, 0, f){
            if(t[0][i]==1 && t[1][j]==1 && j*100 <= i*e && i+j<=f){
                double buf = (double)100*j / (i+j);
                if(buf > ans){
                    ans = buf;
                    ans_i = i;
                    ans_j = j;
                }
            }
        }
    }
    printf("%d %d", ans_i+ans_j, ans_j);

    return 0;
}

Measured memory_bytes: 128
#include <list>
#include <cstdio>

using namespace std;

int main()
{
	int n, v;

	char c[12];

	list<int> l;

	scanf("%d", &n);

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

		if (c[0] == 'i')
		{
			scanf("%d", &v);

			l.push_front(v);
		}
		else if (c[6] == 'F')
		{
			l.pop_front();
		}
		else if (c[6] == 'L')
		{
			l.pop_back();
		}
		else
		{
			scanf("%d", &v);

			list<int>::iterator it = l.begin();

			while (it != l.end())
			{
				if (*it == v)
				{
					l.erase(it); break;
				}

				it++;
			}
		}
	}

	list<int>::iterator it = l.begin();

	while (it != l.end())
	{
		if (it == l.begin())
		{
			printf("%d", *it);
		}
		else
		{
			printf(" %d", *it);
		}

		it++;
	}

	printf("\n");

	return 0;
}

Measured memory_bytes: 33984
#include<stdio.h>
int main(){
    int K, S;
    int br=0;
    scanf("%d%d", &K, &S);
    
    for(int x=0; x<=K; x++){
            for(int y=0; y<=K; y++){
                    int z = S - x - y;
                            if(z>=0 && z<=K){
                                         br++;
                                         }
                    }
            }
    printf("%d", br);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>/
using namespace std;
string s; 
int i=0;
int main()
{    
    getline(cin,s); 
    while(i<s.length()){
        if(s[i]!='0'&&s[i]!='1'){
            if(i>0) s.erase(i-1,2),i--;
            else s.erase(i,1);
        }
        else i++;
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <queue>
#include <string.h>
#include <stdint.h>
#include <cmath>

#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);

#define ll long long
#define ld long double
#define ull unsigned long long
#define ut uint64_t

#define pb push_back
#define ins insert
#define er erase

#define fi(i, b) for (int i=0;i<b;i++)
#define fll(i, b) for (ll i=0;i<b;i++)
#define fla(i,a,b) for (ll i=a;i<b;i++)

#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vb vector<bool>
#define vst vector<string>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvl vector<vector<ll>> 


#define all(v) v.begin(), v.end()
#define lb lower_bound
#define ub upper_bound
#define mxe max_element
#define mne min_element

#define srt(v) sort(all(v))
#define rsrt(v) sort(v.rbegin(), v.rend())

#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second

#define mii map<int, int>
#define mll map<ll, ll>
#define umii unordered_map<int, int>
#define umll unordered_map<ll, ll>

#define si set<int>
#define sll set<ll>
#define usi unordered_set<int>
#define usll unordered_set<ll>
#define spii set<pii>
#define spll set<pll>

#define pqi priority_queue<int>
#define pqll priority_queue<ll>

 #define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a)*1ll * (b)) / gcd(a, b)

#define nl "\n"
using namespace std;

double PI = (acos(-1));

ll md = 1000000007;
ll ma = 998244353;

ll pw(ll a, ll b)
{
    ll c = 1, m = a;
    while (b){
        if (b & 1)c = (c * m);
        m = (m * m);
        b /= 2;
    }
    return c;
}

ll pwmd(ll a, ll b){
    ll c = 1, m = a;
    while (b){
        if (b & 1)
            c = ((c * m)) % md;
        m = (m * m) % md;
        b /= 2;
    }
    return c;
}


ll modinv(ll n)
{
    return pwmd(n, md - 2);
}
ll min(ll a,ll b){
    if(a>=b)return b;
    return a;
}
//vst vect={'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'};




// AB DEKHO JAADU...

void solve(){
    ll l[5];
    fi(i,5){cin>>l[i];
    }
    fi(i,5){
        if(l[i]==0)cout<<i+1<<nl;;
    }
    
}

    
    


int main(){
    fast;
    ll tests=1;
    //cin>>tests;
    while(tests--){
        solve();
    }

    return 0;
    }

// KHATAM HO GAYA:)...





Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const long long INF = 1LL << 60;

int n;
string s;

int main()
{
  cin >> n >> s;
  rep(i,s.size())
  {
    int x = s[i] - 'A';
    s[i] = 'A'+ (x+n)%26;
  }
  cout << s << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#define ll long long
#define pll pair<ll, ll>
#define mp make_pair
using namespace std;
ll n,m;
pll a[100010];
ll res=0;
int main()
{
	cin >>n>>m;
	for (int i=0;i<n;i++)
	{
		int x,y;
		cin >>x>>y;
		a[i]=mp(x,y);
	}
	sort(a,a+n);
	for (int i=0;i<n;i++)
	{
		if (!m) break;
		if (a[i].second<=m)
		{
			res+=a[i].first*a[i].second;
			m-=a[i].second;
		}
		else
		{
			res+=a[i].first*m;
			m=0;
		}
	}
	cout <<res;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<algorithm>
#include<iomanip>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(int i = a;i < b; i++)

int main() {

	int n;
	cin >> n;

	int maxi = 0, submaxi = 0;

	vector<int> a(n);
	rep(i, 0, n) {
		cin >> a[i];
		if (maxi >= a[i]) submaxi = max(submaxi, a[i]);
		maxi = max(maxi, a[i]);
	}

	rep(i, 0, n) {
		if (maxi == submaxi && a[i] == maxi) cout << maxi << endl;
		else if (maxi != submaxi && a[i] == maxi) cout << submaxi << endl;
		else cout << maxi << endl;
	}

	return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL<<60;

// 入力
int N;
long long W, weight[110], value[110]; // 品物の個数は 100 個なので少し余裕持たせてサイズ 110 に

// DPテーブル
long long dp[110][100100] = {0};


int main() {
  cin >> N >> W;
    for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];
 // DPループ
    for (int i = 0; i < N; ++i) {
for (int sum_w = 0; sum_w <= W; ++sum_w) {
 if (sum_w - weight[i] >= 0) {
 chmax(dp[i+1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
}
 // i 番目の品物を選ばない場合
            chmax(dp[i+1][sum_w], dp[i][sum_w]);
}
}
cout << dp[N][W] << endl;
}

Measured memory_bytes: 79360
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

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

ll mod = 1000000007;

ll gcd(ll a, ll b){
    if(a<b) swap(a,b);
    if(a%b == 0) return b;
    else return gcd(b,a%b);
}

// ll kaijo(int n){
//     ll ans = 1;
//     if(n == 0) return 1;
//     rep(i,n){
//         ans *= (i+1);
//         ans %= mod;
//     }
//     return ans;
// }

ll comb(int n, int r)
{
  if (n == r || r == 0)
    return 1;
  else
    return (comb(n, r - 1) * (n - r + 1) / r);
}

const int N_MAX = 100010;
ll Per[N_MAX] = {}; // n!
ll Per_inv[N_MAX] = {}; //(n!)^-1
 
ll nCr(ll n, ll r){
    if(n<r) return 0;
 
    if (n == r || r == 0)
        return 1;
    else
        return Per[n] * Per_inv[n-r] % mod * Per_inv[r] % mod;  
}
ll mod_pow(ll a, ll b){
    if(b==0) return 1;
 
    // 肩が奇数
    if(b%2==1){
        return a * mod_pow(a, b-1) % mod;
    }
    else{
        return mod_pow(a*a % mod, b/2) % mod;
    }
}

int main(){
    int s; cin >> s;
      // nCr高速化準備
    Per[1] = 1;
    FOR(i, 2, N_MAX){
        Per[i] = i * Per[i-1] % mod;
    }
 
    Per_inv[1] = 1;
    FOR(i, 2, N_MAX){
        Per_inv[i] = mod_pow(Per[i], 1000000005);
    }
 
    
    ll ans = 0;
    s -= 3;
    int cnt = 0;
    int s2 = s;
    ll now = 0;
    while(s>=0){
        ans +=  nCr(s2,cnt);
        ans %= mod;
        s2-=2;
        s-=3;
        cnt++;
    }
    cout << ans << endl;    
}

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

int main() {
  int H, R;
  cin >> H >> R;
  int ans;
  if (H<0 && H+R==0) {
    ans=0;
  } else if (H>=0 && (H-R>=0 || H-R<0)) {
    ans=1;
  } else if (H<0 && H+R<0) {
    ans=-1;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 3192
($A,$B,$C,$D,$E,$F)=glob<>;
$A*=100;
$B*=100;

for$x(0..$F/$A){
	for$y(0..($F-$A*$x)/$B){
		push@a,$A*$x+$B*$y;
	}
}
shift@a;
@a=sort{$a-$b}@a;

for$x(0..$F/$C){
	for$y(0..($F-$C*$x)/$D){
		push@b,$C*$x+$D*$y;
	}
}
@b=sort{$a-$b}@b;

$aa=$a[0];
for$a(@a){
	for$b(@b){
		last if$a+$b>$F||100*$b>$a*$E;
		if($b/($a+$b)>$z){
			$z=$b/($a+$b);
			$aa=$a;
			$bb=$b;
		}
	}
}

print$aa+$bb,$",$bb+0,$/


Measured memory_bytes: 10836
N = gets.to_i
A = gets.split.map &:to_i
(0...N).each do |i|
  A[i] -= i+1
end
A.sort!

def sunuke(b)
  (0...N).map do |i|
    (A[i]-b).abs
  end.inject(&:+)
end


l = A[0]
r = A[-1]
while true
  m = (l+r)/2
  sm = sunuke(m)
  if sunuke(m-1)<sm
    r = m
    next
  end
  if sm>sunuke(m+1)
    l = m
    next
  end
  puts sm
  exit
end


Measured memory_bytes: 43704