akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#define N 100

int main(){
  int b,i,j,B[N],min,v,cnt=0;
  
  scanf("%d",&b);
  if(b<1 || b>100)exit(0);
  
  for(i=0;i<b;i++){
    scanf("%d",&B[i]);
    if(B[i]<0 || B[i]>100)exit(1);
  }
  for(i=0;i<b;i++){
    min=i;
    for(j=i;j<b;j++){
      if(B[j]<B[min]){
	min=j;
      }
    }
    if(min!=i){
        v=B[i];
	B[i]=B[min];
	B[min]=v;
	cnt++;
    }
  }
  for(i=0;i<b;i++){
    printf("%d",B[i]);
    if(i==b-1)printf("\n");
    else printf(" ");
  }
  printf("%d\n",cnt);
  
  return 0;
}



Measured memory_bytes: 2140
import itertools
n = int(input())
xy = []
for i in range(n):
  x,y = map(int, input().split())
  xy.append([x,y])

a={}
for v in itertools.combinations(xy,2):
  z = list(v)
  z.sort()
  x = z[1][0]-z[0][0]
  y = z[1][1]-z[0][1]
  if (x,y) not in a:
    a[(x,y)] = 1
  else:
    a[(x,y)] += 1
if n == 1:
  print (1)
else:
  print (n-max(a.values()))

Measured memory_bytes: 9124
#include <bits/stdc++.h>
#include <cstring> 
using namespace std;
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mpp make_pair
#define int long long int
#define F first
#define mem(a,b) memset(a,b,sizeof(a))
#define F first
#define S second
#define MOD 998244353
#define in_range(x, y, r, c) (x < r && y < c && x >= 0 && y >= 0)
#define MAXN 200008
#define MAXI 10000000000007

 
signed main(){
 
    fast;
    
    #ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    
    int n, m, sum=0, i;
    cin>>n>>m;
    int a[n];
    for(i=0;i<n;i++){
    	cin>>a[i];
    	sum+=a[i];
    }
    sort(a, a+n, greater<int>());
    if(a[m-1]>=ceil((double)sum/(4.0*m)))
    	cout<<"Yes"<<endl;
    else
    	cout<<"No"<<endl;
}	

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
int n,a,b;
cin>>n>>a>>b;

ol(min(n*a,b));
return 0;
}



Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
vector<int> v[100100];
vector<int> visited(100100);
int rec(int node,int cnt){
    if(node==2){
        return cnt;
    }
    if(visited[node]){
        return -1;
    }
    else{
        visited[node] = true;
        return rec(v[node][0],cnt+1);
    }
}
int main(){
    int n;
    cin >> n;
    rep(i,n){
        int x;
        cin >>x;
        v[i+1].push_back(x);
    }
    cout << rec(1,0)<<endl;
    return 0;
}

Measured memory_bytes: 6144
#include<stdio.h>
#include<string.h>
int main()
{
          int a,b,res=0,i;
          char op;
          for(i=0;;i++)
          {
                    scanf("%d %c %d",&a,&op,&b);

          switch(op)
          {
case'+':
          res=a+b;
          printf("%d\n",res);
          break;
case'-':
          res=a-b;
          printf("%d\n",res);
          break;
case'/':
          res=a/b;
          printf("%d\n",res);
          break;
case'*':
          res=a*b;
          printf("%d\n",res);
          break;
case'?':
          return 0;

          }

          res=0;
          }
          return 0;
}



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

using namespace std;
using ll = long long;
#define MOD 1000000007

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  for (auto& a : A) cin >> a;
  ll ans = 0;
  for (int k = 0; k < 63; k++) {
    ll m = 1ll << k, c = 0;
    for (auto a : A)
      if (a >> k & 1) c++;
    ans += m % MOD * c % MOD * (N - c) % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
import java.util.*;

public class Main {
	int MOD = 1000000007;
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			char [][] data = new char[2][n];
			for(int i = 0; i < 2; i++){
				data[i] = sc.next().toCharArray();
			}
			
			long [][][] dp = new long[n][3][3];
			if(data[0][0] == data[1][0]){
				dp[0][0][0] = 1;
				dp[0][1][1] = 1;
				dp[0][2][2] = 1;
			}
			else{
				dp[0][0][1] = 1;
				dp[0][1][0] = 1;
				dp[0][0][2] = 1;
				dp[0][2][0] = 1;
				dp[0][1][2] = 1;
				dp[0][2][1] = 1;
			}
			for(int i = 0; i < n; i++){
				for(int j = 0; j < 3; j++){
					for(int k = 0; k < 3; k++){
						if(dp[i][j][k] == 0) continue;
						if(j == k){
							int next = i + 1;
							if(next >= n) continue;
							if(data[0][next] == data[1][next]){
								for(int ncolor = 0; ncolor < 3; ncolor++){
									if(ncolor == j) continue;
									dp[next][ncolor][ncolor] = (dp[next][ncolor][ncolor] + dp[i][j][k]) % MOD;
								}
							}
							else{
								for(int nj = 0; nj < 3; nj++){
									for(int nk = 0; nk < 3; nk++){
										if(nj == j || nk == k) continue;
										if(nj == nk) continue;
										dp[next][nj][nk] = (dp[next][nj][nk] + dp[i][j][k]) % MOD;
									}
								}
							}
						}
						else{
							int next = i + 2;
							if(next >= n)continue;
							if(data[0][next] == data[1][next]){
								for(int ncolor = 0; ncolor < 3; ncolor++){
									if(ncolor == j || ncolor == k) continue;
									dp[next][ncolor][ncolor] = (dp[next][ncolor][ncolor] + dp[i][j][k]) % MOD;
								}
							}
							else{
								for(int nj = 0; nj < 3; nj++){
									for(int nk = 0; nk < 3; nk++){
										if(nj == j || nk == k) continue;
										if(nj == nk)continue;
										dp[next][nj][nk] = (dp[next][nj][nk] + dp[i][j][k]) % MOD;
									}
								}
							}
						}
					}
				}
			}
			if(data[0][n-1] == data[1][n-1]){
				long ans = 0;
				for(int i = 0; i < 3; i++){
					for(int j = 0; j < 3; j++){
						ans = (ans + dp[n-1][i][j]) % MOD;
					}
				}
				System.out.println(ans);
			}
			else{
				long ans = 0;
				for(int i = 0; i < 3; i++){
					for(int j = 0; j < 3; j++){
						ans = (ans + dp[n-2][i][j]) % MOD;
					}
				}
				System.out.println(ans);
			}
		}
	}



	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

}


Measured memory_bytes: 21972
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cstring>
#define INF 0x7fffffffffffffff/*
#define max std::max
#define min std::min*/
using namespace std;
typedef long long LL;
int n,l=1,r=3;
LL a[200010],pre[200010],ans=1e17;
LL k1,k2,p;
int main(){
	scanf("%d",&n);
	int i;
	for(i=1;i<=n;i++) scanf("%lld",&a[i]);
	pre[0]=0;
	for(i=1;i<=n;i++) pre[i]=pre[i-1]+a[i];
	LL aa=0,ab=0,ac=0,ad=0;
	for(i=2;i<n-1;++i){
		while(l<i&&abs(pre[l]-(pre[i]-pre[l]))>=abs(pre[l+1]-(pre[i]-pre[l+1])))l++;
		while(r<n&&abs(pre[r]-pre[i]-(pre[n]-pre[r]))>=abs(pre[r+1]-pre[i]-(pre[n]-pre[r+1])))r++;
		aa=pre[l];ab=pre[i]-pre[l];ac=pre[r]-pre[i];ad=pre[n]-pre[r];
		ans=min(ans,max(max(aa,ab),max(ac,ad))-min(min(aa,ab),min(ac,ad)));
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 3328
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n # root = -size or parent

    def find(self, x):
        if self.parents[x] < 0:# - = root
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:# - → reverse
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):# for print
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def main():
    N, M, K = map(int, input().split())
    f_uni = UnionFind(N)
    not_cand = [0] * N
    for _ in range(M):
        A, B = map(int, input().split())
        A -= 1
        B -= 1
        not_cand[A] += 1
        not_cand[B] += 1
        f_uni.union(A,B)
    
    for _ in range(K):
        C, D = map(int, input().split())
        C -= 1
        D -= 1
        if f_uni.same(C,D):
            not_cand[C] += 1
            not_cand[D] += 1
    ans = [0] * N
    for i in range(N):
        ans[i] = f_uni.size(i) - not_cand[i] - 1
    
    print(*ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 14136
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
#define MAX_V 100010
const int INF = 1e9;
struct edge { int to, cost; };
typedef pair<int, int> P;

int V, E, r;
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d + V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (int i = 0; i < G[v].size(); i++) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push({d[e.to], e.to});
            }
        }
    }
}

int main() {
    cin >> V >> E >> r;
    for (int i = 0; i < E; i++) {
        int s, t, d; cin >> s >> t >> d;
        G[s].push_back({t, d});
    }

    dijkstra(r);
    for (int i = 0; i < V; i++) {
        if (d[i] == INF) cout << "INF" << endl;
        else cout << d[i] << endl;
    }
}


Measured memory_bytes: 13144
#include<stdio.h>
int main(){
	int m, n, i, sum=0, ans;
	scanf("%d%d", &m, &n);
	for(i=0; i<n; i++){
		scanf("%d", &ans);
		sum += ans;
	}
	ans = sum<=m ? m-sum : -1;
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 1732
n = int(input())
*A, = map(int, input().split())
a, b, c = A.count(3), A.count(2), A.count(1)
DP = [[[0.0 for k in range(a+b+c+1)] for j in range(a+b+1)] for i in range(a+1)]
for i in range(a+1):
    for j in range(a-i+b+1):
        for k in range(a-i+b-j+c+1):
            if i+j+k == 0:
                continue
            DP[i][j][k] = n
            if i > 0:
                DP[i][j][k] += i*DP[i-1][j+1][k]
            if j > 0:
                DP[i][j][k] += j*DP[i][j-1][k+1]
            if k > 0:
                DP[i][j][k] += k*DP[i][j][k-1]
            DP[i][j][k] /= i+j+k
print(DP[a][b][c])


Measured memory_bytes: 501640
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

char change(char a, char b) {
	switch(a) {
	case 'r':
		return (b == 'g' ? 'b' : 'g');
	case 'g':
		return (b == 'r' ? 'b' : 'r');
	case 'b':
		return (b == 'r' ? 'g' : 'r');
	}
}

bool ok(string s) {
	REP(i, s.size()-1) {
		if(s[i] != s[i+1]) {
			return false;
		}
	}
	return true;
}

struct state {
	string s;
	int t;
	state(string s, int t) : s(s), t(t) {};
};

int main() {
	string s;
	while(cin >> s, s != "0") {
		queue<state> Q;
		Q.push(state(s, 0));
		set<string> S;
		S.insert(s);		
		int ans = -1;
		while(!Q.empty()) {
			state st = Q.front();
			Q.pop();
			string cs = st.s;

			if(ok(cs)) {
				ans = st.t;
				break;
			}

			REP(i, cs.size()-1) {
				if(cs[i] != cs[i+1]) {
					string ns = cs;
					char a = cs[i];
					char b = cs[i+1];
					ns[i] = change(a, b);
					ns[i+1] = change(a, b);

					if(S.find(ns) == S.end()) {
						S.insert(ns);
						Q.push(state(ns, st.t+1));
					}
				}
			}
		}

		if(ans != -1) {
			cout << ans << endl;
		} else {
			cout << "NA" << endl;
		}
	}

	return 0;
}

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

int main(void){
    int n, x, t;
    cin >> n >> x >> t;
    int ans;
    if(n%x == 0) ans = (n/x)*t;
    else ans = ((n/x)*t)+t;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define int long long 
signed cnt(int n){
  int m;
  if(n<=0) return 0;
  if(n==1) return 1;
  m=cnt(n-1);
  return n+m;
}

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

  int x,n;
  
  cin>>n;
  
  x=cnt(n);
  cout<<x<<'\n';
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    double W,H,w,h;
    cin>>W>>H>>w>>h;
    cout<<W*H/2<<" ";
    if(w*2==W&&h*2==H){
        cout<<"1"<<endl;
    }
    else{
        cout<<"0"<<endl;
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

int main(){
    string S;
    cin >> S;
    int N = S.length();
    char xxx = S[0];
    char xx = S[1];
    char x;
    int ansl = -1;
    int ansr = -1;

    if(xxx == xx){
        cout << 1 << " " << 2 << endl;
        return 0;
    }

    for(int i = 2; i < N; i++){
        x = S[i];
        if(x == xx || x == xxx){
            ansr = i;
            ansl = i-2;
            break;
        }
        xxx = xx;
        xx = x;
    }

    if(ansl == ansr && ansl == -1){
        cout << -1 << " " << -1 << endl;
    }
    else{
        cout << ansl+1 << " " << ansr+1 << endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define loop(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define len(a) (int)a.size()
#define allv(a) (a).begin(),(a).end()
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double err = 1e-9;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;



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

	int h,w,n;
	cin>>h>>w>>n;
	
	int x, y;
	cin>>y>>x;
	
	string s, t;
	cin>>s>>t;
	
	bool val = 0;

	map<char, int> mp;
	mp['L'] = 0;
	mp['R'] = 1;
	mp['U'] = 2;
	mp['D'] = 3;

	int da[4] = {w - x, x - 1, h - y, y - 1};

	loop(i,0,n)
	{
		da[mp[s[i]]]++;

		if(da[0] >= w)
			val = 1;
		if(da[1] >= w)
			val = 1;
		if(da[2] >= h)
			val = 1;
		if(da[3] >= h)
			val = 1;

		int v = mp[t[i]];
		if(v & 1)
			v--;
		else v++;
		
//		loop(j,0,4)
//			cout<<da[j]<<' ';
//		cout<<endl;
		
		da[v] = max(da[v] - 1, 0);

//		if(val)
//			cout<<"VALID ON "<<i<<endl;
	}		
	cout<<(val ? "NO" : "YES")<<endl;

	return 0;
}


Measured memory_bytes: 920
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;

    

    void calc()
    {
        if (check()) Console.WriteLine("YES");
        else Console.WriteLine("NO");
    }
    
    bool check()
    {

        cin = new Scanner();
        int N = cin.nextInt();
        int[] A = cin.ArrayInt(N);
        int M = cin.nextInt();
        int[] B = cin.ArrayInt(M);

        Array.Sort(A);
        Array.Sort(B);

        int a = 0;
        int b = 0;
        while (a < N && b < M)
        {
            if (A[a] == B[b])
            {
                a++; b++;
            }
            else a++;
        }

        if (b >= M) return true;
        else return false;
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int N; cin >> N;
    string S, T; cin >> S >> T;
    string ans = "";
    rep(i, 2*N){
        if(i % 2 == 0) ans += S[i/2];
        else ans += T[i/2];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let n = get!(i32);
    println!("{}", n*800 - n/15*200);
}

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

using namespace std;

void bSort(int N, int a[]) {

    int n;
    int b[N];

    for(int i=0; i<N; i++) {
    }
}

int main() {

    int N, bp=0, ap=0;
    cin >> N;

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

    sort(a, a+N);
    reverse(a, a+N);

    for(int i = 0; i < N; i++) {
        if(i%2 == 0) {
            ap += a[i];
        }else{
            bp += a[i];
        }
    }

    cout << ap-bp << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include<set>
#include<vector>
#define MAX 5000
using namespace std;
typedef long long ll;
typedef pair<ll, ll> point;
int main(void) {
    ll i, j, h, w, d, q, num, l, r, dis[100000];
    point posi[90001];
    cin >> h >> w >> d;
    for(i=1; i<=h; i++) {
        for(j=1; j<=w; j++) {
            cin >> num;
            posi[num] = make_pair(i, j);
        }
    }
    cin >> q;
    for(i=1; i<=h*w-d; i++)
        dis[i] = 0;
    for(i=1; i<=h*w-d; i++)
        dis[i+d] = dis[i] + abs(posi[i+d].first-posi[i].first) + abs(posi[i+d].second-posi[i].second);
        
    
    for(i=0; i<q; i++) {
        cin >> l >> r;
        cout << dis[r]-dis[l] << endl;
    }
}


Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>//小数精度 	cout << fixed << setprecision(5) << tmp << endl;
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define All(X)      (X).begin(),(X).end()

int n,m;
int data[25][50010];

vector<int> money;

int main(){
	int n,m;
	cin >> n >> m;
	REP(i,m){
		int tmp;
		cin >> tmp;
		money.push_back(tmp);
	}
	sort(All(money));
	REP(i,m){
		data[i][0] = 0;
	}
	//data[0][1] = 1;

	FOR(j,1,n+1){
		REP(i,m){
			ll int tmp1,tmp2;
			tmp1 = 10000000;
			tmp2 = 10000000;
			if(i!=0){
				tmp1 = data[i-1][j];
			}
			if(j-money[i]>=0){
				tmp2 = data[i][j-money[i]] + 1;
			}
			data[i][j] = min(tmp1,tmp2);
		}
	}
	cout << data[m-1][n] <<endl;

	return 0;

}

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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a+b==c+d)cout << "Balanced" << endl;
    else if(a+b>c+d) cout << "Left" << endl;
    else cout << "Right" << endl;
    return 0;
}

Measured memory_bytes: 256
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
count=0
for _ in range(n):
  result=c
  a=list(map(int,input().split()))
  for i,j in zip(a,b):
    result+=i*j
  if result>0: count+=1
print(count)

Measured memory_bytes: 9212
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#include <cstring>
#include <iomanip>

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9 + 7;
const int N = 300+5, inf = 1e9+5;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

double dp[N][N][N];
int n;

double f(int one, int two, int thr) {
    if (one == 0 && two == 0 && thr == 0) return 0;
    if (one < 0 || two < 0 || thr < 0) return 0;
    if (dp[one][two][thr] != -1) return dp[one][two][thr];

    double x = 0;
    double all = one+two+thr;
    x += n/all;
    x += one/all * f(one-1, two, thr);
    x += two/all * f(one+1, two-1, thr);
    x += thr/all * f(one, two+1, thr-1);
    return dp[one][two][thr] = x;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    int cnt[4] = {};
    rep (i, 0, n) {
        int x; cin >> x;
        cnt[x]++;
    }
    std::fill(&dp[0][0][0], &dp[0][0][0] + sizeof(dp) / sizeof(dp[0][0][0]), -1);
    cout <<  setprecision(15) << fixed << f(cnt[1], cnt[2], cnt[3]) << endl;

    return 0;
}

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

int main() {
  int N, sum = 0;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  for(int i = 0; i < N; i++) {
    for(int j = i + 1; j < N; j++) {
      for(int k = j + 1; k < N; k++) {
        if(vec.at(i)==vec.at(j)||vec.at(j)==vec.at(k)||vec.at(k)==vec.at(i))
          continue;
        if(vec.at(i) < vec.at(j) + vec.at(k) && vec.at(i) > abs(vec.at(j) - vec.at(k)))
          sum++;
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define lop(i,n,a) for(int i=0;i<n;i+=a)
#define rep(i,n,a) for(int i=a;i<n;i++)
#define inarr(arr,n) lop(i,n,1)cin>>arr[i]
#define ll long long int
#define pb push_back
#define all(v) v.begin(),v.end()
#define endl "\n"
#define eb emplace_back
#define fr first
#define sc second
#define pii pair<int,int>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ret return 0
#define pi 3.1415926536
#define hell 1000000007
using namespace std;
// syntax for min priority_queue of pairs
// priority_queue<pair<ll,ll>,vector<pair<ll,int>>,greater<pair<ll,int>>> q;
int solve(){
  int n;cin>>n;
  map<int,int> mp;
  int arr[n];
  lop(i,n,1){
      int t;cin>>t;
      mp[t]++;
      arr[i]=t;
  }
  if(mp[1]==0){
      cout<<-1<<endl;
  }
  else{
      int sum=0;
      int j=1;
      for(int i=0;i<n;i++){
         if(arr[i]==j)sum++,j++;
         
      }
      cout<<n-sum<<endl;
  }
  ret;
}
int main(){
    IOS;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    ret;
}
 


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

using namespace std;

const int N = 200 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int L;
int p[N];
vector< pair<int, int> > g[N];

bool read() {
    if (!(cin >> L))
        return false;

    return true;
}

void solve() {
    auto n = 0;

    for (int i = 1; L > 1; ++i) {
        if (L & 1)
            p[i] = 1;

        L /= 2;
        n = max(n, i + 1);

        if (L != 0)
            g[i] = { { i + 1, 0 }, { i + 1, (1 << (i - 1)) } };
    }

    auto t = (1 << (n - 1));
    auto m = 0;

    for (int i = 1; i < n; ++i) {
        if (p[i]) {
            g[i].emplace_back(n, t);
            t += (1 << (i - 1));
        }

        m += g[i].size();
    }

    cout << n << ' ' << m << endl;

    for (int i = 1; i <= n; ++i)
        for (const auto v : g[i])
            cout << i << ' ' << v.first << ' ' << v.second << endl;
}

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

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 4992
"""
https://atcoder.jp/contests/dp/tasks/dp_f
"""
from collections import defaultdict
s = input()
t = input()
ls = len(s)
lt = len(t)
dp = [[0] * (lt + 1) for _ in range(ls + 1)]
for i in range(ls):
    for j in range(lt):
        if s[i] == t[j]:
            dp[i + 1][j + 1] = 1 + dp[i][j]
        else:
            dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1])

# print(dp[ls][lt])
N = dp[ls][lt]
y = ls
x = lt
ans = ''
while N:
    if dp[y][x] == dp[y - 1][x]:
        y -= 1
        continue
    if dp[y][x] == dp[y][x - 1]:
        x -= 1
        continue
    else:
        ans = s[y - 1] + ans
        N -= 1
        x -= 1
        y -= 1

print(ans)


Measured memory_bytes: 112220
N,M=map(int,input().split())
s,t=map(int,input().split())
for i in range(M-1):
  a,b=map(int,input().split())
  s=max(s,a)
  t=min(t,b)
if t>=s:
  print(t-s+1)
else:
  print(0)

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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;




int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;

	string s;
	cin>>s;
	ll ans =0,prev=-1;
	for(int i=0;i<s.length();i++)
		if(s[i]!='A' && s[i]!='C' && s[i]!='G' && s[i]!='T'){
			ans=max(ans,i-prev-1);
			prev=i;
		}
	ll n = s.length();
	cout<<max(ans,n-prev-1)<<"\n";

		

}


Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
//#define MOD 1000000007
#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
    int N; cin >> N;
    string S; cin >> S;
    int m = S.size();
    rep(i,m){
        char c = S[i];
        int d = 'Z'-c;
        if(d >= N) S[i] += N;
        else{
            int k = N-d;
            S[i] = 'A'+k-1;
        }
    }
    cout << S << endl;
}



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

using namespace std;

int main() {
  vector<vector<int>> a(3, vector<int>(3, 0));
  for (auto &seq : a) {
    for (auto &v : seq)
      cin >> v;
  }

  int n;
  cin >> n;
  vector<bool> b(101, false);
  for (int i = 0; i < n; ++i) {
    int tmp;
    cin >> tmp;
    b[tmp] = true;
  }

  bool det1 = b[a[0][0]] == true && b[a[0][1]] == true && b[a[0][2]];
  bool det2 = b[a[1][0]] == true && b[a[1][1]] == true && b[a[1][2]];
  bool det3 = b[a[2][0]] == true && b[a[2][1]] == true && b[a[2][2]];
  bool det4 = b[a[0][0]] == true && b[a[1][0]] == true && b[a[2][0]];
  bool det5 = b[a[0][1]] == true && b[a[1][1]] == true && b[a[2][1]];
  bool det6 = b[a[0][2]] == true && b[a[1][2]] == true && b[a[2][2]];
  bool det7 = b[a[0][0]] == true && b[a[1][1]] == true && b[a[2][2]];
  bool det8 = b[a[0][2]] == true && b[a[1][1]] == true && b[a[2][0]];
  string ans = (det1 || det2 || det3 || det4 || det5 || det6 || det7 || det8) ? "Yes" : "No";
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a==b && a!=c) {
        	System.out.println("Yes");
        }
        else if(a==c && a!=b) {
        	System.out.println("Yes");
        }
        else if(b==c && b!=a) {
        	System.out.println("Yes");
        }
        else {
        	System.out.println("No");
        }
	}
}

Measured memory_bytes: 23252
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 10010010010010;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

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

    int N;cin >> N;
    vector<int> retu(N+2,0);
    for(int i = 1;i<=N;i++) cin >> retu.at(i);
    int sum = 0;
    for(int i = 0;i<N+1;i++) {
        sum += abs(retu.at(i+1)-retu.at(i));
    }

    for(int i = 1;i < N+1;i++){
        cout << sum-abs(retu.at(i)-retu.at(i-1))-abs(retu.at(i+1)-retu.at(i))+abs(retu.at(i+1)-retu.at(i-1)) << endl;
    }
    
}


Measured memory_bytes: 3736
Module Module1

    Sub Main()
        'let'
        Dim N As Long = Console.ReadLine()
        Dim a() As Long = Array.ConvertAll(Of String, Long)(Console.ReadLine.Split(), AddressOf Long.Parse)

        Array.Sort(a)

        'var'
        Dim ans As Long = 0

        For i As Long = 0 To N - 1
            ans += New Long() {-1, 1}(i Mod 2) * a(i)
        Next

        Console.WriteLine(Math.Abs(ans))

    End Sub

End Module

Measured memory_bytes: 11220
//============================
// ABC137a -+-X
//
// 2019/08/12
//============================

#include <iostream>
#include <math.h>

using namespace std;

int main(int argc, char* argv[])
{
  int A, B;
  cin >> A >> B ;

  cout << max(max(A+B, A-B), A*B) << endl;

  return 0;  
}


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

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
#define INF (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};

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

    ll c = 1, m = 0;
    int k, a, b;
    cin >> k >> a >> b;

    rep(i, k){
        if(c >= a && (b - a) > 1 && k - i >= 2){
            i += 1;
            c += b - a;
        }else{
            c ++;
        }
    }

    cout << c << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;
typedef long long ll;

int main(){

 ll a,b,k;
 cin>>a>>b>>k;

 ll n = (b-a+1);

 if(n<= k){
    for(int i=a;i<=b;i++)
        cout<<i<<endl;
    return 0;
 }

 set<int>ans;

 for(ll i=a;i<a+k;i++) ans.insert(i);

 for(ll i=b-k+1;i<=b;i++) ans.insert(i);

 for(auto it = ans.begin();it!= ans.end();it++)
    cout<<*it<<endl;

 return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


lint ceilll(lint a, lint b) {
  return (a + b - 1) / b;
}

int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n; cin >> n;
  lint a = 1e5;
  for (int _ = 0; _ < n; ++_) {
    a = ceilll(21 * a, 20 * 1000) * 1000;
  }
  cout << a << '\n';
}


Measured memory_bytes: 3120
#!/usr/bin/env python3
n = int(input())
a = list(map(int, input().split()))

ans = 1
f = 0

for i in range(n):
    if f == 0:
        f = 1
    elif f == 1:
        if a[i] > a[i - 1]:
            f = 2
        elif a[i] < a[i - 1]:
            f = 3
    elif f == 2:
        if a[i] < a[i - 1]:
            ans += 1
            f = 1
    elif f == 3:
        if a[i] > a[i - 1]:
            ans += 1
            f = 1
print(ans)


Measured memory_bytes: 19948
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
	    Scanner sc = new Scanner(System.in);
	    int n = sc.nextInt();
	    sc.close();
	    
      if(n>=30){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }


	}
}

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

#define ll long long

using namespace std;

int main()
{
    ll n,dist;
    dist = 1e18;
    cin >> n;
    ll j = 1;
    while(j * j <= n)
    {
        if(n % j == 0)
        {
            ll f = n / j;
            ll s = j;
            dist = min(dist, f - 1 + s - 1);
        }
        j++;
    }
    cout << dist;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**5)

H, N = map(int, input().split())
AB = [[int(i) for i in input().split()] for _ in range(N)]
AB.sort(key=lambda x: x[0]/x[1], reverse=True)

INF = 10 ** 18
dp = [INF] * (H + 1)
dp[0] = 0
for A, B in AB :
  for i in range(H + 1) :
    if dp[i] != INF :
      ni = min(H, i + A)
      dp[ni] = min(dp[ni], dp[i] + B)
      
print(dp[-1])

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

using namespace std;

using ll = long long;

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

    int n;
    cin >> n;

    vector<ll> a(n), b(n);
    for (auto &x : a) cin >> x;
    for (auto &x : b) cin >> x;

    ll ans = 0;
    vector<ll> bb(n);
    for (ll i = 0, t = 1; i < 31; ++i) {
        for (int j = 0; j < n; ++j)
            bb[j] = b[j] % (2 * t);

        sort(bb.begin(), bb.end());

        ll cnt = 0;
        for (int j = 0; j < n; ++j) {
            const int aa = a[j] % (2 * t);

            // a_j + b_k \in [T, 2T)
            cnt += distance(lower_bound(bb.begin(), bb.end(), t - aa),
                            lower_bound(bb.begin(), bb.end(), 2 * t - aa));

            // a_j + b_k \in [3T, 4T)
            cnt += distance(lower_bound(bb.begin(), bb.end(), 3 * t - aa),
                            lower_bound(bb.begin(), bb.end(), 4 * t - aa));
        }

        // Update
        ans += (cnt % 2) * t;
        t *= 2;
    }

    cout << ans << endl;

    return 0;
}


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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

int main(){
    init();
    int a,b; cin >> a >> b;
    for(int i = 1;i<=3;i++){
        if((a*b*i) % 2 != 0){
            cout <<"Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    long long int sum=0;
    int N;
    cin >> N;
    for(int i=1;i<=N;i++){
        if((i%5 != 0) && (i%3 !=0)){sum +=i;}

    
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
pair<long long,long long> a[100000];
long long n,m,c,r;
int main()
{
	cin>>n>>m;
	for (int i=0;i<n;i++)
	  scanf("%I64d%I64d",&a[i].first,&a[i].second);
	sort(a,a+n);
	int i=0;
	while(c+a[i].second<m)
	{
		r+=a[i].first*a[i].second;
		c+=a[i++].second;
	}
	cout<<r+(m-c)*a[i].first<<endl;
	return 0;
}


Measured memory_bytes: 1792
n = int(input())
dormitory = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]

i=0
for i in range(n):
    b,f,r,v = map(int, input().split())
    dormitory[b-1][f-1][r-1] += v

for b in range(4):
    for f in range(3):
        for r in range(10):
            print("",dormitory[b][f][r],end='')
        print('')
    if b != 3:
        print("#"*20)


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

int main() {
  long long a, b;
  cin>>a>>b;
  if (a > 0) {
    cout<<"Positive"<<endl;
    return 0;
  }
  if (a * b <= 0) {
    cout<<"Zero"<<endl;
    return 0;
  }
  if ((b - a + 1) % 2 == 0) {
    cout<<"Positive"<<endl;
  } else {
    cout<<"Negative"<<endl;
  }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(A: "List[List[int]]", N: int, b: "List[int]"):
    result_flag = False
    for i in range(3):
        if A[i][0] in b and A[i][1] in b and A[i][2] in b:
            result_flag = True
        if A[0][i] in b and A[1][i] in b and A[2][i] in b:
            result_flag = True
    if A[0][0] in b and A[1][1] in b and A[2][2] in b:
        result_flag = True
    if A[0][2] in b and A[1][1] in b and A[2][0] in b:
        result_flag = True

    if result_flag:
        print("Yes")
    else:
        print("No")
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    A = [
        [int(next(tokens)) for _ in range(3)] for _ in range(3)
    ]  # type: "List[List[int]]"
    N = int(next(tokens))  # type: int
    b = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(A, N, b)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
   int N;
   cin >> N;
   string S;
   cin >> S;
   int x=0;
   int ma =0;

   for(int i=0;i<N;i++){
      if(S[i]=='I'){
         x++;
      }
      else{
         x--;
     }
      ma=max({ma,x});
   }
   cout << ma <<endl;
   return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
const long long mod = 1000000007;
 
 
int main() {
	int N;
	scanf("%d", &N);
	char*S = new char[N + 1];
	scanf("%s", S);
	int cnt = 0;
	for (char s1 = '0'; s1 <= '9'; s1++) {
		int p1 = 0;
		for (; p1 < N; p1++) {
			if (S[p1] == s1)break;
		}
		p1++;
		if (p1 == N)continue;
		for (char s2 = '0'; s2 <= '9'; s2++) {
			int p2 = p1;
			for (; p2 < N; p2++) {
				if (S[p2] == s2)break;
			}
			p2++;
			if (p2 == N)continue;
			for (char s3 = '0'; s3 <= '9'; s3++) {
				int p3 = p2;
				for (; p3 < N; p3++) {
					if (S[p3] == s3) {
						cnt++;
						break;
					}
				}
				p3++;
				if (p3 == N)continue;
 
			}
		}
	}
	printf("%d", cnt);
	return 0;
}

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

const long double PI = acos(-1);
 
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 IsPrime(ll num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0){
            // 素数ではない
            return false;
        }
    }
    // 素数である
    return true;
}

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

    double sum = 0;
    for (int i = 0; i < n; i++){
        for (int j = i; j < n; j++){
            sum += sqrt(pow(x[i]-x[j], 2) + pow(y[i]-y[j], 2));
        }
    }
    sum = sum*2 / (double)n;
    cout << setprecision(16) << sum << endl;
    return 0;
}

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


int main() {
    int H, W;
    scanf("%d %d", &H, &W);
    char map[H][W];
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            scanf("\n%c", &map[i][j]);
        }
    }

    int mx[4] = {1, 0, -1, 0};
    int my[4] = {0, 1, 0, -1};
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            if(map[i][j] == '#') {
                bool feasible = false;
                for(int k = 0; k < 4; k++) {
                    int py = i + my[k];
                    int px = j + mx[k]; 
                    if(map[py][px] == '#') {
                        feasible = true;
                        break;
                    }
                }
                if(!feasible) {
                    printf("No\n");
                    return 0;
                }
            }
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N];
		for(int i = 0;i < N;++i)
			a[i] = sc.nextInt();
		sc.close();
		
		boolean flag = true;
		int alice = 0, bob = 0;
		Arrays.sort(a);
		for(int i = N-1;i >= 0;--i) {
			if(flag)
				alice += a[i];
			else
				bob += a[i];
			flag = !flag;
		}
		System.out.println(alice-bob);
	}
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define int long long
#define ll long long
#define pp pair<int,int>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
int max(int x, int y)
{
    return x>y ? x : y;
}
int min(int x, int y)
{
    return x<y ? x : y;
}
void _(int&a , int b)
{
    a=(a%mod+b%mod)%mod;
    a=(a+mod)%mod;
}
ll cl(ll a,ll b)
{
    return (a/b)+(!(!(a%b)));
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s,t;cin >> s >> t;
    if(s==t.substr(0,t.size()-1))cout << "Yes";else cout << "No";
    }

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

int main(void)
{
   long long a, b, c, d;
   cin >> a >> b >> c >> d;
   long long result = max(b * d, max(b * c, max(a * c, a * d)));
   cout << result << endl;
   return 0;
}


Measured memory_bytes: 3632