akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define all(box) box.begin(), box.end()

using namespace std;

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

const long long INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[b]+=siz[a];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

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

const int MOD=998244353;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
signed main(){
	int n;
	cin>>n;
	int a[100010];
	rep(i,n)cin>>a[i];
	sort(a,a+n);
	int b[100010];
	b[0]=a[0];
	rep(i,1,n)b[i]=b[i-1]+a[i];
	int cnt=1;
	for(int i=n-2;i>=0;i--){
		if(b[i]*2>=a[i+1])cnt++;
		else break;
	}
	cout<<cnt<<endl;
}

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

int main() {
  string s;
  cin>>s;
  int kazu=s.size();
  for(int i=s.size()/2-1;i>=0;i--){
    kazu=i*2;  
    string a=s.substr(0,i);
    string b=s.substr(i,i);
    //cout<<a<<" "<<b<<endl;
    if(a==b){
      cout<<kazu<<endl;
      return 0;
    }
    s.erase(s.size()-2,2);
  }
  cout<<0<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int[] array1 = new int[n];
        final int[] array2 = new int[n];

        for (int i = 0; i < n; i++) {
            array1[i] = scanner.nextInt();
        }

        int sum1 = 0;
        for (int i = 0; i < n; i++) {
            final int tmp = scanner.nextInt();
            array2[i] = tmp;
            sum1 += tmp;
        }

        int answer = 0;
        int sum2 = 0;
        for (int i = 0; i < n; i++) {
            sum2 += array1[i];
            answer = Math.max(answer, sum1 + sum2);
            sum1 -= array2[i];
        }

        System.out.println(answer);
    }
}


Measured memory_bytes: 23764
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

typedef long long ll;

int main(void) {
  ll a, b, n;
  cin >> a >> b >> n;
  ll x = min(b-1, n);
  cout << a*x/b - a * (x/b) << endl;
  return 0;
}


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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i) 
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

constexpr static int MOD = 1000000000 + 7;
constexpr static int inf = INT_MAX / 2;
constexpr static llong INF = 1LL<<31;
constexpr static int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
    cin.tie(0); 
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    llong l;
    cin >> l;
    vector<llong> A(n);
    rep(i, n) cin >> A[i];

    int possible_knot;
    bool flag = false;
    rep(i, n - 1) {
        if (A[i] + A[i + 1] >= l) {
            flag = true;
            possible_knot = i + 1;
            break;
        }
    }

    if (! flag) {
        cout << "Impossible" << endl;
    } else {
        cout << "Possible" << endl;
        for (int i = 1; i < possible_knot; ++i) {
            cout << i << endl;
        }
        for (int i = n - 1; i > possible_knot; --i) {
            cout << i << endl;
        }
        cout << possible_knot << endl;
    }

    return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int count=0;
    while(n--)
    {
        int x,y;
        cin>>x>>y;
        if(x==y)
        {
            count++;
            if(count>=3)
            {
                cout<<"Yes";
                break;
            }
        }
        else
        {
            count=0;
        }
        
        
    }
    if(count<=2)
    {
        cout<<"No";
    }
    
    
}

Measured memory_bytes: 3612
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
#include <random>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define REPE(i, n) for (int (i)=0; (i) <= (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }


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

	int ans = 0;
	REPE(i, a) REPE(j, b) REPE(k, c)
	{
		if (i * 500 + j * 100 + k * 50 == x) ans++;
	}
	cout << ans << endl;
}



Measured memory_bytes: 3592
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<queue>
#include<cstring>
using namespace std;
int n;
vector<int>G[100010];
int par[100010];
int deg[100010];
int dp[100010];
char buf[100010];
bool del[100010];
int nd[100010];
int cnt;
int sb;
int ans;
void dfs(int x,int p)
{
	for(int i=0;i<G[x].size();i++)
	{
		int y=G[x][i];
		if(y==p)continue;
		par[y]=x;
		deg[x]++;
		dfs(y,x);
	}
}
void solve(int x,int p)
{
	int mx1=-1e9,mx2=-1e9;
	for(int i=0;i<G[x].size();i++)
	{
		int y=G[x][i];
		if(y==p || del[y])continue;
		solve(y,x);
		if(dp[y]>mx1)mx2=mx1,mx1=dp[y];
		else if(dp[y]>mx2)mx2=dp[y];
	}
	dp[x]=max(dp[x],mx1+nd[x]);
	ans=max(ans,max(mx1+mx2+nd[x],mx1+nd[x]));
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		G[x].push_back(y);
		G[y].push_back(x);
	}
	scanf("%s",buf+1);
	int rt=0;
	for(int i=1;i<=n;i++)
	{
		if(buf[i]=='W')
		{
			rt=i;
			break;
		}
	}
	if(!rt)
	{
		printf("0");
		return 0;
	}
	dfs(rt,0);
	queue<int>q;
	cnt=n-1;
	for(int i=1;i<=n;i++)if(!deg[i])q.push(i);
	while(!q.empty())
	{
		int x=q.front();
		q.pop();
		if(buf[x]=='B')
		{
			del[x]=true;
			cnt--;
			deg[par[x]]--;
			if(!deg[par[x]])q.push(par[x]); 
		}
	}
	cnt*=2;
	for(int i=1;i<=n;i++)
	{
		if(del[i])continue;
		int s=0;
		for(int j=0;j<G[i].size();j++)s+=(!del[G[i][j]]);
		if((buf[i]=='W' && !(s&1)) || (buf[i]=='B' && (s&1)))nd[i]=2,cnt++;
	}
	solve(rt,0);
	printf("%d",cnt-ans);
	return 0;
}

Measured memory_bytes: 14848
N,M = map(int,input().split())
voy = [[] for i in range(N)]
for i in range(M):
    a,b = map(int,input().split())
    voy[a-1].append(b)
alen = len(voy[0])
flag = 0
for j in range(alen):
    qu = voy[0][j]-1
    if N in voy[qu]:
        print("POSSIBLE")
        flag = 1
        break
if flag == 0:
    print("IMPOSSIBLE")

Measured memory_bytes: 29056
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    if(a<10&&b<10){
        cout <<a*b<<endl;
    }
    else{
        cout <<-1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define endl '\n'
#define f first
#define s second
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define debug(...) cout << " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " << endl

using ld = long double;
using ll = long long;
using pii = pair <int,int>;
using pll = pair <ll,ll>;
using vi = vector <int>;
using vll = vector <ll>;
using vpii = vector <pii>;
using vpll = vector<pll>;
using vs = vector <string>;

const ll mod = 1e9 + 7;

int main(){
  fastio;

  ll n;
  cin >> n;

  if(n == 1){
    cout << 0 << endl;
    return 0;
  }
  ll total = 1;

  ll w1 = 1;
  ll w2 =1;
  for(int i=0;i<n;i++){
    w1 *= 9, w1 %= mod;
    w2 *= 8, w2 %= mod;
    total *= 10, total %= mod;
  }

  w1 *= 2;
  w1 %= mod;
  ll ans = (total - (w1 - w2) + mod) % mod;  
  cout << ans << endl;

  return 0;
}

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

using namespace std;

int main(){
 int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  int dx=tx-sx;
  int dy=ty-sy;
  string res="";

  for(int i=0;i<dx;i++) res+='R';
  for(int i=0;i<dy;i++) res+='U';
  
  for(int i=0;i<dx;i++) res+='L';
  for(int i=0;i<dy;i++) res+='D';

  res+='D';
  for(int i=0;i<dx+1;i++) res+='R';
  for(int i=0;i<dy+1;i++) res+='U';
  res+='L';
  
  res+='U';
  for(int i=0;i<dx+1;i++) res+='L';
  for(int i=0;i<dy+1;i++) res+='D';
  res+='R';
  
  cout << res << endl;
}

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

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();
        sc.close();

        int[] nums = new int[] {a, b, c};

        Arrays.sort(nums);


        	System.out.printf("%d %d %d\n",nums[0], nums[1], nums[2]);


	}

}



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

int main() {
    string s;
    cin>>s;
    int n = s.size();
    int ans = 0;

    for(int i=0; i<n/2; i++) {
        if(s[i]!=s[n-1-i]) ans++;
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
def input_int():
    return(int(input()))

def input_int_list():
    return(list(map(int,input().split())))

def input_int_map():
    return(map(int,input().split()))

def run():
    q_num = input_int()

    count_num = 0

    for _ in range(q_num):

        a, b = input_int_map()

        if a == b:
            count_num += 1

            if count_num == 3:
                print('Yes')
                return
        else:
            count_num = 0
    print('No')

run()



Measured memory_bytes: 9184
import java.util.*;


public class Main {
    static void solve() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int h = sc.nextInt();
        ArrayList<Integer> b = new ArrayList<Integer>();
        int maxA = 0;
        for(int i = 0; i < n; i++) {
            int newA = sc.nextInt();
            int newB = sc.nextInt();
            b.add(newB);
            if(newA > maxA){
                maxA = newA;
            }
        }
        for(int i = n-1; i >= 0; i--){
            if(b.get(i) < maxA){
                b.remove(i);
            }
        }
        int sumB = 0;
        for(int i = b.size()-1; i >= 0; i--){
            sumB += b.get(i);
        }
        int count = 0;
        if(h > sumB){
            h -= sumB;
            count += h/maxA;
            h = h%maxA;
            if(h > 0){
                h -= maxA;
                count++;
            }
            h += sumB;
        }
        Collections.sort(b);
        for(int i = b.size()-1; i >= 0; i--){
            if(h <= 0){
                break;
            }
            h -= b.get(i);
            b.remove(i);
            count++;
        }
        System.out.println(count);
    }

    public static void main(String[] args) {
        solve();
    }
}


Measured memory_bytes: 73108
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    int ans = 0;
    for (int i = 1; i <= N; i += 2) {
        int divisor = 0;
        for (int j = 1; j * j <= i; j++) {
            if (i % j != 0) continue;
            if (i == j) divisor++;
            else divisor += 2;
        }
        if (divisor == 8) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.awt.Point;
import java.io.*;
import java.nio.Buffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.StringTokenizer;
import java.util.TreeSet;

import javax.swing.event.TreeSelectionEvent;
import javax.swing.plaf.basic.BasicTreeUI.TreeCancelEditingAction;

import org.omg.PortableInterceptor.INACTIVE;
public class Main {

public static void A(BufferedReader br)throws Exception
{
	String in= br.readLine();
	StringTokenizer st= new StringTokenizer(in);
	int n= Integer.parseInt(st.nextToken());
	in=br.readLine();
	st=new StringTokenizer(in);
	int h= Integer.parseInt(st.nextToken());
	in=br.readLine();
	st=new StringTokenizer(in);
	int w= Integer.parseInt(st.nextToken());
	int c=0;
	if(h==n)
	{
		System.out.println(n-w+1);
		return;
	}
	else if(w==n)
	{
		System.out.println(n-h+1);
		return;
	}
	else if(h>n||w>n)
	{
		System.out.println(0);
		return;
	}
	else
	{
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				if((i+w)<=n && (j+h)<=n)
				{
					c++;
				}
				else
				{
					//System.out.println("sorry   "+(i+h)+"  "+(j+w));
					break;
				}
			}
		}
		System.out.println(c);
		return;
	}
}

public static void main(String[]args) throws Exception
{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	A(br);

	
}
	
}


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

int main() {
  char b, c[128];
  c['A'] = 'T';
  c['C'] = 'G';
  c['T'] = 'A';
  c['G'] = 'C';

  cin >> b;
  cout << c[b] << endl;

  return 0;
}


Measured memory_bytes: 256
from bisect import bisect_right, bisect_left
s = [ord(i) - ord("a") for i in input()]
t = [ord(i) - ord("a") for i in input()]
index = [[] for _ in range(26)]

for i, x in enumerate(s):
    index[x].append(i)


l_s = len(s)

for x in index:
    if x:
        x.append(x[0] + l_s)

cnt = -1
for r in t:
    seq = index[r]
    if not seq:
        cnt = -2
        break
    i = cnt % l_s
    j = bisect_right(seq, i)
    cnt += seq[j] - i

print(cnt+1)




Measured memory_bytes: 9036
import sys
from functools import lru_cache
 
#read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
def mp(arg):
  return map(int,arg.split())

n=read()
a=list(reads())
if a[0]>1:
  print("-1")
  exit()
res=0
node=[0 for _ in range(n+1)]
node[-1]=a[-1]
#node[-1][0]=node[-1][1]=a[-1]
#sub=[0]*n
for i in range(n-1,-1,-1):
  #node[i][0]=(node[i+1][0]+1)//2+a[i]
  node[i]=min(node[i+1]+a[i],1<<i)
#print(node)
for i in range(n):
  sub=node[i]-a[i]
  node[i+1]=min(node[i+1],sub*2)
#print(sub)
#print(node)
for i in range(n+1):
  if node[i]<a[i]:
    print("-1")
    exit()
  if (node[i]<=0 and i<n) :
    print("-1")
    exit()
  res+=node[i]
print(res)


Measured memory_bytes: 646308
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <vector>

#define X first
#define Y second
#define PB push_back

using namespace std;

typedef long long ll;
typedef pair < int, int > pii;
typedef vector < int > vi;

const int N = 1e6 + 500;
const int INF = 0x3f3f3f3f;
const int MOD = 998244353;

int mini = 0, maxi = 0, n;
char s[N];
int desno[N];

int probaj(int x){
	if(desno[0] < x)
		return n;
	int cur = 0, gran = 0;
	for(int i = 0;i < n;i++){
		if(s[i] == '1'){
			cur++;
		}
		else if(s[i] == '0'){
			cur--;
		}
		else{
			if(cur + desno[i + 1] > x)
				cur--;
			else
				cur++;
		}
		gran = max(cur, gran);
	}
	return gran - x;
}

int main(){
	scanf("%s", s);
	n = strlen(s);
	desno[n] = 0;
	for(int i = n - 1;i >= 0;i--){
		if(s[i] == '1' || s[i] == '?'){
			desno[i] = min(desno[i + 1] + 1, 0);
		}
		else{
			desno[i] = desno[i + 1] - 1;
		}
	}
	int sol = n;
	for(int x = desno[0];x >= desno[0] - 50;x--)
		sol = min(sol, probaj(x));
	printf("%d\n", sol);
	return 0;
}






Measured memory_bytes: 8660
import math
n, m = map(int, input().split())
s = [list(map(int,input().split()))[1:] for i in range(m)]
p = list(map(int, input().split()))


def is_on(s, x, p):
    parity = 0
    for i in s:
        parity += (x >> (i-1)) & 1
    return parity % 2 == p


ans = 0
for i in range(int(math.pow(2, n))):
    on = 1
    for j in range(m):
        if not is_on(s[j], i, p[j]):
            on = 0
            break
    ans += on
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    string s;
    cin >> s;
    int ans = 100;
    for(char c = 'a'; c <= 'z'; c++){
        string t = s;
        int num = 0;
        while(true){
            string t_d = "";
            rep(i,t.size()-1){
                if (t[i] == c && t[i+1] == c) continue;
                else if (t[i] == c || t[i+1] == c) t_d.push_back(c);
                else t_d.push_back(t[i]);
            }
            if (t_d.size() == 0) break;
            t = t_d;
            num++;
        }
        ans = min(ans, num);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<cstdio>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge { ll to, cost; };
const ll INF = 100000000000000000;
ll n, m, s, t, u, v, a, b;

ll V;
vector<edge> G[2][100000];
ll d[2][100000];
ll mini[100000];

void dijkstra(int num, int start) {
  for (ll i = 0; i < n; i++) d[num][i] = INF;
  d[num][start] = 0;
  priority_queue<P, vector<P>, greater<P> > que;
  que.push(P(0, start));
  while (!que.empty()) {
    P p = que.top(); que.pop();
    ll cost = p.first, from = p.second;
    if (d[num][from] < cost) continue;
    for (ll i = 0; i < G[num][from].size(); i++) {
      edge e = G[num][from][i];
      ll to = e.to, newcost = cost + e.cost;
      if (d[num][to] > newcost) {
        d[num][to] = newcost;
        que.push(P(newcost, to));
      }
    }
  }
}

int main() {
  scanf("%lld%lld%lld%lld", &n, &m, &s, &t);
  s--; t--;
  for (ll i = 0; i < m; i++) {
    scanf("%lld%lld%lld%lld", &u, &v, &a, &b);
    u--; v--;
    edge e1, e2, e3, e4;
    e1.to = v, e2.to = u;
    e1.cost = e2.cost = a;
    G[0][u].push_back(e1), G[0][v].push_back(e2);
    e3.to = v, e4.to = u;
    e3.cost = e4.cost = b;
    G[1][u].push_back(e3), G[1][v].push_back(e4);
  }
  dijkstra(0, s);
  dijkstra(1, t);
  for (ll i = 0; i < n; i++) mini[i] = d[0][i] + d[1][i];
  for (ll i = n - 2; i >= 0; i--) mini[i] = min(mini[i], mini[i + 1]);
  for (ll i = 0; i < n; i++) printf("%lld\n", 1000000000000000 - mini[i]);
}


Measured memory_bytes: 19140
n = gets.to_i
a = n.times.map{gets.split.map(&:to_i)}

total_games = n * (n - 1) / 2
games = 0
today_games = 0
day = 0
possible_player = {}
today_played = {}
played_count = Array.new(n, 0)

for i in 0...n do
  possible_player[i] = 1
end

while games < total_games do
  today_games = 0
  possible_player.each_key do |i|
    if played_count[i] < (n - 1) && !today_played.include?(i)
      j = a[i][played_count[i]] - 1
      if played_count[j] < (n - 1) && !today_played.include?(j) && (a[j][played_count[j]] - 1) == i
        today_played[i] = 1
        today_played[j] = 1
        played_count[i] += 1
        played_count[j] += 1
        today_games += 1
      end
    end
  end
  if today_games == 0
    day = -1
    break
  else
    games += today_games
  end
  possible_player = today_played
  today_played = {}
  day += 1
end
puts day


Measured memory_bytes: 56700
k,n=map(int,input().split())
a=list(map(int,input().split()))
d=[]

for i in range(n):
    if i!=0:
        d.append(abs(a[i]-a[i-1]))
    else:
        d.append(abs(a[i]-a[i-1]+k))
d.sort()

ans=sum(d)-max(d)
print(ans)

Measured memory_bytes: 26436
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val h = sc.nextInt()
    val m = sc.nextInt()
    println(problem168c(a, b, h, m))
}

fun problem168c(a: Int, b: Int, h: Int, m: Int): Double {
    val alpha = (h * 60 + m) * (Math.PI * 2) / 720
    val beta = m * (Math.PI * 2) / 60
    val xA = a * Math.cos(alpha)
    val yA = a * Math.sin(alpha)
    val xB = b * Math.cos(beta)
    val yB = b * Math.sin(beta)
    val res = Math.sqrt((xA - xB) * (xA - xB) + (yA - yB) * (yA - yB))
    return res
}

Measured memory_bytes: 36568
N,K = map(int,input().split())

ans = 0

if K == 0 :
    ans = N**2
else :
    for b in range(1,N+1) :
        p = N//b
        r = N % b
        ans += max(0, b-K)*p + max(0, r-K+1)

print(ans)


Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _20190309_01 {
    class Program {
        static void Main(string[] args) {
            var line0 = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var H = line0[0];
            var W = line0[1];
            var line1 = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var h = line1[0];
            var w = line1[1];
            Console.WriteLine((H - h) * (W - w));
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
//#include <iomanip>
 
using namespace std;
//#define
 
int main() {
    int h, w;
 
    while(1){
        cin >> h >> w;
        if(h==0 && w==0) break;
 
        for(int i=0;i<h;i++){
            for(int k=0;k<w;k++){
               if((i==0)||(i==(h-1))){
                cout << '#';
               
               }else if((k==0)||(k==(w-1))){ 
                cout << '#';
               }else{
                cout << '.';
               }
            }
            cout << "\n";
        }
        cout << "\n";
    }
    return 0;
}

Measured memory_bytes: 1120
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAXN=100005;
int n,m,q,a[MAXN],pos[MAXN],beg=0,dest[MAXN];
bool vis[MAXN];
int cnt[MAXN];
int main()
{
	scanf("%d%d",&n,&m);
	scanf("%d",&q);
	for(int i=1;i<=q;++i)
		scanf("%d",a+i);
	for(int i=q;i>0;--i){
		if(!vis[a[i]]){
			pos[a[i]]=++beg;
			dest[beg]=a[i];
			vis[a[i]]=true;
		}
	}//beg为在a[]中有的数 的数量 
	int t=0;
	for(int i=1;i<=m;++i)
		if(!vis[i])dest[beg+(++t)]=i;//预处理 
	cnt[0]=n;
	int mx=0;
	for(int i=q;i>0;--i){
		int o=pos[a[i]];
		if(cnt[o-1]){
			--cnt[o-1];
			++cnt[o];
			mx=max(mx,o);
		}/*else if(mx<o-1){
			puts("No");
			return 0;
		}*/
	}	
	int st=n;
	for(int i=0;i<=beg;++i)
		if(cnt[i]){st=i;break;}
	for(int i=st+2;i<=m;++i)
		if(dest[i]<dest[i-1]){
			puts("No");
			return 0;
		}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;i++)
#define per(i,a,b) for(int i=(b),i##_st=(a);i>=i##_st;i--)
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define debug(x) cerr<<#x" = "<<x<<endl
#define Debug(...) fprintf(stderr, __VA_ARGS__)
#define Es(x,i) for(Edge *i=G[x];i;i=i->nxt)
typedef pair<int,int> pii;
typedef long long ll;
const int inf=~0u>>1,MOD=1e9+7;//*
char *TT,*mo,but[(1<<15)+2];
#define getchar() ((TT==mo&&(mo=((TT=but)+fread(but,1,1<<15,stdin)),TT==mo))?-1:*TT++)//*/
inline int rd() {
	int x,c,f=1;while(!isdigit(c=getchar()))f=c!='-';x=c-'0';
	while(isdigit(c=getchar()))x=x*10+c-'0';return f?x:-x;
}
const int N=2e5+11;
vector<int> v[N];
int n,m,ans,a[N<<2],b[N<<2];
#define All 1,0,m+1
#define mid (L+R>>1)
#define lson o<<1,L,mid
#define rson o<<1|1,mid+1,R
void updata(int o,int L,int R,int l,int r,int x){
//	cout<<L<<" "<<R<<" "<<l<<" "<<r<<endl;
	if(L==l&&R==r){
		a[o]+=x,b[o]+=x;
	}else{
		if(r<=mid)updata(lson,l,r,x);
		else if(l>mid)updata(rson,l,r,x);
		else updata(lson,l,mid,x),updata(rson,mid+1,r,x);
		a[o]=max(a[o<<1],a[o<<1|1])+b[o];
	}
}
int query(int o,int L,int R,int l,int r){
//	cout<<"f1 "<<L<<" "<<R<<" "<<l<<" "<<r<<endl;
	if(L==l&&R==r)return a[o];
	else{
		int rr;
		if(r<=mid)rr=query(lson,l,r)+b[o];
		else if(l>mid)rr=query(rson,l,r)+b[o];
		else rr=max(query(lson,l,mid),query(rson,mid+1,r))+b[o];
		return rr;
	}
}
int main(){
#ifdef flukehn
	freopen("test.txt","r",stdin);
#endif
	n=rd(),m=rd(),ans=max(0,n-m);
	rep(i,1,n){
		int l=rd(),r=rd();
		v[l].pb(r);
	}
	rep(i,0,m+1){
		updata(All,i,i,i-m-1);
	}
	rep(i,0,m){
		for(auto u:v[i]){
			updata(All,0,u,1);
		}
		ans=max(ans,query(All,i+1,m+1)-i);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 14848
#include<iostream>
using namespace std;
int dp[3005][3005];
#include<vector>
#include<algorithm>
int main()
{
    
    string s,t;
    cin>>s>>t;
    int x=s.length(),y=t.length();
    for(int i=1;i<=x;i++){
    for(int j=1;j<=y;j++){
    if(s[i-1]!=t[j-1])
    dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    else
    dp[i][j]=1+dp[i-1][j-1];
    }}
    vector<char>v;
    int i=x,j=y;
    while(i>0 && j>0){
    if(dp[i][j]==dp[i-1][j])i--;
    else if(dp[i][j]==dp[i][j-1])j--;
    else if(dp[i][j]!=dp[i-1][j-1]){
    v.push_back(t[j-1]);
    i--;j--;}
    }
    reverse(v.begin(),v.end());
    for(int i=0;i<dp[x][y];i++)
    cout<<v[i];
    
    return 0;
}

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

using namespace std;

const int max_n = 303, inf = 1000111222;

int n, m;
char a[max_n][max_n];
bitset<max_n> b[max_n];
long long ans;

void proc(int x1, int y1, int x2, int y2) {
    //cout << x1 << " " << y1 << " " << x2 << " " << y2 << " -> ";
    int x0 = 0, y0 = 0;
    if (min(y1, y2) < 0) {
        y0 = -min(y1, y2);
    }
    y1 += y0;
    y2 += y0;
    //cout << x0 << " " << y0 << " " << x1 << " " << y1 << " " << x2 << " " << y2 << ": ";
    for (int i = 0; i + x2 < n; ++i) {
        ans += ((b[i] >> y0) & (b[i + x1] >> y1) & (b[i + x2] >> y2)).count();
    }
    //cout << ans << endl;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; ++i) {
        scanf("%s", a[i]);
        for (int j = 0; j < m; ++j) {
            b[i][j] = (a[i][j] == '#');
        }
    }
    for (int x1 = 0; x1 < n; ++x1) {
        for (int y1 = -m + 1; y1 < m; ++y1) {
            if (x1 == 0 && y1 <= 0) {
                continue;
            }
            int l = x1 + abs(y1);
            for (int x2 = x1; x2 < n; ++x2) {
                for (int z = -1; z <= 1; z += 2) {
                    int y2 = (l - x2) * z;
                    if (abs(y1 - y2) >= m || x2 - x1 + abs(y1 - y2) != l || x2 + abs(y2) != l) {
                        continue;
                    }
                    if (x1 == x2 && y1 < y2) {
                        continue;
                    }
                    proc(x1, y1, x2, y2);
                    if (y2 == 0) {
                        break;
                    }
                }
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <tuple>
#include <iterator>
using namespace std;
using ll = long long;
const int INF = 1000001;

int main()
{
  ll n;
  cin >> n;
  vector<ll> a(n), b(n);
  for (ll i = 0; i < n; ++i)
  {
    cin >> a[i];
    b[i] = a[i] - i - 1;
  }

  sort(b.begin(), b.end());
  ll c = b[ceil(n / 2.0) - 1];
  ll d = b[floor(n / 2.0) - 1];
  ll sum = 0;
  ll tsum = 0;
  for (ll i = 0; i < n; ++i)
  {
    sum += abs(a[i] - d - i - 1);
    tsum += abs(a[i] - c - i - 1);
  }
  ll ans = min(sum, tsum);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3328
n = int(input())
d = {}
for i in range(n):
    name, p = input().split(' ')
    p = int(p)
    d[name] = d.get(name, []) + [(-p, i+1)]
for key in sorted(d):
    d[key] = sorted(d[key])
    for i in range(len(d[key])):
        print(d[key][i][1])

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

string s, t;
int dp[3004][3004];

int main() {
	cin>>s>>t;
	memset(dp,0,sizeof(dp));
	for(int i = 0;i<s.length();i++)
		for(int j =0 ;j<t.length();j++)
		{
			
			if(s[i] == t[j])
				dp[i+1][j+1] = dp[i][j]+1;
			else{
				dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]);
			}
		}
	string ans;
	int n = s.length(), m = t.length();
	while(n>0 && m>0){
		if(s[n-1] == t[m-1]){	
			ans += s[n-1];
			n--;m--;
			continue;
		}
		if(dp[n][m-1]>dp[n-1][m]){
			m--;
			continue;
		}
		n--;
	}
	reverse(ans.begin(),ans.end());
	cout<<ans;
	return 0;
}

Measured memory_bytes: 35584
//  Mayank Agarwal
//  IIIT Hyderabad



#include<bits/stdc++.h>
using namespace std;
const long long int M = 1000000007; 
#define ll long long int
#define ld double
#define pb push_back
#define mp make_pair
ll a1[3010],a2[3010];
ll dp[3010][3010];
ll n,t;
ll solve(ll ind,ll wei)
{
    if(ind>=n)
    {
        return 0;
    }
    if(dp[ind][wei]!=-1)
    {
        return dp[ind][wei];
    }
    ll ans=0;
    if(wei>a1[ind])
    {
        ans=max(solve(ind+1,wei),solve(ind+1,wei-a1[ind])+a2[ind]);
    }
    else
    {
        ans=max(a2[ind],solve(ind+1,wei));
    }
    return dp[ind][wei]=ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin>>n>>t;
    for (int i = 0; i < 3002; ++i)
    {
        for (int j= 0; j < 3002; ++j)
        {
            dp[i][j]=-1;
        }
    }
    std::vector<pair<ll,ll> > v;
    for (int i = 0; i < n; ++i)
    {
        ll a,b;
        cin>>a>>b;
        v.pb(mp(a,b));
    }
    sort(v.begin(),v.end());
    for (int i = 0; i < n; ++i)
    {
        a1[i]=v[i].first;
        a2[i]=v[i].second;
    }
    cout<<solve(0,t)<<'\n';
}


Measured memory_bytes: 71168
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, m; cin>>n>>m;
	int sum = 0;
	for (int i = 0; i < m; i++) {
		int t; cin>>t;
		sum += t;
	}
	if (sum > n) cout<<"-1";
	else cout<< n - sum;
	return 0;
}

Measured memory_bytes: 3676
open Printf
open Scanf

let id x = x
let pair x y = x, y

let n, x = scanf "%d %d" pair
let vs = Array.init n @@ fun _ -> scanf " %d" id

let () =
    Array.sort (fun x y -> x - y) vs;
    let count = ref 0 in
    let rest = ref x in
    for i = 0 to n - 1 do
        if vs.(i) <= !rest then begin
            incr count;
            rest := !rest - vs.(i)
        end else begin
            printf "%d\n" !count;
            exit 0
        end 
    done;
    if !rest <> 0 then decr count;
    printf "%d\n" !count

Measured memory_bytes: 4480
n, x, y = map(int, input().split())
L1 = x - 1
L2 = n - y
C = y - x + 1
for k in range(1, n):
    ans = 0
    if 2 * k == C:
        ans += C // 2
    elif 2 * k < C:
        ans += C
    for L in L1, L2:
        if C % 2 == 0 and 0 < k - C // 2 <= L:
            ans += 1
        ans += max(0, (min(L, k-1) - max(1, k - (C - 1) // 2) + 1) * 2) + (L >= k)
    ans += max(0, L1 + L2 + 2 - k) - sum(k <= x for x in [L1, L2+1, L2, L1+1]) + (k == 1)
    print(ans)

Measured memory_bytes: 75124
#include <stdio.h>

int main ()
{
    int a, b, c, d, sum;

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

    sum = 0;
    if (b <= a)
        sum += b;
    else
        sum += a;

    if (d <= c)
        sum += d;
    else
        sum += c;

    printf ("%d\n", sum);

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	lint x,num=0;
	cin>>x;
	rep1(i,x){
		num+=i;
		if(x<=num){
			cout<<i<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        int a = int.Parse(s[0]);
        int b = int.Parse(s[1]);

        string ret = "";
        ret += (a / b) + " ";
        ret += (a % b) + " ";
        ret += string.Format("{0:0.000000}", ((double)a / (double)b));

        Console.WriteLine(ret);
    }
}


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

int main(){
    int X;
    cin >> X;
    int tmp=0;
    int ans=0;
    while(X>0){
        tmp++;
        X-=tmp;
    }
    cout << tmp << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] s = sc.next().split("");
        int count = 0;
        for (int i = 0; i < s.length; i++) {
            if (s[i].equals("1")) {
                count++;
            }
        }
        System.out.println(count);
    }

}


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

string f(ll n) {
    if(n == 0) return "";
    n--;
    return f(n / 26) + string(1, 'a' + n % 26);
}

int main()
{
    ll n;
    cin >> n;
    cout << f(n) << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int W = 1e5+5;
const int N = 105;
int weight[N], value[N];
ll dp[N][W];
int n, w;


ll max_value(int pos, int cap )
{
    
    if(cap > w)
    return INT_MIN;
    if(pos >= n)
    return 0;
    if(dp[pos][cap] != -1)
        return dp[pos][cap];
    ll res;
    res = max((ll)max_value(pos+1, cap + weight[pos] )+ value[pos], (ll)max_value(pos+1, cap) );
    dp[pos][cap] = res;
    return res;
}

int main() {
	
	cin >> n >> w;
	for(int i = 0; i < n; ++i)
	{
	    cin >> weight[i] >> value[i];
	}
	memset(dp, -1, sizeof(dp));
	ll ans = max_value(0, 0);
	cout << ans;
	return 0;
}


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

#define PI 4*atan(1)
#define INF 1e8

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

int main(){
  int m, n_min, n_max;
  while(cin >> m >> n_min >> n_max, m||n_min||n_max){
    vector<int> P(m);
    for(int i = 0; i < m; i++){
      cin >> P[i];
    }
    int diff = 0, ans;
    for(int i = n_min; i <= n_max; i++){
      if(diff <= P[i-1] - P[i]){
        diff = P[i-1] - P[i];
        ans = i;
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 2996
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

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

    ll r = 0;
    for (int l = 0; l < 2; l++) {
        for (int i = 0; i < n; i++) {
            a[i] *= -1;
        }
        sort(a.begin(), a.end());

        vector<int> b(n);
        int j = 0;
        for (int i = 0; i < n; i++) {
            b[j++] = a[i];
            if (j == n) break;
            b[j++] = a[n - 1 - i];
            if (j == n) break;
        }

        ll s = 0;
        for (int i = 1; i < n; i++) {
            if (i == n - 1) {
                s += abs(b[i] - b[0]);
            } else {
                s += abs(b[i] - b[i - 1]);
            }
        }
        r = max(r, s);
    }

    cout << r << endl;

    return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int H,W;
int A[222][222];

int dp[444][222][222];

signed main(){
    cin>>H>>W;
    rep(i,H)rep(j,W)cin>>A[i][j];

    for(int i=0;i<H+W-2;i++){
        for(int j=0;j<=i&&j<W;j++){
            for(int k=0;k<=i&&k<W;k++){
                int x1=j,y1=i-j;
                int x2=k,y2=i-k;

                rep(b,4){
                    int nx1=x1,ny1=y1;
                    int nx2=x2,ny2=y2;

                    if(b&1)nx1++;
                    else ny1++;

                    if(b>>1&1)nx2++;
                    else ny2++;

                    if(nx1>=W||ny1>=H||nx2>=W||ny2>=H)continue;
                    if(nx1!=nx2||ny1!=ny2)chmax(dp[i+1][nx1][nx2],dp[i][j][k]+A[ny1][nx1]+A[ny2][nx2]);
                    else chmax(dp[i+1][nx1][nx2],dp[i][j][k]+A[ny1][nx1]);
                }
            }
        }
    }

    cout<<dp[H+W-2][W-1][W-1]+A[0][0]<<endl;
    return 0;
}


Measured memory_bytes: 152192
#include <stdio.h>
#include <stdbool.h>

int main() {
	int A[3][3], N,b[10];
	bool a[3][3] = {false};
	for (int i = 0; i < 3;i++) {
		for (int j = 0; j < 3;j++) {
			scanf("%d",&A[i][j]);
		}
	}
	scanf("%d",&N);
	for (int h = 0; h < N; h++) {
		scanf("%d",&b[h]);
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (A[i][j]==b[h]) {
					a[i][j] = true;
				}
			}
		}
	}

	if ((a[0][0]==true&& a[0][1] == true && a[0][2] == true)
		|| (a[1][0] == true && a[1][1] == true && a[1][2] == true)
		|| (a[2][0] == true && a[2][1] == true && a[2][2] == true)
		|| (a[0][0] == true && a[1][1] == true && a[2][2] == true)
		|| (a[0][2] == true && a[1][1] == true && a[2][0] == true)
		|| (a[0][0] == true && a[1][0] == true && a[2][0] == true)
		|| (a[0][1] == true && a[1][1] == true && a[2][1] == true)
		|| (a[0][2] == true && a[1][2] == true && a[2][2] == true)
		) {
		printf("Yes");
	}
	else {
		printf("No");
	}

	return 0;
}

Measured memory_bytes: 128
def main():
	line = input()
	vector = [int(x) for x in line.split()]
	maxim = max(vector)
	k = int(input())
	sum = 0
	used = 0
	for i in range(3):
		if vector[i] == maxim and used == 0:
			sum += vector[i] * 2 ** k
			used = 1
		else:
			sum += vector[i]
	print(sum)
 
 
 
if __name__ == "__main__":
	main()

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
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();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

string s;

signed main() {
  cin >> s;

  for (int i = 0; i + 1 < s.size(); i++) {
    if (s[i] == s[i + 1]) {
      cout << i + 1 << " " << i + 2 << endl;
      return 0;
    }
  }

  for (int i = 0; i + 2 < s.size(); i++) {
    if (s[i] == s[i + 2]) {
      cout << i + 1 << " " << i + 3 << endl;
      return 0;
    }
  }

  cout << "-1 -1" << endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,b) for(ll i=(a);i<=(b);++i)
#define req(i,a,b) for(ll i=(a);i>=(b);--i)
#define name "a"
#define pb push_back
#define sz size()
#define ff first
#define ss second
#define xd '\n'
#define dc " "
typedef pair < ll , ll > ii;
const ll maxn = 3e5+7, oo = 1e18, base = 311, mod = 1e9+7;
const double PI = 3.141592654;
ll t, n, a[maxn], res, f[maxn], k, st[maxn<<2];
ll get(int i, int l, int r, int x, int y)
{
    if (l > y || r < x)
        return 0;
    if (x <= l && r <= y)
        return st[i];
    int m = (l+r)/2;
    return max (get(2*i, l, m, x, y) , get(2*i+1, m+1, r, x, y));
}
void update(int i, int l, int r, int x, int v)
{
    if (l > x || r < x)
        return ;
    if (l == r)
    {
        st[i] = v;
        return;
    }
    int m = (l+r)/2;
    update(2*i, l, m, x, v);
    update(2*i+1, m+1, r, x, v);
    st[i] = max (st[2*i] , st[2*i+1]);
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen(name".inp","r",stdin);
    //freopen(name".out","w",stdout);
    cin >> n >> k;
    rep (i, 1, n)
        cin >> a[i];
    rep (i, 1, n)
    {
        f[i] = get(1, 0, 300000, max(0ll, a[i] - k), a[i] + k) + 1;
        update(1, 0, 300000, a[i], f[i]);
    }
    rep (i, 1, n)
        res = max (res, f[i]);
    cout << res;
}


Measured memory_bytes: 16500
N = int(input())
A = list(map(int,input().split()))

def gcd(tmp_1,tmp_2):
    if tmp_2 == 0:
        return tmp_1
    else:
        return gcd(tmp_2, tmp_1%tmp_2)

tmp_3 = A[0]
for i in range(1,N,1):
    tmp_3 = gcd(tmp_3,A[i])

print(tmp_3)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl '\n'
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);

template <typename T>
vector<T> make_vec(size_t a, T n) { return vector<T>(a, n); }
template <typename T, typename... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
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;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

signed main() {
    INIT;
    cin >> S;
    REP(i, S.size()) {
        if (S[i] == 'B') {
            if (T.size() != 0)
                T.pop_back();
        } else
            T.push_back(S[i]);
    }
    cout << T << endl;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c,k,m,mk; cin>>a>>b>>c>>k;
  m=max({a,b,c}); mk=m;
  for(int i=0; i<k; i++) mk*=2; 
  cout<<a+b+c-m+mk;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fr(i,c,b) for(int i=c;i<b;i++)
#define frl(i,c,b) for(ll i=c;i<b;i++)
#define si(x) int x; scanf("%d", &x)
#define sll(x) ll x; scanf("%lld", &x)
#define pi(x) printf("%d", x)
#define pll(x) printf("%lld", x)
#define nl printf("\n")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define MAX 100001
#define M 1000000007
#define pb push_back
 
typedef long long int ll;
 
using namespace std;
 
int main()
{
 
    si(n);
    si(w);
    ll a[n]; ll val[n];
    fr(i,0,n)
    {
        cin>>a[i]>>val[i];
    }
    
    
    ll dp[n+1][w+1];
    fr(i,0,n+1)
        fr(j,0,w+1)
            dp[i][j]=0;
    
    for(int i=1;i<n+1;i++)
    {
        fr(j,1,w+1)
        {
            if(a[i-1]<=j)
            {
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-a[i-1]]+val[i-1]);
            }
            else
                dp[i][j]=dp[i-1][j];
        }
    }
  
    cout<<dp[n][w];
    
}


Measured memory_bytes: 82540