akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define mod 1000000007
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>

const double pi = 3.14159;
const int inf = 100007;
const int N = 100005;

int main() {

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

    int t = 1;
    //cin>>t;

    while(t--) {
      ll a;
      double b;
      cin>>a>>b;
      ll bb = b*100+0.5;
      a*=bb;
      a/=100;
      cout<<a<<"\n";
    }
}


Measured memory_bytes: 3700
import math
from functools import reduce

K = int(input())
result = 0

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

for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            result += gcd(a, b, c)

print(result)

Measured memory_bytes: 69452
N, A, B = map(int, input().split())
S = input()
a = 0
b = 0

for s in S:
    if s == 'a':
        if a+b<A+B:
            print("Yes")
            a += 1
        else:
            print("No")
    elif s == 'b':
        if a+b<A+B and b<B:
            print("Yes")
            b += 1
        else:
            print("No")        
    else:
        print("No")

Measured memory_bytes: 4016
N = int(input())
H = list(map(int,input().split()))

stp = [0]*(N+1)
stp[0] = 0

for i in range(1,N):
    if H[i]<=H[i-1]:
        stp[i] = stp[i-1] +1
    else:
        stp[i] = 0
        
print(max(stp))

Measured memory_bytes: 20444
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    int ans=0;
    //odd
    if(n<2)
        ans=0;
    else ans=n*(n-1)/2;
    //even
    if(m<2)
     ans+=0;
    else ans+=m*(m-1)/2;
    cout<<ans;
    

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;

vector<vector<pair<int,int>>>edges;

int memo[17][1 << 16];
struct aa {
	int now;
	bitset<17>eats;
	int time;
};
class Compare {
public:
	//aaが昇順に並ぶ
	bool operator()(const aa&l, const aa&r) {
		return l.time> r.time;
	}
};


int main() {
	while (1) {
		for (int i = 0; i < 17; ++i) {
			for (int j = 0; j < (1 << 16); ++j) {
				memo[i][j] =99999999;
			}
		}
		int N, M, L, S, T; cin >> N >> M >> L >> S >> T;
		if (!N)break;
		S--;
		edges.clear();
		edges.resize(L+1);
		int diss[300][300];
		for (int i = 0; i < N; ++i) {
			
			for (int j = 0; j< N; ++j) {

				diss[i][j] = i==j?0:99999999;

			}
			
		}
		for (int i = 0; i < M; ++i) {
			int a, b, c; cin >> a >> b >> c;
			a--; b--;
			diss[a][b] = c;
			diss[b][a] = c;
		}

		for (int i = 0; i < N; ++i) {
			for (size_t j = 0; j < N; j++)
			{
				for (size_t k = 0; k < N; k++)
				{
					diss[j][k] = min(diss[j][k],diss[j][i] + diss[i][k]);
				}
			}
		}
		vector<pair<int, int>>ramens;
		ramens.push_back(make_pair(S, 0));
		for (int i = 0; i < L; ++i) {
			int j, e; cin >> j >> e;
			j--;
			ramens.push_back(make_pair(j,e));
		}
		for (int i = 0; i < L+1; ++i) {
			for (int j = 0; j< L + 1; ++j) {
				if (i != j) {
					edges[i].push_back(make_pair(j, diss[ramens[i].first][ramens[j].first]));
				}
			}
		}

		priority_queue<aa, vector<aa>, Compare>que;
		que.push(aa{ 0,bitset<17>(1),0 });


		memo[0][0] = 0;
		int ans = 0;
		while (!que.empty()) {
			aa atop(que.top());
			que.pop();
			bitset<17>nbs(atop.eats);
			if (atop.now == 0) {
				ans = max(ans, int(nbs.count()));
				if (ans == L + 1)break;
			}

			for (auto j : edges[atop.now]) {
				const int nextplace = j.first;
				if (!nbs[nextplace]|| nextplace == 0) {
					const int nexttime = atop.time + j.second;
					if (nexttime < memo[nextplace][nbs.to_ulong() / 2] && nexttime <= T) {
						if (nextplace == 0) {

							memo[nextplace][nbs.to_ulong() / 2] = nexttime;
							que.push(aa{ nextplace,nbs,nexttime });
						}

						if (!nbs[nextplace]) {
							nbs[nextplace] = true;
							int alltime = nexttime + ramens[nextplace].second;
							if (alltime < memo[nextplace][nbs.to_ulong() / 2] && alltime <= T) {
								memo[nextplace][nbs.to_ulong() / 2] = alltime;
								que.push(aa{ nextplace,nbs, alltime });
							}
							nbs[nextplace] = false;
						}
					}
				}
			}
		}
		cout << ans-1 << endl;
	}
	return 0;
}

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

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

    int n, m, q;
    cin >> n >> m >> q;

    vector<int> l(m), r(m);
    rep(i, m){
        cin >> l[i] >> r[i];
        --l[i];
        --r[i];
    }

    vector<vector<int>> sm(n, vector<int>(n, 0));
    rep(i, m){
        for(int j = r[i]; j < n; ++j) ++sm[l[i]][j];
    }

    rep1(i, n) rep(j, n) sm[n-i-1][j] += sm[n-i][j];
    
    rep(_, q){
        int a, b;
        cin >> a >> b;
        --a;
        --b;

        cout << sm[a][b] << "\n";
    }

    return 0;
}

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

long long a[100005];
bool cmp(int x , int y)
{
    return x>y;
}
int main()
{
    int n;
    scanf("%d",&n);
    long long l = 0 , r = 0;
    for(int i = 1;i <= n;i++)
    {
        scanf("%lld",&a[i]);
    }
    sort(a+1,a+1+n,cmp);
    for(int i = 1;i <= n;i++)
    {
        if(i >= 2 && a[i] == a[i - 1] && a[i] > l) l = a[i];
        if(i >= 4 && a[i] == a[i - 1] && a[i] < l && a[i] > r) r = a[i];
        if(i >= 4 && a[i] == a[i - 1] && a[i] == a[i - 2] && a[i] == a[i - 3] && a[i] > r) r = a[i];
        if(r * l != 0) break;
    }
    printf("%lld",r * l);
    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <climits>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define MOD 1000000007LL

int main()
{
  int n, a;
  ll ans=0;

  cin >> n;

  for (int i=1; i<=n; i++) {
    cin >> a;
    if (a%2==1 && i%2==1) ans++;
  }

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


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <iostream>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;

int main(){
    long a,sum=0;
    cin>>a;
    int b;
    cin>>b;
    int n[b];
    for(int i=0;i<b;i++){
        cin>>n[i];
        sum+=n[i];
    }
    if(a-sum<0)cout<<-1;
    else cout<<a-sum;
    return 0;
}


Measured memory_bytes: 3660
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Set;

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

        int A = scan.nextInt();
        int B = scan.nextInt();
        System.out.println(A*B);
    }
}



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

vector<int> enum_div(int n) {
	vector<int> ans;
	for (int i = 1; i * i <= n; ++i) {
		if (n % i == 0) {
			ans.push_back(i);
			if (i != 1 && i * i != n) {
				ans.push_back(n / i);
			}
		}
	}
	ans.push_back(n);
	return ans;
}

signed main() {
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> now(n, 0);
	vector<int> ans;
	for (int i = 0; i < n; ++i)cin >> a[i];
	for (int i = n - 1; i >= 0; --i) {
		if ((a[i] + now[i]) % 2) {
			ans.push_back(i);
			for (int x: enum_div(i + 1)) {
				now[x - 1]++;
			}
		}
	}
	cout << ans.size() << endl;
	for (auto x : ans)cout << x + 1 << " ";
	cout << endl;
}

//coutの時に+1!

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

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

    vector<ll> x(N), y(N), h(N);
    rep(i, N) cin >> x[i] >> y[i] >> h[i];

    ll H;

    for (int cx = 0; cx <= 100; cx++) {
        for (int cy = 0; cy <= 100; cy++) {
            bool ok = true;

            set<ll> s;
            set<ll> t;

            // H = abs(x[0] - cx) + abs(y[0] - cy) + h[0];
            // H = max(H, 0LL);

            for (int i = 0; i < N; i++) {
                // if (h[i] == 0) continue;
                // ll now = abs(x[i] - cx) + abs(y[i] - cy) + h[i];
                // if (H != now) {
                //     ok = false;
                //     break;
                // }
                if (h[i] > 0) {
                    s.insert(abs(x[i] - cx) + abs(y[i] - cy) + h[i]);
                } else {
                    t.insert(abs(x[i] - cx) + abs(y[i] - cy) + h[i]);
                }
            }

            // if (ok && H >= 1) {
            if (s.size() == 1) {
                H = *s.begin();
                // cout << cx << " " << cy << " " << H << endl;
                // return 0;
                bool ok = true;
                rep(i, N) {
                    ll now = max(H - abs(x[i] - cx) - abs(y[i] - cy), 0LL);
                    if (now != h[i]) {
                        ok = false;
                        break;
                    }
                }
                if (ok) {
                    cout << cx << " " << cy << " " << H << endl;
                    return 0;
                }
            }
        }
    }
}

Measured memory_bytes: 3612
import sys

s = sorted(list(input()))
t = sorted(list(input()), reverse=True)

st = "".join(s)
tt = "".join(t)

if st == tt:
    print("No")
    sys.exit()

stlist = [st, tt]
stlist = sorted(stlist)
if stlist[0] == st:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
#define vel vector<int>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
signed main() {
	int ans = 0;
	int n; cin >> n;
	for (long long i = 1; i*i <= n; i++) {
		if(n%i==0){
			if ((n / i) - 1 > i) {
				ans += (n / i) - 1;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

vector<int> div(auto n) {
  vector<int> d;
  for(auto i = 1; i * i <= n; ++i) {
    if(n % i) continue;
    d.emplace_back(i);
    if(i * i != n) d.emplace_back(n / i);
  }
  return d;
}

int toi(char c) {
  return c - '0';
}
int toi(string s) {
  int r = 0;
  for(auto c: s) r = 10 * r + toi(c);
  return r;
}

int dif(auto l, auto g) {
  auto n = l.size();
  if(2 < n) {
    if(l.substr(0, n-2) != g.substr(0, n-2)) return 10;
    l = l.substr(n-2, 2);
    g = g.substr(n-2, 2);
  }
  return toi(g) - toi(l);
}

int eq(auto n) {
  int r = 10;
  for(auto d: div(n.size())) if(d != n.size()) {
    string l = "~", g = "";
    for(auto i = 0; i < n.size(); i += d) {
      auto s = n.substr(i, d);
      l = min(l, s);
      g = max(g, s);
    }
    r = min(r, dif(l, g));
  }
  return r;
}

int neq(auto n) {
  int l = 10, g = 0;
  for(auto i = 0; i < n.size(); ++i) {
    auto t = toi(n[i]);
    if(t == 1) {
      if(i == n.size() - 1) return 10;
      t = 10 * t + toi(n[++i]);
    }
    l = min(l, t);
    g = max(g, t);
  }
  return g - l;
}

int main() {
  string n;
  cin >> n;
  cout << min(eq(n), neq(n)) << endl;
}

Measured memory_bytes: 3460
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define ill long long
#define fcout cout << fixed << setprecision(10)
using namespace std;

int main() {
  int a;
  cin >> a;
  if(a >= 30) cout << "Yes\n";
  else cout << "No\n";
}

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

struct node { ll x,y; }a[1010];

int n;
bool bo1[233],bo2[233];

inline ll rd()
{
	ll x=0,f=1;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main()
{
	n=rd();
	for (int i=1;i<=n;i++)
	{
		int x=rd(),y=rd();
		a[i].x=x+y;a[i].y=x-y;
	}
	for (int i=1;i<=n;i++) if ((a[i].x&1)!=(a[i].y&1)) { puts("-1");return 0; }
	for (int i=2;i<=n;i++) if ((a[i].x&1)!=(a[1].x&1)) { puts("-1");return 0; }
	if (a[1].x&1)
	{
		puts("39");
		for (int i=0;i<39;i++) printf("%lld ",1LL<<i);
		puts("");
		for (int i=1;i<=n;i++)
		{
			ll hh=((1LL<<39)-1-a[i].x)/2;
			for (int j=0;j<39;j++) if ((1LL<<j)&hh) bo1[j]=false;else bo1[j]=true;
			hh=((1LL<<39)-1-a[i].y)/2;
			for (int j=0;j<39;j++) if ((1LL<<j)&hh) bo2[j]=false;else bo2[j]=true;
			for (int j=0;j<39;j++)
			{
				if (bo1[j]&&bo2[j]) putchar('R');
				if (!bo1[j]&&!bo2[j]) putchar('L');
				if (bo1[j]&&!bo2[j]) putchar('U');
				if (!bo1[j]&&bo2[j]) putchar('D');
			}
			puts("");
		}
	}
	else
	{
		puts("40");
		printf("1 ");
		for (int i=0;i<39;i++) printf("%lld ",1LL<<i);
		puts("");
		for (int i=1;i<=n;i++)
		{
			if (a[i].x==0) { for (int j=0;j<39;j++) bo1[j]=false;bo1[39]=true; }
			else
			{
				ll hh=((1LL<<39)-1-(a[i].x-1))/2;
				bo1[0]=1;
				for (int j=0;j<39;j++) if ((1LL<<j)&hh) bo1[j+1]=false;else bo1[j+1]=true;
			}
			if (a[i].y==0) { for (int j=0;j<39;j++) bo2[j]=false;bo2[39]=true; }
			else
			{
				ll hh=((1LL<<39)-1-(a[i].y-1))/2;
				bo2[0]=1;
				for (int j=0;j<39;j++) if ((1LL<<j)&hh) bo2[j+1]=false;else bo2[j+1]=true;
			}
			for (int j=0;j<40;j++)
			{
				if (bo1[j]&&bo2[j]) putchar('R');
				if (!bo1[j]&&!bo2[j]) putchar('L');
				if (bo1[j]&&!bo2[j]) putchar('U');
				if (!bo1[j]&&bo2[j]) putchar('D');
			}
			puts("");
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	char str[101];
	int len,i,n,j=0,k=0;
	scanf("%s",str);
	len=strlen(str);
	for(i=0;i<=len;i++)
	{
		if(str[i]=='C') 
		{
		j=1;
		break;
		}
	}
	for(n=i;n<=len;n++)
	{
		if(str[n]=='F')
		{
		k=1;
		break;
		}
	}
	if(j+k==2) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		int[] a = new int[n];
		int i;
		
		for (i = 0; i < n; i++)
			a[i] = stdIn.nextInt();
		
		int count = SelectionSort(a, n);
		
		System.out.print(a[0]);
		for (i = 1; i < n; i++)
			System.out.print(" " + a[i]);
		System.out.println();
		System.out.println(count);
	}
	
	public static int SelectionSort(int[] a, int n) {
		int i, j, minat, t, count = 0;
		for (i = 0; i < n; i++) {
			minat = i;
			for (j = i + 1; j < n; j++)
				if (a[j] < a[minat])
					minat = j;
			if (i != minat) {
				t = a[i];
				a[i] = a[minat];
				a[minat] = t;
				count++;
			}
		}
		return count;
	}
}

Measured memory_bytes: 26280
#include<stdio.h>
int max(int a, int b) {
	if (a >= b) return a;
	return b;
}
int main() {
	int a, b, c, d, e;
	int n, m;
	scanf("%d %d %d %d %d", &a, &b, &c, &d, &e);
	if (b % d) n = b / d + 1;
	else n = b / d;
	if (c % e) m = c /e + 1;
	else m = c / e;
	printf("%d\n", a - max(n, m));
	return 0;
}

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

int main()
{
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	
	int dx = x1 - x2;
	int dy = y1 - y2;
	
	int x3 = x2 + dy;
	int y3 = y2 - dx;
	int x4 = x1 + dy;
	int y4 = y1 - dx;
	
	cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, y int
	fmt.Scan(&n, &y)
	for i := 0; i <= n; i++ {
		for j := 0; j <= n-i; j++ {
			k := n - i - j
			if 10000*i+5000*j+1000*k == y {
				fmt.Println(i, j, k)
				return
			}
		}
	}
	fmt.Println(-1, -1, -1)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<pii, lint> ppl;
typedef pair<lint, lint> pll;
typedef complex<double> xy_t;
typedef vector<lint> poly;

int main(){
    int n;
    scanf("%d", &n);
    int L[n];
    int m = 1010;
    lint cnt[m+1], sum[m+2];
    rep(i, m+1) cnt[i] = 0;
    rep(i, n){
        scanf("%d", &L[i]);
        ++cnt[L[i]];
    }
    sum[0] = 0;
    rep(i, m+1) sum[i+1] = sum[i] + cnt[i];

    sort(L, L+n);
    lint ans = 0;
    rep(i, m)For(j, i+1, m)if(cnt[i] && cnt[j]){
        ans += cnt[i] * cnt[j] * (sum[min(m+1, i+j)] - sum[j+1]);
    }

    rep(i, m)if(cnt[i] >= 2){
        ans += (sum[i] + sum[min(m+1, 2*i)] - sum[i+1]) * (cnt[i])*(cnt[i]-1)/2;
        if(cnt[i] >= 3) ans += (cnt[i])*(cnt[i]-1)*(cnt[i]-2)/6;
    }

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

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

int main(){
   int n,s,A =0;
   cin >> n;
   vector <int> a(n);
   vector <int> b(n);
   for(int i=0;i<n;i++){
      cin>>a.at(i)>>b.at(i);
      if(s<a.at(i)){
         s=a.at(i);
         A=s+b.at(i);
   }}
   cout<< A<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define sz size
#define pb push_back
#define mper make_pair
#define PI 3.14159
#define F first
#define S second
#define ll long long
//#define forik(i, a, b) for(ll i = a; i <= b; ++i)
#define vl vector<ll>
#define pll pair<ll, ll>
using namespace std;
  
ll f(ll n, ll x) { 
    if(n % x == 0) {
    	return n * 2ll - x;  
    } 
    else { 
    	return 2ll * x * (n / x) + f(x, n % x);    
    } 
}
 
int main() { 
	ll n, x; 
	cin >> n >> x;  
	cout << f(n - x, x) + n; 
	return 0;
}

Measured memory_bytes: 256
import numpy as np
import sys


def validation(c, a, b):
    for i in range(3):
        for j in range(3):
            if c[i][j] != a[i] + b[j]:
                print('No')
                return sys.exit()
    print('Yes')
    return sys.exit()


c_1 = list(map(int, input().split()))
c_2 = list(map(int, input().split()))
c_3 = list(map(int, input().split()))
c = np.array([c_1, c_2, c_3])
for i in range(np.max(c)+1):
    a = []
    b = []
    a.append(i)
    b.append(c[0][0] - a[0])
    b.append(c[0][1] - a[0])
    b.append(c[0][2] - a[0])
    a.append(c[1][0] - b[0])
    a.append(c[2][0] - b[0])
    validation(c, a, b)

Measured memory_bytes: 12504
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<tint> vtint;
typedef vector<vint> vvint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=550;
//↑templete
signed main(){

	int A[5][5]={};
	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++)
			cin>>A[i][j];
	
	int N;
	cin>>N;
	for(int k=0;k<N;k++){
		int b;
		cin>>b;
		for(int i=0;i<3;i++)
			for(int j=0;j<3;j++)
				if(A[i][j]==b)
					A[i][j]=0;
	}

	bool bingo=0;
	for(int i=0;i<3;i++){
		bool temp=0;
		for(int j=0;j<3;j++)
			if(A[i][j])
				temp=1;
		if(!temp)
			bingo=1;
	}
	for(int j=0;j<3;j++){
		bool temp=0;
		for(int i=0;i<3;i++)
			if(A[i][j])
				temp=1;
		if(!temp)
			bingo=1;
	}
	if(!A[0][0] && !A[1][1] && !A[2][2])
		bingo=1;
	if(!A[0][2] && !A[1][1] && !A[2][0])
		bingo=1;

	if(bingo)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,m,pd[100001],ans[100001];
vector<int>v[100001];
void bfs()
{
	queue<int>q;
	int n1,n2,tnt=0;
	q.push(1);
	pd[1]=1;
	while(!q.empty())
	{
		n1=q.front();
		tnt++;
		q.pop();
		for(int i=0;i<v[n1].size();i++)
		{
			n2=v[n1][i];
			if(pd[n2]==0)
			{
				ans[n2]=n1;
				pd[n2]=1;
				q.push(n2);
			}
		}
	}
	if(tnt!=n)
	{
		printf("No");
		return;
	}
	puts("Yes");
	for(int i=2;i<=n;i++)
	printf("%lld\n",ans[i]);
}
signed main()
{
	int x,y;
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%lld%lld",&x,&y);
		v[x].push_back(y);
		v[y].push_back(x);
	}
	bfs();
    return 0;
}

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

#define N 500
#define NN 8000
#define INF 1LL << 60

int n;
long long a[N][N];
int prime[2*N];
char tbl[NN];

long long gcd(long long x, long long y)
{
	long long r;

	if( x < y ) {
		swap( x, y );
	}
	while((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
}

long long lcm(long long x, long long y)
{
	return (x * (y / gcd(x, y) ) );
}

int main()
{
	cin >> n;

	if( n == 2 ) {
		cout << "4 7" << endl;
		cout << "23 10" << endl;
		return 0;
	}

	// create prime table
	tbl[0] = tbl[1] = 1;
	for( int i = 0; i < NN; i++ ) {
		if( !tbl[i] ) {
			for( int j = i + i; j < NN; j += i ) {
				tbl[j] = 1;
			}
		}
	}
	int idx = 0;
	for( int i = 0; i < NN; i++ ) {
		if( !tbl[i] ) {
			prime[idx] = i;
			idx++;
			if( idx >= 2*N ) {
				break;
			}
		}
	}

	for( int i = 0; i < n; i++ ) {
		for( int j = 0; j < n; j++ ) {
			if( ( (i + j) % 2) == 0 ) {
				int idx1 = (i - j + n - 1) / 2;
				int idx2 = (i + j) / 2;
				a[i][j] = (long long)prime[idx1] * prime[idx2 + n];
			}
		}
	}

	for( int i = 0; i < n; i++ ) {
		for( int j = 0; j < n; j++ ) {
			if(  ( (i + j) % 2) != 0 ) {
				long long aa[4] = {0};
				int li = i - 1;
				int ri = i + 1;
				int uj = j - 1;
				int dj = j + 1;
				if( li >= 0 ) {
					aa[0] = a[li][j];
				}
				if( ri < n ) {
					aa[1] = a[ri][j];
				}
				if( uj >= 0 ) {
					aa[2] = a[i][uj];
				}
				if( dj < n ) {
					aa[3] = a[i][dj];
				}
				long long l = 0;
				for( int k = 0; k < 4; k++ ) {
					if( aa[k] ) {
						if( l == 0 ) {
							l = aa[k];
						}
						else {
							l = lcm( l, aa[k] );
						}
					}
				}
				a[i][j] = l + 1;
			}
		}
	}

	for( int i = 0; i < n; i++ ) {
		for( int j = 0; j < n; j++ ) {
			cout << a[i][j];
			if( j == n - 1 ) {
				cout << endl;
			}
			else {
				cout << " ";
			}
		}
	}

	return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
	int x, m;
	vector<int> a(101, 0);
	while(cin >> x){
		a[x] += 1;
	}
	m = *(max_element(a.begin(), a.end()));
	for(int i = 1;i <= 100;++i){
		if(a[i] == m) {
			cout << i << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3004
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	long long r,c;
	scanf("%lld%lld",&r,&c);
	if(r==1 && c==1)
	{
		puts("1");
		return 0;
	}
	if(r==1) printf("%lld\n",max(c-2,0ll));
	else if(c==1) printf("%lld\n",max(r-2,0ll));
	else printf("%lld\n",1ll*(r-2)*(c-2));
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[1000000+5];
ll arr[1000000+5];
/*arr[0]=1;
dp[0]=1;*/
int main()
{
    /*ll n,x=1,i;
    cin>>n;
    ll mod=1000000007;
    ll dp[n+2]
    for(i=1;i<=n-1;i++)
    {
        x=x*2;
        x=x%mod;
    }
    x=x+n-1;
    x=x%mod;
    cout<<x;*/
    /*ll n;
    cin>>n;
    ll a[n],i;
    for(i=0;i<n;i++)
    {
        cin>>n;
    }*/
    ll n,i,x,y,j;
    cin>>n;
    ll dis[4][2]={{1,1},{1,-1},{-1,1},{-1,-1}};
    std::vector<ll> low(4,INT_MAX);
    std::vector<ll> high(4,INT_MIN);
    for(i=0;i<n;i++)
    {   
        cin>>x>>y;
        for(j=0;j<4;j++)
        {
            low[j]=min(low[j],x*dis[j][0]+y*dis[j][1]);
            high[j]=max(high[j],x*dis[j][0]+y*dis[j][1]);
        }
    }
    ll ans=0;
    for(i=0;i<4;i++)
    {
        ans=max(ans,abs(high[i]-low[i]));
    }
    cout<<ans;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<long long> vl;
typedef std::vector<std::vector<long long>> vvl;
#define out(x) cout<<x<<"\n";
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}
 
ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}

using namespace std;

int n, m;

template<typename T>
struct edge{
  int to;
  T cost;
  edge(int to,T cost):to(to),cost(cost){}
};


template<typename T>
vector<vector<T>> dijkstra(vector<vector<edge<T>>> &g,int s){//sは始点
  const auto INFTY=numeric_limits<T>::max();//2回以上使うときはオーバーフローに気をつける(INFTYのときはif文で弾くなど)
  vector<vector<int>> dist(n, vector<int>(3, INFTY));
  using p = pair<int, int>;
  using P = pair<T,p>;
  priority_queue<P, vector<P>, greater<P>> pq;
  dist[s][0]=0;
  pq.emplace(dist[s][0],p{s,0});
  while(!pq.empty()){
    auto x=pq.top();pq.pop();
    int v=x.second.first;//頂点
    int u = x.second.second;//頂点の状態
    if (dist[v][u] < x.first)
      continue; //最短距離でなければ飛ばす
    for(auto e:g[v]){
      if(dist[e.to][(u+1)%3]>dist[v][u]+e.cost){
        dist[e.to][(u+1)%3]=dist[v][u]+e.cost;
        pq.emplace(dist[e.to][(u+1)%3],p{e.to,(u+1)%3});
      }
    }
  }
  return dist;
}




void solve()
{
  cin >> n >> m;
  vector < vector<edge<int>>> g(n);
  rep(i,m){
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    g[u].eb(v, 1);
  }
  int s, t;
  cin >> s >> t;
  s--;
  t--;
  auto d = dijkstra(g, s);
  const auto inf = numeric_limits<int>::max();
  if (d[t][0] ==inf){
    cout << -1 << endl;
  }
  else {
    cout << d[t][0]/3 << endl;
  }
}

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


Measured memory_bytes: 11264
#include<stdio.h>

int main()
{
   char c[5];
   int i,n=0;

   scanf("%s",c);
   for(i=0;i<4;i++){
      if(c[i]=='+')
         n++;
      else if (c[i]=='-')
         n--;
   }
   printf("%d\n",n);
   return 0;
}


Measured memory_bytes: 128
type edge = {a: int; b: int; i: int}

let degrees edges =
  let n = (List.length edges) + 1 in
  let rec helper edges acc =
    match edges with
    | [] -> acc
    | {a=a; b=b} :: rst ->
      acc.(a) <- acc.(a) + 1;
      acc.(b) <- acc.(b) + 1;
      helper rst acc in
  helper edges (Array.make n 0)
;;

let solve n edges =
  let k =
    let rec find_max l i m =
      if i == Array.length l then m
      else if l.(i) > m then find_max l (i+1) l.(i)
      else find_max l (i+1) m in
    find_max (degrees edges) 0 0 in
  let p = Array.make n 0 in
  let cs = Array.make (n-1) 0 in
  let rec choose_color es prev cnt =
    match es with
    | [] -> cs
    | e :: rst ->
      let cnt = if e.a == prev then cnt else 0 in
      let color = if e.a == 0 then cnt
        else if cnt < p.(e.a) then cnt else cnt + 1 in
      p.(e.b) <- color; cs.(e.i) <- color;
      choose_color rst e.a (cnt+1) in
  (k, choose_color edges 0 0)
;;

let read () =
  let n = read_int () in
  let rec read_edges i acc =
    if i == n-1 then acc else
      let input = Str.split (Str.regexp " ") (read_line ()) in
      let a::b::[] = List.map int_of_string input in
      let edge = {a=a-1; b=b-1; i=i} in
      read_edges (i+1) (edge :: acc) in
  let edges = List.sort (fun e1 e2 -> e1.a - e2.a) (read_edges 0 []) in
  (n, edges) in
let print k colors =
  print_endline (string_of_int k);
  for i = 0 to ((Array.length colors) - 1) do
    print_endline (string_of_int (colors.(i) + 1))
  done in
let n, edges = read() in
let k, colors = solve n edges in
print k colors


Measured memory_bytes: 19200
def main():

    n, m, l = map(int, input().split())
    matrix_a = [list(map(int, input().split())) for i in range(n)]
    matrix_b = [list(map(int, input().split())) for j in range(m)]
    matrix_c = [[0 for i in range(l)] for j in range(n)]
    for i in range(n):
        for j in range(l):
            matrix_c[i][j] = sum(matrix_a[i][k] * matrix_b[k][j] for k in range(m))

    for row in matrix_c:
        print(' '.join(map(str, row)))

main()

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

int main(){
    int N,max=1,maxNum=0;
    cin>>N;
    vector <int> a(N);
    for (int i=0;i<N;i++){
        cin>>a.at(i);
        if (a.at(i)>max){
            max= a.at(i);
            maxNum=i;
        }
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    for (int i=0;i<N;i++){
        if(i==maxNum){
            cout<<a.at(1)<<endl;;
        }else{
            cout<<max<<endl;
        }
    }
}



Measured memory_bytes: 2432
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 666666;
ll res,n,k;char s[N];
int main() {
	scanf("%s",s+1);n=strlen(s+1);
	int cnt=1;while(s[cnt+1]==s[1])cnt++;
	read(k);
	bool flag=1;rep(i,2,n)flag&=s[i]==s[1];
	if(flag){cout<<n*k/2;return 0;}
	rep(i,2,n)if(s[i]==s[i-1]){
		s[i]='?';res+=k;
	}
	if(s[1]==s[n]){
		
		if(cnt&1)res+=k-1;
	}
	cout<<res;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
using namespace std;

typedef long long ll;

int main()
{
    ll N,K,Q;
    cin >> N >> K >> Q;
    vector<int> A(Q);
    for(int i=0; i<Q; i++){
        cin >> A[i];
        A[i]--;
    }
    vector<ll> ans(N, K-Q);
    for(int i=0; i<Q; i++){
        ans[A[i]]+=1;
    }
    
    for(int i=0; i<N; i++){
        if(ans[i]>0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    

    return 0;
}

Measured memory_bytes: 1792
N, K = map(int, input().split())
listh = list(map(int, input().split()))
list.sort(listh, reverse=True)
#print(listh)
if N <= K:
    print(0)
    exit
else:
    del listh[:K]
    #print(listh)
    ans = sum(listh)
    print(ans)


Measured memory_bytes: 26024
<?php
$n=(int)trim(fgets(STDIN));
$min=(int)trim(fgets(STDIN));
$MAX=-$min;
for($i=1;$i<$n;$i++){
  $R=(int)trim(fgets(STDIN));
  if($MAX<$s=$R-$min) $MAX=$s;
  if($min>$R) $min=$R;
}
print $MAX;
?>

Measured memory_bytes: 15328
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	long long int n, a[5];
	cin >> n >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
	long long int mi = a[0];
	for(int i = 1;i < 5;i++){
		mi = min(mi, a[i]);
	}
	cout << 4 + ((n - 1) / mi) + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(a,n) for (int a = 0; a < (n); ++a)
using namespace std;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
typedef vector<vector<ll> > Graph;
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 ll INF = 1e18;

//UnionFind
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int n) : par(n, -1) { }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }

    bool merge(int x, int y) {//xの木とyの木を結合する
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    ll size(int x) {//sizeの取得
        return -par[root(x)];
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
    ll n,m;
    cin >> n >> m;
    UnionFind u(n);
    rep(i,m){
        ll a,b;
        cin >> a >> b;
        a--;b--;
        u.merge(a,b);
    }
    ll ans = 0;
    rep(i,n){
        chmax(ans,u.size(i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4048
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<VL> VVL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T>  // chmax(max, a);
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> //chmin(min,a)
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}

ll Max=-1000000000,Min=1e9+1;
       
int main(){
    int b,x=0,y=0,z=0,n,m,h,k,w,sum2=0,ans=0;
    string s,t;
    bool f=true;
    cin >> n;
    map<string,int> a;
    rep(i,n){
        cin >> s;
        if(a.empty()==1){
            a.insert(make_pair(s,1));
            continue;
        }
        if(a.find(s) != a.end()){
            a.find(s)->second++;
        }
        else{
            a.insert(make_pair(s,1));
        }
    }
    cin >> m;
    rep(i,m){
        cin >> s;
        if(a.find(s) != a.end()){
            a.find(s)->second--;
        }
        else{
            a.insert(make_pair(s,-1));
        }
    }

    for( auto i = a.begin(); i != a.end() ; ++i ) {      //for文で回す。
        if(i->second > ans)
            ans = i->second;
    }

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



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top,S[1000];

void push(int x)
{
	S[++top] = x;
}

int pop()
{
	top--;
	return S[top+1];
}

int main()
{
	int a,b;
	char s[100];
	
	top = 0;
	
	while( scanf("%s",s) != EOF )
	{
		if( s[0] == '+' )
		{
			a = pop();
			b = pop();
			push(a + b);
		}
		else if( s[0] == '-' )
		{
			b = pop();
			a = pop();
			push(a - b);
		}
		else if( s[0] == '*' )
		{
			a = pop();
			b = pop();
			push(a * b);
		}
		else
		{
			push(atoi(s));
		}
	}
	
	printf("%d\n",pop());
	
	return 0;
}

Measured memory_bytes: 548
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#include<list>
#include<limits>
#include<bitset>
#include<ctype.h>
#include<set>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007LL;
const ll INF=1000000000;
const int MAX=100001;
const double EPS=1e-10;
int main(){
    string s,t,l;
    cin>>s;
    cin>>t;
    cin>>l;
    cout<<s[0]<<t[1]<<l[2]<<endl;
    return 0;
}

                           


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;

const int maxn = 100100;

int n;
ll A,B,tot,ma,cnt;
ll hel[maxn],hc[maxn];
ll read(){ ll s=0,f=1; char ch=getchar(); while(ch<'0' || ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0' && ch<='9'){ s=s*10+ch-'0'; ch=getchar(); } return s*f; }

bool check(ll T){
	cnt=0;
	for(int i = 1; i <= n ; i++){
		hc[i]=hel[i]-1ll*T*B;
		if(hc[i]>0){
			if(hc[i]%(A-B)==0){
				cnt+=hc[i]/(A-B);
			}else{
				cnt+=(hc[i]/(A-B))+1;
			}
		}
	}
	return cnt<=T?true:false;
}

ll Binary_Search(){
	ll L=1,R=ma/B+1,ans;
	
	while(L<=R){
//		printf("%lld %lld\n",L,R);
		ll mid=(L+R)>>1;
		if(check(mid)) ans=mid,R=mid-1;
		else L=mid+1;
	}
	return ans;
}

int main(){
	tot=0; cnt=0; ma=0;
	n=read(),A=read(),B=read();
	
	for(int i=1;i<=n;i++){
		hel[i]=read();
		ma=max(ma,hel[i]);
	}
	
	printf("%lld",Binary_Search());
	
	return 0;
}

Measured memory_bytes: 5284
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<ll> V;
typedef map<ll, ll> M;

int main()
{

    ll N, W, w[110], v[110];
    vector<V> vec(4);
    V num;
    M m;

    cin >> N >> W;
    REP(i, N)
    {
        cin >> w[i] >> v[i];

        if (m[w[i]] == 0)
        {
            int j = 0;
            while (vec[j].size() != 0)
                j++;

            m[w[i]] = j + 1;

            num.push_back(w[i]);
        }

        vec[m[w[i]] - 1].push_back(v[i]);
        //cout << m[w[i]] - 1 << endl;
    }

    for (int i = 0; i < 4; i++)
        SORT(vec[i]);

    ll ans = 0;

    REP(i, vec[0].size() + 1)
    REP(j, vec[1].size() + 1)
    REP(k, vec[2].size() + 1)
    REP(l, vec[3].size() + 1)
    {
        ll a = 0;

        ll b = 0;

        if (i > 0)
        {
            b += i * num[0];

            REP(m, i)
            a += vec[0][vec[0].size() - m - 1];
        }

        if (j > 0)
        {
            b += j * num[1];

            REP(m, j)
            a += vec[1][vec[1].size() - m - 1];
        }

        if (k > 0)
        {
            b += k * num[2];

            REP(m, k)
            a += vec[2][vec[2].size() - m - 1];
        }

        if (l > 0)
        {
            b += l * num[3];

            REP(m, l)
            a += vec[3][vec[3].size() - m - 1];
        }

        if (b > W)
            continue;

        ans = max(ans, a);
    }

    cout << ans << endl;

    return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
typedef pair<int,int> P;

//-----------------------------------------------------------------------

void decode(string &s,char c)
{
    int l=s.size();
    if(c=='J'){
	if(l>0) s=s[l-1]+s.substr(0,l-1);
    }
    else if(c=='C'){
	if(l>0) s=s.substr(1)+s[0];
    }
    else if(c=='E'){
	if(l%2==0) s=s.substr(l/2)+s.substr(0,l/2);
	else s=s.substr(l/2+1)+s[l/2]+s.substr(0,l/2);
    }
    else if(c=='A'){
	reverse(ALL(s));
    }
    else if(c=='P'){
	REP(i,s.size()){
	    if(isdigit(s[i])) s[i]=(s[i]-'0'+9)%10+'0';
	}
    }
    else{
	REP(i,s.size()){
	    if(isdigit(s[i])) s[i]=(s[i]-'0'+1)%10+'0';
	}
    }
}
    
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin>>n;
    REP(i,n){
	string s,msg;
	cin>>s>>msg;
	for(int i=s.size()-1;i>=0;i--){
	    decode(msg,s[i]);
	}
	cout<<msg<<endl;
    }

}



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

int main(){
  ll MOD = 1000000007;
  int n, k;
  cin >> n >> k;
  vi a(n+1);
  rep(i,n) cin >> a[i+1];
  vector<vector<ll>> dp(n+1, vector<ll>(k+1));
  dp[0][0] = 1;
  for(int i=1; i<=n; i++){
    vector<ll> sum(k+2);
    sum[0] = 0;
    for(int j=1; j<=k+1; j++) sum[j] = (sum[j-1] + dp[i-1][j-1]) % MOD;
    for(int j=0; j<=k; j++) dp[i][j] = (sum[j+1] - sum[max(0, j-a[i])] + MOD) % MOD;
  }
  cout << dp[n][k] << endl;
}


Measured memory_bytes: 83200
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <array>
#include <stack>
#include <queue>
#include <chrono>
#include <numeric>

#pragma warning(disable:4996)
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
typedef long long Int;

using namespace std;

struct point{
	int x;
	int y;
	point(int _x, int _y) :x(_x), y(_y){}
};

char tile[20][20];
stack<point> st;

int main()
{
	cin.tie(0); ios::sync_with_stdio(false); 
	//fstream fs("input.txt");
	////////////ここから開始///////////

	
	int x(-1), y(-1);
	while (true){
		REP(i, 20)REP(j, 20)tile[i][j] = '#';
		cin >> x >> y;
		if (x == 0 && y == 0)
			break;
		//fs >> x >> y;
		REP(i, y){
			REP(j, x){
				cin >> tile[i][j];
				//fs >> tile[i][j];
			}
		}

		REP(i, y){
			REP(j, x){
				if (tile[i][j] == '@')
					st.emplace(i, j);
			}
		}

		int dx[]{0, 1, 0, -1};
		int dy[]{1, 0, -1, 0};
		int ans(1);

		while (!st.empty()){
			point now = st.top();
			st.pop();
			REP(i, 4){
				int x1 = now.x + dx[i];
				int y1 = now.y + dy[i];
				if (x1 > 19 || x1 < 0 || y1 > 19 || y1 < 0)
					continue;

				if (tile[x1][y1] == '.'){
					st.emplace(x1, y1);
					tile[x1][y1] = '#';
					++ans;
				}
			}
		}

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

Measured memory_bytes: 1204
import sys
import decimal # 10進法に変換，正確な計算

def input():
    return sys.stdin.readline().strip()

def main():
    s = input()
    if s[0] == "S":
        print("Cloudy")
        return
    elif s[0] == "C":
        print("Rainy")
        return
    print("Sunny")
    

    
    
main()

Measured memory_bytes: 5076
#include<iostream>
#include<string>
#include<cctype>
#include<cassert>
#include<cmath>
#include<complex>

#define ARITHMETIC_EXPRESSION_SYNTAX_ERROR 0
#define fr first
#define sc second

using namespace std;
typedef long long int elem;
typedef complex<elem> comp;
typedef pair<const char *, comp> parsed;
typedef const char *ccp;

parsed expr(ccp);
parsed term(ccp);
parsed fact(ccp);

bool boverflow=false;

inline bool bOverflow(const comp &c){
	//cout<<c<<endl;
	if( c.real() < -10000 || c.real() > 10000 )
		return true;
	if( c.imag() < -10000 || c.imag() > 10000 )
		return true;
	return false;
}
void print_complex(const comp &c){
	if(c.real())
		cout<<c.real();
	if(c.imag()){
		if(c.real()&&c.imag()>0)
			cout<<"+";
		cout<<c.imag()<<"i";
	}
	if(c.real()==0&&c.imag()==0)
		cout<<"0";
}

parsed expr(ccp p){
	parsed r = term(p);
	while( *(r.fr)=='+'||*(r.fr)=='-' ){
		ccp op=r.fr;
		parsed l = term(op+1);
		if(*op=='+'){
			r.fr=l.fr;r.sc=r.sc+l.sc;
		}else{
			r.fr=l.fr;
			r.sc=r.sc-l.sc;
		}
		if(bOverflow(r.sc))boverflow=true;
	}
	if(bOverflow(r.sc))boverflow=true;
	return r;
}
parsed term(ccp p){
	parsed r=fact(p);
	while(*(r.fr)=='*'){
		ccp op=r.fr;
		parsed l=fact(op+1);
		if(*op=='*'){
			r.fr=l.fr;
			r.sc=r.sc*l.sc;
		}
		if(bOverflow(r.sc))boverflow=true;
	}
	if(bOverflow(r.sc))boverflow=true;
	return r;
}
parsed fact(ccp p){
	if(*p=='('){
		parsed tp=expr(p+1);
		return parsed(tp.fr+1,tp.sc);
	}
	if(*p=='-'){
		parsed tp=fact(p+1);
		tp.sc*=-1;
		return tp;
	}
	if(*p=='i'){
		comp t(0,1);
		parsed ret(p+1,t);
		return ret;
	}
	if(isdigit(*p)){
		elem num=*p-'0';
		parsed ret;
		while(isdigit(*(++p))){
			num*=10;
			num+=*p-'0';
			if(num>10000)boverflow=true;
		}
		comp t(num,0);
		ret.sc = t;

		ret.fr=p;
		return ret;
	}else{
		assert(ARITHMETIC_EXPRESSION_SYNTAX_ERROR);
		return parsed(NULL,0);
	}
}

int main(){
	while(true){
		string s;
		comp ans;
		cin>>s;
		boverflow=false;
		if(cin.eof())
			break;
		ans=expr(s.c_str()).sc;
		if(boverflow){
			cout<<"overflow\n";
		}else{
			print_complex(ans);
			cout<<endl;
		}
	}
	return 0;
}

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

int main ()
{
    int n, m;
    cin >> n >> m;
    int A[n][m], B[m], C[n] = {0};
    for (int i = 0;i < n;i++)
    {
        for (int j = 0;j < m;j++)
        {
            cin >> A[i][j];
        }
    }
    for (int i = 0;i < m;i++)
    {
        cin >> B[i];
    }
    
    for (int i = 0;i < n;i++)
    {
        C[i] = 0;
        for (int j = 0;j < m;j++)
        {
            C[i] += A[i][j] * B[j];
        }
    }
    
    for (int i = 0;i < n;i++)
    {
        cout << C[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3100
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = sum(b)

for i in range(n-1):
    if a[i]+1 == a[i+1]:
        ans += c[a[i]-1]

print(ans)


Measured memory_bytes: 9048
/**
 * @author      : omgursocute
 * @created     : 26/01/2020
 * @task        : B
 */

// ===== TEMPLATE STARTS HERE ===== //

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#define FORa(i, a, b) for(ll i = (a); i <= (b); ++i)
#define FORb(i, a, b, c) for(ll i = (a); i <= (b); i += (c))
#define FORn(i, n) for(ll i = 0; i < (n); ++i)
#define FORra(i, a, b) for(ll i = (a); i >= (b); --i)
#define FORrb(i, a, b, c) for(ll i = (a); i >= (b); i -= (c))
#define FORrn(i, n) for(ll i = ((n)-1); i >= 0; --i)
#define NUMARGC(_1, _2, _3, _4, NAME, ...) NAME
#define FOR(...) NUMARGC(__VA_ARGS__, FORb, FORa, FORn)(__VA_ARGS__)
#define RFOR(...) NUMARGC(__VA_ARGS__, FORrb, FORra, FORrn)(__VA_ARGS__)

#define XFOR(i, x) for(__typeof((x).begin()) i = (x).begin(); i != (x).end(); ++i)
#define RXFOR(i, x) for(__typeof((x).rbegin()) i = (x).rbegin(); i != (x).rend(); ++i)

#define pll pair<ll, ll>
#define pii pair<int, int>
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define range(x, a, b) ((x).begin()+a), ((x).begin()+b)
#define pb push_back

#define sqr(x) 1ll*(x)*(x)
#ifndef ONLINE_JUDGE
#define debug(x) cerr << '[' << #x << ']' << " = " << x << '\n'
#else
#define debug(x) "cute"
#endif

namespace io {
	void Speed() {
		ios::sync_with_stdio(false);
		cin.tie(NULL); cout.tie(NULL);
	}
#ifndef ONLINE_JUGDE
	void In(string s) {freopen(s.c_str(), "r", stdin);}
	void Out(string s) {freopen(s.c_str(), "w", stdout);}
	void setIO(string s) {In(s + ".inp"); Out(s + "out");}
#endif
}

// ======= TEMPLATE ENDS HERE ======= //

int main() {
	io::Speed();
	
	ll h, n;
	cin >> h >> n;
	ll sum = 0;
	while(n--) {
		ll x; cin >> x;
		sum += x;
	}

	cout << ((sum >= h) ? "Yes" : "No");

	return 0;
}



Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		int x = Integer.parseInt(sc.next());
		int y = Integer.parseInt(sc.next());
		sc.close();
		if(a + b <= 2 * c){
			ou.print(a * x + b * y + "\n");
		}else{
			if(x < y) ou.print(Math.min(x * c * 2 + (y - x) * b , Math.max(x , y) * 2 * c) + "\n");
			else ou.print(Math.min(y * c * 2 + (x - y) * a , Math.max(x , y) * 2 * c) + "\n");
		}
		ou.flush();
    }
}

Measured memory_bytes: 38304