akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;

int HelloWorld(){
	cout << "Hello World" << endl;
	return 0;
}

int XCubic(){
	int x;
	cin >> x;
	if (1 <= x && x <= 100){
		x = x*x*x;
		cout << x << endl;
		return 0;
	}
	return 1;
}

int Rectangle(){
	int a, b, area, perimeter;

	cin >> a >>b;
	if (1 <= a && b <= 100){
		area = a*b;
		perimeter = (a + b) * 2;
		cout << area << " " << perimeter << endl;
		return 0;
	}
	return 1;
}

int Watch(){
	int S;
	cin >> S;
	
	
	int D = 60;
	int s = S%D;
	int m = (S / D) % D;
	int h = (S / D) / D;
	if (0 <= S && S <= 86400){
		printf("%u:%u:%u\n", h, m, s);
		return 0;
	}
	
	return 1;
}

int SmallLargeOrEqual(){
	int a, b;
	cin >> a >> b;
	if (!(a <= a && b <= 1000)) return 1;
	if (a < b)		cout << "a < b" << endl;
	else if (a > b) cout << "a > b" << endl;
	else			cout << "a == b" << endl;
	return 0;
}

int Range(){
	int a, b,c;
	bool flag = true;

	cin >> a >> b >> c;
	if (!(0 <= a && a <= 100)) return 1;
	if (!(0 <= b && b <= 100)) return 1;
	if (!(0 <= c && c <= 100)) return 1;

	if (!(a < b)) flag=false;
	if (!(b < c)) flag = false;

	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

int SortingThreeNumbers(){
	int a, b, c,temp;
	cin >> a >> b >> c;

	if (!(1 <= a && a <= 10000)) return 1;
	if (!(1 <= b && b <= 10000)) return 1;
	if (!(1 <= c && c <= 10000)) return 1;

	if (a > b){
		temp = a;
		a = b;
		b = temp;
	}
	if (b > c){
		temp = b;
		b = c;
		c = temp;
	}
	if (a > b){
		temp = a;
		a = b;
		b = temp;
	}

	printf("%u %u %u\n", a, b, c);
	
	
	return 0;
}

int CircleInARectangle(){
	int W, H, x, y, r;
	bool flag = true;
	cin >> W >> H >> x >> y >> r;
	if (!(-100 <= x && x <= 100)) return 1;
	if (!(-100 <= y && y <= 100)) return 1;
	if (!(0 <= W && W <= 100)) return 1;
	if (!(0 <= H && H <= 100)) return 1;
	if (!(0 <= r && r <= 100)) return 1;


	if ((x - r) < 0) flag = false;
	if ((y - r) < 0) flag = false;
	if (W < (x + r)) flag = false;
	if (H < (y + r)) flag = false;

	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

int PrintManyHelloWorld(){
	for (int i = 0; i < 1000; i++){
		HelloWorld();
	}
	return 0;
}

int PrintTestCases(){
	int x,i=1;
	
	while (1){
		cin >> x;
		if (x == 0) break;
		cout << "Case " << i++ << ": " << x << endl;
	}

	return 0;

}

int SwappingTwoNumbers(){
	int x, y, temp;
	
	for (int i = 0;; i++){
		cin >> x >> y;
		if (x == 0 && y == 0) break;
		if (x > y){
			temp = x;
			x = y;
			y = temp;
		}
		cout << x << " " << y << endl;
	}
	return 0;
}


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

int main(){
	//HelloWorld();
	//XCubic();
	//Rectangle();
	//Watch();
	//SmallLargeOrEqual();
	//Range();
	//SortingThreeNumbers();
	//CircleInARectangle();
	//PrintManyHelloWorld();
	//PrintTestCases();
	//SwappingTwoNumbers();
	HowManyDivisors();
	return 0;
}

Measured memory_bytes: 3104
#include<cstdio>
#include<cmath>
#include <stdlib.h>
#include<algorithm>

using namespace std;

int op(int x,int y,int a){
	if(a==0)return x+y;
	if(a==1)return x-y;
	if(a==2)return y-x;
	if(a==3)return x*y;
}

int judge_a(int a,int b,int c,int d,int x,int y,int z){
	return op(a,op(b,op(c,d,z),y),x);
}

int judge_b(int a,int b,int c,int d,int x,int y,int z){
	return op(op(a,b,x),op(c,d,y),z);
}

bool eq(int a,int b,int c,int d){
	if( (a==b)||(a==c)||(a==d)||(b==c)||(b==d)||(c==d) ){
		return false;
	}
	else{
		return true;
	}
}

int main(){
	int ans,num[4],a,b,c,d,x,y,z,t=1;
	char p[4]={'+','-','-','*'};
	while( scanf("%d %d %d %d",&num[0],&num[1],&num[2],&num[3]) != EOF ){
		if(num[0]+num[1]+num[2]+num[3]==0)break;
		t=1;
		for(a=0;a<4&&t;a++){
		for(b=0;b<4&&t;b++){
		for(c=0;c<4&&t;c++){
		for(d=0;d<4&&t;d++){
		if(eq(a,b,c,d)){
		for(x=0;x<4&&t;x++){
		for(y=0;y<4&&t;y++){
		for(z=0;z<4&&t;z++){
			if(judge_a(num[a],num[b],num[c],num[d],x,y,z)==10&&t){
				printf("(");
				if(x!=2){
					printf("%d%c",num[a],p[x]);
				}
				if(y==2){
					printf("(");
				}
				else{
					printf("(%d%c",num[b],p[y]);
				}
				if(z==2){
					printf("(%d-%d)",num[d],num[c]);
				}
				else{
					printf("(%d%c%d)",num[c],p[z],num[d]);
				}
				if(y==2){
					printf("-%d)",num[b]);
				}
				else{
					printf(")");
				}
				if(x==2){
					printf("-%d",num[a]);
				}
				printf(")\n");
				t=0;
			}
			if(judge_b(num[a],num[b],num[c],num[d],x,y,z)==10&&t){
				printf("(");
				if(z==2){
					if(y==2){
						printf("(%d-%d)-",num[d],num[c]);
					}
					else{
						printf("(%d%c%d)-",num[c],p[y],num[d]);
					}
					if(x==2){
						printf("(%d-%d)",num[b],num[a]);
					}
					else{
						printf("(%d%c%d)",num[a],p[x],num[b]);
					}
				}
				else{
					if(x==2){
						printf("(%d-%d)",num[b],num[a]);
					}
					else{
						printf("(%d%c%d)",num[a],p[x],num[b]);
					}
					printf("%c",p[z]);
					if(y==2){
						printf("(%d-%d)",num[d],num[c]);
					}
					else{
						printf("(%d%c%d)",num[c],p[y],num[d]);
					}
				}
				t=0;
				printf(")\n");
			}
		}}}}}}}}
		if(t)printf("0\n");
	}
	return 0;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

void func(long long N, long long K, std::vector<long long> A){

    lli small = 0,large = 1e9+1;

    SORT(A);
    while(small+1<large){
        lli middle = (small+large)/2;
        
        lli cnt = 0;
        REP(i,0,N){
            cnt += (A[i]-1)/middle;
        }
        LOG2(middle,cnt);
        if(cnt <= K){
            large = middle;
        }
        else{
            small = middle;
        }
    }
    cout<<large<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    func(N, K, std::move(A));
    return 0;
}


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

#define ll long long

bool check(int s, int p) {
    while(1 < s) {
        s = s&1 ^ (s>>1);
    }
    return p == s;
}

int main() {
    int N, M;
    cin >> N >> M;
    
    int line[M];
    fill(line, line + M, 0);

    for(int i = 0;i < M;i++) {
        int K;
        cin >> K;
        for(int k = 0;k < K;k++) {
            int s;
            cin >> s;
            line[i] ^= 1<<(s - 1);
        }
    }
    int p[M];
    for(int i = 0;i < M;i++) {
        cin >> p[i];
    }

    int count = 0;
    for(int i = 0;i < 1<<N;i++) {
        bool nya = true;
        for(int j = 0;j < M;j++) {
            nya = nya && check(line[j]&i, p[j]);
        }
        if(nya)count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int K, N;
    cin >> K >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    A.pb(K + A[0]);
    int ma = 0;
    rep(i, N) {
        ma = max(ma, A[i + 1] - A[i]);
    }
    output(K - ma);
    
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

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

#define bil ((ll)1e9)
#define mod ((ll)1e9+7)

int main(int argc,char* argv[]){
    string s;
    cin >> s;

    ll step=0;
    for(ll count=1;count<s.size();count++){
        if(s[count]!=s[count-1])
            step++;
    }

    cout << step << endl;

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int R,G,B,N; cin>>R>>G>>B>>N;
  int ans=0;
  REP(i,0,max(0LL,N/R)){
    REP(j,0,max((N-i*R)/G,0LL)){
      if((N-i*R-j*G)%B==0)
        ans++;
    }
  }
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v){
  const char* delimiter = "";
  for(const auto& x:v) cout << exchange(delimiter, ",") << x;
  return os;
}
int32_t main(){
  // const size_t LIM=1e5;
  size_t n,q; cin>>n>>q;
  string str; cin>>str;
  vector<size_t> sum(n+1); sum[0]=0; sum[1]=0;
  for(size_t i=2; i<n+1; ++i){
    if(str[i-2]=='A'&&str[i-1]=='C') sum[i]=sum[i-1]+1;
    else sum[i]=sum[i-1];
  }
  // cout<<sum<<endl;
  for(size_t i=0; i<q; ++i){
    size_t l,r; cin>>l>>r;
    cout<<sum[r]-sum[l]<<'\n';
  }
}

Measured memory_bytes: 1792
#include<stdio.h>
int main() {
  int i=0, j, flag=1, kawari, N, count=0;
  scanf("%d", &N);
  int A[N];
  for(i = 0; i < N; i++) {
    scanf("%d", &A[i]);
  }
  i = 0;
  while(flag == 1) {
    flag=0;
    for(j = N-1; j >= i+1; j--) {
      if(A[j] < A[j-1]) {
	kawari = A[j];
	A[j] = A[j-1];
	A[j-1] = kawari;
	flag = 1;
	count++;
      }
    }
    i++;
  }
  
  for(j = 0; j < N; j++) {
    if(j > 0) printf(" ");
    printf("%d", A[j]);
  }
  printf("\n%d\n", count);
  return 0;
}

Measured memory_bytes: 604
n = int(input())
a = [int(i) for i in input().split()]
mean = sum(a)/len(a)

tmp1 = 10000
tmp2 = 0

for i in range(len(a)):
  if abs(a[i]-mean) < tmp1 :
    tmp1 = abs(a[i]-mean) 
    tmp2 = i
    
#print(tmp1)
print(tmp2)

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

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

	int unit[N];

	for(int i = 0; i < N; i++){
		cin >> unit[i];
	}
	int ans = 0, min = 0;
	for(int i = 0; i < N; i++){
		min = 0;
		for(int j = 0; j < i; j++){
			if(unit[j] > unit[i]) min = 1;
		}
		if(min == 0) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''
#import copy

#import numpy as np
s=input().strip()
n=len(s)
f=True
for i in range(n//2):
    if s[i]==s[-i-1]:
        if s[i//4]==s[(-i-1)//4-(len(s)//2+1)]:
            if s[len(s)//2+1+i//4]==s[(-i-1)//4]:
                continue
            else:
                f=False
        else:
            f=False
    else:
        f=False
if f:
    print("Yes")
else:
    print("No")
#l=int(input())



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

int main() {
  int A, B;
  cin >> A >> B;

  int result = 0;
  if (A == B){
    result += A + A;
    cout << result << endl;
  }
  else{
    result += max(A,B);
    result += max(A-1,B-1);
  
    cout << result << endl;
  }  
}


Measured memory_bytes: 256
N = int(input())
T = list(map(lambda t: int(t) * 10, input().split()))
V = list(map(int, input().split())) + [0]
R = sum(T)

maxSpeed = [10**18] * (R + 1)
maxSpeed[0] = 0
maxSpeed[R] = 0
now = 0
for i, t in enumerate(T):
    now += t
    maxSpeed[now] = min(V[i], V[i + 1])

now = 0
for v, t in zip(V, T):
    for i in range(t + 1):
        maxSpeed[now + i] = min(maxSpeed[now + i], v)
    now += t

for t in range(1, R + 1):
    maxSpeed[t] = min(maxSpeed[t], maxSpeed[t - 1] + 0.1)
for t in range(R)[::-1]:
    maxSpeed[t] = min(maxSpeed[t], maxSpeed[t + 1] + 0.1)

base = 0
upper = 0
for v1, v2 in zip(maxSpeed, maxSpeed[1:]):
    base += min(v1, v2)
    upper += abs(v1 - v2)
ans = base + upper / 2
print(ans / 10)


Measured memory_bytes: 6260
#include <iostream>
 
using namespace std;
 
int main() {
    int N, A, B, C, D;
    string S;
    cin >> N >> A >> B >> C >> D >> S;
    
    S = "#" + S + "#";
 
    auto can_reach = [&](int start, int end) {
        for (int i = start; i <= end - 1; i++) {
            if (S[i] == '#' && S[i + 1] == '#') return false;
        }
        return true;
    };
 
    if (!can_reach(A, C) || !can_reach(B, D)) {
        cout << "No" << endl;
        return 0;
    }
 
    if (C > D) {
        bool snuke_can_over = false;
        for (int i = B; i <= D; i++) {
            if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') {
                snuke_can_over = true;
            }
        }
        if (!snuke_can_over) {
            cout << "No" << endl;
            return 0;
        }
    }
 
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 772
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int a[200010];
int main(){
    int n;cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    bool f=true;
    ll ans=0;
    for(int i=n-1;i>=0;i--){
        if(i){
            if(a[i]>a[i-1]){
                if(a[i]-a[i-1]==1){
                    ans++;
                }else{
                    f=false;
                    break;
                }
            }else{
                ans+=a[i];
            }
        }else{
            if(a[i]){
                f=false;
            }
        }
    }
    if(!f){
        cout<<-1<<endl;
        return 0;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int y = sc.nextInt();

		for ( int i=0; i<=x; i++ ) {
			int lg = i*2 + (x-i)*4;
			if ( lg==y ) {
				System.out.println("Yes");
				System.exit(0);
			}
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 35772
#include<stdio.h>

int main(void){
  int n,y,i,j;
  scanf("%d %d",&n,&y);
  for(i=0;i<=n;i++){
    for(j=0;j<=n;j++){
      int tmp;
      if(i+j>n) break;
      tmp = y-(10000*i+5000*j);
      if(0<=tmp && tmp/1000==n-(i+j)){
        printf("%d %d %d\n",i,j,n-(i+j));
        return 0;
      }
    }
  }
  printf("-1 -1 -1\n");
  return 0;
}

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

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

	int N = S.size();
	string s[4] = { "dreamer", "eraser", "dream", "erase" };
	string ans = "YES";
	int i = N;
	while( i > 0 ) {
		int flag = 0;
		for( int j = 0; j < 4; j++ ) {
			int sz = s[j].size();
			if( i - sz >= 0 && S.substr( i - sz, sz ) == s[j] ) {
				flag = 1;
				i -= sz;
				break;
			}
		}
		if( flag == 0 ) {
			ans = "NO";
			break;
		}
	}

	cout << ans << endl;
}


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

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

  ll n;
  cin >> n;

  vector<tuple<ll, ll, ll>> p(n);
  rep(i, n) {
    cin >> get<0>(p[i]) >> get<1>(p[i]) >> get<2>(p[i]);
  }

  ll h;

  // 中央座標を仮定
  rep(cx, 100 + 1) {
    rep(cy, 100 + 1) {
      // 高さを仮定
      FORm(it, p) {
        ll x = get<0>(*it);
        ll y = get<1>(*it);
        ll z = get<2>(*it);
        if (z > 0) {
          h = z + abs(x - cx) + abs(y - cy);
          break;
        }
      }
      bool correct = true;
      // 矛盾がないか確認
      FORm(it, p) {
        ll x = get<0>(*it);
        ll y = get<1>(*it);
        ll z = get<2>(*it);

        ll calc_z = h - abs(x - cx) - abs(y - cy);
        chmax(calc_z, 0ll);
        if (calc_z != z) {
          correct = false;
          break;
        }
      }
      if (correct) {
        cout << cx << " " << cy << " " << h << endl;
        return 0;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 256
A,B=map(int,input().split())
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
a=make_divisors(A)
b=make_divisors(B)
kouyakusuu=set(a)&set(b)
out=[]
kouho=sorted(list(kouyakusuu))
del kouho[0]
for a in range(len(kouho)-1):
    for b in range(a+1,len(kouho)):
        if kouho[b]%kouho[a]==0:
            out.append(kouho[b])
answer=set(out)
print(len(kouho)+1-len(answer))


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



int dp[80][245][245];
int E[80];
int N;
int dfs(int x,int y,int z){
	if( x == N-1 ) return y;
	else{
		if( dp[x][y][z] != -1 ) return dp[x][y][z];
		int ans = -1e9;
		ans = max(ans,dfs(x+1,z,x+2<N?E[x+2]:0));
		if(z&&x+2<N) ans = max(ans,dfs(x+1,z-1,y+E[x+2]));
		return dp[x][y][z] = ans;
	}
}
int main(){
	int T;
	cin >> T;
	while(T--){
		memset(dp,-1,sizeof(dp));
		cin >> N;
		for(int i = 0 ; i < N ; i++) cin >> E[i];
		cout << dfs(0,E[0],E[1]) << endl;
	}
}

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

using namespace std;
using ll = long long;

#define MOD 1000000007
template<int mod>
struct ModInt{
   int x;
   ModInt():x(0){}
   ModInt(long long y):x(y>=0?y%mod:(mod-(-y)%mod)%mod){}
   ModInt &operator+=(const ModInt &p){
	   if((x+=p.x)>=mod)x-=mod;
	   return *this;
   }
   ModInt &operator-=(const ModInt &p){
	   if((x+=mod-p.x)>=mod)x-=mod;
	   return *this;
   }
   ModInt &operator*=(const ModInt &p){
	   x=(int)(1LL*x*p.x%mod);
	   return *this;
   }
   ModInt &operator/=(const ModInt &p){
	   *this*=p.inverse();
	   return *this;
   }
   ModInt &operator^=(long long p){
	   ModInt res = 1;
	   for (; p; p >>= 1) {
		   if (p & 1) res *= *this;
		   *this *= *this;
	   }
	   return *this = res;
   }
   ModInt operator-()const{return ModInt(-x);}
   ModInt operator+(const ModInt &p)const{return ModInt(*this)+=p;}
   ModInt operator-(const ModInt &p)const{return ModInt(*this)-=p;}
   ModInt operator*(const ModInt &p)const{return ModInt(*this)*=p;}
   ModInt operator/(const ModInt &p)const{return ModInt(*this)/=p;}
   ModInt operator^(long long p)const{return ModInt(*this)^=p;}
   bool operator==(const ModInt &p)const{return x==p.x;}
   bool operator!=(const ModInt &p)const{return x!=p.x;}
   explicit operator int() const { return x; }
   ModInt operator=(const int p) {x = p; return ModInt(*this);}
   ModInt inverse()const{
	   int a=x,b=mod,u=1,v=0,t;
	   while(b>0){
		   t=a/b;
		   a-=t*b;
		   std::swap(a,b);
		   u-=t*v;
		   std::swap(u,v);
	   }
	   return ModInt(u);
   }
   friend std::ostream &operator<<(std::ostream &os,const ModInt<mod> &p){
	   return os<<p.x;
   }
   friend std::istream &operator>>(std::istream &is,ModInt<mod> &a){
	   long long x;
	   is>>x;
	   a=ModInt<mod>(x);
	   return (is);
   }
};
typedef ModInt<MOD> mint;



int main()
{
	int n; cin >> n;
	vector<mint> a(n);
	for(int i = 0; i < n; i++)cin >> a[i];
	mint sum = 0;
	mint ans = 0;
	for(int i = 0; i < n; i++) {
		ans += sum * a[i];
		sum += a[i];
	}
	cout << ans << endl;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	int ans=0;
	vector<int>a(1e5+1,0);
	for(int i=0;i<n;++i){
		int A; cin>>A;
		if(A>1e5)++ans;
		else ++a.at(A);
	}
	for(int i=1;i<=1e5;++i){
		int&v=a.at(i);
		if(v&&v!=i)ans+=v>i?v-i:v;
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N, K;
  cin >> N >> K;

  vector<ll> v;
  v.push_back(0);
  rep(i,N){
    ll a;
    cin >> a;
    v.push_back(a);
  }

  ll sum = 0;
  REP(i,1,K+1){
    sum += v[i];
  }

  REP(i,K+1,N+1){
    ll tmp = sum;
    sum += v[i];
    sum -= v[i-K];
    if(tmp < sum) cout << "Yes" << endl;
    else cout << "No" <<endl;
  }
  
  return 0;
}


Measured memory_bytes: 5364
# include <cstdio>
# include <cstring>
using namespace std;

int main()
{
	char a[100];
	char b[100];
	scanf("%s",a);
	int len = strlen(a);
	int k = 0;
	for(int i = 0;i < len;i++)
	{
		if(a[i] == 'B')
		{
			if(k != 0) 
				k--;
		}
		else
		{
			b[k++] = a[i];
		}
	}
	b[k] = '\0'; 
	printf("%s\n",b);
	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> A(Q), C(N, K-Q);
    rep(i, Q) {
        int a;
        cin >> a;
        a--;
        C[a] ++;
    }
    rep(i, N) {
        if (C[i] > 0) {
            cout << "Yes" << '\n';
        }else{
            cout << "No" << '\n';
        }
    }
}

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


Measured memory_bytes: 1408
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int> l(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> l.at(i);
	}
	sort(l.begin(), l.end());
	int sum = 0;
	bool ans = false;
	for (int i = 0; i < n; i++) {
		if (i + 1 == n) {
			if (sum > l.at(i)) {
				ans = true;
			}
			break;
		}
		sum += l.at(i);
	}
	string s = "No";
	if (ans) {
		s = "Yes";
	}
	cout << s << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>

int main(){
  
  long long int N, tmp;
  std::vector<long long int> B;
  long long int ans = 0;
  
  scanf("%lld", &N);
  for(long long int i = 0; i < N-1; i++){
    scanf("%lld", &tmp);
    B.push_back(tmp);
  }
  
  // solve problem
  ans += B[0];
  for(long long int i = 1; i < N-1; i++){
    ans += std::min(B[i], B[i-1]);
  }
  ans += B[N-2];
  
  std::cout << ans << std::endl;
  
  return 0;
}


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

int main() {
	int result[31];
	result[0] = 1;
	result[1] = 1;
	result[2] = 2;
	for (int i = 3; i < 31; i++) {
		result[i] = result[i - 1] + result[i - 2] + result[i - 3];
	}
	
	int n;
	while (cin >> n, n) {
		cout << result[n] / 3650 + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef long long ll;
typedef long lint;
typedef long double ld;

lint tri_n(lint a)
{
	a--;
	return ((a * (a+1)) / 2);
}


int  main()
{
	lint n ; cin >> n;
	vector<lint> a(n);
	unordered_map<lint, lint> mp;
	rep(i, n)
	{
		cin >> a[i];
		mp[a[i]]++;
	}
	lint sum = 0;
	set<lint> st;
	rep(i, n)
	{
		if (!st.count(a[i]))
		{
			st.insert(a[i]);
			sum += tri_n(mp[a[i]]);
		}
	}
	rep(i, n)
	{
		cout << sum - ( tri_n(mp[a[i]]) - tri_n(mp[a[i]] - 1) ) << endl;
	}
	return 0;
}

Measured memory_bytes: 15048
//Suffle
#include<iostream>
#include<string>
using namespace std;

int main()
{
	string n;
	int j, h;
	
	while(1){	
	cin >> n;
		if(n == "-")
		break;
	cin >> j;
		for(int i = 0; i < j; i++){
			cin >> h;

			n.insert(n.size(), n.substr(0, h));
			n.erase(0, h);


		}
	cout << n << endl;

	}
	return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)n; i++)
#define REPR(i, n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define FORR(i, m, n) for(int i=(int)m-1; i>=(int)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
typedef long long ll;
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }



void solve(long long N){
	ll min = 1e18;
	for (ll i=1; i*i<=N; i++) {
		if (N%i == 0) {
			ll a = i;
			ll b = N / i;
			chmin(min, a+b-2);
		}
	}
	cout << min << "\n";
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
import sys

s = input()
half = int( (len(s)-1) / 2 ) + 1
# print(s)

for i in range( half-1 ):
  if s[i] != s[-i-1]:
    print('No')
    sys.exit()
  
s1 = s[:half-1]
s2 = s[half:]
#print(s1, s2)

if s1 == s2:
  print('Yes')
else:
  print('No')



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

#define ll long long
#define pb push_back
#define vi vector<int>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define sizeOf(A) (sizeof(A))/(sizeof(A[0]))
#define odd(x) ((x) % (2))
#define fastio ios_base::sync_with_stdio(false), cin.tie(0);
const ll MOD = 1e9 + 7;

int main() {
    fastio;

    int n;
    cin >> n;
    int A[n];
    FOR(i, 0, n) {cin >> A[i];}
    if (odd(n)) {
        for (int i = n; i >= 1; i -= 2) {
            cout << A[i-1] << " ";
        }
        for (int i = 2; i <= n-1; i += 2) {
            cout << A[i-1] << " ";
        }
    } else {
        for(int i = n; i >= 2; i -= 2) {
            cout << A[i-1] << " ";
        }
        for (int i = 1; i <= n-1; i+= 2) {
            cout << A[i-1] << " ";
        }
    }

    return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int N;
int walk(const vector<vector<bool>>& V, int cur, set<int> done) {
    if (done.size() == N) return 1;
    int res = 0;
    rep(i, N) {
        if (done.count(i) == 0 && V[cur][i]) {
            set<int> d2 = done;
            d2.insert(i);
            res += walk(V, i, d2);
        }
    }
    return res;
}

int main() {
    int M; cin >> N >> M;
    vector<vector<bool>> V(N, vector<bool>(N,false));

    rep(i, M) {
        int a, b; cin >> a >> b;
        V[a - 1][b - 1] = true;
        V[b - 1][a - 1] = true;
    }
    set<int> done = {0};
    cout << walk(V, 0, done) << endl;
}


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

#define BUF (100005)

int N;
int A[BUF];
void input(void){
	scanf("%d",&N);
	for(int i=1;i<=N;i++){
		scanf("%d",&A[i]);
	}
}

int main(void){
	input();
	
	std::sort(A+1,A+N+1);
	int tmp[BUF];
	int cnt=0;

	int i=0;
	while(1){
		i++;
		if(i>=N)break;
		if( A[i]==A[i+1] ){
			tmp[cnt] = A[i];
			i++;
			cnt++;
		} 
	}

	/*
	for(int j=0;j<cnt;j++){
		printf("%d\n",tmp[j]);
	}
	*/



	if(cnt<2){
		printf("0\n");
	}else{
		long ans =(long)tmp[cnt-1]*(long)tmp[cnt-2]; 
		printf("%ld\n",ans);
	}
	
	return 0;
}


Measured memory_bytes: 768
n,m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

a[0]%=m
(n-1).times{|i|
  a[i]%=m
  a[i+1]=(a[i]+a[i+1])%m
}

h = Hash.new(0)
h[0] = 1
ans = 0
a.each{|t|
  ans += h[t]
  h[t]+=1
}

puts ans


Measured memory_bytes: 12164
# -*- coding: utf-8 -*-
import sys

def main():
    list = []
    for i in range(10):
        list.append(int(input()))
    list.sort(lambda num_1, num_2: num_2 - num_1)
    for i in range(3):
        print(list[i])

if __name__ == '__main__':
    main()

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

int main() {
  string s,t;
  cin>>s>>t;
  int ans=0;
  rep(i,3) {
    if (s[i]==t[i]) ans++;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
#include <set>
#include <string>
#include <cstring>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define FIXED_FLOAT(x)  std::fixed <<std::setprecision(7)<<(x)
#define MAX 100
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INF 1e9
#define ll long long
#define vi vector<int>
#define all(a) a.begin(), a.end()
#define pb push_back
#define ull unsigned long long


using namespace  std;
const int N = 1e3 + 5;


void solve(){
    ll k, a, b;
    cin >> k >> a >> b;
    for(int i=a;i <=b;i++) {
        if(i%k==0) {
            cout << "OK";
            return;
        }
    }
    cout << "NG";

}
int main() {
    fast;
    solve();

}



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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define pb push_back

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;

inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }

void solve() {

}

int main() {
  int k,x;
  cin >> k >> x;
  if( k * 500 >= x ) puts("Yes");
  else puts("No");
  return 0;
}


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

#define MAX_N 100000

int N;
ll T[MAX_N] = {0};
ll A[MAX_N] = {0};

void solve(){
    ll res = 1;
    ll t_max  = max(T[0], T[N - 1]);
    ll a_max = max(A[0], A[N - 1]);
    for(int i = 1; i < N - 1; i++){
        t_max = max(t_max, T[i]);
        a_max = max(a_max, A[i]);
        if(T[i - 1] < T[i] && A[i + 1] < A[i] && T[i] == A[i]){
            continue;
        }
        else if(T[i - 1] < T[i] && T[i] <= A[i]){
            continue;
        }
        else if(A[i + 1] < A[i] && A[i] <= T[i]){
            continue;
        }   
        else if(A[i] == A[i + 1] && T[i] == T[i - 1]) {
            res = (res * min(T[i], A[i])) % 1000000007;
        }
        else{
            cout << 0 << endl;
            return ;
        }
    }
    if(t_max != a_max){
        cout << 0 << endl;
        return ;
    }
    cout << res << endl;
    return ;
}


int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> T[i];
    }
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    solve();
    return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod 1000000007
#define MOD 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 1e18

int main()
{
    string s;
    cin >> s;
    int n=s.length(),p=2019;
    if(p==2)
    {
        lli ans=0;
        for(int i=s.length()-1;i>-1;i--)
        {
            int t=s[i]-'0';
            if(t%2==0)
                ans+=i+1;
        }
        cout << ans << endl;
    }
    else if(p==5)
    {
        lli ans=0;
        for(int i=s.length()-1;i>-1;i--)
        {
            int t=s[i]-'0';
            if(t%5==0)
                ans+=i+1;
        }
        cout << ans << endl;
    }
    else
    {
        int rarr[n];
        int t=s[n-1]-'0',prem=t%p,power=10;
        rarr[n-1]=prem;
        for(int i=s.length()-2;i>-1;i--)
        {
            t=s[i]-'0';
            prem=(power*t+prem)%p;
            rarr[i]=prem;
            power=(power*1LL*10)%p;
        }
        // for(int i=0;i<n;i++)
        //     cout << rarr[i] << " ";
        // cout << endl;
        int nnum[p];
        for(int i=0;i<p;i++)
            nnum[i]=0;
        nnum[rarr[0]]=1;
        lli ans=0;
        for(int i=1;i<n;i++)
        {
            ans+=nnum[rarr[i]];
            nnum[rarr[i]]+=1;
        }
        ans+=nnum[0];
        cout << ans << endl;
    }
}


Measured memory_bytes: 4472
#include <iostream>
#include <string>
#include <stdio.h>
#include <cstring>

using namespace std;
int n,m;
string st;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    cin >> st;
    bool kt = true;
    if (st[n] != '-') kt = false;
    int length = st.length();
    if (kt == true)
    for (int i = 0; i <= length; i++)
      if (st[i] == '-' && i != n)
      {
        kt = false;
        break;
      }
    if (kt == true) cout << "Yes"; else cout << "No";
}


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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;

	char buf[bufl],*s=buf,*t=buf;

	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}

	inline int ty()
	{
		int a=0;int b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 103;

int n,m,val[_][_],e[_][_],pir[_],ed[_],ans[_][_]={0};
vector<int> got[_][_];

int dfs(int x)
{
	for(int i=1;i<=n;i++)
	{
		if(ed[i] || !e[x][i])continue;
		ed[i]=1;
		if(!pir[i] || dfs(pir[i])){pir[i]=x;return 1;}
	}
	return 0;
}

int main()
{
	n=ty(),m=ty();
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			val[i][j]=ty(),got[i][(val[i][j]-1)/m+1].emplace_back(val[i][j]);
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=n;j++)
			for(int k=1;k<=n;k++)
				e[j][k]=!got[j][k].empty();
		memset(pir,0,sizeof(pir));
		for(int j=1;j<=n;j++)memset(ed,0,sizeof(ed)),assert(dfs(j));
		for(int j=1,x;j<=n;j++)x=pir[j],ans[x][i]=got[x][j].back(),got[x][j].pop_back();
	}

	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)printf("%d%c",ans[i][j]," \n"[j==m]);
	for(int i=1;i<=m;i++)
	{
		int temp[_];
		for(int j=1;j<=n;j++)temp[j]=ans[j][i];
		sort(temp+1,temp+n+1);
		for(int j=1;j<=n;j++)ans[j][i]=temp[j];
	}
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)printf("%d%c",ans[i][j]," \n"[j==m]);

	return 0;
}


Measured memory_bytes: 1024
m=int(input())
d=[]
c=[]
z=0
for i in range(m):
    a,b=map(int,input().split())
    d.append(a)
    c.append(b)
    z+=a*b
ans=0
print(sum(c)-1+(z-1)//9)
exit()
def ika(x,y):
    ret=0
    z=x*y
    ret+=y-1
    while z>9:
        s=list(str(z))
        ret+=len(s)-1
        i5=0
        for i in range(len(s)):
            s[i]=int(s[i])
        g=0
        while g<len(s)-1:
            if s[g]+s[g+1]>=10:
                #ret+=1
                g+=2
            else:
                g+=1
        z=sum(s)
        ret+=(z-10)//10
    return [ret,z]
ka=[]
for i in range(m):
    f=ika(d[i],c[i])
    ans+=f[0]
    ka.append(f[1])
print(ans+ika(sum(ka),1)[0]+len(ka)-1)


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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

#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 pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int a,b;
	cin >> a >> b;
	if(a==1)a=14;
	if(b==1)b=14;
	if(a>b){
		cout << "Alice\n";
	}else if(b>a){
		cout << "Bob\n";
	}else{
		cout << "Draw\n";
	}
	return 0;
}


Measured memory_bytes: 256
xs, ys, xt, yt = map(int, input().split())
p1 = 'R' * (xt - xs) + 'U' * (yt - ys)
p2 = 'L' * (xt - xs) + 'D' * (yt - ys)
p3 = 'D' + 'R' * (xt - xs + 1) + 'U' * (yt - ys + 1) + 'L'
p4 = 'U' + 'L' * (xt - xs + 1) + 'D' * (yt - ys + 1) + 'R'
print(p1 + p2 + p3 + p4)

Measured memory_bytes: 38512
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i=(ll)(r);i<(ll)(n);++i)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define P(x) cout<<(x)<<endl;
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
ll n, m, k, ans, sum, count = 0; string s; char c;

int main(){
    cin >> n;
    vi v(n);
    REP(i, n) {
        cin >> v[i];
    }
    REP(i,n) {
        FOR(j,i+1,n) {
          //cout << v[i] << ' ' << v[j] << endl;
          ans = chmax(ans, abs(v[i] - v[j]));
        }
    }
    P(ans)
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  int32_t main()
  {        

      IOS
      map<char,int> mp;


      string s;
      cin>>s;

      for(int i=0;i<s.length();i++)
      {
        mp[s[i]]++;
      }

      bool ok=true;

      if(mp.size()!=2)
      {
        ok=false;

      }
      for(auto i:mp)
      {
        if(i.second!=2)
        {
          ok=false;
        }
      }


      if(ok)
      {
        cout<<"Yes";
      }
      else
      {
        cout<<"No";
      }

    return 0;
 
     }

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

int main() {
    int N;
    cin >> N;
    bool flag = false;
    for (int i = 0; i <= 100; i++ ){
        for (int j = 0; j <= 100; j++){
            if (4 * i + 7 * j == N){
                flag = true;
            }
        }
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
x,n = map(int, input().split())

if n < 1:
  print(x)
  exit()

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

data.sort()

result = [(abs(x - i), i) for i in range(data[0]-1, data[-1]+2) if i not in data]
r = sorted(result, key=lambda x: x[0])

print(r[0][1])

Measured memory_bytes: 9196
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cctype>  // std::islower(), std::isupper(), std::tolower, std::toupper
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {
  int N; std::cin >> N;
  std::string S = std::to_string(N);

  int SN = 0;
  for(auto&& s : S) { SN += s-'0'; }

  if ( N % SN == 0 ) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;

  return 0;
}


Measured memory_bytes: 256
n, k =map(int,input().split())
MOD = 10**9 + 7
ans = 0
for i in range(k,n+2):
  L = (i-1)*i / 2  #初項0,末項l,項数iの等差数列の和
  H = ((n-i)+(n+1))*i //2 #初項a,末項l,項数iの等差数列の和
  ans += H - L + 1
  ans %= MOD
print(int(ans))

Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long m,d;
    cin>>m>>d;
    long long count1=0;
    for(int i=1;i<=d;i++)
    {
        long long a=i/10,b=i%10;
        if(a>=2 && b>=2 && a*b<=m)
            count1++;
    }
    cout<<count1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[60][60][3000];
int main(){
	int n,a;cin>>n>>a;
	int x[60];
	for(int i=0;i<n;i++){
		cin>>x[i];
	}
	dp[0][0][0]=1;
	for(int i=0;i<n;i++){
		for(int j=0;j<=i;j++){
			for(int k=0;k<=2600;k++){
				dp[i+1][j][k]+=dp[i][j][k];
				dp[i+1][j+1][k+x[i]]+=dp[i][j][k];
			}
		}
	}
	ll ans=0;
	for(int i=1;i<=n;i++){
		ans+=dp[n][i][i*a];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 69888
#include <stdio.h>
#define INF 2147483647

void bfs(int);
void enqueue(int);
int dequeue();

int n,head,tail,Q[100],color[100],d[100],A[100][100];

int main(){
  int i,j,u,k,v;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    for(j=0;j<n;j++) A[i][j]=0;
  }
  
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      A[u-1][v-1]=1;
    }
  }
  bfs(0);

  for(i=0;i<n;i++){
    if(d[i]==INF) d[i]=-1;
    printf("%d %d\n",i+1,d[i]);
  }

  return 0;
}

void bfs(int s){
  int i,u;

  for(i=0;i<n;i++){
    color[i]=0;
    d[i]=INF;
  }

  color[s]=1;
  d[s]=0;
  enqueue(s);

  while(head!=tail){
    u=dequeue();

    for(i=0;i<n;i++){
      if(A[u][i]==1&&color[i]==0){
	color[i]=1;
	d[i]=d[u]+1;
	enqueue(i);
      }
    }
    color[u]=2;
  }
}

void enqueue(int x){
  Q[tail]=x;
  if(tail+1==100) tail=0;
  else tail++;
}

int dequeue(){
  int x;

  x=Q[head];
  if(head+1==100) head=0;
  else head++;

  return x;
}

Measured memory_bytes: 636
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)       (((a) > (b)) ? (a) : (b))               /* ２個の値の最大値 */
#define min(a, b)       (((a) < (b)) ? (a) : (b))               /* ２個の値の最小値 */
#define ENTER           printf("\n")                                    /* 改行プリント */
int DBG = 1;                                                                            /* デバッグプリント 提出時は0
 */
/* main *************************************************************/
int main()
{
        int             h,w,a[30][30],b,c,d,i,j,k,n,m,x,y,ans = 0x7fffffff;

        scanf("%d %d", &h, &w);

        for(i=1;i<=h;i++) {
                for(j=1;j<=w;j++) {
                        scanf("%d", &a[i][j]);
                }
        }
        for(i=1;i<=h;i++) {
                for(j=1;j<=w;j++) {
                        n = 0;
                        for(x=1;x<=h;x++) {
                                for(y=1;y<=w;y++) {
                                        n += min ( abs(i-x) , abs(j-y) ) * a[x][y];
                                }
                        }
                        ans = min (ans , n );
                }
        }

        printf("%d\n",ans );


        return 0;
}



Measured memory_bytes: 2136
#include <iostream>
#include <cmath>
#include <algorithm>

int main() {
	int N, M;
	std::cin >> N >> M;
	double tot=0;
	double arr[N];
	for (int i=0;i<N;i++){std::cin>>arr[i];tot+=arr[i];}
	std::sort(arr,arr+N,[](double &a, double &b)->bool{return a>b;});
	bool flag = true;
	double epsilon = 0.000001;
	double threshold = tot/(4.0*M);
	for(int i=0; i<M; i++) {
		//if (abs(arr[i]-threshold)<=epsilon)continue;
		if (arr[i] < threshold) {flag=false;break;}
	}
	std::cout << (flag?"Yes":"No");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef set <int> si;
typedef set <int> :: iterator sitr;
typedef set <ll> :: iterator sltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef mset <int> :: iterator msitr;
typedef mset <ll> :: iterator msltr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
ll n,k,a,b;
ll ans;
int main(){
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        if(i%k==0){a++;}
        if(k%2==0){
            if( i % (k) == k/2){b++;}
        }
    }
    ans =  a*a*a + b*b*b;
    printf("%lld\n",ans);
}


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

int main(void) {
	int num, sum = 0;
	cin >> num;
	vector<int> vec(num - 1);

	for (int i = 0; i < num - 1; i++) cin >> vec.at(i);

	sum = vec.at(num - 2);
	for (int i = num - 2; i > 0; i--) {
		if (vec.at(i) < vec.at(i - 1)) sum += vec.at(i);
		else sum += vec.at(i - 1);
	}
	sum += vec.at(0);

	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func inputIntSlice(size int) []int {
	slice := make([]int, size)
	for i := range slice {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	n, k := nextInt(), nextInt()
	a := inputIntSlice(n)

	cnt := []int{0, 0}
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if a[i] > a[j] {
				// あるAiの内部で発生するもの
				if i < j {
					cnt[0]++
				}
				// Ai, Ajの間で発生するもの
				cnt[1]++
			}
		}
	}

	mod := int64(1000000007)
	sel := int64(k*(k-1)) / 2 % mod
	ans := ((int64(cnt[0])*int64(k))%mod + (int64(cnt[1])*sel)%mod) % mod
	fmt.Println(ans)
}


Measured memory_bytes: 640
#162
import math
from functools import reduce

def gcd(*number):
    return reduce(math.gcd, number)

K = int(input())
combinations = []
combinations.extend([[i+1]*3 for i in range(K)])
for i in range(K):
    combinations.extend([[i+1,i+1,j+1] for j in range(K) if j>i])
    for j in range(K):
        combinations.extend([[i+1,j+1,k+1] for k in range(K) if (j>i and k>j)])
result=0
for combination in combinations:
    a, b, c = combination
    if(a==b and b==c):
        result += a
    elif((a==b and b!=c) or (b==c and c!=a) or (c==a and a!=b)):
        result += gcd(a,b,c)*6
    else:
        result += gcd(a,b,c)*6
    
print(result)

Measured memory_bytes: 146928
#include <stdio.h>
#include <ctype.h>
int main()
{
	int c, n, i, counter[26]={0};
	char alpha[26]="abcdefghijklmnopqrstuvwxyz";
	while(1){
		c=getchar();
		if(c==EOF){
			break;
		}
		if(isalpha(c)){
			c=tolower(c);
			n=c-'a';
			counter[n]++;
		}
	}
	for(i=0; i<26; i++){
		printf("%c : %d\n", alpha[i], counter[i]);
	}
	return 0;
}

Measured memory_bytes: 524