akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cstring>
#include <ctype.h>
#include<stdlib.h>

#define flin            freopen("input.txt", "r", stdin); 
#define flout           freopen("output.txt", "w", stdout);
#define ll              long long
#define ull             unsigned long long
#define fastio          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define nl              '\n'
#define nll             '\0'
#define pb              push_back
#define bdyptb          return 0;
#define sorted(x)       sort(x.begin(), x.end())
#define reversed(x)     reverse(x.begin(), x.end())
#define all(x)          x.begin(), x.end()
#define mset(a, b)      memset(a, b, sizeof(a));
#define testcase        ll t,tt; cin>>tt; for(t=1;t<=tt;t++)

#define pi acos(-1.00)   
#define mx 1000007

using namespace std;
int gcd(int x,int y)
{        
    return x ? gcd(y%x,x) : y;   
}  

int main()
{
    fastio;
    int n;
    cin>>n;
    int p[n+1];
    for(int i=1; i<=n; i++)
    cin>>p[i];
    int x=30000;
    int a[n+1],b[n+1];
    for(int i=1; i<=n; i++)
    {
        a[i]=(i*x);
        b[i]=((n-i+1)*x);
    }

    for(int i=1; i<=n; i++)
    b[p[i]]+=i;


    for(int i=1; i<=n; i++)
    cout<<a[i]<<' ';
    cout<<nl;
    
    for(int i=1; i<=n; i++)
    cout<<b[i]<<' ';
    cout<<nl;

    bdyptb;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

  string s, t;
  cin >> s >> t;

  int n, m;
  n = s.length();
  m = t.length();

  int dp[n+1][m+1];
  // dp[i][j] : sのi文字目、tのj文字目のLCSの長さ
  rep(i, n+1) rep(j, m+1) dp[i][j] = 0;

  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= m; j++){
      if(s[i-1] == t[j-1]){
	dp[i][j] = dp[i-1][j-1] + 1;
      }else{
	dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
      }
    }
  }

  // dp配列を逆からたどってLCSを作成する
  // LCSの長さが更新されたときの文字を追加していく

  string ans = "";
  int x = n;
  int y = m;
  while(x > 0 && y > 0){
    if(dp[x][y] == dp[x-1][y]){
      x--;
    }else if(dp[x][y] == dp[x][y-1]){
      y--;
    }else{
      x--;
      y--;
      ans.push_back(s[x]);
    }
  }

  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}


Measured memory_bytes: 35456
# ビット演算でなく, itertoolsモジュールのproductとrange(2)の組み合わせを活用.
# ※を！

from itertools import product

h, w, k = map(int, input().split())
c = [list(input()) for _ in range(h)]
#print(c)

ans = 0

#l = list(product(range(2), repeat=h))
#m = list(product(range(2), repeat=w))
#print(l)
#print(m)

for row_bit in product(range(2), repeat=h):# ※長さがhで, 要素が'1'か'0'であるすべての組み合わせをすべて列挙
    for col_bit in product(range(2), repeat=w):
        cnt = 0
        for row in range(h):
            for col in range(w):
                #print(row_bit[row] and col_bit[col])
                if c[row][col] == "#" and (row_bit[row] and col_bit[col]):# ここのブール演算！
                    cnt += 1
        if cnt == k:
            ans += 1

print(ans)

Measured memory_bytes: 9204
n,q=map(int, input().split())
*p,=range(n+1)
r=[0]*(n+1)
def par(x):
    if p[x]==x:
        return x
    res = p[x]=par(p[x])
    return res

def union(x,y):
    px=par(x);py=par(y)
    if px==py:
        return
    if r[px]>r[py]:
        p[py]=px
        r[py]+=1
    elif r[px]<r[py]:
        p[px]=py
        r[px]+=1
    else:
        p[px]=py
        r[py]+=1
for _ in range(q):
    t,u,v=map(int, input().split())
    if t:
        print(1 if par(u)==par(v) else 0)
    else:
        union(u,v)
    


Measured memory_bytes: 81192
import java.util.*;

public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        String str1 = sc.next();
        if(str1.equals("ABC")){
            System.out.println("ARC");
        }else if(str1.equals("ARC")){
            System.out.println("ABC");
        }
    }
}

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

int Comp(const void *a,const void *b){
  return *(int*)a - *(int*)b;
}

int main(void){
  int n,d[100000];
  scanf("%d", &n);
  for(int i = 0;i < n;i++){
    scanf("%d",&d[i]);
  }
  qsort(d,n,sizeof(int),Comp);
  printf("%d\n",d[n/2]-d[n/2 - 1]);
}

Measured memory_bytes: 892
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    A = list(map(int, input().split()))

    for i in range(N):
        v = A[i]
        j = i - 1
        while 0 <= j and A[j] > v:
            A[j + 1] = A[j]
            j -= 1
        A[j + 1] = v
        print(" ".join(map(str, A)))


if __name__ == "__main__":
    main()



Measured memory_bytes: 5612
N, M = map(int, input().split())

lst = [0] * N
pre1 = 0
pre2 = 0
skips = set([int(input()) for _ in range(M)])
for x in range(N):
    if x in skips:
        lst[x] = 0
    elif x in [0, 1]:
        lst[x] = 1
    else:
        lst[x] = (lst[x - 1] + lst[x - 2]) % 1000000007

if N == 1:
    print(lst[-1])
else:
    print((lst[-1] + lst[-2]) % 1000000007)

Measured memory_bytes: 13936
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    vector<int> cnt(N,0);
    for(int i=0; i<N; i++){
        int p;
        cin >> p;
        p--;
        if(i==0){
            cnt[p]=1;
        }else{
            cnt[p]=cnt[p-1]+1;
        }
    }

    int ans=N;
    for(int i=0; i<N; i++){
        ans=min(ans,N-cnt[i]);
    }
    cout << ans << endl;
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>s;

    if((s[0]==s[1] && s[1]==s[2]) ||(s[1]==s[2] && s[2]==s[3]) ) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

int main(){
    int A, B;
    cin >> A >> B;
    if(A==1 || B==1){
        if(A==B) cout<<"Draw" << endl;
        else if(A<B) cout<<"Alice";
        else cout << "Bob";
    }else{
        if(A==B) cout<<"Draw" << endl;
        else if(A<B) cout<<"Bob";
        else cout << "Alice";
    }
}

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

int main()
{
  int K;
  string S;
  cin >> K >> S;
  if(S.size() <= K) cout << S << endl;
  else{
    for(int i = 0;i < K;i++){
      cout << S.at(i);
    }
    cout << "..." << endl;
  }
}


Measured memory_bytes: 3632
#include<stdio.h>

int main() {
	char inp;
	int sum;
	while (1) {
		sum = 0;
		while (1) {
			scanf("%c", &inp);
			if (inp == '\n')break;
			sum += inp - 48;
		}
		if (sum == 0)break;
		printf("%d\n", sum);
	}

	return 0;
}


Measured memory_bytes: 2716
#include<iostream>
#include<set>
using namespace std;
main(){
  long a,b,k;
  cin>>a>>b>>k;
  set<long>s;
  for(int i=0;i<k;++i){
    if(a+i>b)break;
    s.insert(a+i);
  }
  for(int i=0;i<k;++i){
    if(b-i<a)break;
    s.insert(b-i);
  }
  for(auto x:s)cout<<x<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)

//変数
int N,n;

//解法
void solve() {
	n = N;
	int S_n = 0;

	while (1) {
		S_n += N % 10;
		N /= 10;
		if (N == 0) break;
	}

	cout << (n%S_n == 0 ? "Yes" : "No");

	return;
}

int main() {
	//入力
	cin >> N;
	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int cnt, arr[100000];

int bsearch(int x) {
	int lo = 0, hi = cnt-1;
	while (lo < hi) {
		int mid = (lo+hi)/2;
		if (arr[mid] < x) {
			hi = mid;
		} else {
			lo = mid+1;
		}
	}
	if (lo >= 0 && lo < cnt && arr[lo] < x) return lo;
	else return -1;
}

int main(void) {
	int n;
	scanf("%d", &n);

	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		int f = bsearch(x);

		if (f < 0) arr[cnt++] = x;
		else arr[f] = x;
	}

	printf("%d\n", cnt);
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int tmp = b - a;
        if(a - b >= 0) {
            System.out.println("delicious");
        } else if (b - a <= x) {
            System.out.println("safe");
        } else {
            System.out.println("dangerous");
        }
    }
}

Measured memory_bytes: 35668
s=input()
k=int(input())
n=len(s)
ss=s[0]
li=[]
check=0
for i in range(n-1):
    if s[i+1]==s[i]:
        check+=1
    elif s[i+1]!=s[i]:
        li.append(check)
        check=0
li.append(check)

ans=0
for i in li:
    ans+=(i+1)//2
ans*=k

if k>0:
    aa=0
    for i in range(n-1):
        if s[i+1]==s[i]:
            aa+=1

    if aa==n-1:
        ans=(n*k)//2
    elif s[0]==s[-1]:

        a=li[0]+li[-1]+2
        ans=ans+(a//2)*(k-1)
        ans=ans-((li[0]+1)//2*(k-1))-((li[-1]+1)//2*(k-1))

   
print(ans)


Measured memory_bytes: 3064
//Be Name Khoda
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)1e6 + 7;
bool f(string s)
{
	if(s.size() < 7)
		return false;
	if(s[0] == 'd' and s[1] == 'r' and s[2] == 'e' and s[3] == 'a' and s[4] == 'm' and s[5] == 'e' and s[6] == 'r')
		return true;
	return false;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	while(n)
	{
		if((n % 10) == 9)
			return cout << "Yes", 0;
		n /= 10;
	}
	cout << "No";
}

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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    int t;
    cin >> t;

    while (t--) {
        int n; cin >> n;
        vector<ll> a(n); REP(i, n) cin >> a[i];
        string s; cin >> s;

        int ans = 0;
        vector<ll> dp;
        for (int i = n; i--;) {
            for (ll j : dp) a[i] = min(a[i], a[i]^j);
            if (a[i]) {
                if (s[i] == '0') dp.push_back(a[i]);
                else ans = 1;
            }
        }
        cout << ans << '\n';
    }
    return 0;
}

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

using namespace std;
# define M_PI 3.14159265358979323846
# define epsi 1e-9
# define F first
# define S second
# define REP(i,a,b) for(int i=a;i<=b;i++)
using ll = long long int;
const int MOD = 1e9 + 7;
int main()
{
    int k;
    cin>>k;
    string s;
    cin>>s;
    if(s.length()<=k)
    {
        cout<<s;
    }
    else
    {
        string temp=s.substr(0,k);
        cout<<temp<<"...";
    }
    
}

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

#define rff freopen("input.txt","r",stdin)
#define debug(x) cout<<#x<<"="<<x<<endl
#define pii pair<int,int>
#define PQ priority_queue
#define ll long long
#define pb push_back
#define mp make_pair
#define re return
const int INF=0x7fffffff;

int main(){
	unsigned ll a,b,ans=0;
	cin>>a>>b;
	while (a<=b){
		ans++;
		a*=2;
	}
	cout<<ans;
	re 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[]args){
        Scanner entrada = new Scanner(System.in);
        int A = entrada.nextInt();
        
        if(A<1200){
            System.out.println("ABC");
        }else if(A<2800){
            System.out.println("ARC");
        }else{
            System.out.println("AGC");
        }
    }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
  long long x, k, d, c, m;
  cin >> x >> k >> d;
  if (d == 0) {
    m = x;
  }
  else {
    if (x > 0) {
      if (x/d < k) {
        for (long long i = 1; i <= k; i++) {
          if (x - i * d <= 0) {
            c = i;
            break;
          }
        }
        if (c%2 == k%2) {
          m = -(x - c * d);
        }
        else {
          m = x - (c - 1) * d;
        }
      }
      else {
        m = x - k * d;
      }
    }
  
    else {
      if (-x/d < k) {
        for (long long i = 1; i <= k; i++) {
          if (x + i * d >= 0) {
            c = i;
            break;
          }
        }
        if (c%2 == k%2) {
          m = (x + c * d);
        }
        else {
          m = -(x + (c - 1) * d);
        }
      }
      else {
        m = -(x + k * d);
      }
    }
  }
  cout << m << endl;
}

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

int main(void) {
  int N,t;
  cin>>N;
  long long cnt=0;

  vector<long long> A(N+1);
  vector<long long> B(N);

  for(int i=0;i<(N+1);i++){
    cin>>A.at(i);
  }

  for(int i=0;i<N;i++){
    cin>>B.at(i);
  }

  for(int i=0;i<N;i++){
    t = min(A.at(i), B.at(i));
    cnt += t;
    A.at(i) -= t;
    B.at(i) -= t;

    t = min(A.at(i+1),B.at(i));
    cnt += t;
    A.at(i+1) -= t;
    B.at(i) -= t;
  }
  cout<<cnt<<endl;

}


Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	int N, M;
	cin >> N >> M;
	vector<vector<int>>v(N);
	rep(i, M) {
		int A, B;
		cin >> A >> B;
		A--; B--;
		v[A].push_back(B);
		v[B].push_back(A);
	}
	vector<int>ans(N, INF);
	ans[0] = 0;
	queue<int>q;
	q.push(0);
	while (q.size()) {
		int now = q.front();
		q.pop();
		for (int i = 0; i < v[now].size(); i++) {
			int next = v[now][i];
			if (ans[next] != INF)continue;
			ans[next] = now;
			q.push(next);
		}
	}
	cout << "Yes" << endl;
	for (int i = 1; i < N; i++)cout << ans[i] + 1 << endl;
}

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

long long min(long long x,long long y){
	if(x>y){
		return y;
	}else{
		return x;
	}
}

int main(){
	int N;
	long long input,total[200010]={0};
	
	long long answer=1000000000000000000LL;
	
	cin >> N;
	for(int i=1;i<=N;i++){
		cin >> input;
		total[i]=total[i-1]+input;
	}
	
	for(int i=1;i<N;i++){
		answer=min(answer,abs(total[i]-(total[N]-total[i])));
	}
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main (void)
{
	int a=0,b=0,i=0,j=0,N=0,X=0,Xmin=0,answer=0,Y=0;

  	scanf("%d",&N);

  	int A[N];

  	for(i=0;i<N;i++)
    {
      scanf("%d",&a);
      A[i]=a;
    }


  	for(i=0;i<N;i++)
      {
        b=A[i];
        Y=b-1;
      	Xmin=Xmin+Y*Y;
    	}

  	answer=1;
  
  	X=0;
  	i=0;

  	for(j=1;j<101;j++)
    {
      for(i=0;i<N;i++)
      {
        b=A[i];
        Y=b-j;
      	X=X+Y*Y;
      }

      if(X<Xmin)
      {
      	Xmin=X;
        answer=j;
      }
     
      X=0;
    }

  	printf("%d",Xmin);

  	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int N=65;
const double eps=1e-9;
int n,k;
double x[N],y[N],c[N],r[N];
double dis(pair<double,double> a,pair<double,double> b) {
    return sqrt((a.first-b.first)*(a.first-b.first)+(a.second-b.second)*(a.second-b.second));
}
vector<pair<double,double> > cal(double x1,double y1,double r1,double x2,double y2,double r2) {//两圆交点
    x1-=x2,y1-=y2;
    double S=x1*x1+y1*y1,a=(S+r2*r2-r1*r1)/2,D=S*r2*r2-a*a;
    if(D<0) return {};
    double A1=a*x1,B1=y1*sqrt(D);
    double A2=a*y1,B2=x1*sqrt(D);
    return {{(A1+B1)/S+x2,(A2-B2)/S+y2},{(A1-B1)/S+x2,(A2+B2)/S+y2}};
}
bool check(double t) {
    for(int i=0;i<n;i++) r[i]=t/c[i];
    vector<pair<double,double> > vec;
    for(int i=0;i<n;i++) {
        vec.push_back({x[i],y[i]});
        for(int j=i+1;j<n;j++) {
            auto v=cal(x[i],y[i],r[i],x[j],y[j],r[j]);
            for(auto it:v) vec.push_back(it);
        }
    }
    for(auto it:vec) {
        int cnt=0;
        for(int i=0;i<n;i++) {
            if(r[i]+eps>=dis(it,{x[i],y[i]})) cnt++;
        }
        if(cnt>=k) return true;
    }
    return false;
}
int main() {
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++) {
        scanf("%lf%lf%lf",&x[i],&y[i],&c[i]);
    }
    double L=0,R=1e9;
    for(int i=0;i<100;i++) {
        double mid=(L+R)/2;
        if(check(mid)) R=mid;
        else L=mid;
    }
    printf("%.12f\n",R);
    return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
d = [[1, 1], [1, 0], [0, 1], [-1, -1], [-1, 0], [-1, 1], [0, -1], [1, -1]]

for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            cnt = 0
            for y, x in d:
                if 0 <= i + y < h and 0 <= j + x < w:
                    if s[i+y][j+x] == "#":
                        cnt += 1
            s[i][j] = str(cnt)
        else:
            continue

for i in s:
    print("".join(i))

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

int main(){
    int N;
    int64_t K;
    cin>>N>>K;
    vector<int64_t> A(N);
    for(auto &a:A)cin>>a;
    int64_t X=0;
    for(int64_t b=(1LL<<40);b;b>>=1){
        if(b>K) continue;
        int cnt=0;
        for(auto a:A) cnt+=!!(a&b);
        if(cnt<N-cnt&&(X|b)<=K) X|=b;
    }
    int64_t ans=0;
    for(auto &a:A) ans+=(X^a);
    cout<<ans<<endl;
    return 0;
}

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

using ll = long long;
const int MAX = 210000;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

ll COM(int n, int k){
  if(n < k) return 0;
  if(n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modpow(ll a, ll n, ll mod){
  ll res = 1;
  while(n > 0){
    if(n & 1) res = res * a % mod;
     a = a * a % mod;
     n >>= 1;
  }
  return res;
}

int main(){
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    COMinit();
    ll ans = 0;
    for(int i = b; i < w; i++){
        ans += 1LL * COM(h - a - 1 + i, i) * COM(a + w - i - 2, w - i - 1);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5120
a=[[10*[0]for _ in range(3)]for _ in range(4)]
for _ in[0]*int(input()):
 b,f,r,v=map(int,input().split())
 a[b-1][f-1][r-1]+=v
for i in range(4):
 for j in range(3):print('',*a[i][j])
 if i!=3:print('#'*20)


Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve(ll N);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll N;
    cin >> N;
    solve(N);
}

void solve(ll N){
    ll sum=0;
    repe(i,1,N){
        if(i%3&&i%5)sum+=i;
    }
    cout<<sum<<endl;
}



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

int main(){
    char x;
    cin>>x;

    if(x<=90){
        cout<<"A"<<endl;
    }else{
        cout<<"a"<<endl;
    }
}



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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> P;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

string s;
int K;
signed main() {
    cin >> s >> K;
    int idx = 0;
    for (int i = K; i > 0;) {
        while ((s[idx] == 'a' || 'z' - s[idx] >= i) && idx != s.length() - 1) idx++;
        if (idx == s.length() - 1) {
            (((s[idx] += i % 26) -= 'a') %= 26) += 'a';
            i = 0;
        } else {
            i -= 'z' - s[idx] + 1;
            s[idx] = 'a';
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
using namespace std;


typedef long long ll;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)

const int mod = 1000000007;

int main(){
  ll n;
  cin >> n;
  ll ans = ((n - 1)  * n) / 2;
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N = int(input())
A = map(int, input().split())

ans = 0
for i, a in enumerate(A, start=1):
    if i % 2 == 1 and a % 2 == 1:
        ans += 1
print(ans)


Measured memory_bytes: 9200
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cstring>

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define vii vector<int>
#define vll vector<ll>
#define vip vector<pair<int,int> >
#define pb push_back


int main(int argc,char* argv[])
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //#ifndef ONLINE_JUDGE
    //   freopen("input.txt", "r", stdin);
    //   freopen("output.txt", "w",stdout);
    //#endif

    int n,k,c;
    cin>>n>>k;
    vii rem;
    while(n>=k)
    {

        c=n%k;
        n=n/k;
        rem.pb(c);
    }
    rem.pb(n);

    cout<<rem.size();




    return 0;
}


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

#define MAX_N 10000

using namespace std;

int N;
int k[MAX_N];

void solve();

int main()
{
	while (cin>>N&&N) {
		for (int i=0; i<N; i++) cin>>k[i];
		solve();
	}
}

void solve()
{
	int zero=0;
	sort(k,k+N);
	if (k[N-1]<2) {
		cout<<"NA"<<endl;
	} else if (k[0]>=2) {
		cout<<N+1<<endl;
	} else {
		while (k[zero]==0) zero++;
		cout<<N+1-zero<<endl;
	}
	
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, v[50];
double d;

int main() {
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> v[i];
	}
	sort(v, v + N);
	d = v[0];
	for (int i = 1; i < N; ++i) {
		d += v[i];
		d /= 2;
	}
	printf("%.10f\n", d);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
#define pb push_back

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n; cin >> n;
	vector<P>r(n), b(n);
	rep(i, n)cin >> r[i].first >> r[i].second;
	rep(i, n)cin >> b[i].first >> b[i].second;
	sort(ALL(r)); sort(ALL(b));
	int ans = 0;
	rep(i, n) {
		int now = 0;
		int idx = -1;
		rep(j, r.size()) {
			if (r[j].first < b[i].first&&r[j].second < b[i].second) {
				if (r[j].second >= now) {
					now = r[j].second; idx = j;
				}
			}
		}
		if (idx >= 0) {
			ans++; r.erase(r.begin() + idx);
		}
	}
	cout << ans << endl;
	return 0;
}

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

ll lucas_memo[87] = {0};
ll lucas(int n) {
  if (n == 0) return 2;
  if (n == 1) return 1;
  if (lucas_memo[n] != 0) return lucas_memo[n];
  return lucas_memo[n] = lucas(n-1) + lucas(n-2);
}

int main() {
  int N; cin >> N;
  cout << lucas(N) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <functional>

using namespace std;

template <class T>
struct Edge {
    int to;
    T cost;
    Edge(int to, T cost) : to(to), cost(cost){};
};

template <class T = int>
class Graph {
public:
    explicit Graph(int N = 0) : size(N) { path.resize(size); }
    void span(int u, int v, T cost = 1) { path[u].push_back(Edge<T>(v, cost)); }
    vector<Edge<T>> operator[](int v) const { return path[v]; }

    int size;
    vector<vector<Edge<T>>> path;
};

int main() {
    int N;
    cin >> N;
    Graph<> graph(N);
    for (int i = 0; i < N; ++i) {
        int v, k;
        cin >> v >> k;
        --v;
        for (int j = 0; j < k; ++j) {
            int sv;
            cin >> sv;
            graph.span(v, --sv);
        }
    }

    vector<int> d(N, -1), f(N, -1);
    function<int(int, int)> dfs = [&](int v, int t) -> int {
        d[v] = t;
        for (auto e : graph[v]) {
            if (d[e.to] < 0) t = dfs(e.to, t + 1);
        }
        return f[v] = ++t;
    };

    int t = 0;
    for (int v = 0; v < N; ++v) {
        if (d[v] < 0) t = dfs(v, t + 1);
    }

    for (int v = 0; v < N; ++v) {
        cout << v + 1 << " " << d[v] << " " << f[v] << endl;
    }
    return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
 
int main() {
    long long int a, b, c; 
    cin >> a >> b >> c;

    long long int T = (c-a-b)*(c-a-b) - 4*a*b;

    if(c-a-b>0 && T>0 ){
        cout << "Yes" << endl; 
    }
    else{
        cout << "No" << endl;
    } 
}

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

typedef long long ll;

struct Data {
  ll num1;
  ll num2;
  bool operator<( const Data&another ) const {
    return num1 < another.num1;
  }
};
 
int main() {
  ll N,M;
  cin >> N >> M;
  vector<Data> D(N);
  for (int i = 0; i < N; i++) cin >> D[i].num1 >> D[i].num2;
  
  sort(D.begin(),D.end());
  
  ll money = 0;
  ll j = 0;
  
  for (int i = 0; i < M; i++) {
    if (D[j].num2 == 0) j++;
    money += D[j].num1;
    D[j].num2--;
  }
  
  cout << money << endl;  
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define int long long
#define INF 1e9 + 7
#define cae cout << ans << endl;
#define cye cout << "Yes" << endl;
#define cne cout << "No" << endl;
#define r0 return 0;
using namespace std;
typedef pair<int,int>P;
typedef long long ll;
signed main() {
    string s;
    cin >> s;
    string y;
    string m;
    y += s[0];
    y += s[1];
    m += s[2];
    m += s[3];
    
    if (y == "01" || y == "02" || y == "03" || y == "04" || y == "05" || y == "06" || y == "07" || y == "08" || y == "09" || y == "10" || y == "11" || y == "12") {
        if (m == "01" || m == "02" || m == "03" || m == "04" || m == "05" || m == "06" || m == "07" || m == "08" || m == "09" || m == "10" || m == "11" || m == "12") {
            cout << "AMBIGUOUS" << endl;
        } else {
            cout << "MMYY" << endl;
        }
    } else if (m == "01" || m == "02" || m == "03" || m == "04" || m == "05" || m == "06" || m == "07" || m == "08" || m == "09" || m == "10" || m == "11" || m == "12") {
        cout << "YYMM" << endl;
    } else {
        cout << "NA" << endl;
    }
    r0
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define FORR(x, arr) for(auto& x:arr)
#define ITR(x, c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
typedef pair<int, int> P;

string s;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> s;
	if (s[0]==s[1]&&s[1]==s[2] || s[1]==s[2]&&s[2]==s[3]) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 768
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a=sc.nextInt(),b=sc.nextInt();
        if(a < b)System.out.println("a < b");
        else if(a > b)System.out.println("a > b");
        else System.out.println("a == b");
    }
}



Measured memory_bytes: 26340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int maxn=1e6+5;
vector<ll> V;
int pre[maxn];
int main() {
	string a,b;cin>>a>>b;
	int ans=0;
	for(int i=0;i<a.length();i++) {
		ans+=(a[i]!=b[i]);
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3932
#include<stdio.h>

int main(void)
{
	int h,w,i,j;
	while(1){
		scanf("%d %d",&h, &w);
		if(h == 0 && w == 0)break;
		
		for(i = 0;i < h;i++){
			for(j = 0;j < w;j++){
				if(i == 0 || j  == 0 || j == w -1 || i == h -1){
				       printf("#");
				}else{
			 	printf(".");
				}
			}
		printf("\n");
		}
        printf("\n");
	}
	return 0;
}	

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

#############
# Libraries #
#############
import random
import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache

D = int(input().strip())
C = list(map(int,input().split()))
S = [list(map(int, input().split())) for _ in range(D)]

ans = 0
score = 0
last = [[-1] for i in range(26)]
schedule = []

for d in range(D):
  t = random.choice(range(26))
  last[t].append(d)
  score += S[d][t]
  schedule.append(t)

for i in range(26):
  last[i].append(D)
  for k in range(len(last[i])-1):
    g = last[i][k+1]-last[i][k]-1
    score -= C[i]*g*(g+1)//2

count = 2000000

while count:
  count -= 1
  prev = score
  d,q = random.choice(range(D)),random.choice(range(26))
  p = schedule[d]
  schedule[d] = q
  score -= S[d][p]
  score += S[d][q]
  
  pos = last[p].index(d)
  score -= C[p]*(last[p][pos]-last[p][pos-1])*(last[p][pos+1]-last[p][pos])
  last[p].remove(d)
  
  pos = bisect.bisect(last[q],d)
  score += C[q]*(d-last[q][pos-1])*(last[q][pos]-d)
  bisect.insort(last[q],d)
  if score<prev:
    score = prev
    bisect.insort(last[p],d)
    last[q].remove(d)
    schedule[d] = p
    
for i in schedule:
  print(i+1)


Measured memory_bytes: 84632
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  int x,y;
  bool operator < (const P &a )const{
    //if(y!=a.y)
    return y>a.y;
  };
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[1];
int l[1];
int j[1];

long long x,y,z,mod=1000000007;
string r;
//char r[2];

P u[1];
queue<int> q;
stack<int> s;
//set<int> s;
map<int,int> p;

vector<int> v;


bool as(P a,P b)
{
  if(a.x!=b.x)
  return a.x<b.x;
  return a.y>b.y;
}

int f(long long n,long long m,long long k)
{
  if(n>=m)
  {
    if(k) return 0;
    if(n==m) return 10;
    return 1;
  }
  int p=0;
  for(int t=-9;t<=9;t++)
  if(2*(n-m)<=k+(long long)t*(m-n)&&k+(long long)t*(m-n)<=2*(m-n))
  {
    //printf("%d %d %d\n",n,m,k+t*(m-n));
    if(n>1||t>0) p+=f(n*10,m/10,k+t*(m-n))*(10-abs(t));
    else p+=f(n*10,m/10,k+t*(m-n))*(9-abs(t));
  }
  return p;
}

void g(int n)
{
  e*=10;
  if(n<10) //return n;
  {
    e+=n;
    return;
  }
  e+=n%10;
  g(n/10);
  //return g(n/10)
}

int main()
{
  scanf("%d",&a);
  //a=10;
  //for(a=1;a<=10000;a++)
  //{
  for(c=1;c*10<=a;c*=10);
  
  //c*=10;
  //d=f(1,(long long)c*10,a)+f(1,c,a);
  d=0;
  for(long long p=c;p<=(long long)c*c*10;p*=10)
  {
  d+=f(1,p,a);
    //printf("%d %d\n",p,f(1,p,a));
  }
  //printf("%d ",f(1,(long long)c*10,a)+f(1,c,a));
  k=0;
  /*for(int t=1;t<=1000000;t++)
    {
      e=0;
      g(t);
      if(e==t+a)
      {
        //printf("#%d ",t);
       k++;
      }
    }*/
  printf("%d\n",d);
  //if(d!=k) printf("%d %d %d\n",a,d,k);
  //}
}
//8




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

def calc(x,A,B):
    return A*x//B-A*(x//B)
#for i in range(100):
#    print(i,calc(i,A,B))

if N>=B-1:
    print(calc(B-1,A,B))
else:
    print(calc(N,A,B))

Measured memory_bytes: 9172
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long ll;

ll N;
ll a,b,c;

int main() {
    cin >> N;
    vector<ll> ct(N),C(N),res(N);
    vector<pair<ll,ll>> P(N),sizep(N);
    vector<vector<ll>> G(N,vector<ll>());
    for(int i=0;i<N-1;i++){
        ll tmpa,tmpb;
        cin >> tmpa >> tmpb;
        tmpa--;tmpb--;
        P[i]=make_pair(tmpa,tmpb);
        G[tmpa].push_back(tmpb);
        G[tmpb].push_back(tmpa);
        ct[tmpa]++;
        ct[tmpb]++;
    }
    for(int i=0;i<N;i++){
        sizep[i]=make_pair(ct[i],i);
    }
    sort(sizep.rbegin(),sizep.rend());

    priority_queue<ll> que;
    for(int i=0;i<N;i++){
        cin >> C[i];
        que.push(C[i]);
    }
    sort(C.rbegin(),C.rend());
    ll ans=0;
    priority_queue<pair<ll,ll>> fq;
    fq.push(make_pair(que.top(),sizep[0].second));
    que.pop();
    res[fq.top().second]=fq.top().first;
    while(!fq.empty()){
        pair<ll,ll> tmpp = fq.top();fq.pop();
        ll idx=tmpp.second;
        //res[idx]=tmpp.first;
        priority_queue<pair<ll,ll>> Q;
        /*
        if(res[idx]==0){
            ll tmp=que.top();que.pop();
            res[idx]=tmp;
        }
        */
        for(auto v : G[idx]){
            Q.push(make_pair(sizep[v].first,v));
        }
        while(!Q.empty()){
            pair<ll,ll> tp = Q.top();Q.pop();
            if(res[tp.second]==0){
                ll temp=que.top();que.pop();
                res[tp.second]=temp;
                fq.push(make_pair(temp,tp.second));
                ans+=min(res[tp.second],res[idx]);
            }
        }
    }
    /*
    for(int i=0;i<N;i++){
        ll idx=sizep[i].second;
        priority_queue<pair<ll,ll>> Q;
        if(res[idx]==0){
            ll tmp=que.top();que.pop();
            res[idx]=tmp;
        }
        for(auto v : G[idx]){
            Q.push(make_pair(sizep[v].first,v));
        }
        while(!Q.empty()){
            pair<ll,ll> tp = Q.top();Q.pop();
            if(res[tp.second]==0){
                ll temp=que.top();que.pop();
                res[tp.second]=temp;
                ans+=min(res[tp.second],res[idx]);
            }
        }
    }
    */


    cout << ans << endl;
    for(int i=0;i<N;i++){
        cout << res[i];
        if(i!=N-1){
            cout << " ";
        }
    }
    cout << endl;
}

Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
int a[105];
int main(){
	int n;cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	reverse(a,a+n);
	for(int i=0;i<n-1;i++)cout<<a[i]<<' ';
	cout<<a[n-1]<<"\n";
	return 0;
}


Measured memory_bytes: 3124
#include <cstdio>
#include <algorithm>
using namespace std;
int a[99999];
int main(){
  int c,n,k,i,x,y;
  for(scanf("%d",&c);c;printf("%d\n",x),c--){
    for(scanf("%d%d%d",&n,&k,&x),i=0;i<n-1;i++)
      scanf("%d",&y),a[i]=y-x,x=y;
    sort(a,a+n-1);
    for(x=i=0;i<n-k;i++)x+=a[i];
  }
}

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

int main(){
  int n, x;
  cin >> n >> x;
  int a[110];
  for(int i = 0;i < n;i++){
    cin >> a[i];
  }

  sort(a,a+n);

  int ans = 0;
  for(int i = 0;i < n;i++){
    if(i != n-1){
      if(x >= a[i]){
        ans++;
        x -= a[i];
      }else{
        break;
      }
    }else{
      if(x == a[i]) ans++;
    }
  }

  cout << ans << endl;
  return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int a, b;
    cin >> a >> b;
    if ( a % 2 == 0 || b % 2 == 0 ) {
        cout << "Even" << endl;
    }
    else {
        cout << "Odd" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
string b,a;
long long rez;
int fr[280];
int main()
{
    cin>>b;
    for(auto it:b)fr[it]++;
    for(int i=0;i<b.size();i++)
    {
        fr[b[i]]--;
        //cout<<(int)b.size()-1-i-fr[b[i]]<<"\n";
        rez+=((int)b.size()-1-i-fr[b[i]]);
    }
    cout<<rez+1;
    return 0;
}


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

const char NL = '\n';
const int MOD = 1e9 + 7;

void solve()
{
    int k; cin >> k;
    int n = 0;
    for (int i = 1; i <= k; ++i) {
        n = (n * 10 + 7) % k;
        if (n == 0) {
            cout << i << NL;
            return;
        }
    }
    cout << -1 << NL;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}

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

long long int gcd(int a,int b,int c){
	long long int ans;
	for(int i=1; i<=a&&i<=b&&i<=c; i++)
	{
		if(a%i==0 && b%i==0 && c%i==0)
		{
			ans = i;
		}
	}
	return ans;
}

int main()
{
	long long int k,sum=0;
	cin >> k;
	for(int i=1; i<=k; i++)
	{
		for(int j=1; j<=k; j++)
		{
			for(int l=1; l<=k; l++)
			{
				sum+=gcd(i,j,l);
				
			}
		}
	}
	cout << sum;
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef pair<ll,ll> pll;
const int inf = 999999999;
const int nax = 2e6 + 7;
ll  n, m , s;
vector< pair< ll , ll > > gra[nax];
priority_queue<pll , vector<pll> , greater< pll > >pq;
ll dis[nax];
void shortest_path(){
    for(int i = 0 ; i < n ; i++)
		dis[i] = inf;
    pq.push({0 , s});
    dis[s] = 0;
    while(!pq.empty()){
        pll mini = pq.top();
        pq.pop();
        ll u = mini.second;
      //  ll wt = mini.first;
        for(auto it : gra[u]){
            ll v = it.first;
            ll vt = it.second;
            if(dis[v] > dis[u] + vt){
                dis[v] = dis[u] + vt;
                pq.push({dis[v] , v});
			}
        }
    }
}
int main(){
	dhoom;
    cin >> n >> m >> s;
    for(int i = 0 ; i < m ; i++){
        int u , v , wt;
        cin >> u >> v >> wt;
        gra[u].push_back({v, wt});
    //    gra[v].push_back({u,wt});
    }
    shortest_path();
    for(int i = 0 ; i < n ;i++){
		if(dis[i] == inf)
			cout << "INF" << endl;
		else 
			cout << dis[i] << endl;
    }
    return 0;
}




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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b){
    if(b!=c){
      cout << "Yes";
      return 0;
    }
  }
  if(b==c){
    if(c!=a){
      cout << "Yes";
      return 0;
    }
  }
  if(c==a){
    if(c!=b){
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";
}


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

int main()
{
    int H, W;
    cin>>H>>W;
    vector<vector<int>> A(H, vector<int>(W));
    for (int y=0; y<H; y++)
        for (int x=0; x<W; x++)
            cin>>A[y][x];
    vector<vector<int>> B(H, vector<int>(W));
    for (int y=0; y<H; y++)
        for (int x=0; x<W; x++)
            cin>>B[y][x];
    vector<vector<int>> D(H, vector<int>(W));
    for (int y=0; y<H; y++)
        for (int x=0; x<W; x++)
            D[y][x] = abs(A[y][x]-B[y][x]);

    int L = (H+W+1)*80;
    vector<vector<vector<bool>>> T(H, vector<vector<bool>>(W, vector<bool>(2*L+1)));
    for (int y=0; y<H; y++)
        for (int x=0; x<W; x++)
        {
            if (x==0 && y==0)
                T[y][x][L-D[0][0]] = true,
                T[y][x][L+D[0][0]] = true;
            else
            {
                if (x>0)
                    for (int i=-(x+y)*80; i<=(x+y)*80; i++)
                        if (T[y][x-1][i+L])
                            T[y][x][i-D[y][x]+L] = true,
                            T[y][x][i+D[y][x]+L] = true;
                if (y>0)
                    for (int i=-(x+y)*80; i<=(x+y)*80; i++)
                        if (T[y-1][x][i+L])
                            T[y][x][i-D[y][x]+L] = true,
                            T[y][x][i+D[y][x]+L] = true;
            }
        }
    int ans = L;
    for (int i=-L; i<=L; i++)
        if (T[H-1][W-1][i+L])
            ans = min(ans, abs(i));
    cout<<ans<<endl;
}


Measured memory_bytes: 23040
#include <stdio.h>
int main(void){
    int N,K,P,i,win;

    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d %d",&K,&P);
        win=K%P;
        if(K%P==0)
            win=P;
        printf("%d\n",win);
    }
    return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<string>
using namespace std;
int main(void){
    string S;
    int strLength ;
    int counterA,counterB,answer;
    cin >> S;
    strLength = S.size();
    
    // 0101010101....のパターン
    int digits = 0;//開始桁
    int nowDigits;
    counterA = 0;
    for(int i=0;i < strLength;i++){
        nowDigits = S[i]-'0';
        if(digits != nowDigits){//現在の桁と白黒二値が一致していない場合
            counterA = counterA+1;
        }
      //次は0→1、1→0に入れ替え
        digits = (digits+1)%2;
    }
    /** 101010101010101....のパターン
    digits = 1;
    counterB = 0;
    for(int i=0;i<strLength;i++){
        cout << i << " ketameniHosiiDigits is " << digits << endl;
        nowDigits = S[i]-'0';
        if(digits =! nowDigits){
            cout << i << "KetaMenoDigitsGa" << "Org:" << nowDigits << "//To:" << digits <<"noTameHenkannsimasu" << endl;
            counterB = counterB+1;
        }
        digits = (digits+1)%2;
        cout << i+1 << "ketaMeni Hituyouna Digits is " << digits << endl;
    }
    cout << S << "to0....:" << counterA << endl;
    cout << S << "to1....:" << counterB << endl;**/
    // 1010101....の変換がうまくいかないため、一旦counterBという変数は010101変換関数の逆を行く
    counterB = strLength - counterA;
    if(counterB < counterA){
        answer = counterB;
    }
    else{// counterA <= counterB
        answer = counterA;
    }
    cout << answer   << endl;   
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
#include<math.h>
int ara_D[100][200];
int ara[100000];
char ara1[100000];
int main()
{
    int i,j,k,l,n,t,df,v;
    while(gets(ara1))
    {
        l=strlen(ara1);
        k=l-2;
        printf("%c%d%c\n",ara1[0],k,ara1[l-1]);
    }
    return 0;
}



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

int main(){
    int x;
    cin>>x;
    for(int a=-118;a<=119;a++){
        for(int b=-119;b<=118;b++){
            if(pow(a,5)-pow(b,5)==x){
                cout<<a<<" "<<b<<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 4020
#include <iostream>
using namespace std;
int main()
{
  int N, K;
  cin >> N >> K;
  int ans = 1;
  for (int i = 0; i < N; i++) {
    if (ans < K) {
      ans *= 2;
    } else {
      ans += K;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3540
#include <iostream>

using namespace std;

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); ++i) {
        for (int j = i + 1; j < s.size(); ++j) {
            if (s[i] == 'C' && s[j] == 'F') {
                cout <<"Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256