akhauriyash/Code-Regression huggingface dataset:
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever while (true)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
using namespace std;
// clang-format on

main {
  int n;
  cin >> n;
  while (n--) {
    string x, y;
    cin >> x >> y;
    vvi dp(x.size() + 1, vi(y.size() + 1));
    dp[0][0] = 0;
    loop(i, 1, x.size() + 1) loop(j, 1, y.size() + 1) {
      if (x[i - 1] == y[j - 1]) {
        dp[i][j] = dp[i - 1][j - 1] + 1;
        continue;
      }
      dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
    }
    cout << dp.back().back() << endl;
  }
}

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

int main() {
  int64_t n,k; cin >> n >> k;
  int64_t ans = k*pow(k-1,n-1);
  printf("%ld\n", ans);
}

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

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

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.*;

class Node {
    public int parent;
    public int left;
    public int right;
}

public class Main implements Runnable {
    static final int MAX = 25;
    static final int NIL = -1;
    Node[] T = new Node[MAX];

    public static void main(String[] args) throws Exception {
        Thread.setDefaultUncaughtExceptionHandler((t, e) -> System.exit(1));
        new Thread(null, new Main(), "", 16 * 1024 * 1024).start();
    }

    public void run() {
        int nodeTotalCount = 0;
        int root = 0;

        // 入力
        for (int i = 0; i < T.length; i++) {
            T[i] = new Node();
            T[i].parent = NIL;
        }
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            nodeTotalCount = Integer.parseInt(br.readLine());
            for (int i = 0; i < nodeTotalCount; i++) {
                String[] line = br.readLine().split(" ");
                int id = Integer.parseInt(line[0]);
                int left = Integer.parseInt(line[1]);
                int right = Integer.parseInt(line[2]);
                T[id].left = left;
                T[id].right = right;
                if (T[id].left != NIL) {
                    T[left].parent = id;
                }
                if (T[id].right != NIL) {
                    T[right].parent = id;
                }
            }
            for (int i = 0; i < nodeTotalCount; i++) {
                if (T[i].parent == NIL) {
                    root = i;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        // 出力
        System.out.println("Preorder");
        preParse(root);
        System.out.println();
        System.out.println("Inorder");
        inParse(root);
        System.out.println();
        System.out.println("Postorder");
        postParse(root);
        System.out.println();
    }

    void postParse(int u) {
        if (u == NIL) {
            return;
        }
        postParse(T[u].left);
        postParse(T[u].right);
        System.out.printf(" %d", u);
    }

    void preParse(int u) {
        if (u == NIL) {
            return;
        }
        System.out.printf(" %d", u);
        preParse(T[u].left);
        preParse(T[u].right);
    }

    void inParse(int u) {
        if (u == NIL) {
            return;
        }
        inParse(T[u].left);
        System.out.printf(" %d", u);
        inParse(T[u].right);
    }
}



Measured memory_bytes: 30964
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
const ll mod = 998244353;


ll N;


int main() {
	cin >> N;
	int t=0, x=0, y=0;
	FOR(i, 0, N) {
		int T, X, Y;
		cin >> T >> X >> Y;
		int dis = abs(X - x) + abs(Y - y);
		if (T - t >= dis && (T - t - dis) % 2 == 0) {
			if (i == N - 1) {
				cout << "Yes" << endl;
				break;
			}
			t = T;
			x = X;
			y = Y;

		}
		else {
			cout << "No" << endl;
			break;
		}
	}
	



	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define imp() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define endl "\n"
#define lli long long int 
#define ll long long 
int main() {
	 string str;string t;cin>>str>>t;size_t found = str.find(t); 
    if (found!= string::npos)
	 {
	     cout<<0<<"\n";
	 }
	 else
	 {
	     int j=0;int c=0;int minn=INT_MAX;
	  for(int i=0;i<=str.size()-t.size();i++)
	  {int k=0;c=0;
	      for(int j=i;j<str.size();j++)
	    {
	       if(k<t.size())
	        {if(str[j]!=t[k])
	    {c++;
	    }k++;
	        }
	        
	   //k++;
	       // k++;
	    }
	    //cout<<c<<"\n";
	    minn=min(minn,c);
	  }
	  cout<<minn<<"\n";
	 }
	return 0;
}


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

using namespace std;

#define INF 0x7FFFFFFF

int main() {
  int N, T, A;
  
  cin >> N >> T >> A;
  
  int ans_i = 0;
  double ans_temperature = INF;
  
  for (int i = 1; i <= N; i++) {
    int in;
    
    cin >> in;
    
    if (ans_temperature > abs(A - T + in * 0.006d)) {
      ans_temperature = abs(A - T + in * 0.006d);
      ans_i = i;
    }
  }
  
  cout << ans_i << endl;
  
  return 0;
}

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

int main(){
  int n,tmp,cnt=0;
  cin >> n;
  vector<int> masu(n);
  for(int i=0;i<n;i++){
    cin >> tmp;
    masu.at(i)=tmp;
  }
  for(int i=0;i<n;i++){
    if((i+1)%2==1&&masu.at(i)%2==1)cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        char[] c = Console.ReadLine().ToCharArray();
        int sl = 0;
        string s = "";
        for (int i = 0; i < c.Length; i++)
        {
            if (c[i] == '0')
            {
                s += '0';
                sl++;
            }
            else if (c[i] == '1')
            {
                s += '1';
                sl++;
            }
            else if (c[i] == 'B')
            {
                if (s.Length == 1 || s.Length == 0)
                {
                    s = "";
                }
                else
                {
                    s = s.Remove(s.Length - 1);
                }
            }
        }
        Console.WriteLine(s);
    }
}



public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int Cin()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int main()
{
	int n;
	cin >> n;
	int c2 = 0,c4 = 0;
	rep(i,n){
		int a; cin >> a;
		if(a%4 == 0) c4++;
		else if(a%2 == 0) c2++;
	}
	if(c4) n--;
	cout << (c4*2+c2/2*2 >= n ? "Yes" : "No") << endl;
	

	return 0;
}

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

int main(){
	int n,i;
	cin>>n;
	for(i=0;i<n;i++){
		int y,m,d,j,k,sum=0;
		cin>>y>>m>>d;
		if(y%3==0){
			sum-=(m-1)*20;
			sum-=d-1;
		}else{
			for(;m>1;m--){
				if(m%2==0){
					sum-=20;
				}else{
					sum-=19;
				}
			}
			sum-=d-1;
		}
		for(;y<1000;y++){
			if(y%3==0){
				sum+=200;
			}else{
				sum+=195;
			}
		}
		cout<<sum<<endl;
	}
    return 0;
}

Measured memory_bytes: 1160
N = int(input())

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

ans = [-1 for i in range(N)]

for i in range(N):
    num = N-i
    index = 2
    cnt = 0
    while num * index <= N:
        if ans[num*index -1] != -1:
            cnt += ans[num*index -1]
        index += 1
    if cnt % 2 == 1:
        if a_dic[num-1] == 1:
            ans[num-1] = 0
        else:
            ans[num-1] = 1
    else:
        if a_dic[num-1] == 1:
            ans[num-1] = 1
        else:
            ans[num-1] = 0



print(sum(ans))
for i in range(N):
    if ans[i] == 1:
        print(i+1)


Measured memory_bytes: 7276
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }

bool f[26];

int main(int argc, char const *argv[]) {
  string s;
  cin >> s;
  int n=sz(s);
  rep(i,n){
    int m=s[i]-'a';
    f[m] = true;
  }

  if(n<26){
    rep(i,26){
      if(!f[i]){
        s+='a'+i;
        break;
      }
    }
      cout << s << endl;
  }
  else if(s=="zyxwvutsrqponmlkjihgfedcba") cout << "-1" << endl;
  else {
    string t=s;
    next_permutation(all(s));
    rep(i,n){
      cout << s[i];
      if(s[i]!=t[i]) break;
    }
    cout << endl;
  }

  return 0;
}


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

int main(){
  double a, b;
  cin >> a >> b;
  double c = 0, d = 0;
  for (int i = 0; i < (int)a; i++) c += b * pow(10.0, (double)i);
  for (int i = 0; i < (int)b; i++) d += a * pow(10.0, (double)i);
  if (a < b) cout << (long)d;
  else cout << (long)c;
  
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N; cin>>N;
  vector<int>A(N);
  vector<int>B(N);
  long long a=0;
  long long b=0;
  for(int i=0;i<N;i++){cin>>A[i];a+=A[i];}
  for(int i=0;i<N;i++){cin>>B[i];b+=B[i];}
  if(a>b){cout<<"No"<<endl; return 0;}
  long long c=b-a;
  long long d=0;
  for(int i=0;i<N;i++){
    if(A[i]-B[i]>0)d+=A[i]-B[i];
    else if((B[i]-A[i])%2==1)d++;
  }
  if(c<d){cout<<"No"<<endl; return 0;}
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 3692
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    vector<ll> a(5);
    cin>>n;
    rep(i,5)cin>>a[i];
    ll minmove = *std::min_element(a.begin(), a.end());
    ll ans=((n+minmove-1)/minmove)+4;
    cout<<ans<<endl;
    
   return 0;
}

Measured memory_bytes: 256
import numpy as np

N=int(input())

A=np.array(input().split(),dtype=np.int32)

A_i=np.argsort(A)

result=""

for i in range(N):
    if(i==N-1):
        result=result+"{}".format(A_i[i]+1)
    else:
        result=result+"{} ".format(A_i[i]+1)

print(result)

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

vector<LL> get_divisors(LL n){
  vector<LL> ret;
  
  for(int i=1;i<sqrt(n)+1;i++){
    if(n%i==0){
      ret.push_back(i);
      if(i!=(LL)n/i){
        ret.push_back((LL)n/i);
      }
    }
  }
  
  sort(ret.rbegin(),ret.rend());
  return ret;
}

int main(){
  LL N,K;
  cin >> N >> K;
  vector<LL> A(N);
  vector<LL> r(N);
  vector<LL> r_m(N);
  LL Asum=0;
  rep(i,N){
    cin>>A[i];
    Asum+=A[i];
  }
  
  vector<LL> divisors = get_divisors(Asum);
  for(LL div :divisors){
    rep(i,N){
      r[i]=A[i]%div;
    }
    sort(r.begin(),r.end());
    rep(i,N){
      if(i>=1){
        r[i]+=r[i-1];
      }
    }

    LL i=0;
    do{
      //if(div==5){
      //  cout<<r[i] << " "<< r[N-1] << "\n";
      //  cout<<r[i] << " "<< (div*(N-i-1)-(r[N-1]-r[i])) << "\n";
      //}
      if(r[i]%div == (div*(N-i-1)-(r[N-1]-r[i]))%div &&
         max(abs(r[i]),abs((div*(N-i-1)-(r[N-1]-r[i]))))<=K
        ){
        //cout<<r[i]<<"LL\n";
        cout << div ;
        return 0;
      }
      i++;
    }while(i<N-1);
  }
  
  cout<<"1";
  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

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

		int inA = 0, inB = 0;

		try {
			String[] s = scanner.nextLine().split(" ");
			inA = Integer.parseInt(s[0]);
			inB = Integer.parseInt(s[1]);
		} catch (NumberFormatException e) {
		} catch (NullPointerException e) {
		}

		scanner.close();

		if (inA >= 13) {
			System.out.println(inB);
		} else if (12 >= inA && inA >= 6) {
			System.out.println(inB / 2);
		} else {
			System.out.println(0);
		}

	}

}


Measured memory_bytes: 23764
n = int(input())
F = [list(map(int, input().split())) for _ in range(n)]
P = [list(map(int, input().split())) for _ in range(n)]

m = -(10 ** 10)
for i in range(1, 1024):
    r = 0
    for f, p in zip(F, P):
        r += p[bin(i & int(''.join(str(_) for _ in f), 2))[2:].count('1')]
    m = max(r, m)
print(m)

Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
long long a[2001];
long long mod=1e9+7;
int main()
{
	long long n;
	scanf("%lld",&n);
	a[1]=0,a[2]=0,a[3]=1;
	for(long long i=4;i<=n;i++)
	{
		a[i]=(a[i-1]+a[i-3])%mod;
	}
	printf("%lld",a[n]);
	return 0;
}

Measured memory_bytes: 3816
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second

using namespace std;

int main(){
    double l;
    cin >> l;
    double ans;
    ans = (l/3)*(l/3)*(l/3);
    printf ("%.12lf", ans);
    return 0;
}




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

int main(void) 
{
   int a;
   cin >> a;
   cout << a + a*a + a*a*a << endl;
   return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_H=100,MAX_W=100;
const int INF=1e8;
int H,W;
struct edge{
	int to,cap,rev;
	edge(int t=-1,int c=0,int r=-1):to(t),cap(c),rev(r){}
};
vector<edge> G[MAX_H+MAX_W+2];
void addedge(int u,int v,int c1,int c2){
	G[u].push_back(edge(v,c1,G[v].size()));
	G[v].push_back(edge(u,c2,G[u].size()-1));
}
bool used[MAX_H+MAX_W+2];
int dfs(int v,int f){
	if (v==H+W+1){
		return f;
	}
	used[v]=true;
	for(auto &e:G[v]){
		if (!used[e.to] && e.cap>0){
			int d=dfs(e.to,min(f,e.cap));
			if (d>0){
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}
int mxflow(){
	int ans=0;
	for(;;){
		fill(used,used+H+W+2,false);
		int f=dfs(0,INF);
		if (f>0){
			ans+=f;
		}else{
			break;
		}
	}
	return ans;
}
int main(){
	cin>>H>>W;
	int sh,sw,th,tw;
	REP(i,H){
		string s;
		cin>>s;
		REP(j,W){
			switch(s[j]){
				case 'o':
					addedge(i+1,j+H+1,1,1);
					break;
				case 'S':
					addedge(0,i+1,INF,0);
					addedge(0,j+H+1,INF,0);
					sh=i;
					sw=j;
					break;
				case 'T':
					addedge(i+1,H+W+1,INF,0);
					addedge(j+H+1,H+W+1,INF,0);
					th=i;
					tw=j;
					break;
			}
		}
	}
	if (sh==th || sw==tw){
		cout<<-1<<endl;
	}else{
		cout<<mxflow()<<endl;
	}
	return 0;
}

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

using namespace std;

long long x,y;

int main(){
	scanf("%lld%lld", &x, &y);
	
	for(int i = 0; ; i++){
		if(x * (1LL << i) > y)
		return 0 * printf("%d\n", i);
	}
}


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

int main() {
	int n, m, h[100010],ma[100010];
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		cin >> h[i];
		ma[i] = 0;
	}
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		ma[a] = max(ma[a], h[b]);
		ma[b] = max(ma[b], h[a]);
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		ans += h[i] > ma[i];
	}
	cout << ans << endl;
return 0;
}

Measured memory_bytes: 4408
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int main()
{
    int n;
    cin >> n;
    
    int a[n];
    std::map<std::string,int> m;
    for(int i=0; i<n; i++){
        std::string tmp;
        cin >> tmp;
        m[tmp] = 0;
    }
    cout << m.size() << endl;
}


Measured memory_bytes: 19220
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

alpha2num = lambda c: ord(c) - ord('A') + 1
num2alpha = lambda c: chr(c+64)

n = ni()
s = input()
ans = ""
for i in range(len(s)):
    c = num2alpha(((alpha2num(s[i]) + n) % 26))
    if c != '@':
        ans += c
    else:
        ans += 'Z'


print(ans)






Measured memory_bytes: 3064
#include <stdio.h>

int main()
{
	int n, i, a, b, sumA = 0, sumB = 0;
	while (1) {
		scanf("%d", &n);
		if (n == 0) break;

		sumA = sumB = 0;
		for (i = 0;i < n;i++) {
			scanf("%d %d", &a, &b);
			if (a > b)  sumA += a + b;
			if (a < b)  sumB += a + b;
			if (a == b) {
				sumA += a;
				sumB += b;
			}
		}

		printf("%d %d\n", sumA, sumB);
	}
	return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
int main(){
    int a,b;

    scanf("%d %d",&a,&b);

    if(a==1 && b==2){
        printf("3\n");
    }else if(a==1 && b==3){
        printf("2\n");

}else if(a==3 && b==2){
        printf("1\n");
}else if(a==2 && b==1){
        printf("3\n");

}else if(a==3 && b==1){
        printf("2\n");
}else if(a==2 && b==3 ){
        printf("1\n");

}
return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace Finding_Missing_Cards
{
    class Program
    {
        static void Main(string[] args)
        {
            int count = int.Parse(Console.ReadLine());
            FindingMissingCards problem = new FindingMissingCards();
            for (int i = 0; i < count; i++)
            {
                string line = Console.ReadLine();
                string[] strs = line.Split(' ');
 
                problem.AddCard(strs[0], int.Parse(strs[1]));
            }
 
            List<string> answers = problem.FindMissingCards();
            foreach (string answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
 
    public class FindingMissingCards
    {
         
        private List<List<bool>> isFinded;
 
        public FindingMissingCards()
        {
            isFinded = new List<List<bool>>();
            for (int i = 0; i < 4; i++)
            {
                isFinded.Add(new List<bool>());
                for (int j = 0; j < 13; j++)
                {
                    isFinded[i].Add(false);
                }
            }
        }
 
        public void AddCard(string suit, int number)
        {
            if (suit.Equals("S")) isFinded[0][number - 1] = true;
            if (suit.Equals("H")) isFinded[1][number - 1] = true;
            if (suit.Equals("C")) isFinded[2][number - 1] = true;
            if (suit.Equals("D")) isFinded[3][number - 1] = true;
 
        }
 
        public List<string> FindMissingCards()
        {
            List<string> missingCards = new List<string>();
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 13; j++)
                {
                    if (isFinded[i][j] == false)
                    {
                        string card = "";
                        if (i == 0) card += "S";
                        if (i == 1) card += "H";
                        if (i == 2) card += "C";
                        if (i == 3) card += "D";
 
                        card += " " + (j + 1);
                        missingCards.Add(card);
                    }
                }
            }
            return missingCards;
        }
    }
}

Measured memory_bytes: 5720
from collections import deque
N,M = map(int,input().split())

adj = [list() for _ in range(N)]

for _ in range(M):
    a,b = map(int,input().split())
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)

parent = [None]*N
queue = deque([0])
while queue:
    u = queue.popleft()
    for v in adj[u]:
        if parent[v] is None:
            parent[v] = u
            queue.append(v)

print('Yes')
print(*(x+1 for x in parent[1:]), sep='\n')


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

signed main() {
  int n,k;
  cin >> n >> k;

  vector<pair<int,int>> sushi(n);
  for (int i = 0; i < n; i++) {
    cin >> sushi[i].second >> sushi[i].first;
  }
  sort(sushi.rbegin(),sushi.rend());

  priority_queue<pair<int,int>, vector<pair<int,int>>, greater<>> que;
  vector<int> cnt(n + 1, 0);
  int answer = 0;
  int kind = 0;
  for (int i = 0; i < k; i++) {
    int val = sushi[i].first;
    int x = sushi[i].second;
    que.emplace(val, x);
    answer += val;
    if(cnt[x] == 0) kind++;
    cnt[x]++;
  }
  answer += kind * kind;

  int tmp = answer;
  for (int i = k; i < n; i++) {
    int new_val = sushi[i].first;
    int new_x = sushi[i].second;

    //すでにその種類の寿司が集合にある
    if(cnt[new_x] > 0) continue;

    int old_val = 0;
    int old_x = 0;

    //どれを抜くか
    while (!que.empty()) {
      pair<int,int> p = que.top();
      if(cnt[p.second] > 1 && new_x != p.second) {
        old_val = p.first;
        old_x = p.second;
        que.pop();
        break;
      }
      que.pop();
    }

    if(old_x == 0) break;

    cnt[old_x]--;
    cnt[new_x]++;

    tmp -= kind * kind;
    kind++;
    tmp += kind * kind;
    tmp -= old_val;
    tmp += new_val;

    answer = max(answer, tmp);
  }

  cout << answer << '\n';
}


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

int main(){
    string S;
    cin >> S;
    if(S.size() == 0 || S.size() == 1 || S.size() % 2 == 1){
        cout << "No"<<endl; 
        return 0;        
    }
    rep(i,S.size()){
        if(i % 2 == 0 && S[i] != 'h'){
            cout << "No"<<endl; 
            return 0;
        }else if(i % 2 == 1 && S[i] != 'i'){
            cout << "No"<<endl;             
            return 0;
        }
    }
    cout << "Yes" << endl;
}


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

int main(){
  int n;
  cin>>n;
  bool answer=false;
  for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
    	if(n==i*j) answer=true;
    } 
  }
  if(answer) printf("Yes");
  else printf("No");
}


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

int main() {
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> B(M);
    rep(i, M) cin >> B.at(i);
    int res = 0;
    rep(i, N) {
        vector<int> A(M);
        int wa = 0;
        rep(j,M) {
            cin >> A.at(j);
            wa += B[j] * A[j];
        }
        wa += C;
        if (wa > 0) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int i, n, c, h;
  int d[4][13];
  char l;

  scanf("%d", &n);

  for ( h = 0; h < 4; h++)
    {
      for ( c = 0; c < 13; c++)
	{
	  d[h][c] = 0;
	}
    }

  for ( i = 0; i < 2*n; i++)
    {
      scanf("%c %d", &l, &c);
      if ( l == 'S' ) { h = 0; }
      if ( l == 'H' ) { h = 1; }
      if ( l == 'C' ) { h = 2; }
      if ( l == 'D' ) { h = 3; }
      d[h][c] = 1;
    }

  for ( h = 0; h < 4; h++)
    {
      for ( c = 1; c <= 13; c++)
	{
	  if ( d[h][c] != 1 )
	    {
	      if ( h == 0 ) { l = 'S';}
	      if ( h == 1 ) { l = 'H';}
	      if ( h == 2 ) { l = 'C';}
	      if ( h == 3 ) { l = 'D';}
	      printf("%c %d\n", l, c);
	    }
	}
    }
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 1e9+7;



int main(){
    ll N; cin >> N;
    ll ans = 0;
    for(int A = 1; A < N; A++){
        ll n = N/A;
        if(N % A == 0) n--;
        ans += n;
    }
    cout << ans << endl;

}


Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <cmath>

#define mst(a,b)memset(a, b, sizeof(a))
#define repi(a,b)for(ll i = a; i < b; i++)
#define repj(a,b)for(ll j = a; j < b; j++)
#define pii pair<int,int>

#ifdef LOCAL
#define fre()freopen("in.txt","r",stdin)
#endif
#ifndef LOCAL
#define fre()
#endif

//static int x = []() {
//	std::ios::sync_with_stdio(false);
//	std::cin.tie(NULL);
//	return 0;
//}();

#define FASTIO
#ifdef FASTIO
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
//#define scanf abcabc
//#define printf abcabc
#endif
//#ifndef FASTIO
//#define cin abcabc
//#define cout abcabc
//#endif

typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;

using namespace std;


int main() {
	int a, b, c; cin >> a >> b >> c;
	int t = max(max(a, b), c);
	cout << (a + b + c - t) << endl;
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include "atcoder/all"
typedef long long int ll;
using namespace std;
// using namespace atcoder;
#define mod 1000000007
#define MAXN 200005
ll Pow(ll a, ll n) {
    if (n == 0) return 1;
    if (n % 2) return (a * Pow(a, n - 1)) % mod;
    else {
        ll k = Pow(a, n / 2);
        return (k * k) % mod;
    }
}
ll gyakusuu[MAXN + 1];
ll nCk(ll n, ll k) {
    if (k > n) return 0;
    ll ret = 1;
    for (ll i = 1; i <= k; i++) {
        ret = ret * (n - k + i) % mod;
        ret = ret * gyakusuu[i] % mod;
    }
    return ret;
}
int main() {
    ll n, m, k;
    cin >> n >> m >> k;
    for (int i = 1; i <= MAXN; i++) {
        gyakusuu[i] = Pow(i, mod - 2);
    }
    ll ret1 = (n * (n - 1) * (n + 1) / 6) % mod;
    ll ret2 = (m * (m - 1) * (m + 1) / 6) % mod;
    ll ret = (m * m * ret1 + n * n * ret2) % mod;
    cout << nCk(n * m - 2, k - 2) * ret % mod << endl;
    return 0;
}

Measured memory_bytes: 5196
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    k=int(input())
    a,b=map(int,input().split())
    for i in range(a,b+1):
        if i%k==0:
            print("OK")
            break
    else:
        print("NG")

if __name__=='__main__':
    main()

Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
#define reps(i,j,k) for(int i=j;i<k;++i)
#define rep(i,j) reps(i,0,j)
int stage[12][12];
int W,H;
int check(){
	int prev = -1;
	int cnt = 0;
	int res = 0;
	rep(i,H){
		rep(j,W){
			if(prev != stage[i][j] || prev == 0){
				if(cnt >= 3){
					res += stage[i][j-1]*cnt;
					reps(k,j-cnt,j){
						stage[i][k] = 0;
					}
				}
				prev = stage[i][j];
				cnt = 1;
			}
			else{
				cnt++;
			}
		}
		if(cnt >= 3){
			res += stage[i][W-1]*cnt;
			reps(k,W-cnt,W){
				stage[i][k] = 0;
			}
		}
		cnt = 0;
		prev = -1;
	}
	return res;
}

void drop(){
	rep(i,H-1){
		rep(j,W){
			int c = i;
			while(stage[i][j] == 0){
				if(c == H)break;
				reps(k,i+1,H){
					stage[k-1][j] = stage[k][j];
				}
				stage[H-1][j] = 0;
				c++;
			}
		}
	}
}

int main(){
	W = 5;
	while(scanf("%d",&H),H){
		rep(i,12){
			rep(j,12){
				stage[i][j] = 0;
			}
		}
		rep(i,H){
			rep(j,W){
				scanf("%d",&stage[H-i-1][j]);
			}
		}

		int score = 0;
		while(true){
			int tmp = check();
			/*puts("**************");
			rep(i,H){
				rep(j,W){
					printf("%d",stage[i][j]);
				}
				puts("");
			}*/
			if(tmp == 0)break;
			score += tmp;
			drop();
		}	
		printf("%d\n",score);
	}
	return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
int main() {
    string s, p;
    cin >> s >> p;
    s += s;
    if (strstr(s.c_str(), p.c_str())) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <vector>
#include <string>

int main() {
	int H, W, K;
	std::cin >> H >> W >> K;
	int map[H][W];
	std::string data;
	for (int i = 0; i < H; ++i) {
		std::cin >> data;
		for (int j = 0; j < W; ++j) {
			if (data.substr(j, 1) == ".") {
				map[i][j] = 1;
			} else if (data.substr(j ,1) == "#") {
				map[i][j] = 0;
			}
		}
	}
	long int counter = 0;
	for (int bit1 = 0; bit1 < (1<<H); ++bit1) {
		std::vector<int> Sh;
		for (int i = 0; i < H; ++i) {
			if (bit1 & (1<<i)) {
				Sh.push_back(i);
			}
		}
		for (int bit2 = 0; bit2 < (1<<W); ++bit2) {
			std::vector<int> Sw;
			for (int j = 0; j < W; ++j) {
				if (bit2 & (1<<j)) {
					Sw.push_back(j);
				}
			}
			/*
			std::cout << "Sh : {";
			for (auto i : Sh) {
				std::cout << i << ",";
			}
			std::cout << "}" << std::endl;
			std::cout << "Sw : {";
			for (auto i : Sw) {
				std::cout << i << ",";
			}
			std::cout << "}" << std::endl;
			*/
			int map2[H][W];
			for (int h = 0; h < H; ++h) {
				for (int w = 0; w < W; ++w) {
					map2[h][w] = map[h][w];
				}
			}
			for (auto h : Sh) {
				for (int n = 0; n < W; ++n) {
					map2[h][n] = 2;
				}
			}
			for (auto w : Sw) {
				for (int m = 0; m < H; ++m) {
					map2[m][w] = 2;
				}
			}
			int count = 0;
			for (int k = 0; k < H; ++k) {
				for (int l = 0; l < W; ++l) {
					if (map2[k][l] == 0) {
						count += 1;
					}
				}
			}
			if (count == K) {
				counter += 1;
			}
		}
	}
	std::cout << counter << std::endl;
}


Measured memory_bytes: 3188
#include <iostream>
using namespace std;
int a[6];
string s;
void C(int i,int j,int k,int l){
  int t;t=a[i];a[i]=a[j];a[j]=a[k];a[k]=a[l];a[l]=t;
}
int main(){
  for(int i=0;i<6;i++)cin>>a[i];
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='E')for(int j=0;j<3;j++)C(0,2,5,3);
    if(s[i]=='W')C(0,2,5,3);
    if(s[i]=='S')for(int j=0;j<3;j++)C(0,1,5,4);
    if(s[i]=='N')C(0,1,5,4);
  }
  cout<<a[0]<<endl;
}


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

using namespace std;


void solve(){
    long long i,j;
    long long n;
    cin >> n;
    long long ans = 0;
    for(i = 1;i*i+i<n;i++){
        if((n-i)%i == 0) ans += (n-i)/i;
    }
    cout << ans << endl;
}

int main(){
    solve();
}


Measured memory_bytes: 256
#include <stdio.h>
int main (){
    int a,b,c,i;
    int cnt=0;
        scanf("%d %d %d",&a,&b,&c);
    for(i=a;i<=b;i++){
            if(c%i==0)
            cnt++;
    }
    printf("%d\n",cnt);
    return 0;
}



Measured memory_bytes: 2056
#include <iostream>
#include <string>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i <= (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

int main()
{
	int N;
	int sum=0;
	int a;
	cin >> N;
	REP(i,N){
		cin >> a;
		if(a%2==1){
			sum++;
		}
	}
	if(sum%2==0){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>

typedef long long ll;
#define MIN(x, y) (x < y ? x : y)
#define MAX(x, y) (x > y ? x : y)

using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	
	string line = "";
	cin >> line;
	bool flag = true;

	for(int i = 0; i < a + b + 1; ++i){
		if(a == i && line[i] != '-'){
			flag = false;
		} else if(a != i && !(line[i] >= '0' && line[i] <= '9')){
			flag = false;
		}
	}

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




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100010],s[100010];
int main()
{
	int n,i,tot;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	
	for(i=1;i<=n;i++)s[a[i]]++;
	tot=0;
	for(i=1;i<=100000;i++)if(s[i]>1)tot+=(s[i]-1);
	if(tot%2==0)printf("%d",n-tot);
	else printf("%d",n-tot-1);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
/* * * *   * * *   	* * * */
#define ll long long
#define ld long double
#define ms(a,v) memset(a,v,sizeof a)
#define pii pair<int, int>
/* * * *   * * *   	* * * */
/* *
 *
 * Author: Hamkor
 *
 * */
int main(){
	int n; scanf("%d", &n);
	int ans=0;
	for (int i=1; i<=n; ++i){
		int x=i, cur=0;
		while (x)x/=10, cur++;
		if (cur&1)ans++;
	}
	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 256
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;


int main(void) {

    int N,R; cin>>N>>R;
    if(N>=10) cout<<R<<endl;
    else cout<<R+100*(10-N)<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char s[500005];int ans,l,r,mid,n,a[500005];
bool chk(int x)
{
	int sb=n,gg=0;
	for(int i=1;i<=n;i++) a[i]=(s[i]-'0')*9;a[1]+=9*x;
	for(int i=1;i<=sb;i++) if(a[i]>9){if(i==sb) a[++sb]=0;a[i+1]+=a[i]/10;a[i]%=10;}
	for(int i=1;i<=sb;i++) gg+=a[i];return gg<=9*x;
}
int main()
{
	scanf("%s",s+1);l=1,r=n=strlen(s+1);reverse(s+1,s+n+1);
	for(mid=l+r>>1;l<=r;mid=l+r>>1) if(chk(mid)) ans=mid,r=mid-1;else l=mid+1;
	printf("%d\n",ans);
}

Measured memory_bytes: 2688
n=int(input())
x_list=[]
u_list=[]
for i in range(n):
  x,u=input().split()
  x_list.append(float(x))
  u_list.append(u)
sum=0
for i in range(n):
  if u_list[i]=="JPY":
    sum+=x_list[i]
  else:
    sum+=x_list[i]*380000.0
print(sum)

Measured memory_bytes: 9100
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long int li;
#define mkp make_pair
#define sc(x) scanf("%lld",&x)
#define pf(x,y) printf("%lld %lld", x,y)
#define pfn printf("\n")
#define fr(i,a,n) for(i = a ; i < n ; i++)
map<long int , list<long int> > mp;
int vis[100001];
int dist[100001];
long int maxi = 0;
void dfs(long int src){
	vis[src] = 1;
//	cout << src << endl;
	for(auto i: mp[src]){
		if(!vis[i])dfs(i);
//		cout << i << " " << dist[i] << endl;
		dist[src] = max(dist[src],1+dist[i]);
	}
	if(maxi<dist[src])maxi=dist[src];
}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long int n,m,x,y;
	cin >> n >> m;

	
	for(int i = 0 ; i < m ; i++){
		cin >> x >> y;
		mp[x].push_back(y);

	}

	for(long int i = 1 ; i <=n;i++){
		if(!vis[i])
			dfs(i);
	}
//	for(int i = 1 ; i<=n;i++){
////		cout << ind[i].first << " " << ind[i].second <<endl;
//		cout << dist[i] << " ";
//	}
	cout << maxi<< endl;
	return 0;
}


Measured memory_bytes: 19432
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 210
#define INF 10000005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int n;
int X,Y,E;
ll K;

struct edge{int to,cap,rev;};

vector<edge> G[SIZE];
bool used[SIZE];

//グラフ追加: from -> to (cap)
void add_edge(int from, int to, int cap){
	G[from].push_back((edge){to,cap,(int)G[to].size()});
	G[to].push_back((edge){from,0,(int)G[from].size()-1});
}

//パスを一本見つける
int dfs(int v, int t, int f){
	if(v==t)return f;
	used[v] = true;
	for(int i=0;i<G[v].size();i++){
		edge &e = G[v][i];
		if(!used[e.to] && e.cap>0){
			int d = dfs(e.to,t,min(f,e.cap));
			if(d>0){ //v -> G[v][i].toにd流す
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s,int t){
	int flow = 0;
	for(;;){
		memset(used,0,sizeof(used));
		int f = dfs(s,t,INF);
		if(f==0)return flow;
		flow += f;
	}
}


int main()
{
	scanf("%d",&n);
	int a,b;
	for(int i=0;i<n;i++)add_edge(200,i,1);
	for(int i=0;i<n;i++)add_edge(100+i,201,1);
	P V[2][100];
	for(int j=0;j<2;j++){
		for(int i=0;i<n;i++){
			scanf("%d %d",&a,&b);
			V[j][i] = make_pair(a,b);
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(V[0][i].first<V[1][j].first && V[0][i].second<V[1][j].second){
				add_edge(i,100+j,1);
			}
		}
	}
	int ans = max_flow(200,201);
	printf("%d\n",ans);
	return 0;
}


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

map<int,int> mp;

int f(int n){
    for(int i=2;i*i<=n;i++){
        while(!(n%i)){
            mp[i]++;
            n /= i;
        }
    }
    if(n != 1) mp[n]++;
}

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

    for(int i=1;i<=N;i++) f(i);

    long long ans = 1;
    long long MOD = 1e9+7;

    for(auto& a : mp) ans = (ans * (a.second + 1)) % MOD;

    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <functional>

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

int main()
{
	int h[1500], w[1500];
	int sh[1500], sw[1500];
	for(;;) {
		map<int, int> mh;
		map<int, int> mw;
		int N, M;
		scanf("%d%d", &N, &M);
		if(N==0 && M==0) return 0;
		rep(i, N) scanf("%d", h+i);
		rep(i, M) scanf("%d", w+i);
		rep(i, N) {
			int s=0;
			rep(j, i+1) s += h[j];
			sh[i] = s;
		}
		rep(i, M) {
			int s=0;
			rep(j, i+1) s += w[j];
			sw[i] = s;
		}
		rep(i, N) {
			if(mh.find(sh[i])!=mh.end()) mh[sh[i]]++;
			else mh.insert(make_pair(sh[i], 1));
			rep(j, i) {
				int s = sh[i]-sh[j];
				if(mh.find(s)!=mh.end()) mh[s]++;
				else mh.insert(make_pair(s, 1));
			}
		}
		rep(i, M) {
			if(mw.find(sw[i])!=mw.end()) mw[i]++;
			else mw.insert(make_pair(sw[i], 1));
			rep(j, i) {
				int s = sw[i]-sw[j];
				if(mw.find(s)!=mw.end()) mw[s]++;
				else mw.insert(make_pair(s, 1));
			}
		}
		int c=0;
		for(map<int, int>::iterator it=mh.begin(); it!=mh.end(); it++) {
			if(mw.find(it->first)!=mw.end()) c += it->second*mw[it->first];
		}
		printf("%d\n", c);
	}
}

Measured memory_bytes: 18000
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define MOD 1000000007
#define rep(i,n)for(int i=0;i<n; i++)
typedef long long ll;

using namespace std;

int main(){

    ll mod = 1000000007;
    int n, m;
    cin >> n >> m;

    ll a=0, b=0;
    // x axis
    rep(i,n){
       ll x;
       scanf("%lld", &x);
       (a += x*(2*i -  n +1)) %= mod; 
    }

    //y axis
    rep(i,m){
       ll y;
       scanf("%lld", &y);
       (b += y*(2*i -  m +1)) %= mod; 
    }

    cout << (a*b) % mod << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb push_back
#define eb emplace_back
#define fs first
#define sc second
using lint = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vii = vector<pii>;

char s[200001];

int main(){
  scanf("%s",s);

  int cnt = 0;
  for(int i=0;s[i];++i)
    cnt += s[i]-'0';

  puts(cnt%9 ? "No" : "Yes");
}


Measured memory_bytes: 3872
N = int(input())
S = []
for _ in range(N):
    S.append(input())
    
print("AC x " + str(S.count("AC")))
print("WA x " + str(S.count("WA")))
print("TLE x " + str(S.count("TLE")))
print("RE x " + str(S.count("RE")))

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

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

#define vt          vector
#define sz(x)       (int)(x).size()
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

signed main() {
    ios::sync_with_stdio(0), cin.tie(0);

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

    int mn = sz(t);
    for (int i = 0; i <= sz(s) - sz(t); i++) {
        int cur = 0;
        for (int j = 0; j < sz(t); j++) {
            if (s[i + j] != t[j]) cur++;
        }
        mn = min(mn, cur);
    }

    cout << mn;
}


Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<int,int>
#define INT_MAX 2147483647
#define MOD 1000000007
using namespace std;
typedef long long ll;



int main(void) {
	int s, w; cin >> s>> w;
	if (s > w) {
		cout << "safe" << endl;
	}
	else {
		cout << "unsafe" << endl;
	}
	return 0;
}


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

int main(){
	int a, b, c, d, f;
	double e;
	cin >> a >> b >> c >> d >> e >> f;
	a *= 100; b *= 100;
	vector<bool> water(f+10, false), suger(f+10, false);

	for(int i = 0; i <= f; i++)
	{
		for(int j = 0; j <= f; j++)
		{
			int w = i*a + j*b, s = i*c + j*d;
			if(w <= f) water[w] = true;
			if(s <= f) suger[s] = true;
		}
	}
	
	int  wans = 0, sans = 0;
	double conans = 0, conmax = e/(e+100);

	for(int i = 0; i <= f; i+=100)
	{
		for(int j = 0; j <= f; j++)
		{
			if(water[i] && suger[j] && i+j <= f){
				double con2 = (double)j / (double)(i+j);
				if(con2 <= conmax && con2 >= conans){
					conans = con2;
					wans = i;
					sans = j;
				}
			}	
		}
	}
	
	cout << wans+sans << ' ' << sans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)	

int max(ll a, ll b) {
	ll max;
	if (a > b) max = a;
	else max = b;
	return max;
}
int min(ll a, ll b) {
	ll min;
	if (a < b) min = a;
	else min = b;
	return min;
}


int main() {
	int n, k;
	int h[100002];
	int cnt = 0;

	cin >> n >> k;

	rep(i, n) cin >> h[i];

	rep(i, n) {
		if (h[i] >= k) cnt++;
	}

	cout << cnt << endl;
}

Measured memory_bytes: 640
import numpy as np

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

# 持ち帰る最大値の重さまでのリストを作る。
# 持ち帰れる重さが10なら、添字が10までのリストを作る。
# 持ち帰る各重さ毎の最大値を持つ。
dp = np.zeros(W+1, dtype=np.int64)

for _ in range(N):
    # dp[:W-w+1]+v
    # 次の品物を持ち帰っても重さの上限Wを超えない値以降だけを取得して、次の品物の価値を追加する
    # 持ち帰れる最大値-次の品物の重さしているので、同じ重さの品物が複数あった場合もより価値が高い方で比較される

    # dp[w:]
    # 現在の重さw以上の値を取得する

    # maximum(dp[:W-w+1]+v, dp[w:], out=dp[w:])
    # 2つの配列の要素を比較して、大きい方の要素を返す。
    # 次の品物を持ち帰った方が価値の総和が大きくなる場合は価値が更新される。
    w, v = map(int, input().split())
    np.maximum(dp[:W-w+1]+v, dp[w:], out=dp[w:])

print(dp[-1])


Measured memory_bytes: 14600
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
using namespace std;

int main(){
  int x;
  cin >> x;
  if(x==7||x==5||x==3) printf("YES\n");
  else printf("NO\n");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;


int main() {
    auto lcm = [&](ll x, ll y){ return x/__gcd(x, y)*y; };
    auto g = [&](ll x, ll y){
        ll a = 1;
        for (int i = 1; i <= y; ++i) {
            (a *= x) %= y;
            if(a == 1) return i;
        }
        return 0;
    };
    ll a, b, c, d, e, f;
    while(cin >> a >> b >> c >> d >> e >> f, a){
        cout << lcm(g(a, b), lcm(g(c, d), g(e, f))) << "\n";
    }
    return 0;
}


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9+5;
const ll INFLL = 1e18l+5;

int main(){
    string s,t;
    cin>>s>>t;
vector<vector<int>> dp(s.size()+1, vector<int>(t.size()+1,0));
    string ans;
    for(int i=1; i<=s.size(); ++i){
        for(int j=1; j<=t.size(); ++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]);    
        }
    }
    int i=s.size(), j=t.size();
    
    while(i>=1&&j>=1){
            if(dp[i][j]!=dp[i-1][j]&&dp[i][j]!=dp[i][j-1]){
                i--;
                j--;
                ans.push_back(s[i]);
            }

            else if(dp[i][j]==dp[i][j-1]) j--;
            else if(dp[i][j]==dp[i-1][j]) i--;

        
    }
    //cout<<dp[s.size()][t.size()];
    reverse(ans.begin(),ans.end());
    cout<<ans;

    
}

Measured memory_bytes: 38640