akhauriyash/Code-Regression huggingface dataset:
#include <iostream> 
using namespace std;
int main() {
	int N, Ycount;
	cin >> N;

	Ycount = 0;

	for (int i = 0; i < N; i++) {
		char S;
		cin >> S;

		if (S == 'Y') {
			Ycount++;
		}
	}

	if (Ycount > 0) {
		cout << "Four" << endl;
	}

	else {
		cout << "Three" << endl;
	}
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

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

	int N; cin >> N;
	vector<P> stu;
	for (int i = 0; i < N; i++) {
		int num; cin >> num;
		stu.push_back(P(num, i + 1));
	}
	sort(stu.begin(), stu.end());
	for (int i = 0; i < N; i++) cout << stu[i].second << " ";
	cout << endl;
	return 0;
}

Measured memory_bytes: 1780
inputValues = [int(i) for i in input().split()]
n = inputValues[0]
m = inputValues[1]
votes = [int(i) for i in input().split()]
total = sum(votes)
cnt = 0
for i in votes:
    if i >= total*(1/(4*m)):
        cnt += 1
        # print(i)
if cnt >= m:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9176
n = int(input())

class Node():
    def __init__(self):
        self.parent = None
        self.left_child = None
        self.right_sibling = None
        self.type = None

tree = []
for _ in range(n):
    tree.append(Node())

for _ in range(n):
    tmp = list(map(int, input().split()))
    id = tmp[0]
    degree = tmp[1]
    children = tmp[2:]
    if degree > 0:
        tree[id].left_child = children[0]
        for (cnt, child) in enumerate(children):
            tree[child].parent = id
            if cnt < degree - 1:
                tree[child].right_sibling = children[cnt + 1]
    
    
def get_depth(id):
    out = 0
    node = tree[id]
    while node.parent is not None:
        out += 1
        node = tree[node.parent]
    return out

def get_children(id):
    left_child_id = tree[id].left_child
    if left_child_id is None:
        return []
    node = tree[left_child_id]
    out = [left_child_id]
    while node.right_sibling is not None:
        out.append(node.right_sibling)
        node = tree[node.right_sibling]
    return out

def get_type(id):
    node = tree[id]
    if node.parent is None:
        return 'root'
    elif node.left_child is not None:
        return 'internal node'
    else:
        return 'leaf'
    
for id in range(n):
    print(f"node {id}: parent = {-1 if tree[id].parent is None else tree[id].parent}, depth = {get_depth(id)}, {get_type(id)}, {get_children(id)}")


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

int main()
{
	int x,y,cnt=0,x1;
	cin>>x>>y;
	x1=x;
	rep(x){
		int a = i*2;
		int b = x1*4;
		if(a+b==y){
			cout<<"Yes";
			cnt=1;
			break;
		}
		x1--;
	}
	if(cnt==0){
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
const int MaxN = 303;
int n,m,a[MaxN][MaxN];
int p[MaxN],cnt[MaxN];
bool f[MaxN];

int main() {
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;++i) for (int j=1;j<=m;++j) scanf("%d",&(a[i][j]));
	memset(f,0xff,sizeof f);
	for (int i=1;i<=n;++i) p[i]=1,cnt[a[i][p[i]]]++;
	int ans=0;
	for (int i=1;i<=m;++i) ans=max(ans,cnt[i]);
	ans=min(ans,n);
	for (int i=1;i<m;++i) {
		int mx=1;
		for (int j=2;j<=m;++j) if (cnt[j]>cnt[mx]) mx=j;
		cnt[mx]=0,f[mx]=false;
		for (int j=1;j<=n;++j) {
			if (!f[a[j][p[j]]]) {
				while (p[j]<=m && !f[a[j][p[j]]]) p[j]++;
				cnt[a[j][p[j]]]++;
			}
		}
		mx=1;
		for (int j=2;j<=m;++j) if (cnt[j]>cnt[mx]) mx=j;
		ans=min(ans,cnt[mx]);
	}
	printf("%d\n",ans);
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  for (int i=0; i<N; i++) {
    string C;
    cin >> C;
    
    if (C=="Y") {
      cout << "Four" << endl;
      break;
    }  
    
    if (i==N-1) {
      cout << "Three" <<endl;
    }
  }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
const int MOD=1e9+7;
const double eps=1e-8;
typedef long long ll;
//orz yht
using namespace std;
int a,b,c;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>a>>b>>c;
	if(a==b && b!=c || a==c && b!=c || b==c && a!=c || b==c && a!=b)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#include <iostream>

using namespace std;

void resolve()
{
    int L;
    cin >> L;

    double L2 = (double)L;
    double ans = (L2 / 3) * (L2 / 3) * (L2 / 3);

    printf("%lf\n", ans);
}

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


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

int main(){
    int n;
    cin >> n;
    int a[n][2];
    for(int i=0; i<n; i++){
        cin >> a[i][0] >> a[i][1];
    }

    bool flag = false;
    for(int i=0; i<n-2; i++){
        if(a[i][0]!=a[i][1]) continue;
        if(a[i+1][0]!=a[i+1][1]) continue;
        if(a[i+2][0]!=a[i+2][1]) continue;
        flag = true;
        break;
    }
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3632
#include<iostream>

using namespace std;

int main(){
  int N,p[60],z=0;
  cin >> N;
  for(int i=0; i<N;i++){
    cin >> p[i];
  }
  for(int i=0; i<N;i++){
   if(p[i]==i+1){
     z=z+1;
   }
 }
  if(z==N){
    cout << "YES";
  }else{
  if(z==N-2){
      cout << "YES";



  }else{
    cout << "NO";
  }}

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;

constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main() {
    int N; cin>>N;
    i64 cumsum[N]; REP(i,N) cumsum[i]=0;
    REP(i,N) {
        int a;
        cin>>a;
        if (i==0) cumsum[i] = a;
        else cumsum[i] = cumsum[i-1]+a;
    }
    i64 ans = 1e15;
    REP(i,N-1) ans = min(ans,abs(cumsum[N-1]-2*cumsum[i]));
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
s=input()

ans='No'

for i,ss in enumerate(s):
  if i%2==0:
    if ss =='R' or ss=='U' or ss=='D':
      ans ='Yes'
    else:
      ans='No'
      break
  else:
    if ss=='L' or ss=='U' or ss=='D':
      ans='Yes'
    else:
      ans='No'
      break
print(ans)

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

int main(){
    string s;
    cin >> s;
    ll n = s.size();
    ll p[2019] = {};
    ll t = 0; 
    ll d = 1;
    ll ans = 0;
    for(ll i = n-1; i >= 0; i--){
        p[t]++;
        t = ((s[i]-'0')*d + t)%2019;
        d = (d*10)%2019;
        ans += p[t];
    }
    cout << ans << endl;
}

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

const int MAXN = 105;
int n, a[MAXN], ans = 1e9;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int t = -100; t <= 100; t++) {
		int r =0;
		for (int i = 0; i < n; i++)
			r += (a[i] - t) * (a[i] - t);
		ans = min(ans, r);
	}
	cout << ans;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int ans=a+b<a-b?a-b:a+b;
		ans=ans<a*b?a*b:ans;
		System.out.println(ans);
	}
}

Measured memory_bytes: 25044
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String S = scan.next();
        if (S.equals("RRR")) {
            System.out.println(3);
            return;
        }
        if (0 <= S.indexOf("RR")) {
            System.out.println(2);
            return;
        }
        if (0 <= S.indexOf("R")) {
            System.out.println(1);
            return;
        }
        System.out.println(0);
    }
}


Measured memory_bytes: 35612
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            while ((line = br.readLine()) != null) {
            	String[] str=line.split(" ");
            	double a=Double.parseDouble(str[0]);
            	double b=Double.parseDouble(str[1]);
            	double c=Double.parseDouble(str[2]);
            	double s=a*b*Math.sin(Math.PI*c/180)/2;
            	System.out.println(s);
            	System.out.println(a+b+Math.sqrt(a*a+b*b-2*a*b*Math.cos(Math.PI*c/180)));
            	System.out.println(2*s/a);
            	break;
            }
        }
    }


}

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

int arr[101];
int n;
bool vis[2][100001], memo[2][100001];

bool STONE(int bx, int k) 
{
	if(k < 0)
	return 1;
	else if(k == 0)
	return 0;	
	if(vis[bx][k])
	return memo[bx][k];	
	bool ans = 0;
	for(int i=1;i<=n;i++)
	ans |= (1 ^ STONE(bx ^ 1, k - arr[i]));	
	vis[bx][k] = 1;
	memo[bx][k] = ans;
	return ans;
}

int main(void)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	memset(memo, 0, sizeof(memo));
	memset(vis, 0, sizeof(vis));
	int k;
	std::cin>>n>>k;
	for(int i=1;i<=n;i++)
	std::cin>>arr[i];
	bool ans = STONE(0, k);	
	if(ans)
	std::cout<<"First\n";
	else std::cout<<"Second\n";
	return 0;	
}

Measured memory_bytes: 8448
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
using ll=long long;
int n;
ll a[100010];
ll b[100010];
ll d[100010];
int solve(){
  if(accumulate(a,a+n, 0LL)<accumulate(b,b+n, 0LL)) return -1;
  REP(i,n)d[i]=a[i]-b[i];
  sort(d,d+n,greater<int>());
  int zero;
  ll lack=0;
  for(int i=0;i<n;i++){
    if(d[i]>=0){
      zero=i+1;
      continue;
    }
    lack-=d[i];
  }
  if(n==zero) return 0;
  for(int i=1;i<zero;i++){
    d[i]+=d[i-1];
  }
  int used=distance(d,lower_bound(d,d+zero,lack))+1;
  return n-zero+used;
}

int main(){ _;
  cin>>n;
  REP(i,n)cin>>a[i];
  REP(i,n)cin>>b[i];

  cout<<solve()<<endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
//auto->.
//map<int,int>::iterator i

vector<int> sieve(int n) 
{ 

    vector<bool> prime(n+1,true); 
       
    prime[0] = false; 
    prime[1] = false; 
    int m = sqrt(n); 
   vector<int> ans;
    for (int p=2; p<=m; p++) 
    { 
    
        if (prime[p]) 
        { 
         
            for (int i=p*2; i<=n; i += p) 
            prime[i] = false; 
        } 
    }  
    //vector<int> ans; 
    for (int i=0;i<n;i++) 
        if (prime[i]) 
            ans.push_back(i); 
    return ans; 
}

int gcd(int a,int b)
{
	if(b==0) return a;
	return gcd(b,a%b);
}
int mod = 1e9 + 7;
int power(int a , ll b)
{
	int res = 1;
	while(b)
	{
		if(b & 1)
			res = 1LL * res * a % mod;
		a = 1LL * a * a % mod;
		b >>= 1;
	}
	return res;
}
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}
ll min(int a,ll b)
{
	if(a>b)
	return b;
	return a;
}
ll max(int a,ll b)
{
	if(a>b)
	return a;
	return b;
}
ll myXOR(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}
int conti(int x)
{
	if(x<1)
	return 0;
	if(x%4==0)
	return x;
	if(x%4==1)
	return 1;
	if(x%4==2)
	return x+1;
	if(x%4==3)
	return 0;
}
  
bool ispfsq(long double x) 
{   
  // Find floating point value of  
  // square root of x. 
  long double sr = sqrt(x); 
  
  // If square root is an integer 
  return ((sr - floor(sr)) == 0); 
}
ll cnt(ll x,ll lcm,ll m)
{
return (x/lcm)*m + min(m,x-(x/lcm)*lcm+1);

}
#define PI 3.141592653589793
int n;
int fen[1000010];
void update(int i,int d)
{
	fen[i]+=d;
	for(;i<n;i+=(i&(-1*i)))
	 fen[i]+=d;
}
int sum(int ind)
{
	int s=0;
	while(ind>0)
	{
		s+=fen[ind];
		ind-=ind&(-1*ind);
	}
	return s;
}
int a[30002],b[30002];
void solve()
{
int n;
cin>>n;
int arr[n],dp[n];
for(int i=0;i<n;i++)
{
cin>>arr[i];
dp[i]=INT_MAX;
}
dp[0]=0;
for(int i=0;i<n;i++)
{
	for(int j=1;j<=2;j++)
	{
		if(i+j<n)
		{
			dp[i+j]=min(abs(arr[i]-arr[i+j])+dp[i],dp[i+j]);
		}
	}
}

cout<<dp[n-1];
}


   
/*void dfs(vector<int> adj[],bool visited[],int a)
{
	if(visited[a]==false)
	visited[a]=true;
	else
	return;
	v++;
	e+=adj[a].size();
	for(int i=0;i<adj[a].size();i++)
	{
		
		if(!visited[adj[a][i]])
		{
		
		dfs(adj,visited,adj[a][i]);

	      }
	}
	}	
*/	
	


/*int dfs(vector<int> adj[],int v,int c,int p)
{
//	cout<<p<<" "<<v<<" "<<c<<"\n";
	c+=arr[v];
	if(c>m)
	{
	return 0;
    }
	if(adj[v].size()==1&&v!=1)
	return 1;
	int a=0;
	for(int i=0;i<adj[v].size();i++)
	{
		if(adj[v][i]!=p)
		{
			
			int x=dfs(adj,adj[v][i],c*arr[adj[v][i]],v);
			a+=x;
		}
	}
	return a;
}
*/

int main()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//func();
int mul=0;
if(mul==1)
{
 int t;
 
    cin>>t;
   while(t--)
    {
		solve();
	cout<<"\n";
    }
}
else
{
	solve();
}
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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; }

const long long INF = 1LL << 60;

int main(){
  int a, b, c, k;
  cin >> a >> b >> c >> k;

  if(k <= a){
    cout << k << endl;
  }
  else if(k <= a+b){
    cout << a << endl;
  }
  else if(k <= a+b+c){
    cout << a - (k-(a+b)) << endl;
  }

  return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <limits>
#include <cmath>

using namespace std;

int main() {
    string s;
    cin >> s;
    for (size_t i = 0; i < s.size(); ++i)
        cout << 'x';
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

int main(){
    int m,k;cin >> m >> k;
    if(m==1){
      if(k==0) puts("0 0 1 1");
      else puts("-1");
    }
    else if(k>=(1<<m)) puts("-1");
    else{
        for (int i = 0; i < (1<<m); i++) {
            if(i==k) continue;
            cout << i << " ";
        }
        cout << k << " ";
        for (int i = (1<<m)-1; i >=0 ; i--) {
            if(i==k) continue;
            cout << i << " ";
        }
        cout << k << endl;
    }
    return 0;
}


Measured memory_bytes: 1792
import math


def get_sieve_of_eratosthenes(n):# エラトステネスのふるい(O(NloglogN)). ~nまでの素数をリストで返す.
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]


Q = int(input())
ls = [0]
prime = set(get_sieve_of_eratosthenes(10**5 + 10))

output = []
for i in range(1, 10**5+1):
    if (i in prime) & (int((i+1)/2) in prime):
        ls.append(ls[i-1]+1)
    else: ls.append(ls[i-1])
#print(ls[:10])
for q in range(Q):
    l, r = map(int, input().split())
    output.append(ls[r]-ls[l-1])
print(*output, sep="\n")



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

/*
 * To execute Java, please define "static void main" on a class
 * named Solution.
 *
 * If you need more classes, simply define them inline.
 */

public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(), M = sc.nextInt();
    int X = sc.nextInt(), Y = sc.nextInt();
    int maxX = X, minY = Y;
    for(int i = 1; i<=N; i++){
      int x = sc.nextInt();
      maxX = Math.max(x, maxX); 
    }
    for(int i = 1; i<=M; i++){
      int y = sc.nextInt();
      minY = Math.min(y, minY);
    }
    if(maxX < minY){
      System.out.println("No War"); 
    }
    else{
      System.out.println("War");
    }
  }
}


Measured memory_bytes: 36004
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
string s;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s;
  int ans = 0;
  FOR(i, 0, sz(s)){
    if((s[i]=='g') && (i%2==1)){
      ans++;
    }else if((s[i]=='p') && (i%2==0)){
      ans--;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
	int n;
	cin>>n;
	double arr[n];
	double s1=0,s=0;
	for (int i = 0; i < n; ++i)
	{
		/* code */
		cin>>arr[i];
		s1=s1+(1/arr[i]);
	}
	s=1/s1;
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
A,B,C,X=map(int,sys.stdin)

ans=0
for i in range(min(A,X//500)+1):
    ta=X-i*500
    for j in range(min(B,ta//100)+1):
        tb=ta-j*100
        if C*50>=tb:
            ans+=1

print(ans)


Measured memory_bytes: 9172
using System;
using System.Text;

class Program
{
    static void Main()
    {
        string[] str = Console.ReadLine().Split(' ');
        int n = int.Parse(str[0]);
        int m = int.Parse(str[1]);
        int l = int.Parse(str[2]);


        long[,] A = new long[n, m];
        long[,] B = new long[m, l];

      
        

        for (int i = 0; i < n; i++)
        {
            string[] str2 =Console.ReadLine().Split(' ');
            for (int j = 0; j < m; j++)
            {
                A[i, j] = long.Parse(str2[j]);
            }
        }





        for (int i = 0; i < m; i++)
        {
            string[] str3 = Console.ReadLine().Split(' ');
            for (int j = 0; j < l; j++)
            {
                B[i, j] = long.Parse(str3[j]);
            }
        }

        long[,] Answer = MultiMatrix(A, B);

        for (int i = 0; i < Answer.GetLength(0); i++)
        {
            for (int j = 0; j < Answer.GetLength(1); j++)
            {
                if (j == 0)
                    Console.Write("{0}", Answer[i, j]);
                else
                    Console.Write(" {0}", Answer[i, j]);
            }
            Console.WriteLine();
        }
    }
       
    
    

    static long[,] MultiMatrix(long[,] x,long[,] y)
    {
        int Row = x.GetLength(0);
        int Colum = y.GetLength(1);

        long[,] Multip = new long[Row, Colum];

        for (int i = 0; i < Row; i++) 
        {
            for (int j = 0; j < Colum; j++) 
            {
                long Sum = 0;

                for (int k =0;k < x.GetLength(1); k++)
                {
                    long Multiplication = x[i, k] * y[k, j];

                    Sum += Multiplication;
                }

                Multip[i, j] = Sum;
            }
        }

        return Multip;
    }

   

}

Measured memory_bytes: 9912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll x,y,z,k,a[1000],b[1000],c[1000];
    vector<ll>d;
    cin >> x >> y >> z >> k;
    for(int i = 0; i<x; i++)
        cin >>a[i];
    for(int i = 0; i<y; i++)
        cin >> b[i];
    for(int i = 0; i<z; i++)
        cin >> c[i];
    sort(a,a+x,greater<long long>());
    sort(b,b+y,greater<long long>());
    sort(c,c+z,greater<long long>());

    for(int i = 0; i<x; i++)
    {
        for(int j = 0; j<y; j++)
        {
            for(int u = 0; u<z; u++)
            {
                if((i+1)*(j+1)*(u+1) <= k)
                {
                    d.push_back(a[i]+b[j]+c[u]);
                }
                else
                    break;
            }
        }
    }
    sort(d.begin(),d.end(),greater<long long>());
    for(int i = 0; i<k; i++)
    {
        cout << d[i] << endl;
    }
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
struct P
{
    //string r;
    int x,y,z;

    bool operator<(const P &a)const{
       // if(y!=a.y)
       // return y>a.y;
       return x>a.x;
//        return z>a.z;
    }
};
struct S
{
    //double a;
    int x,y;
};
vector<int> v[311210];

int a,b,c,i,k,d,n,m,e,dy[15]={0,0,-1,1,-1,1,-1,1},dx[15]={-1,1,0,0,1,1,-1,-1};
int l[55];
int o[5555];
//int dy[10]={1,0,-1,-1,-1,0},dx[10]={0,1,1,0,-1,-1};
//int dy1[10]={1,1,0,-1,0,1},dx1[10]={0,1,1,0,-1,-1};
long long x,y,z,mod=100000007;
P u[1600];
int j[5333];
queue<P> q;
//queue<int> q;
stack<int> s,s1;
//queue<P> q;

deque<int> de;
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_map<int, int > p;
string r,r1;
//char r[310];
//char r1[222][555];
bool as(P a,P b)
{
    if(a.x!=b.x)
        return a.x<b.x;
    return a.z<b.z;
}

int main()
{
    scanf("%d %d",&a,&b);
    cin>>r;
    for(int t=0;t<r.size();t++)
    if((t!=a&&r[t]=='-')||(t==a&&r[t]!='-'))
    {
        puts("No");
            return 0;
    }
    puts("Yes");
}


Measured memory_bytes: 7552
import java.util.ArrayList;
import java.util.Scanner;

class Main{

	static	int[] data;




	public static void main(String[] args) {





		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		long pow = 1000000000+7;
		data = new int[1001];


		for(int i = 2;i <= n;i++){
			num(i);
		}

		ArrayList<Integer> adddata = new ArrayList<Integer>(); 
		for(int i = 2;i <= n;i++){
			if(data[i] > 0){
				adddata.add(data[i] + 1);
			}
		}

		long ans = 1;
		for(int i = 0; i < adddata.size();i++){
			ans *= adddata.get(i);
			ans %= pow;
		}
		System.out.println(ans);




	}



	static void num(int n){


		int num = n;
		for(int i = 1;i <= n;i++){
			if(n % i == 0){
				data[i]++;
				n /= i;
				i = 1;
			}
		}
		return;

	}
}


class Pair implements Comparable{
	Character from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}




Measured memory_bytes: 21460
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
 
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> x(n);
    rep(i, n) cin >> x[i];
 
    int ans = 0;
    rep(i, n){
        ans += min(x[i] - 0, k - x[i]) * 2;
    }
    cout << ans << endl;
}

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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    int N, M;
    std::cin >> N >> M;

    ll sum = 0;
    map<ll, ll> map;
    map[0]++;
    REP(i, N) {
        ll a;
        std::cin >> a;
        sum += a;
        map[sum % M]++;
    }

    ll ans = 0;
    for(const auto& v : map) {
        ans += (v.second * (v.second - 1)) / 2;
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 4224
N = gets.to_i
A = gets.split.map(&:to_i).sort

MAX = A.max
mem = Array.new(MAX + 1,0)
A.each do |a|
  a.step(MAX, a) {|n| mem[n] += 1 }  
end
puts A.count {|i| mem[i] == 1 }

Measured memory_bytes: 38292
fun main() {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val roads = IntArray(n + 1)
    repeat(m) {
        val (a, b) = readLine()!!.split(' ').map { it.toInt() }
        roads[a]++
        roads[b]++
    }
    println(roads.slice(1..n).joinToString("\n"))
}

Measured memory_bytes: 40128
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long n,MIN=1LL<<60,ans;
    cin>>n;
    long long s[n];
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    sort(s,s+n);
    for(int i=0;i<n-1;i++){
        if(abs(s[i]-s[n-1]/2)+abs(s[i]-s[n-1]/2-1)<MIN){
            ans=s[i];
            MIN=abs(s[i]-s[n-1]/2)+abs(s[i]-s[n-1]/2-1);
            //cout<<ans<<" "<<MIN<<endl;
        }
    }
    cout<<s[n-1]<<" "<<ans<<endl;
}


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

int main()
{
    int n,ans=0;
    string s1="",s2="",t;
    cin>>n;
    for(int i=0;i<n;i++)
        {
            cin>>t;
            s1+=t;
        }
    for(int i=0;i<n;i++)
        {
            cin>>t;
            s2+=t;
        }
    if(s1<s2)
        swap(s1,s2);
    while(s2!=s1)
    {
        ++ans;
        next_permutation(s2.begin(),s2.end());
    }
    cout<<ans;
}



Measured memory_bytes: 3584
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

ll A[200000];

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

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

	for (int i=0; i+K<N; i++) {
		if (A[i] < A[i+K]) cout << "Yes" << endl;
		else cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 5176
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222


ll b[11], dp[11][11111];



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

  cin >> n >> m;
  vll a(m);
  rep(i,m) cin >> a[i];
  sort(all(a));
  b[1] = 2; b[2] = 5; b[3] = 5; b[4] = 4;
  b[5] = 5; b[6] = 6; b[7] = 3; b[8] = 7; b[9] = 6;
  dp[0][0] = 1;
  rep(i, m) {
    rep(j, n + 1) dp[i + 1][j] = dp[i][j];
    rep(j, n - b[a[i]] + 1) {
      if (!dp[i + 1][j]) continue;
      dp[i + 1][j + b[a[i]]] = max(dp[i + 1][j + b[a[i]]], dp[i + 1][j] + 1);
    }
  }
  ll cur = n, cnt = 0;
  rrep(i, m) {
    cnt = 0;
    while (cur - b[a[i]] >= 0 && dp[i + 1][cur - b[a[i]]] == dp[i + 1][cur] - 1) {
      cnt++;
      cur -= b[a[i]];
    }
    rep(j, cnt) cout << a[i];
  }
  cout << endl;




  return 0;
}

Measured memory_bytes: 1024
#coding:utf-8
import random

D = int(input())

C = [int(y) for y in input().split()]

S = []

ans = []

def scoring(inp,poi):
    
    score = 0
    day = 1
    last = [0] * 26
    
    for I in inp:
        score += poi[day-1][I-1]
        last[I-1] = day
        for ind,J in enumerate(last):
            score -= C[ind] * (day - ind - 1)
        day += 1
        
    return score

for i in range(D):
    s = [int(y) for y in input().split()]
    S.append(s)

for i in S:
    k = 0
    num = 0
    for f,t in enumerate(i):
        k = max(k,t)
        if k == t:
            num = f + 1
    ans.append(num)

counter = 500

base = scoring(ans,S)
nbase = 0
d = 0
ansc = ans.copy()

for i in range(counter):
    p = random.randint(0,25)
    q = random.randint(0,D-1)
    ansc[q] = p
    nbase = scoring(ansc,S)
    if nbase > base:
        ans = ansc.copy()
    else:
        ansc = ans.copy()

for i in ans:
    print("{}".format(int(i)))

base = scoring(ans,S)

Measured memory_bytes: 9884
S = str(input())
Q = int(input())

flip = False

head = ""
tail = ""

for q in range(Q):
    Ti = input()
    if Ti == '1':
        flip = not flip
    else:
        _, Fi, Ci = map(str, Ti.split())
        Fi = int(Fi)

        if (Fi^flip)&1:
            head += Ci
        else:
            tail += Ci

S = head[::-1] + S + tail
print( S if not flip else S[::-1])


Measured memory_bytes: 4596
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

#define INF 1e9
#define LLINF 1e18
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

int gcd(int a, int b) {
    if(a % b == 0) {
        return b;
    }
    else {
        return(gcd(b, a % b));
    }
}


int main() {
    char c;
    cin >> c;
    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
        cout << "vowel" << endl;
    }
    else cout << "consonant" << endl;
}

Measured memory_bytes: 256
Scanf.scanf "%d %d" (fun n k ->
    let hist = Array.make 100001 0 in
    for i = 1 to n do
        Scanf.scanf " %d %d" (fun a b ->
            hist.(a) <- hist.(a) + b;
        )
    done;

    let rec loop i asm =
        let asm = asm + hist.(i) in
        if asm >= k then i else loop (i + 1) asm
    in
    loop 1 0 |> Printf.printf "%d\n"
)

Measured memory_bytes: 6716
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n;

signed main() {
	cin >> n;
	rep(i,100) rep(j,100) if (4*i+7*j==n) return cout << "Yes" << ln, 0;
	cout << "No" << ln;
}

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


#define EPS 1e-7


typedef complex<double> vector2D;

#define INF 1e99
const double pi = acos(-1.0);


struct vector3D{
	double x, y, z;

	vector3D(): x(0.0), y(0.0), z(0.0) {}
	vector3D(double x, double y, double z): x(x), y(y), z(z) {}
	
	vector3D &operator +=(const vector3D &v){
		x += v.x;
		y += v.y;
		z += v.z;
	}
};

typedef const vector3D &ref3D;

vector3D operator +(ref3D v1, ref3D v2){
	return vector3D(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z);
}

vector3D operator -(ref3D v1, ref3D v2){
	return vector3D(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z);
}

vector3D operator -(ref3D v){
	return vector3D(-v.x, -v.y, -v.z);
}

vector3D operator *(ref3D v, double a){
	return vector3D(v.x * a, v.y * a, v.z * a);
}

vector3D operator *(double a, ref3D v){
	return v * a;
}

double norm(ref3D v){
	return v.x * v.x + v.y * v.y + v.z * v.z;
}

double abs(ref3D v){
	return sqrt(norm(v));
}

double dot(ref3D v1, ref3D v2){
	return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
}

double divisionlc(ref3D p1, ref3D p2, ref3D pc, double r){
	vector3D v12 = p2 - p1;
	vector3D v1c = pc - p1;

	double a = norm(v12);
	double b = -dot(v12, v1c);
	double c = norm(v1c) - r * r;

	double D = b * b - a * c;
	if( D < 0.0 ){
		return INF;
	}

	double t1 = (-b + sqrt(D)) / a;
	double t2 = (-b - sqrt(D)) / a;

	if( t1 < EPS ) t1 = INF;
	if( t2 < EPS ) t2 = INF;

	return min(t1, t2);
}


vector3D reflect(ref3D v1, ref3D nv){
	vector3D vhor = dot(v1, nv) / norm(nv) * nv;
	vector3D vver = v1 - vhor;
	return vver - vhor;
}


int main(){
	int n;
	double u, v, w;
	while(scanf("%d%lf%lf%lf", &n, &u, &v, &w) == 4){
		vector<vector3D> pc(n);
		vector<double> r(n);
		for(int i = 0; i < n; ++i){
			scanf("%lf%lf%lf%lf", &pc[i].x, &pc[i].y, &pc[i].z, &r[i]);
		}

		vector3D last;
		vector3D dir(u, v, w);

		while(true){
			double mint = INF;
			int mini = -1;

			for(int i = 0; i < n; ++i){
				double t = divisionlc(last, last + dir, pc[i], r[i]);
				if( t < mint ){
					mint = t;
					mini = i;
				}
			}
			if( mini == -1 ) break;
		
			last += dir * mint;
		
			vector3D nv = last - pc[mini];	//平面の法線ベクトル
			dir = reflect(dir, nv);
		}
		
		printf("%f %f %f\n", last.x, last.y, last.z);
	}
}

Measured memory_bytes: 1100
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp std::make_pair
#define pb push_back
#define X first
#define Y second
typedef long long ll; 
int main()
{
	// freopen("ARC091-D.in", "r", stdin); 
	int n, k; 
	scanf("%d%d", &n, &k); 
	ll ans = 0; 
	for (int b = k + 1; b <= n; b++)
		ans += (ll)(n / b) * (b - k) + std::max(n % b - k + 1, 0) - !k; 
	printf("%lld\n", ans);
	return 0; 
}


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


int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	long long sum = 0;
	for(int i=1; i<=n; ++i){
		if(i%3 && i%5)
			sum += i;
	}
	
	cout << sum << "\n";
}

Measured memory_bytes: 3596
#include<stdio.h>
int main()
{
  int a,b,c,d,e,f,g;

    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);

    g=a+b*5+c*10+d*50+e*100+f*500;
      
    if(g>=1000){
     printf("1\n");
      
    }else{
      printf("0\n");
    }

  return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <tuple>

using namespace std;

using PLL = pair<long long, long long>;

int main() {
	int n;
	long long d, a, x, h;
	cin >> n >> d >> a;

	vector<PLL> monsters(n);
	for (int i = 0; i < n; i++) {
		cin >> x >> h;
		monsters[i] = make_pair(x, h);
	}
	sort(monsters.begin(), monsters.end());
	auto max_x = monsters.back().first;

	long long ans = 0;
	long long n_bom = 0;
	queue<PLL> boms;
	for (auto p: monsters) {
		tie(x, h) = p;

		while (!boms.empty()) {
			auto bom = boms.front();
			if (bom.first >= x) {
				break;
			}
			n_bom -= bom.second;
			boms.pop();
		}

		h -= n_bom * a;
		if (h > 0) {
			int tmp = (h + a - 1) / a;
			n_bom += tmp;
			ans += tmp;
			boms.push(make_pair(x + d * 2, tmp));
		}
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<iomanip>
#include<limits>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>


using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define big ((ll)(1e9)+7)


// double c(double x)
// {
//   double X = x;
//   X = int(X) % 10;
//   return X;
// }

int main()
{
  int n,m;
  cin >> n >> m;
  vector<int> s(m);
  vector<int> c(s);
  for(int i = 0;i < m;i++)
  {
    cin >> s[i] >> c[i];
  }
  vector<int> ans(n);
  // ans[0] = 1;
  for(int i = 0;i < n;i++)
  {
    ans[i] = 10;
  }
  for(int i = 0;i < m;i++)
  {
    if(ans[s[i]-1] == 10)
    {
      ans[s[i]-1] = c[i];
    }
    else if(ans[s[i]-1] == c[i])
    {
      continue;
    }
    else
    {
      cout << -1 << endl;
      return 0;
    }
  }
  // for(int i = 0;i < n;i++)
  // {
  //   cout << ans[i] << " ";
  // }
  // cout << endl;
  if(n != 1 && ans[0] == 0)
  {
    cout << -1 << endl;
  }
  else if(n == 1)
  {
    if(ans[0] == 10)
    {
      cout << 0 << endl;
    }
    else
    {
      cout << ans[0] << endl;
    }
  }
  else if(n == 2)
  {
    if(ans[0] == 10)
    {
      if(ans[1] == 10)
      {
        cout << 1 << 0 << endl;
      }
      else
      {
        cout << 1 << ans[1] << endl;
      }
    }
    else
    {
      if(ans[1] == 10)
      {
        cout << ans[0] << 0 << endl;
      }
      else
      {
        cout << ans[0] << ans[1] << endl;
      }
    }
  }
  else
  {
    if(ans[0] == 10)
    {
      if(ans[1] == 10)
      {
        if(ans[2] == 10)
        {
          cout << 100 << endl;
        }
        else
        {
          cout << 10 << ans[2] << endl;
        }
      }
      else if(ans[2] == 10)
      {
        cout << 1 << ans[1] << 0 << endl;
      }
      else
      {
        cout << 1 << ans[1] << ans[2] << endl;
      }
    }
    else if(ans[1] == 10)
    {
      if(ans[2] == 10)
      {
        cout << ans[0] << 0 << 0 << endl;
      }
      else
      {
        cout << ans[0] << 0 << ans[2] << endl;
      }
    }
    else if(ans[2] == 10)
    {
      cout << ans[0] << ans[1] << 0 << endl;
    }
    else
    {
      for(int i = 0;i < n;i++)
      {
        cout << ans[i];
      }
      cout << endl;
    }
  }
}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n,m=parseMap(split(readline()))
    a=sort(parseMap(split(readline())))
    data=sort([parseMap(split(readline())) for i in 1:m],by=x->x[2],rev=true)
    min_index=1
    ans=0
    for (b,c) in data
        i=searchsortedlast(a,c-1)    # c未満の数の末尾を探す
        if min_index>i
            break
        end
        if i<b+min_index
            ans+=(i-min_index+1)*c
            min_index=i+1
        else
            ans+=b*c
            min_index+=b
        end
    end
    println(ans+sum(a[min_index:end]))
end
main()

Measured memory_bytes: 157740
#include<bits/stdc++.h>
#define F(i,a,b) for(int i=(a);i<=(b);++i)
using namespace std;
int n,x,c;
bitset<4000000> St;
int main(){
	scanf("%d",&n);
	St[0]=1;
	F(i,1,n) scanf("%d",&x), St|=St<<x;
	x=St.count();
	F(i,0,4000000){
		if(St[i]) ++c;
		if(c==x/2+1) {printf("%d",i); return 0;} 
	}
	return 0;
}

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

#define MAX 200000
#define SENTINEL 2*1e9
typedef long long ll;

int L[MAX/2+2], R[MAX/2+2];

ll merge(int A[], int n, int left, int mid, int right)
{
	int i,j,k;
	ll cnt = 0;
	int n1 = mid - left;
	int n2 = right - mid;
	for(i = 0; i < n1; ++i)	L[i] = A[left+i];
	for(i = 0; i < n2; ++i)	R[i] = A[mid+i];
	L[n1] = SENTINEL;
	R[n2] = SENTINEL;
	i = j = 0;
	for(k = left; k < right; ++k)
	{
		if (L[i] <= R[j])
		{
			A[k] = L[i++];
		}
		else
		{
			A[k] = R[j++];
			cnt += n1-i;
		}
	}
	return cnt;
}

ll mergeSort(int A[], int n, int left, int right)
{
	int mid;
	ll v1, v2, v3;
	if (left + 1 < right)
	{
		mid = (left + right)/2;
		v1 = mergeSort(A, n, left, mid);
		v2 = mergeSort(A, n, mid, right);
		v3 = merge(A, n, left, mid, right);
		return v1 + v2 + v3;
	}
	else return 0;
}

int main(int argc, char const *argv[])
{
	int A[MAX], n;
	cin>>n;
	for (int i = 0; i < n; ++i)
	{
		scanf("%d",&A[i]);
	}
	ll ans = mergeSort(A, n, 0, n);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4712
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    long long sum=0;
    int a[200000];
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    long long ans=10000000000000000;
    long long sum2=0;
    for(int i=0;i<n-1;i++){
        sum-=a[i];
        sum2+=a[i];
        //cout<<sum2<<" "<<sum<<endl;
        ans=min(ans,abs(sum2-sum));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
S = input()
T = input()

used = []
res  = []

for i in range(len(S)):
    if S[i] not in used:
        used.append(S[i])
    res.append(used.index(S[i]))

#print(used)
#print(res)
used = []
ret = []

for i in range(len(T)):
    if T[i] not in used:
        used.append(T[i])
    ret.append(used.index(T[i]))

if res == ret:
    print('Yes')
else:
    print('No')

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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> stick(N);
  rep(i,N){
    cin >> stick[i];
  }
  sort(stick.begin(),stick.end());
  reverse(stick.begin(),stick.end());
  
  int ans=0;
  rep(i,K){
    ans += stick[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
 
int main()
{
int x,y,b1,i=0,con,con2;
cin>>x>>y;
b1=y;
for( i=0;y>0;i++)
{
    y=y/10;
}
 
 
 
x=x*(pow(10,i));
 
con=x+b1;
 
con2=sqrt(con);
 
if(con==(con2*con2))
    cout<<"Yes";
else
    cout<<"No";
    return 0;
}

Measured memory_bytes: 4008
from collections import Counter
S = input()
d = Counter(S)

na = 0 if "a" not in d.keys() else d["a"]
nb = 0 if "b" not in d.keys() else d["b"]
nc = 0 if "c" not in d.keys() else d["c"]

if abs(na - nb) <= 1 and abs(nc - na) <= 1 and abs(nb - nc) <= 1:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3564
n,k,q = map(int,input().split())
a = [int(input()) for i in range(q)]
lst = [k-q]*(n+1)
for i in a:
  lst[i] += 1
for i in range(1,n+1):
  if lst[i] > 0:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 10452
#17:03
n,m,r = map(int,input().split())
must = list(map(lambda x: int(x)-1,input().split()))
inf = 10**18
wf = [[inf for _ in range(n)] for _ in range(n)]
for i in range(n):
  wf[i][i] = 0
for _ in range(m):
  a,b,l = map(int,input().split())
  a -= 1
  b -= 1
  wf[a][b] = l
  wf[b][a] = l
for k in range(n):
  for i in range(n):
    for j in range(n):
      wf[i][j] = min(wf[i][j],wf[i][k]+wf[k][j])
#print(wf)
can = []
import itertools
for perm in itertools.permutations(range(r)):
  ans = 0
  for i in range(r-1):
    ans += wf[must[perm[i]]][must[perm[i+1]]]
  can.append(ans)
#print(can)
print(min(can))

Measured memory_bytes: 48472
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>

using namespace std;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

void transport(long long x[],long long cnt[],int num){
	if(cnt[num] > 0){
		if(cnt[num] < x[num]) {
			cnt[num+1] += cnt[num];
			cnt[num] = 0;
		}
		else{
			cnt[num] -= x[num];
			cnt[num+1] += x[num];	
		}
	}
	return;
}

int main(){
    int n, m;
	cin >> n >> m;
	long long ans = 0;

	vector<pair<int, int>> x(n);
	REP(i, n){
		cin >> x[i].first >> x[i].second;
	}

	sort(all(x));

	int j = 0;
	REP(i, m){
		ans += x[j].first;
		x[j].second--;
		if(x[j].second == 0) j++;
	}

	cout << ans << endl;
}


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

using namespace std ;

int main()
{
    char s[1000] , t[10000] ;
    int n ;
    cin >> n ;
    scanf("%s" , s + 1 ) ; scanf("%s" , t + 1 ) ;
    for(int i = 1 ; i <= n ; i++ ){
        cout << s[i] << t[i] ;
    }
}



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

typedef long long LL;

int N;
int A[100010];

int gcd(int a , int b){
	return b > 0 ? gcd(b,a%b) : a;
}

int main(){
	scanf("%d" , &N);
	int p = 0;
	LL s = 0;
	repp(i,0,N){
		scanf("%d" , A + i);
		s += A[i] - 1;
		if(A[i] == 1) ++p;
		if(A[i] % 2 == 1) ++p;
	}
	if(s % 2 == 1 || p != 1){
		printf("%s\n" , s % 2 == 1 ? "First" : "Second");
		return 0;
	}
	int t = 0;
	while(p == 1 && s % 2 == 0){
		p = 0;
		s = 0;
		if(A[0] % 2 == 1) --A[0];
		int g = A[0];
		repp(i,1,N){
			if(A[i] % 2 == 1) --A[i];
			g = gcd(g,A[i]);
		}
		repp(i,0,N){
			A[i] /= g;
			if(A[i] == 1) ++p;
			if(A[i] % 2 == 1) ++p;
			s += A[i] - 1;
		}
		++t;
	}
	printf("%s\n" , (s+t) % 2 == 1 ? "First" : "Second");
	return 0;
}


Measured memory_bytes: 512