akhauriyash/Code-Regression huggingface dataset:
a = list(input())
b = list(input())
count = 0
m = 0
ar = []
c = ""
for i in range(len(a)-len(b)+1):
    for j in range(len(b)):
        if b[j] == a[i+j] or a[i+j] == "?":
            count += 1
    if count == len(b):
        for k in range(len(a)):
            if k >= i and k <= i + len(b) - 1:
                c += b[m]
                m += 1
            else:
                if a[k] == "?":
                    c += "a"
                else:
                    c += a[k]
        ar.append("".join(c))
        c = ""
    count = 0
    m = 0
if len(ar) == 0:
    print("UNRESTORABLE")
else:
    print(sorted(ar)[0])

Measured memory_bytes: 3064
#!/usr/bin/env python3
n = int(input())
s = [input() for _ in range(n)]
# m,a,r,c,h で始まる人の名前をcnt[]に保存して、10pattern a[i]*a[j]*a[k]を足せばOK
cnt = [0]*5
for i in range(n):
    if s[i][0] == "M": cnt[0]+=1
    if s[i][0] == "C": cnt[1]+=1
    if s[i][0] == "R": cnt[2]+=1
    if s[i][0] == "A": cnt[3]+=1
    if s[i][0] == "H": cnt[4]+=1
ans = 0
#print(cnt)
for i in range(3):
    for j in range(i+1,4):
        for k in range(j+1,5):
            ans += cnt[i]*cnt[j]*cnt[k]
print(ans)

Measured memory_bytes: 56152
import math

a, b, x = map(int, input().split())

if x <= a*a*b/2:
    print((math.atan(b*b*a/(2*x))/(math.pi))*180)
else:
    print((math.atan((2/a**3)*(a*a*b - x))/(math.pi))*180)

Measured memory_bytes: 3060
def selectionSort(A):
    nSwap = 0
    for i in range(N):
        minIdx = i
        for j in range(i, N):
            if A[j] < A[minIdx]:
                minIdx = j
        if minIdx != i:
            A[i], A[minIdx] = A[minIdx], A[i]
            nSwap += 1
    return A, nSwap

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

sortedA, nSwap = selectionSort(A)
print(' '.join(map(str, sortedA)))
print(nSwap)

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

int main()
{
  ll n, k; cin>>n>>k;
  vector<ll> a(n);
  rep(i, n) {
    cin>>a[i];
    a[i]--;
  }
  vector<ll> b(n, -1);
  vector<ll> c;
  b[0] = 0;
  ll now = 0;
  ll t = 0;
  ll s = 0;
  while (true) {
    c.push_back(now);
    if (b[a[now]] >= 0) {
      s = b[a[now]];
      t = b[now] - b[a[now]] + 1;
      break;
    }
    b[a[now]] = b[now]+1;
    now = a[now];
  }

  if (k < c.size()) {
    cout << c[k]+1 << endl;
    return 0;
  }
  cout << c[(k-s)%t+s]+1 << endl;

  return 0;
}


Measured memory_bytes: 8496
"use strict";
function main(input) {
    var line = input.split("\n");
    const pi = 3.14159265359;
    let R = parseInt(line[0]);
    var circumference = 2*pi*R;
    console.log(circumference.toPrecision(20));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29616
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
using namespace std;
typedef long long int lli;
int main(void)
{
    int K, A, B;
    cin >> K >> A >> B;
    for (int i = A; i <= B; i++)
    {
        if (i % K == 0)
        {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}


Measured memory_bytes: 3596
import numpy as np

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

mat = np.array([[False] * N for i in range(K)])

for i in range(K):
    d = int(input())
    a = list(map(int, input().split()))
    for j in range(d):
        mat[i][a[j]-1] = True

mat = mat.T

ans = 0
for i in range(N):
    flg = False
    for j in range(K):
        if mat[i][j]:
            flg = True

    if not flg:
        ans += 1

print(ans)

Measured memory_bytes: 27144
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	int ab, bc, ca;
	cin >> ab >> bc >> ca;
	cout << ab*bc / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    int n,m,k;
    cin >> n >> m >> k;
    bool flag=0;
    rep(i,n+1) {
        rep(j,m+1) {
            int b=m*i+n*j-2*i*j;
            if (b==k) flag=1;
        }
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
   
    return 0;  
}

Measured memory_bytes: 3604
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

int main(){
	int n,m;
	cin >> n >> m;
	const int INF = 1<<10;
	vector<vector<int>> d(n,vector<int>(n,INF));
	vector<vector<int>> g(m,vector<int>(2));
	REP(i,m){
		int a,b;
		cin >> a >> b;
		a--; b--;
		g[i][0] = a;
		g[i][1] = b;
		d[a][b] = 1;
		d[b][a] = 1;
	}
	
	int ans = 0;
	REP(i,m){
		queue<int> q;
		vector<int> visited(n,0);
		q.push(0);
		visited[0] = 1;
		while(!q.empty()){
			int now = q.front();
			q.pop();
			
			REP(j,n){
				if(now==j) continue;
				if((now==g[i][0]&&j==g[i][1]) || (now==g[i][1]&&j==g[i][0])) continue;
				
				if(d[now][j]==1 && visited[j]==0){
					visited[j] = 1;
					q.push(j);
				}
			}
		}
		
		int sum = 0;
		REP(i,n) sum+=visited[i];
		if(sum!=n) ans++;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
using namespace std;
#define ll long long
ll N,arr[3]={3,5,7},ans;
ll dfs(ll x,ll a,ll b,ll c)
{
	if(x>N)
	return 0;
	else if(a==1&&b==1&&c==1)
	ans++;
	
	dfs(x*10+arr[0],1,b,c);
	dfs(x*10+arr[1],a,1,c);
	dfs(x*10+arr[2],a,b,1);
}	
int main()
{
	cin >> N;
	
	dfs(arr[0],1,0,0);
	dfs(arr[1],0,1,0);
	dfs(arr[2],0,0,1);
	
	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
using namespace std;
int main(){
    int N;
    cin >> N;
    string S[N];
    int count = 0;
    for(int i =0;i<N;i++)
    {
        cin >> S[i];
    }
    set<string> sset(S,S+N);
    for(auto it = sset.begin();it!=sset.end();it++)
    {
        //cout << ' ' << *it << "\n";
        count++;
    }
    cout << count;
    
    return 0;
}

Measured memory_bytes: 25372
const t={input:require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/),n:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.n())}return a}else{const a=t.input[0];t.input.shift();return Number(a)}},s:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.s())}return a}else{const a=t.input[0];t.input.shift();return String(a)}},c:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.c())}return a}else{let a=t.input[0].split('');const b=a[0];a.shift();if(a.length>0){t.input[0]=a.join('')}else{t.input.shift()}return String(b)}},o:(...arg)=>{console.log(...arg)},abs:(a)=>{return Math.abs(a)},min:(...a)=>{return Math.min(...a)},max:(...a)=>{return Math.max(...a)},floor:(a)=>{return Math.floor(a)},asc:(ar:number[])=>{return ar.sort((a,b)=>{return a-b})},desc:(ar:number[])=>{return ar.sort((a,b)=>{return b-a})},sw:(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]}};
const main=()=>{
  let [n,d]=t.n(2)
  let x=[];
  for(let i=0;i<n;i++){
    x[i] = t.n(d)
  }
  let c=0
  for(let i=0;i<n;i++){
    for(let j=0;j<i;j++){
      if(i===j)continue
      let g=0;
      for(let k=0;k<d;k++){
        g+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k])
      }
      if(Number.isInteger(Math.sqrt(g)))c++
    }
  }
  t.o(c)
}
main()


Measured memory_bytes: 7372
#include <cstdio>
using namespace std;
int main(){
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	if(a+b>c+d)
		printf("Left");
	else if(a+b==c+d)
		printf("Balanced");
	else
		printf("Right");
	return 0;
}

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

int main(){
	int n, i;
	ll a[100010];
	ll sum, ans, sum2, ans2;
	bool sign;
	cin>>n;
	for(i=0; i<n; i++) cin>>a[i];
	// s0>0
	sign=true;
	if(a[0]>0){
		ans=0;
		sum=a[0];
	}
	else{
		ans=1-a[0];
		sum=1;
	}
	for(i=1; i<n; i++){
		sign=!sign;
		if(sign){
			if(sum+a[i]>0) sum+=a[i];
			else{
				ans+=1-(sum+a[i]);
				sum=1;
			}
		}
		else{
			if(sum+a[i]<0) sum+=a[i];
			else{
				ans+=1+(sum+a[i]);
				sum=-1;
			}
		}
	}
	// s0<0
	sign=false;
	if(a[0]<0){
		ans2=0;
		sum2=a[0];
	}
	else{
		ans2=1+a[0];
		sum2=-1;
	}
	for(i=1; i<n; i++){
		sign=!sign;
		if(sign){
			if(sum2+a[i]>0) sum2+=a[i];
			else{
				ans2+=1-(sum2+a[i]);
				sum2=1;
			}
		}
		else{
			if(sum2+a[i]<0) sum2+=a[i];
			else{
				ans2+=1+(sum2+a[i]);
				sum2=-1;
			}
		}
	}
	cout<<min(ans, ans2)<<endl;
	return 0;
}

Measured memory_bytes: 1152
N=gets.chomp.to_i
prev = 0
cnt = 0
0.upto(N-1){|d|
	a,_ = gets.chomp.split(' ').map{|n| n.to_i}
	cnt += (a+prev) / 2
	prev = a == 0 ? 0 : (a+prev) % 2
}
puts cnt


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e9+7
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 long long int gcd(long long int m,long long int n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
long long int lcm(long long int number1,long long int number2){
	return number1 * number2 / gcd(number1,number2);	

}
int main(){
  ll A,B,C,D,E,F;
  cin>>A>>B>>C>>D>>E>>F;
  
  double max2=0;
  ll sugar=0;
  ll water=0;
  
  for(ll i=0;i*100*A<F;i++){//A
    for(ll j=0;j*100*B<F;j++){//B
      for(ll k=0;k*C<F;k++){//C
        for(ll m=0;m*D<F;m++){//D
          if(i==0&&j==0){
            continue;
          }
          if(k*C+m*D+A*100*i+B*100*j>F){
            continue;
          }
        double unko=double(double(k*C+m*D)/double(A*100*i+B*100*j+k*C+m*D));
          
          if(max2<=unko&&(k*C+m*D)<=E*(A*i+B*j)){
            max2=double(double(k*C+m*D)/double(A*100*i+B*100*j+k*C+m*D));
          sugar=(k*C+m*D);
            water=(A*100*i+B*100*j);
          }
          }
        }
      }
    }
  
  
  cout<<water+sugar<<" "<<sugar<<endl;
}


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

using namespace std;

int main(void) {
  int N;
  cin >> N;
  int v[1000];
  for(int i = 0; i < N; i++) {
    cin >> v[i]; 
  }
  sort(v, v + N);
  
  cout << defaultfloat << std::setprecision(5);
  
  long double tmp = v[0];
  for(int i = 1; i < N; i++) {
    tmp = (long double)(tmp + v[i]) / 2;
  }
  
  cout << tmp;
  
  return 0; 
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i,j,k;
  int N,K;
  scanf("%d %d",&N,&K);
  if(K==1){
    puts("0");
    return 0;
  }
  else{
    printf("%d\n",N-K);
    return 0;
  }
  return 0;
}



Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//using ll = long long;
//void p(vector<int> A){rep(i,A.size()){cout << A[i] << " ";}cout << "\n";}

int main(){
    string a,b;
    cin >> a >> b;
    vector<string> n(2);
    n[0] = a;
    n[1] = b;
    sort(n.begin(),n.end());
    if(a.size() > b.size())cout << "GREATER";
    else if(a.size() < b.size()) cout << "LESS";
    else if(a != b && n[1] == a)cout << "GREATER";
    else if(a != b && n[0] == a)cout << "LESS";
    else if (a == b)cout << "EQUAL";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int min = 1000;
		String temp = s;
		boolean bool = true;
		for (int i =1;i<s.length();i++) {
			if (s.charAt(i)!=s.charAt(0)) {
				bool= false;
				break;
			}
		}
		if (bool) {
			System.out.println(0);
			return ;
		}
		for (char c= 'a';c<='z';c++) {
			boolean b = false;
			int count =0;
			temp = s;
			while (!b) {
				b = true;
				StringBuffer sb = new StringBuffer();
				for (int i=0;i<temp.length()-1;i++) {
					if (temp.charAt(i)==c||temp.charAt(i+1)==c) {
						sb.append(c);
					} else {
						sb.append(temp.charAt(i));
						b = false;
					}
				}
				temp = sb.toString();
				count ++;
			}
			if (count<min) {
				min = count;
			}
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 38776
import java.util.*;

/**
 * Main
 */
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		char[] S = sc.next().toCharArray();
		String ans = "Yes";

		for (int i = 0; i < S.length; i++) {
			if (i % 2 == 0 && S[i] == 'L') {
				ans = "No";
				System.out.println(ans);
				return;
			}
			if (i % 2 != 0 && S[i] == 'R') {
				ans = "No";
				System.out.println(ans);
				return;
			}

		}

		System.out.println(ans);
		sc.close();
	}
};


Measured memory_bytes: 35520
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);

    int n = Integer.parseInt(r.readLine());
    String[] sl = r.readLine().split("[\\s]+");
    int d = Integer.parseInt(sl[0]);
    int x = Integer.parseInt(sl[1]);

    for(int i = 0; i < n; i++)
    {
      int z = Integer.parseInt(r.readLine());
      for(int j = 0; j < d; j += z)
      {
        x++;
      }
    }

    System.out.println(x);

  }

}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int main()
{
    double n,k;

    cin>>n>>k;
n=abs(n);
k=abs(k);
    double ans=log(n)/log(2);
    double p=log(k)/log(2);
    int len=ans/p;
    // cout<<ans<<" "<<p<<endl;
    cout<<len+1<<endl;
    return 0;
    }

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

int main(){
  int n,a,b,c,d,p,q,res=10000;
  cin >> n >> a >> b >> c >> d;
  a--;b--;c--;d--;
  for(int w=1;w<=n;w++){
    p = abs(a/w-b/w) + abs(a%w-b%w);
    q = abs(c/w-d/w) + abs(c%w-d%w);
    //cout << p <<" " << q << endl;;
    res = min(res,p+q);
  }
  cout << res << endl;
}

Measured memory_bytes: 3104
// 2020 3/26 D - Dice in Line
// 累積和!!!
#include <iostream>
#include <cstdio>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

double E(int x) {
    return  (double)(x + 1) / 2.0;
}



int main() {
    int N, K;
    int p[200010];
    double Ruisekiwa[200010];
    Ruisekiwa[0] = 0.0;
    double ans = 0.0;
    cin >> N >> K;
    rep(i, N) {
        cin >> p[i];
    }
    rep(i, N) {
        Ruisekiwa[1+i] = Ruisekiwa[i] +  E(p[i]);
    }
    rep(i, N-K+1) {
        //要素Nの数列に対し，累積和はN+1
        double tmp = Ruisekiwa[K+i] - Ruisekiwa[i];
        ans = max(ans, tmp);
    }
//    rep(i, N-K+1) {
//        float tmp = 0.0;
//        rep(j, K) {
//            tmp += E(p[i+j]);
//        }
//        cout << i << " : " << tmp << endl;
//        ans = max(ans, tmp);
//    }

    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>

using namespace std;

int main() {
	string abc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	int h, w;
	cin >> h >> w;
	string s;
	int ii, jj;
	ii = jj = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> s;
			if (s == "snuke") {
				ii = i+1;
				jj = j;
			}
		}
	}
	cout << abc[jj] << ii << endl;
	return 0;
}

Measured memory_bytes: 256
/*author : Yashvardhan
Saturday, May 02, 2020
6:04 PM
*/

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

using ll = long long;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define rev(Y) reverse(all(Y))

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int takemod(int a){return ((a%mod)+mod)%mod;}

int pow(int a, int b, int m)
{
	int ans = 1;
	a %= m;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

int modinv(int a){return takemod( pow( takemod(a), mod-2,mod ) );}

int n,m,q;
struct my_struct{
	int a;
	int b; 
	int c; 
	int d;
	
	my_struct(int ad, int bd, int cd, int dd){
		a = ad;
		b = bd;
		c = cd;
		d = dd;
	}
};

vector<my_struct> tmp;

int ans = -1;
void solve(vi arr, int last){
	if(arr.size() == n){
		int val = 0;
		for(int i = 0; i < q; i++){
			my_struct curr = tmp[i];
			if(arr[curr.b] - arr[curr.a] == curr.c){
				val += curr.d;
			}
		}
		ans = max(ans, val);
		return; 
	}
	
	for(int i = last; i <= m; i++){
		vi tarr = arr;
		tarr.pb(i);
		solve(tarr, i);
	}
}

signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	cin >> n >> m >> q;
	
	for(int i = 0; i < q; i++){
		int a,b,c,d;
		cin >> a >> b >> c >> d;
		a--; b--;
		tmp.pb(my_struct(a, b, c, d));
	}

	vi et;
	for(int i = 1; i <= m; i++) solve(et, i);

	cout << ans << endl;

	t2 = clock();
	cerr << endl << t2-t1 << endl;
	
	return 0;
}



Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,y,i,j,k,cou10000,cou5000,judge;
  judge = 0;
  cin >> y >> n;
  cou10000 = n / 10000;
  cou5000 = n / 5000;
  for(i=0;i<=cou10000;i++){
    for(j=0;j<=cou5000;j++){
        k = y - i - j ;
           if(n==i*10000+j*5000+k*1000 && k>=0){
             judge = 1;
             cout << i << " "<< j << " " << k << endl;
             break;
           		}
      }
    if(judge==1){break;}
    }
    if(judge==0){
      cout << -1 << " " << -1 << " " << -1 << endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <iomanip> //小数点以下を表示させる(setprecision())

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'

//DP法
template <class T>
inline bool chmin(T &a, T b) //change minimum
{
        if (a > b)
        {
                a = b;
                return true;
        }
        return false;
}
template <class T>
inline bool chmax(T &a, T b) //change max
{
        if (a < b)
        {
                a = b;
                return true;
        }
        return false;
}

typedef long long ll; //64bit型

using namespace std;

// const long long INF = 1LL << 60; //無限大の値
int INF = 1000000;

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

        if (S[0]==S[1]||S[1]==S[2]||S[2]==S[3])
        {
                puts("Bad");
        }
        else
        {
                puts("Good");
        }
        return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<vector>
using namespace std;
int n,q,k;
int dep[100010];
long long dis[100010];
vector<pair<int,long long> >v[100010];
bool vis[100010];
int par[100010][22];
void dfs(int x)
{
	vis[x]=true;
	for(int i=0;i<v[x].size();i++)
	{
		int y=v[x][i].first;
		long long w=v[x][i].second;
		if(vis[y])continue;
		dep[y]=dep[x]+1;
		par[y][0]=x;
		dis[y]=dis[x]+w;
		dfs(y);
	}
}
int lca(int x,int y)
{
	if(dep[x]<dep[y])swap(x,y);
	for(int i=20;i>=0;i--)
	{
		if(dep[par[x][i]]>=dep[y])x=par[x][i];
	}
	if(x==y)return x;
	for(int i=20;i>=0;i--)
	{
		if(par[x][i]!=par[y][i])
		{
			x=par[x][i];
			y=par[y][i];
		}
	}
	return par[x][0];
}
long long gtdis(int x,int y)
{
	return dis[x]+dis[y]-2LL*dis[lca(x,y)];
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int a,b;
		long long c;
		scanf("%d%d%lld",&a,&b,&c);
		v[a].push_back(make_pair(b,c));
		v[b].push_back(make_pair(a,c));
	}
	dfs(1);
	dep[0]=-1;
	for(int i=1;i<=20;i++)
	{
		for(int j=2;j<=n;j++)par[j][i]=par[par[j][i-1]][i-1];
	}
	scanf("%d%d",&q,&k);
	for(int i=1;i<=q;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		printf("%lld\n",gtdis(x,k)+gtdis(y,k)); 
	}
	return 0;
} 

Measured memory_bytes: 23424
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  for (int i = 0; i < N; i++) {cin >> S.at(i);}
  int A = 0, W = 0, T = 0, R = 0;
  for (int i = 0; i < N; i++) {
    if (S.at(i) == "AC") {A++;}
    else if (S.at(i) == "WA") {W++;}
    else if (S.at(i) == "TLE") {T++;}
    else if (S.at(i) == "RE") {R++;}}
  cout << "AC x " << A << endl;
  cout << "WA x " << W << endl;
  cout << "TLE x " << T << endl;
  cout << "RE x " << R << endl;}

Measured memory_bytes: 6424
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
using namespace std;
using ll = long long;

int main(){
  int N;
  cin >> N;
  ll ldx=1e9,ldy=1e9,rux=0,ruy=0,rdx=1e9,rdy=1e9,lux=1e9,luy=1e9;
  for(int i=0;i<N;i++){
    ll x,y;
    cin >> x >> y;
    if(x+y<ldx+ldy){
      ldx=x;
      ldy=y;
    }
    if(x+y>rux+ruy){
      rux=x;
      ruy=y;
    }
    x=1000000000-x;
    if(x+y<rdx+rdy){
      rdx=x;
      rdy=y;
    }
    x=1000000000-x;
    y=1000000000-y;
    if(x+y<lux+luy){
      lux=x;
      luy=y;
    }
  }
  rdx=1000000000-rdx;
  luy=1000000000-luy;
  ll one=abs(ldx-rux)+abs(ldy-ruy);
  ll two=abs(lux-rdx)+abs(luy-rdy);
  cout << max(one,two) << endl;
}

Measured memory_bytes: 3612
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cstring>
#include<queue>
#include<cmath>
#include<algorithm>
using namespace std;
long long n;
int main() {
	cin>>n;
	cout<<3*n*n;
	return 0;
}


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

int main(){

    int a,b;
    cin >> a >> b;
    if(a==b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int N = sc.nextInt();
        if (N == 1) {
            System.out.println(solve());
        } else {
            int A = sc.nextInt();
            int B = sc.nextInt();

            System.out.println(solve(A, B));
        }

        sc.close();
    }

    static String solve() {
        return "Hello World";
    }

    static int solve(int A, int B) {
        return A + B;
    }
}

Measured memory_bytes: 35916
#include <bits/stdc++.h>
using namespace std;
int main(){
    int x,y,z,k,p,q;
    cin>>x>>y>>z>>k;
    vector<long long int> a(x);
    vector<long long int> b(y);
    vector<long long int> c(z);
    vector<long long int> ab(x*y);
    vector<long long int> abc(3000*z);
    p=q=0;

    for(int i=0;i<x;i++)cin>>a.at(i);
    for(int i=0;i<y;i++)cin>>b.at(i);
    for(int i=0;i<z;i++)cin>>c.at(i);
    for(int i=0;i<x;i++){
        for(int j=0;j<y;j++){
            ab.at(p)=a.at(i)+b.at(j);
            p++;
        }
    }
    sort(ab.begin(),ab.end());
    reverse(ab.begin(),ab.end());
    vector<long long int> ab_n(3000);
    for(int i=0;i<min(3000,x*y);i++){
        ab_n.at(i)=ab.at(i);
    }

    for(int i=0;i<z;i++){
        for(int j=0;j<3000;j++){
            abc.at(q)=c.at(i)+ab_n.at(j);
            q++;
        }
    }

    sort(abc.begin(),abc.end());
    reverse(abc.begin(),abc.end());

    for(int i=0;i<k;i++){
        cout<<abc.at(i)<<endl;
    }
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793
const int INF = 100000000;
int dx[] = {0,1,-1,0,1,-1,1,-1};
int dy[] = {1,0,0,-1,1,-1,-1,1};


int main(){
    int a, b;
    cin >> a >> b;
    cout << (b % a ? b-a : a+b) << endl;
}


Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

//package acl

// Dsu :
type Dsu struct {
	parentOrSize []int
	n            int
}

// NewDsu :
func NewDsu(n int) *Dsu {
	var d Dsu
	d.n = n
	d.parentOrSize = make([]int, n)
	for i := 0; i < n; i++ {
		d.parentOrSize[i] = -1
	}
	return &d
}

// Merge :
func (d Dsu) Merge(a, b int) int {
	x, y := d.Leader(a), d.Leader(b)
	if x == y {
		return x
	}
	if -d.parentOrSize[x] < -d.parentOrSize[y] {
		x, y = y, x
	}
	d.parentOrSize[x] += d.parentOrSize[y]
	d.parentOrSize[y] = x
	return x
}

// Same :
func (d Dsu) Same(a, b int) bool {
	return d.Leader(a) == d.Leader(b)
}

// Leader :
func (d Dsu) Leader(a int) int {
	if d.parentOrSize[a] < 0 {
		return a
	}
	d.parentOrSize[a] = d.Leader(d.parentOrSize[a])
	return d.parentOrSize[a]
}

// Size :
func (d Dsu) Size(a int) int {
	return -d.parentOrSize[d.Leader(a)]
}

// Groups : original implement
func (d Dsu) Groups() [][]int {
	m := make(map[int][]int)
	for i := 0; i < d.n; i++ {
		x := d.Leader(i)
		if x < 0 {
			m[i] = append(m[i], i)
		} else {
			m[x] = append(m[x], i)
		}
	}
	ret := make([][]int, len(m))
	for i, e := range m {
		ret[i] = make([]int, len(e))
		copy(ret[i], e)
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	n, q := getInt(), getInt()

	d := NewDsu(n)
	for i := 0; i < q; i++ {
		t, u, v := getInt(), getInt(), getInt()
		if t == 0 {
			d.Merge(u, v)
		} else {
			if d.Same(u, v) {
				out("1")
			} else {
				out(0)
			}
		}
	}
}


Measured memory_bytes: 4960
n = int(input())
S = []
P = []
S_P = {}
index = {}
for i in range(n):
    s, p = input().split()
    if str(s) in S_P.keys():
        S_P[str(s)].append(int(p))
    else:
        S_P[str(s)] = [int(p)]
    index["{}:{}".format(int(p),str(s))] = i + 1

for i in sorted(S_P.keys()):
    for j in sorted(S_P[i], reverse=True):
        print(index["{}:{}".format(j,i)])

Measured memory_bytes: 3064
import sys
imput=sys.stdin.readline
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
y=[list(map(int,input().split()))[::-1] for i in range(m)]
y.sort()
y=y[::-1]
#print(y)

l=[]
w=0
for i in range(m):
    w+=y[i][1]
    l+=[y[i][0]]*y[i][1]
    if w>=n:
        break

#print(l)
l=l[:n]
ans=0
#print(a,l)
for i in range(n):
    if i<=len(l)-1:
        ans+=max(a[i],l[i])
    else:
        ans+=a[i]

print(ans)

Measured memory_bytes: 26572
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

struct UnionFind {
public:
	using size_type = std::size_t;
	
	UnionFind(size_type n) : n(n), size_(n, 1) {
		par.resize(n);
		std::iota(par.begin(), par.end(), 0);
	}
	
	size_type size(size_type x) { return size_[find(x)]; }
	
	size_type find(size_type x) {
		assert(x < n);
		while (par[x] != x) {
			par[x] = par[par[x]];
			x = par[x];
		}
		return x;
	}
	
	void unite(size_type x, size_type y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (size(x) > size(y)) std::swap(x, y);
		par[x] = y;
		size_[y] += size_[x];
	}
	
	bool issame(size_type x, size_type y) { return find(x) == find(y); }
	
private:
	size_type n;
	std::vector<size_type> size_, par;
};


int main() {
	int N, M;
	cin >> N >> M;
	
	vector<int> A(N);
	REP(i, N) scanf("%d", &A[i]);
	
	UnionFind uf(N);
	REP(i, M) {
		int x, y;
		scanf("%d %d", &x, &y);
		uf.unite(x, y);
	}
	
	vector<vector<int>> dat(N);
	vector<int> res;
	ll ans = 0;
	
	REP(i, N) dat[uf.find(i)].emplace_back(A[i]);
	int cnt = 0;
	REP(i, N) if (!dat[i].empty()) {
		++cnt;
		sort(ALL(dat[i]));
		FOR(j, 1, dat[i].size()) res.emplace_back(dat[i][j]);
		ans += dat[i][0];
	}
	sort(ALL(res));
	
	int nec = 2 * (cnt - 1);
	
	if (nec > N) {
		puts("Impossible");
		return 0;
	}
	
	REP(i, nec - cnt) ans += res[i];
	
	if (cnt == 1) ans = 0;
	cout << ans << endl;
	return 0;
}


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

string convert(ll n) {
    if(n==0) return "";
    n--;
    ll mod = n % 26;
    char cur = (char)('a' + mod);
    ll remain = n/26;
    return convert(remain) + cur;
}

int main(){
    ll x;
    cin >> x;
    cout << convert(x);
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class I,class V=typename I::value_type>V sum_up(const I&l,const I&r){V v;for(I i=l;i!=r;i++)v=i==l?*i:v+*i;return v;}
template<class I,class T=iterator_traits<I>>I operator+(I it,int n){for(int i=0;i<n;i++)it++;return it;}
template<class I,class T=iterator_traits<I>>I operator-(I it,int n){for(int i=0;i<n;i++)it--;return it;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int p;fixprec(int p):p(p){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.p);}
void R_YESNO(bool p){cout<<(p?"YES":"NO")<<endl;}
void R_YesNo(bool p){cout<<(p?"Yes":"No")<<endl;}

int SierpinskiGasket(int n, int m) {
    int k = n - m;
    int n2 = 0, k2 = 0, m2 = 0;
    while(n) {
        n >>= 1;
        n2 += n;
    }
    while (k) {
        k >>= 1;
        k2 += k;
    }
    while (m) {
        m >>= 1;
        m2 += m;
    }
    return n2 > k2 + m2 ? 0 : 1;
}

int main() {
    int N;
    string S;
    cin >> N >> S;
    // 差分だけ考えるので-1してもよい
    for(char &c : S) c--;
    vector<int> A;
    
    // 2が答えの時だけは特別扱い
    // 2が答えのとき，1は含まれないので2を1かのように扱う
    // 0,1が答えのとき，2は0として扱ってもよい(mod 2で計算)

    // 1が存在するか
    bool has1 = false;
    for(char c : S) {
        A.push_back(c - '0');
        if(c == '1') has1 = true;
    }
    // mod2 なので和と差が同じ操作になる，絶対値が恒等変換になる．
    for(int &a : A) {
        if(has1) a %= 2;
        else a /= 2;
    }
    int ans = 0;
    for(int i = 0; i < N; i++) {
        ans ^= A[i] & SierpinskiGasket(N - 1, i);
    }
    if(ans && has1) cout << 1 << endl;
    else if(ans && !has1) cout << 2 << endl;
    else if(!ans) cout << 0 << endl;
    return 0;
}



Measured memory_bytes: 7548
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (let* ((unit-r (read))
         (unit-g (read))
         (unit-b (read))
         (n (read))
         (res 0))
    (loop for r from 0 by unit-r
          while (<= r n)
          do (loop for g from 0 by unit-g
                   for rest = (- n r g)
                   while (<= g n)
                   do (when (and (>= rest 0)
                                 (zerop (mod rest unit-b)))
                        (incf res))))
    (println res)))

#-swank(main)


Measured memory_bytes: 18408
N, M = (int(i) for i in input().split()) 

total = 0
sp = []
for i in range(N):
    a, b = (int(i) for i in input().split())
    sp.append((a,b)) 

sp.sort(key=lambda x:x[0])

#print(sp)
for sh in sp:    
    if M >= sh[1]:
        total += sh[0] * sh[1]
        M = M - sh[1]
    else:
        total += sh[0] * M
        M = 0
    if M == 0:
        break
print(total)


Measured memory_bytes: 58584
#include <iostream>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int ret = 0;
  for (int i=1; i<=N; i++) {
    if (i < 10) ret++;
    else if (i < 100) ;
    else if (i < 1000) ret++;
    else if (i < 10000) ;
    else if (i < 100000) ret++;
    else if (i < 1000000) ;
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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; }

int h, w;
vector<string> s;

vector<int> G[160160];
bool visited[160160];

vector<ll> cnt;

void dfs(int v) {
  if (visited[v]) return;
  visited[v] = true;
  if (s[v / w][v % w] == '#') cnt[0]++;
  else cnt[1]++;
  for (int u: G[v]) {
    dfs(u);
  }
}

int main() {
  cin >> h >> w;
  s.resize(h);
  rep(i, h) cin >> s[i];

  rep(i, h) {
    rep(j, w) {
      rep(k, 4) {
        int ry = i + dy[k], rx = j + dx[k];
        if (ry < 0 || ry >= h || rx < 0 || rx >= w) continue;
        if (s[i][j] != s[ry][rx]) {
          G[i * w + j].push_back(ry * w + rx);
        }
      }
    }
  }
  ll ans = 0;
  rep(i, h) {
    rep(j, w) {
      if (visited[i * w + j]) continue;
      cnt = vector<ll>(2, 0);
      dfs(i * w + j);
      ans += cnt[0] * cnt[1];
    }
  }
  cout << ans << endl;


  
  return 0;
}

Measured memory_bytes: 14336
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int N=110;
const int mod=1e9+7;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
template<typename T> bool chkmax(T &a,T b) { return a<b?a=b,1:0; };
template<typename T> bool chkmin(T &a,T b) { return a>b?a=b,1:0; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
int f[N][N][N],a[N],n;
int main() {
    cin>>n;
    for(int i=1;i<=2*n-1;i++) a[i]=gi();
    sort(a+1,a+2*n);
    f[n][1][0]=1;
    for(int i=n-1;i;i--)
        for(int l=0;l<=2*n-1;l++)
            for(int r=0;l+r<=2*n-1;r++)
                if(f[i+1][l][r]) {
                    int al=(a[i]!=a[i+1]),ar=(a[2*n-i]!=a[2*n-i-1]);
                    for(int dl=1;dl<=l+al;dl++) inc(f[i][l+al-dl+1][r+ar+(dl>1)],f[i+1][l][r]);
                    for(int dr=1;dr<=r+ar;dr++) inc(f[i][l+al+1][r+ar-dr],f[i+1][l][r]);
                }
    int ans=0;
    for(int l=0;l<=2*n-1;l++)
        for(int r=0;l+r<=2*n-1;r++) inc(ans,f[1][l][r]);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <string>
#include <algorithm>
#include <sstream>
#include <vector>

int main(void)
{
    std::string s, t;
    std::cin >> s >> t;
    std::sort(s.begin(), s.end(), std::less<char>());
    std::sort(t.begin(), t.end(), std::greater<char>());
    std::cout << (s < t ? "Yes" : "No") << std::endl;
    return 0;
}


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


int main(){
	int n, m, X, Y;
    int p;
    vector<int> x(0);
    vector<int> y(0);

    cin >> n >> m >> X >> Y;
    for(int i=0;i<n;i++){
        cin >> p;
        x.push_back(p);
    }
    for(int i=0;i<m;i++){
        cin >> p;
        y.push_back(p);
    }

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    if(x[n-1] < y[0]){
        if(X < y[0] && y[0] <= Y){
            cout << "No War" << endl;
            return 0;
        }
    }

    cout << "War" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

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

const int MAX = 1e5 + 5;
vector<int> adj[MAX];
bool visited[MAX];

void dfs(int x) {
    visited[x] = true;
    for (auto &each : adj[x]) if (!visited[each]) dfs(each);
}

void solve() {
    int n, m;
    cin >> n >> m;
    fori (i, 0, m) {
        int u, v, w;
        cin >> u >> v >> w;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    int ans = 0;
    fori (i, 1, n + 1) {
        if (!visited[i]) {
            dfs(i);
            ans++;
        }
    }
    cout << ans << endl;
}

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



Measured memory_bytes: 8960
// Problem: G - Longest Path
// Contest: AtCoder - Educational DP Contest
// URL: https://atcoder.jp/contests/dp/tasks/dp_g
// Parsed on: 2020-09-07 09:26:37
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)

#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

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

using namespace std;

int solve(vector<vector<int>> const &graph, int startNode, vector<int> &dp) {
    if (dp[startNode] != -1) return dp[startNode];

    if (graph[startNode].empty()) {
        dp[startNode] = 0;
        return 0;
    } else {
        int ans = -1;
        for (int a = 0; a < graph[startNode].size(); a++) {
            int node = graph[startNode][a];
            ans = max(ans, solve(graph, node, dp));
        }
        dp[startNode] = ans + 1;
        return dp[startNode];
    }
}

int main() {
    fastio int n, m;
    cin >> n >> m;
    vector<vector<int>> graph(n, vector<int>()), revG(n, vector<int>());
    vector<int> endpoints;
    vector<bool> edp(n, true);
    for (int t = 0; t < m; t++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        graph[a].push_back(b);
        revG[b].push_back(a);
        edp[a] = false;
    }

    for (int a = 0; a < n; a++)
        if (edp[a]) endpoints.push_back(a);

    vector<int> dp(n, -1);

    int ans = -1;
    for (auto &e : endpoints) ans = max(ans, solve(revG, e, dp));
	cout << ans;
    //for (auto &e : dp) cerr << e << " ";

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pi;

ll n,dp[100034];
vector<ll> h;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n;
	for(int i=0;i<=n;i++)
		dp[i]=98765432111;
	for(int i=0;i<n;i++)
	{
		ll a;cin>>a;
		h.push_back(a);		
	}
	dp[0]=0;		
	for(int i=1;i<n;i++)
	{
		dp[i]=min(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
		if(i-2>=0)
			dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 2168
//あらためて見るとこの問題全然わからない

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

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

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


	int N = getint();
	int A[2][200000], B[2][200000];
	int kazuA[29] = {}, kazuB[29] = {};
	rep(i, N) {
		int a = getint();
		A[0][i] = a; 
		rep(j, 28) kazuA[j] += a >> j & 1;
	}
	rep(i, N) {
		int b = getint();
		B[0][i] = b;
		rep(j, 28) kazuB[j] += b >> j & 1;
	}
	int kotae = 0;
	rep(i, 29) {
		int p = i & 1;
		auto Amae = A[p];
		auto Bmae = B[p];
		auto Atugi = A[!p];
		auto Btugi = B[!p];

		int kari = (N & (kazuA[i] ^ kazuB[i])) ^ N;
		if (i) {
			int d = (1 << i) - 1;
			int d2 = 1 << i;
			int k = N;
			rep(j, N) {
				while (k > 0 && (Amae[j] & d) + (Bmae[k - 1] & d) >= d2) k--;
				kari ^= k;
			}
		}
		else kari ^= N;

		if (i != 28) {
			int kazu[2];
			kazu[0] = 0;
			kazu[1] = N - kazuA[i];
			rep(j, N) Atugi[kazu[Amae[j] >> i & 1]++] = Amae[j];
			kazu[0] = 0;
			kazu[1] = N - kazuB[i];
			rep(j, N) Btugi[kazu[Bmae[j] >> i & 1]++] = Bmae[j];
		}
		kotae += (kari & 1) << i;
	}

	printf("%d", kotae);

	Would you please return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
int index(char c) {
	if(c == 'J') return 2;
	if(c == 'O') return 1;
	else return 0;
}
int main() {
	int n;
	string str;
	cin >> n >> str;
	int dp[1001][1<<3] = {};
	for(int i = 0; i < (1 << 3); i++) {
		if(i & 4 && i & 1 << index(str[0])) {
			dp[0][i] = 1;
		}
	}
	for(int i = 1; i < n; i++) {
		for(int j = 0; j < 1 << 3; j++) {
			for(int k = 0; k < 1 << 3; k++) {
				if(!(k & 1 << index(str[i]))) continue;
				if(!(j & k)) continue;
				dp[i][k] += dp[i-1][j];
				dp[i][k] %= 10007;
			}
		}
	}
	int ans = 0;
	for(int i = 0; i < 1 << 3; i++) {
		ans += dp[n-1][i];
		ans %= 10007;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin >> a>> b>>c;
    if(a==b&&a!=c){
        cout<<"Yes";
    }
    else if(a==c&&a!=b){
        cout<<"Yes";
    }
    else if(b==c&&a!=c){
        cout<<"Yes";
    }
    else{
        cout<< "No";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define endl        "\n"
#define si(a)       scanf("%d",&a)
#define si2(a,b)    scanf("%d%d",&a,&b)
#define sl(a)       scanf("%lld",&a)
#define sl2(a,b)    scanf("%lld%lld",&a,&b)
#define pb          push_back
#define mk          make_pair
#define loop(n)     for(int i=0; i<n; i++)
#define FOR(a,b)    for(int i=a; i<=b; i++)
#define sz          size()
#define ff          first
#define ss          second
#define mem(a,val)  memset(a, val, sizeof(a))
#define md          1000000007
#define pi          acos(-1.0)

ll a[200010], m[1000005];
int main()
{
    ll t,n,i,j,k,l,r,mn=0, mx=1;
    sl(n);
    ll cnt=0;
    for(int i=0; i<n; i++)
    {
        sl(a[i]); m[a[i]]++;
    }

    ll f =0;
    for(int i=0; i<n; i++)
    {
        f=0;
        if(m[a[i]]>1) continue;
        for(ll j=1; j*j<=a[i]; j++)
        {

            if(a[i]%j==0)
            {
                if(m[j]>0 && j!=a[i]) f=1;

                ll p=a[i]/j;
                if(m[p]>0 && p!=a[i]) f=1;
            }
        }
        //cout<<a[i]<<" "<<f<<endl;
        if(f==0) cnt++;
    }
  cout<<cnt;
}

Measured memory_bytes: 13132
#include <stdio.h>
 
int main(void)
{
    int i, j, k;
    int n, m, l;
    int a[100][100]={};
    int b[100][100]={};
    long long int c[100][100]={};
     
    scanf("%d%d%d", &n, &m, &l);
     
    for(i=0; i<n; i++) {
        for(k=0; k<m; k++)
            scanf("%d", &a[i][k]);
    }
    for(k=0; k<m; k++) {
        for(j=0; j<l; j++)
            scanf("%d", &b[k][j]);
    }
     
    for(i=0; i<n; i++) {
        for(j=0; j<l; j++) {
            for(k=0; k<m; k++)
                c[i][j]+=a[i][k]*b[k][j];
        }
    }
     
    for(i=0; i<n; i++) {
        for(j=0; j<l; j++) {
            printf("%lld", c[i][j]);
            if(j!=l-1) putchar(' ');
        }
        putchar('\n');
    }
     
    return 0;
}



Measured memory_bytes: 2912