akhauriyash/Code-Regression huggingface dataset:
N,C=map(int, input().split())
D=[list(map(int, input().split())) for _ in range(C)]
c=[list(map(int, input().split())) for _ in range(N)]

from collections import Counter
t=[Counter([c[i][j] for i in range(N) for j in range(N) if (i+j)%3==m]) for m in range(3)]

ans = 10**9
for i in range(C):
    for j in range(C):
        if i==j: continue
        for k in range(C):
            if i==k or j==k: continue
            d = 0
            for before in range(C):
                d += D[before][i] * t[0][before+1]
                d += D[before][j] * t[1][before+1]
                d += D[before][k] * t[2][before+1]
            ans = min(ans, d)
print(ans)

Measured memory_bytes: 8460
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

N,D = LI()
ans = math.ceil(N/(D*2+1))
print(ans)


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

int main(){
	int f;
	int ans;
	cin >> f;
	if(f == 1){
		cout << "Hello World" << endl;
	}else if(f == 2){
		int a;
		int b;
		cin >> a;
		cin >> b;
		ans = a + b;
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#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() {
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> C(N);
  vector<vector<int>> A(N, vector<int>(M));
  rep(i, N) {
    cin >> C.at(i);
    rep(j, M) {
      cin >> A.at(i).at(j);
    }
  }
  // rep(i, N) {
  //   cout << "i " << i << " C.at(i) " << C.at(i) << endl;
  //   rep(j, M) {
  //     cout << "i " << i << " j " << j << " A.at(i).at(j) " << A.at(i).at(j) << endl;
  //   }
  // }

  // 全パターン試す
  int ans = INT_MAX;
  vector<int> v(M, 0);
  for (int bits = 1; bits < (1 << N); bits++) {
    // cout << "bits " << bits << endl;
    int cost = 0;
    rep(i, M) v.at(i) = 0;
    for (int i = 0; i < N; i++) {
      if ((bits >> i) & 1) {
        // Ciが含まれる場合
        cost += C.at(i);
        rep(j, M) {
          v.at(j) += A.at(i).at(j);
        }
      }
    }
    // cout << "cost " << cost << endl;
    // rep(i, N) {
    //   cout << "i " << i << " v.at(i) " << v.at(i) << endl;
    // }

    bool res = true;
    rep(i, M) {
      if (v.at(i) < X) {
        // cout << "break j " << j << endl;
        res = false;
        break;
      }
    }
    if (res && cost < ans) {
      ans = cost;
    }
  }

  if (ans == INT_MAX) {
    ans = -1;
  }

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

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

//priority_queue解
using data = pair<ll,vector<int> >;

int main(){
    
  vector<int> N(3);
  rep(i,3) cin >> N[i];
  int K;
  cin >> K;
  vector<vector<ll> > value(3);
  rep(i,3) {
    value[i].resize(N[i]);
    rep(j,N[i]) cin >> value[i][j];
    sort(value[i].begin(),value[i].end(),greater<ll>()); 
  }

  priority_queue<data> que;
  set<data> set;
  que.push( data(value[0][0] + value[1][0] + value[2][0], vector<int>({0,0,0})));

  rep(k,K) {
    auto c = que.top(); que.pop();
    cout << c.first << endl;

    rep(i,3) {
      if(c.second[i] + 1 < N[i]) {
          ll sum = c.first - value[i][c.second[i]] + value[i][c.second[i] + 1];
          auto num = c.second; num[i]++;
          auto d = data(sum, num);

          if(!set.count(d)) set.insert(d), que.push(d);
      }
    }
  }    

  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
//#define che 
#define debug(...) printf(__VA_ARGS__)
#define PB push_back
#define MP make_pair
using namespace std;


const int maxn= 410; 
typedef long long LL;
const LL MOD = 1e9 +7;
template<class T>
void upsum(T &a , T b){ a=(a+b)%MOD; }
LL f[maxn][maxn][2] , gN, C[maxn][maxn], pre[maxn][maxn],com[maxn][maxn];
int occ[maxn], a[maxn],b[maxn];
int N, n;

int main(){
	
	for (int i=0; i<= 400; i++) C[i][0] =1;
	for (int i=1; i<=400; i++)
		for (int j=1; j<= i; j++) C[i][j] = (C[i-1][j] + C[i-1][j-1])%MOD;
	scanf("%d", &N); n= N/3;
	for (int i=1; i<=N; i++) scanf("%d", &a[i]);
	for (int i=1; i<=N; i++) scanf("%d", &b[i]);
	gN= 1;
	for (int i=1, j=0; i<=n; i++, j++){
		gN= gN*(1LL*(j++)+1)%MOD;
		gN= gN*(1LL*(j++)+1)%MOD;
	}
	#ifdef che
	debug(" gN=%lld\n", gN);
	#endif
	memset(occ, 0 ,sizeof(occ));
	memset(com, 0, sizeof(com));
	for (int i=1, cnt=0; i<=N; i++){
		if ( ! (occ[ a[i]]++) ) cnt++; 
		for (int j=1; j<=N; j++){
			if ( !(occ[b[j]]++)) cnt++;
			com[i][j] =  cnt;
			if ( occ[a[i]] >1 || occ[b[j]] >1) com[i][j]= N*N; // oo 
			#ifdef che
			debug("com[%d][%d] = %lld\n", i, j, com[i][j]);
			#endif
		}
		for (int j=1; j<=N; j++)	if ( !(--occ[b[j]]) ) cnt--;
	}
		
	for (int i=0; i<=N; i++) for (int j=0; j<=N; j++) pre[i][j] = 1;
	memset(f, 0 , sizeof(f));
	
	for (int t=1,cur; t<=n ;t++){
		cur= t&1;
		#ifdef che
		debug("t= %d\n", t);
		#endif
		for (int i=1; i<=N; i++)
			for (int j=1; j<=N; j++){
				LL opt = N-com[i][j]-3*(n-t);
				f[i][j][cur] = 0;
				if ( opt <=0 ) continue;
				f[i][j][cur] = opt*pre[i-1][j-1]%MOD;
				#ifdef che
				debug(" ait= %d, bjt= %d,  opt = %lld, pre= %lld\t\t",  i, j, opt, pre[i-1][j-1]);
				debug("f[%d][%d][%d] = %lld\n", i,j,cur, f[i][j][cur]);
				#endif
			}
		for (int i=0; i<=N; i++) pre[i][0] = pre[0][i] = 0;
		for (int i=1; i<=N; i++)
			for (int j=1; j<=N; j++) pre[i][j] = (pre[i-1][j] + pre[i][j-1] -pre[i-1][j-1] + f[i][j][cur]+MOD)%MOD;
	}
	LL ans= 0;
	
	for (int i=1; i<=N; i++)
		for (int j=1; j<=N; j++) upsum( ans, f[i][j][ n&1]);
	ans= (ans *gN)%MOD;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 6784
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		String S = sc.next();
		String T = sc.next();

		for (int i = 0; i < N; i++)
			System.out.print(S.substring(i, i + 1) + T.substring(i, i + 1));

	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 23252
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN2(s,t);
  if(s==t) {
    OUT("EQUAL");
  } else if(s.size() > t.size()) {
    OUT("GREATER");
  } else if(s.size() < t.size()) {
    OUT("LESS");
  } else {
    REP(i,s.size()) {
      if(s[i] > t[i]) {OUT("GREATER");break;}
      else if(s[i] < t[i]) {OUT("LESS");break;}
    }
  }
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#define Rint register int
#define Temp template<typename T>
#define mem(a,b) memset(a,(b),sizeof(a))
typedef long long LL;
using namespace std;
Temp inline void read(T &x){
    x=0;T w=1,ch=getchar();
    while(!isdigit(ch)&&ch!='-')ch=getchar();
    if(ch=='-')w=-1,ch=getchar();
    while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^'0'),ch=getchar();
    x=x*w;
}

const int maxn=200000+10;
#include<vector>
vector<LL>q[2];  
LL x[maxn],y[maxn];  
LL bit[100];  
int n;  
  
LL solve()
{
    LL ans=0;  
    for(LL i=0;i<62;i++)  
    {  
        LL tot=0;  
        q[0].clear();q[1].clear();  
        for(LL j=1;j<=n;j++)  
            q[(x[j]>>i)&1].push_back(x[j]);  
        for(LL j=0;j<q[0].size();j++)  
            x[++tot]=q[0][j];  
        for(LL j=0;j<q[1].size();j++)  
            x[++tot]=q[1][j];  
        tot=0;  
        q[0].clear();q[1].clear();  
        for(LL j=1;j<=n;j++)  
            q[(y[j]>>i)&1].push_back(y[j]);  
        for(LL j=0;j<q[0].size();j++)  
            y[++tot]=q[0][j];  
        for(LL j=0;j<q[1].size();j++)  
            y[++tot]=q[1][j];  
        LL len1=1,len2=1,len3=1;  
        LL limit1=1LL<<i;  
        LL limit2=1LL<<(i+1);  
        LL all=(1LL<<(i+1))-1; 
        LL sum=0;
        for(LL i=n;i>=1;i--)  
        {  
            while((((x[i]&all)+(y[len1]&all))<limit1) && (len1<=n)) len1++; 
            while((((x[i]&all)+(y[len2]&all))<limit2) && (len2<=n)) len2++;  
            while(((x[i]&all)+(y[len3]&all)<limit1+limit2) && (len3<=n)) len3++;
            sum+=n-(len1-1-len2+1+len3-1);  
        }
        if(sum&1) ans+=bit[i];  
    } 
    return ans;  
}  
  
int main()  
{  
    bit[0]=1;  
    for(LL i=1;i<=61;i++)bit[i]=bit[i-1]*2;
    read(n);
    for(LL i=1;i<=n;i++)read(x[i]);
    for(LL i=1;i<=n;i++)read(y[i]);
    
	printf("%lld\n",solve());
   	return 0;
}  

Measured memory_bytes: 6508
/*
	watch me go
*/

#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;*/
#define int long long
//#define d long double
#define pii pair<int,int>
#define bitcount(a) __builtin_popcountll(a)
#define pb push_back
#define inf (int)1e18
#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
int const mod=998244353;
int const mod1=1000000007;
int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}
#define out(x) cout<<#x<<" = "<<" "<<x<<"\n";
#define trace1(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 haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// ******** Using PBDS ********
 /*typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
                os; */

int modexp(int x, int n){
	if(n==0){
		return 1;
	}
	else if(n&1){
		return (modexp((x*x)%mod, n/2)%mod * x%mod)%mod;
	}
	else{
		return (modexp((x*x)%mod, n/2)%mod);
	}
}
 
int modinv(int n)
{
	return modexp(n,mod-2);
}

signed main() 
{ 
    haha
    int n;
    cin>>n;
    int dp[n+1][3];
    init(dp,0);
    
    for(int i=1;i<=n;i++)
    {
        int a,b,c;
        cin>>a>>b>>c;
        dp[i][0]=a+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=b+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=c+max(dp[i-1][1],dp[i-1][0]);
        
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
   
   
} 


Measured memory_bytes: 2560
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file 
//#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define pb push_back
#define ff first
#define ss second
#define ii insert
#define ld long double
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define ppb pop_back
#define nuenxfiu ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define TT int testcases;cin>>testcases;while(testcases--)
#define mk make_pair
#define MAX ((int)2e9+17)
#define mod ((int)1e9+7)
#define MOD 1000003
//int fact[1000007]={0};
#define N (int)1e6+10
int fpow(int n, int k, int p = mod) {int r = 1; while(k > 0) {if (k & 1) r = r * n%p; n = n * n%p; k = k >> 1;} return r;}
int expo(int x,int y){ int res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
int sub(int a, int b) {return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b) {return ((a%mod)*(b%mod) + mod)%mod;}
int inv(int x) {return expo(x, mod-2);}
using namespace std;



void solve()
{
	int x;
	cin>>x;
	
	int curr=100;
	int ans=0;
	
	while(curr<x)
	{
		curr+=curr/100;
		ans++;
	}
	
	cout<<ans<<endl;
	
	
	
		
	
}
signed main()
{
    
	nuenxfiu
	//TT
	solve();
     return 0;
}

Measured memory_bytes: 3576
A,B=map(int, input().split())


def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(int(n))
  return table

a=set(prime_decomposition(A))
b=set(prime_decomposition(B))

print(len(a&b)+1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int n, counting = 0;
	cin >> n;
	int minOfI = 1e6, p = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> p;
		if (minOfI >= p)
		{
			minOfI = p;
			counting++;
		}
	}
	cout << counting;
	return 0;
}

Measured memory_bytes: 256
object Main extends App{
    val s = io.StdIn.readLine

    val odd = for(i <- (1 to s.length).filter(_ % 2 == 0)) yield s(i - 1)
    val even = for(i <- (1 to s.length).filter(_ % 2 == 1)) yield s(i - 1)
    println(if(odd.contains('R') || even.contains('L')) "No" else "Yes")
}

Measured memory_bytes: 25416
import java.util.Scanner;

public class Main {
	public static class P {
		public double x;
		public double y;
		public P(double x, double y) {
			this.x = x;
			this.y = y;
		}
	}
	
	public static P ta(int d, int a) {
		double dx = d * Math.sin(a * Math.PI / 180.0);
		double dy = d * Math.cos(a * Math.PI / 180.0);
		return new P(dx, dy);
	} 
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			double x = 0.0;
			double y = 0.0;
			int a0 = 0;
			while(sc.hasNext()) {
				String[] str = sc.next().split(",");
				int d = Integer.parseInt(str[0]);
				int a = Integer.parseInt(str[1]);
				if(d == 0 && a == 0) break;
				P p = ta(d, a0);
				x += p.x;
				y += p.y;
				
				if(a < 0) a += 360;
				a0 += a;
				a0 %= 360;
			}
			System.out.printf("%d\n%d\n", (int)x, (int)y);
		}
	}
}


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

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  map<int, int> mp;
  for(int i=0, x; i<n; i++){
    cin >> x;
    mp[x]++;
  }
  priority_queue<int, vector<int>, less<int>> pq;
  for(auto x : mp){
    if(x.second != 0 && x.second >= 2){
      for(int i=0; i<x.second / 2; i++) pq.push(x.first);
    }
  }
  if(pq.empty()){
    cout << "0" << endl;
    return 0;
  }
  long long a, b;
  a = pq.top(); pq.pop();
  b = pq.top(); pq.pop();
  cout << 1ll * a * b << endl;
  return 0;
}


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

int main() {
  int k, n;
  cin >> k >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  
  a.push_back(a[0]+k);
  
  int maxv = 0;
  rep(i, n) maxv = max(maxv, a[i+1]-a[i]);

  cout << k - maxv << endl;
  return 0;
}


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

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt(), K = scn.nextInt();
		long[] NCK = new long[N-K+1];
		NCK[0] = 1;

		long A[] = new long[N];

		long MOD = 1000000007;
		long min = 0;
		long max = 0;

		for(int i = 0;i < N;i++) {
			A[i] = scn.nextLong();
		}
		Arrays.sort(A);
		for(int i = 1;i < N-K+1;i++) {
			NCK[i] = NCK[i-1] * (K+i-1);
			NCK[i] %= MOD;
			NCK[i] *= modinv(i,MOD);
			NCK[i] %= MOD;
		}
		for(int i = 0;i < N-K+1;i++) {
			min += A[i] * NCK[N-K-i];
			min %= MOD;
			max += A[N-1-i] * NCK[N-K-i];
			max %= MOD;
		}
		long ans = max - min;
		ans %=MOD;
		ans += MOD;
		ans %= MOD;
		System.out.println(ans);
	}

	public static long modinv(long a, long mod) {
		long b = mod, u = 1, v = 0;
		long buf = 0;
	    while (b>0) {
	        long t = a / b;
	        a -= t * b;
	        buf = a;
	        a = b;
	        b = buf;
	        u -= t * v;
	        buf = u;
	        u = v;
	        v = buf;
	    }
	    u %= mod;
	    if (u < 0) u += mod;
	    return u;

	}
}


Measured memory_bytes: 61156
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(container) container.begin(), container.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
using namespace std;
using ll = long long;

int main(void){
    Cin(int, a);
    Cin(int, b);
    Cout((a*b % 2 == 0) ? "Even" : "Odd");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
// #define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin); freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp(pair < pii, int > a, pair < pii, int > b)//true for a before b
{
	if(a.F.F/300 < b.F.F/300)
		return 1;
	if(a.F.F/300 > b.F.F/300)
		return 0;
	if(a.F.S < b.F.S)
		return 1;
	if(a.F.S > b.F.S)
		return 0;
	if(a.F <= b.F)
		return 1;
	return 0;
}

const int N = (2e5) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 2*550;
const int SQRT = BUCK+9;

string s;
bool mark[26];

void solve()
{
	int n, i, j, k;
	cin >> s;
	n = s.length();
	if(n < 26)
	{
		for(auto x : s)
			mark[x-'a'] = 1;
		cout << s;
		fo(i,0,26)
			if(!mark[i])
			{
				cout << (char)(i+'a') << '\n';
				return;
			}
	}
	else
	{
		for(i = n-1; i >= 0; i--)
		{
			fo(j,0,26)
				mark[j] = 0;
			fo(j,0,i)
				mark[s[j]-'a'] = 1;
			fo(j,(int)(s[i]-'a')+1,26)
				if(!mark[j])
				{
					fo(k,0,i)
						cout << s[k];
					cout << (char)(j+'a');
					cout << '\n';
					return;
				}
		}		
	}
	cout << -1 << '\n';
	return;
}

int main()
{
	sws;
	clock_t clk;
	clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	int t = 1, cs;
	cout << fixed << setprecision(9);
	// cin >> t;
	fo(cs,1,t+1)
	{
		// cout << "Case #" << cs << ": ";
		solve();
	}
	// Code ends here

	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-


def main():
    from collections import deque

    s = input()
    q = int(input())
    d = deque()
    d.append(s)
    reverse_count = 0

    for i in range(q):
        qi = input().split()

        if qi[0] == '1':
            reverse_count += 1
        else:
            if reverse_count % 2 == 0:
                if qi[1] == '1':
                    d.appendleft(qi[2])
                else:
                    d.append(qi[2])

            else:
                if qi[1] == '1':
                    d.append(qi[2])
                else:
                    d.appendleft(qi[2])

    c = ''.join(map(str, d))

    if reverse_count % 2 == 1:
        c = c[::-1]

    print(c)


if __name__ == '__main__':
    main()


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

int main() {
    int n; long long k;
    cin >> n >> k;
    vector<long long> v(n);
    for (int i = 0; i < n; i++) cin >> v[i];
    deque<long long> kk;
    long long u = k;
    while (u) {
        kk.push_back(u&1);
        u /= 2;
    }
    int maxdigit = 40;
    long long count[maxdigit][2];
    memset(count, 0, sizeof(count));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < maxdigit; j++) {
            if (v[i] & (1LL << j)) count[j][1]++;
            else count[j][0]++;
        }
    }
    long long dpmax[maxdigit];
    for (int i = 0; i < maxdigit; i++) {
        if (i == 0) dpmax[i] = max(count[0][0], count[0][1]);
        else {
            dpmax[i] = dpmax[i-1] + max(count[i][0], count[i][1]) * (1LL << i);
        }
    }
    long long ans = 0;
    long long tmp = 0;
    for (int i = maxdigit - 1; i >= 0; i--) {
        if (i >= kk.size()) {
            tmp += count[i][1] * (1LL << i);
            ans = max(tmp, ans);
        } else {
            if (kk[i] == 1) {
                if (i > 0) ans = max(ans, tmp + dpmax[i-1] + count[i][1] * (1LL << i));
                else ans = max(ans, tmp+dpmax[0]);
                tmp += count[i][0] * (1LL << i);
                ans = max(ans, tmp);
            } else {
                tmp += count[i][1] * (1LL << i);
                ans = max(ans, tmp);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    long long ans = 0;
    vector<long long> res(n, 0);
    for (int i = 0; i < n; i++) {
        if (i - a[i] > 0) ans += res[i - a[i]];
        if (a[i] + i < n) res[a[i] + i]++;
    }
    
    cout << ans << '\n';
    
    return 0;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
#define ll long long
#define pi 3.14159265358979
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

int main(){
    ll n,k,cost=0;
    cin>>n>>k;
    vector<ll> h(n);
    rep(i,n){
        cin>>h[i];
    }
    sort(h.begin(),h.end());
  reverse(h.begin(),h.end());
    rep(i,n){
        if(i>=k){
            cost+=h[i];
        }
    }
    cout<<cost;
}

Measured memory_bytes: 4840
#include "bits/stdc++.h"
using namespace std; 
#define LIM 100003
#define M 1000000007
#define inf 99999999999999999LL	//long long inf
typedef long long ll;

#define sc(x) scanf("%d",&x);
#define sc2(x,y) scanf("%d%d",&x,&y);
#define sc3(x,y,z) scanf("%d%d%d",&x,&y,&z);
#define scl(x) scanf("%lld",&x);
#define scl2(x,y) scanf("%lld%lld",&x,&y);
#define scl3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z);

#define pb push_back
#define mp make_pair
#define fi first
#define se second 
ll power(ll x,ll y,ll z) {	ll ret = 1;	while(y > 0) {	if(y & 1) ret = (ret*x)%z;x = (x*x)%z;y >>= 1;}return ret;}


#define debug(x) cerr<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define debug4(x,y,z,a) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#a<<" :: "<<a<<"\n";




int n, m, vis[LIM], dp[LIM], maxi;
vector< int >graph[LIM] ;
void dfs(int start) {
	dp[start] = 1 ;
	vis[start] = 1 ;
	for(int ele : graph[start]) {
		if(vis[ele])	continue ;
		dfs(ele) ;
	}
	for(int ele : graph[start]) {
		dp[start] = max(dp[start], dp[ele]+1) ;
	}
	maxi = max(maxi, dp[start]-1) ;

}
int main() {
	int i, j, t;
	sc2(n, m) ;
	while(m--) {
		int st, en;	sc2(st, en) ;
		graph[st].pb(en) ;
	}
	for(i=1; i<=n ; i++) {
		if(vis[i] == 0)
			dfs(i) ;
	}
	cout << maxi << endl ;


	return 0;
}




Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N, K;
    cin >> N >> K;
    
    int ans = 0;
    for (int i = 0; i < N; i++){
        int x;
        cin >> x;
        ans += 2 * min( abs(x-0), abs(K-x));
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::HashSet;
use std::cmp;
use std::f64::consts;

fn main() {
    let n: i32 = read();
    let vec: Vec<(i32,i32,i32)> = (0..n).map(|_| (read(),read(),read())).collect();

    let mut ans: String = "".to_string();

    'outer: for cx in 0..101 {
        'inner: for cy in 0..101 {
            let mut set: HashSet<i32> = HashSet::new();

            'last: for t in vec.iter() {
                let height: i32 = calculate_height(
                    t.0,
                    cx,
                    t.1,
                    cy,
                    t.2
                );

                if t.2 == 0 {
                    continue 'last;
                }
                set.insert(height);
            }

            if set.len() == 1 {
                let v: Vec<i32> = set.into_iter().collect();
                let top_height: i32 = v[0];

                let mut ok: bool = true;
                'a: for t in vec.iter() {
                    if !height_is_ok(
                        top_height,
                        t.0,
                        cx,
                        t.1,
                        cy,
                        t.2
                    ) {
                        ok = false;
                        break 'a;
                    }
                }
                if ok {
                    ans = format!("{} {} {}", cx, cy, top_height);
                    break 'outer;
                }
            }
        }
    }

    println!("{}", ans);
}

fn height_is_ok(
    h: i32,
    xi: i32,
    cx: i32,
    yi: i32,
    cy: i32,
    hi: i32
) -> bool {
    let height = cmp::max((h-(xi-cx).abs() - (yi-cy).abs()), 0);
    return height == hi;
}

fn calculate_height(
                xi: i32,
                cx: i32,
                yi: i32,
                cy: i32,
                hi: i32
) -> i32 {
    return (xi-cx).abs() + (yi-cy).abs() + hi;
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 4352
N, K = gets.split.map &:to_i
AB = $<.map{|s|s.split.map &:to_i}
aa = [K]
K.to_s(2).scan(/./){aa << ($`+?0+($&==?0 ? $' : (?1*$'.size))).to_i(2)}
aa.map{|s|s.to_s(2)}

sums = aa.map{|key|[key, 0]}.to_h
AB.each{|a, b|
  sums.each_key{|key|
    sums[key] += b if a | key <= key
  }
}
p sums.values.max


Measured memory_bytes: 11540
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

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

    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(n));
    rep(i, n) rep(j, n) cin >> a[i][j];

    vector<int> dp(1 << n);
    dp[0] = 1;
    rep(s, 1 << n){
        int x = 0;
        rep(i, n){
            if((s >> i) % 2){
                x++;
            }
        }
        rep(i, n){
            if((s >> i) % 2){
                continue;
            }
            if(a[x][i] == 0){
                continue;
            }
            dp[s|(1<<i)] += dp[s];
            dp[s|(1<<i)] %= MOD;
        }
    }
    cout << dp[(1<<n)-1] << endl;

    return 0;
}


Measured memory_bytes: 16640
while gets
a=$_.split.map(&:to_i)
b=gets.split.map(&:to_i)
c,d=0,0;
4.times{|i|
if a[i]==b[i] then
c+=1
else
d+=1 if b.find{|j|j==a[i]}
end
}
print c," ",d,"\n"
end

Measured memory_bytes: 8564
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_map>
#include<unordered_set>
using namespace std;
typedef long long ll;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;
#define mul(a,b) a=a*b%mod;
ll n,L,q;
ll x[100010];
ll p[20][100010];
int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>x[i];
  cin>>L;
  for(int i=0;i<n;i++){
      ll l=i,r=n,mid;
      while(l<r-1){
          mid=(l+r)>>1;
          if(x[mid]<=x[i]+L)l=mid;
          else r=mid;
      }
      p[0][i]=l;
  }
  for(int d=0;d<19;d++)for(int i=0;i<n;i++){
      p[d+1][i]=p[d][p[d][i]];
  }
  cin>>q;
  while(q--){
      ll a,b; cin>>a>>b; a--,b--;
      if(a>b)swap(a,b);
      ll ans=1;
      for(int d=19;d>=0;d--){
          if(p[d][a]<b){
              ans+=(1<<d);
              a=p[d][a];
          }
      }
      cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 17280
program main
  implicit none
  integer(8) :: n, k, mi, ma, md, i
  integer(8), allocatable :: a(:)
  read *, n, k
  allocate (a(n))
  read *, a(:)
  call quicksort(a)

  ! 積がthres以下になるペアがk個以上ある最小のthres
  mi = -2 * 10_8 ** 18  ! NG
  ma = 2 * 10_8 ** 18  ! OK
  do i = 1, 70
    md = mi + (ma - mi) / 2
    if (isok(md)) then
      ma = md
    else
      mi = md
    end if
    if (ma - mi <= 1) exit
  end do

  print "(i0)", ma

  contains

  logical function isok(x)
    ! 積がx以下になるペアがk個以上ある
    integer(8), intent(in) :: x
    integer(8) :: i, cnt, jmin, jmax, count_j, mi, ma, md, j
    cnt = 0
    jmax = n
    if (x < 0) then
      jmin = 1
    else
      jmin = n + 1
    end if
    do i = 1, n - 1
      if (a(i) >= 0) then
        ! a(i) * a(j) <= x となる最大のj > iを求める
        jmax = max(jmax, i)
        do while (jmax > i)
          if (a(jmax) * a(i) > x) then
            jmax = jmax - 1
          else
            exit
          end if
        end do
        count_j = jmax - i
      else
        ! a(i) * a(j) <= x となる最小のj > iを求める
        jmin = max(jmin, i + 1)
        if (x < 0) then
          do while (jmin <= n)
            if (a(jmin) * a(i) > x) then
              jmin = jmin + 1
            else
              exit
            end if
          end do
          count_j = n - (jmin - 1)
        else
          do while (jmin > i + 1)
            if (a(jmin - 1) * a(i) <= x) then
              jmin = jmin - 1
            else
              exit
            end if
          end do
          count_j = n - (jmin - 1)
          ! mi = i  ! ng
          ! ma = n + 1  ! ok
          ! do j = 1, 30
          !   md = mi + (ma - mi) / 2
          !   if (a(i) * a(md) <= x) then
          !     ma = md
          !   else
          !     mi = md
          !   end if
          !   if (ma - mi <= 1) exit
          ! end do
          ! count_j = n - (ma - 1)
        end if
      end if
      cnt = cnt + count_j
    end do
    isok = (cnt >= k)
  end function isok

  recursive subroutine quicksort(a)
    integer(8), intent(inout) :: a(:)
    integer(8) :: pivot, i, j, k, tmp, n
    real(8) :: r
    n = size(a)
    if (n <= 1) return
    i = 1
    j = n
    call random_number(r)
    k = 1 + floor(r * n)
    k = max(1_8, min(k, n))
    pivot = a(k)
    do
      do while (.not. pivot <= a(i))
        i = i + 1
      end do
      do while (.not. a(j) <= pivot)
        j = j - 1
      end do
      if (i >= j) exit
      tmp = a(i)
      a(i) = a(j)
      a(j) = tmp
      i = i + 1
      j = j - 1
    end do
    call quicksort(a(1:i - 1))
    call quicksort(a(j + 1:n))
  end subroutine quicksort
end program main


Measured memory_bytes: 2432
program probC
  implicit none
  integer i,j,a,b,c,tmp,min,max,mid,ans,N,t
  integer abc(3),par(3)

  read(*,*) a,b,c

  abc(1) = a
  abc(2) = b
  abc(3) = c

  N = 3
  do i=1,N-1
     do j=i+1,N
        if(abc(i) .gt. abc(j))then
           t=abc(i)
           abc(i)=abc(j)
           abc(j)=t
        end if
     end do
  end do  

  ans = 0
  do i=1,3
     par(i) = mod(abc(i),2)
  end do

  if(sum(par)==1)then
     ans = ans+1
     do i =1,3
        if ( par(i)==0 ) then
           abc(i)=abc(i)+1
        end if
     end do
  else if(sum(par)==2)then
     ans = ans+1     
     do i =1,3
        if ( par(i)==1) then
           abc(i)=abc(i)+1
        end if
     end do
  end if

  write (*,*)ans+ (2*abc(3)-abc(2)-abc(1))/2




     
    
end program probC


Measured memory_bytes: 768
#include<stdio.h>

int main(){

    int N;
    int p[10];
    int i;
    int max=0;
    int num=0;
    int sum=0;
    
    
    scanf("%d",&N);
    
    for(i=0;i<N;i++){
        scanf("%d",&p[i]);
    }
    
    for(i=0;i<N;i++){
        if(max<p[i]){
            max = p[i];
            num = i;
        }
    }
    
    for(i=0;i<N;i++){
        if(num == i){
            sum += p[i]/2;
        }else{
            sum += p[i];
        }
    }
    
    printf("%d",sum);
    

    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <string>

using namespace std;

#include<stdio.h>
#include <stdlib.h>

class UniteTree{
	public:
		static const int DEFUALTSIZE=100;
		UniteTree();
		UniteTree(int n);
		~UniteTree();
		void unite(int x,int y);
		int find(int x);
		bool same(int x,int y);
		int size(){return _size;};
	private:
		int* _par;
		int* _rank;
		int _size;
		void init(int n){
			_size=n;
			_par = (int *)malloc(n*sizeof(int));
			_rank = (int *)malloc(n*sizeof(int));
			for(int i=0;i<n;i++){
				_par[i]=i;
				_rank[i]=0;
			}
		}
};


UniteTree::~UniteTree(){
	free(_par);
	free(_rank);
}

UniteTree::UniteTree(){
	init(DEFUALTSIZE);
}

UniteTree::UniteTree(int n){
	init(n);
}

int UniteTree::find(int x){
	if(_par[x]==x){
		return x;
	}else{
		return _par[x]=find(_par[x]);
	}
}

void UniteTree::unite(int x,int y){
	x=find(x);
	y=find(y);
	if(x==y)return;
	if(_rank[x]<_rank[y]){
		_par[x]=y;
	}else{
		_par[y]=x;
		if(_rank[x]==_rank[y])_rank[x]++;
	}
}

bool UniteTree::same(int x,int y){
	return find(x)==find(y);
}


int main()
{
	int N,M;
	
	cin>>N>>M;
	vector<int> buf(N,1);
	auto uf = UniteTree(N);
	for (int i= 0;i<M ;i++){
		int x,y,z;
		cin>>x>>y>>z;
		uf.unite(x-1,y-1);
	}
	int ans = 0;
	for (int i= 0;i<N;i++){
		auto x = uf.find(i);
		if (buf[x]){
			buf[x]=0;
			ans+=1;
		}
	}
	cout << ans <<endl;
}

Measured memory_bytes: 1408
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

s = rs()
k = ri()
ss = set()
n = len(s)
for i in range(n):
    for j in range(1, 6):
        ss.add(s[i:i + j])
print(sorted(ss)[k - 1])

Measured memory_bytes: 4464
#include<bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,m,n) for(lli i = m;i <= n;i++)
#define per(i,m,n) for(lli i=m-1;i>=n;i--)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
using namespace std;
int main(){
  bool ok=false;
  int i,j,k;
  lli n,a,b,x,y,z,ans=200001;
  string s,t,r;
  cin>>a>>b;
  rep(i,1,b)
    if((a*i)%b==0){
      cout<<a*i<<endl;
      return 0;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */


int main() {
    vector<bool> check(110, false);
    vector<vector<int>> A(3, vector<int>(3));
    rep(i, 3) {
        rep(j, 3) {
            cin >> A[i][j];
            check[A[i][j]] = true;
        }
    }
    int n, b;
    cin >> n;
    rep(i, n) {
        cin >> b;
        if(check[b] == true) {
            rep(j, 3) {
                rep(k, 3) {
                    if(A[j][k] == b) {
                        A[j][k] = 0;
                    }
                }
            }
        }
    }
    bool ans = false;
    int sumv, sumh;
    rep(i, 3) {
        sumv = 0, sumh = 0;
        rep(j, 3) {
            sumv += A[j][i];
            sumh += A[i][j];
        }
        if(sumv == 0 || sumh == 0) ans = true;
    }
    if(A[0][0] + A[1][1] + A[2][2] == 0 || A[0][2] + A[1][1] + A[0][2] == 0) ans = true;

    if(ans == true) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
X, Y = map(int, input().split())
from math import floor
def Main(X, Y):
    a = (Y-2*X)/2
    b = (4*X-Y)/2
    
    if a < 0 or b < 0:
        return "No"
    elif (a > 0 and floor(a) == a) or (b > 0 and floor(b) == b):
        return "Yes"
    else:
        return "No"
        
    
res = Main(X, Y)
print(res)

Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
const int N=220000;
char s[N];
int l[N],r[N];
int n,k,c;
int main(){
	scanf("%d%d%d%s",&n,&k,&c,s+1);
	
	int i=1,kk=1;
	while(kk<=k){
		if(s[i]=='o')l[kk++]=i,i+=c;
		++i; 
	}
	
	i=n,kk=k;
	while(kk){
		if(s[i]=='o')r[kk--]=i,i-=c;
		--i; 
	}
	
	for(i=1;i<=k;++i)if(l[i]==r[i])printf("%d\n",l[i]);
	
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#define pb push_back
using namespace std;
typedef pair<int,int> pii;

int main(){
  int k;
  cin>>k;
  if(k%2==1) cout<<(k/2)*(k/2+1)<<endl;
  else cout<<(k/2)*(k/2)<<endl;
	       
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long N,x,sum=0;
  cin >> N >> x;
  vector<long> A(N);
  for (long i=0;i<N;i++) {
    cin >> A.at(i);
  }
  
  sort(A.begin(),A.end());
  
  for (long i=0;i<N;i++) {
    sum += A.at(i);
    if (x < sum) {
      cout << i << endl;
      break;
    }
    if (i==N-1) {
      if (x == sum) {
        cout << N << endl;
      }
      else {
        cout << N-1 << endl;
      }
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
#define mod 1e9 + 7;

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

	ll a, b, c, n, m, ans = 0;
	string s;
	cin >> s;
	rep(i, s.size()) {
		if (s[i] == '+') ans++;
		else ans--;
	}
	cout << ans << endl;
		return 0;
}

Measured memory_bytes: 256
N,Y = map(int,input().split())

def solve(N,Y):
    for i in range(N+1):
        for j in range(N+1-i):
            if (Y-(i*10000 + j*5000)) // 1000 != N - i - j:
                continue
            if(Y-(i*10000 + j*5000))  < 0:
                continue
            print(i,j,(Y-(i*10000 + j*5000)) //1000)
            return False
    return True

if solve(N,Y):
    print(-1,-1,-1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int A;
  cin >> A;
  vector<int> vec(A);
  int AAA;
  rep(i, A) {
    cin >> AAA;
    vec.at(i) = AAA;
  }
  sort(vec.begin(), vec.end());
  cout << vec.at(A - 1) - vec.at(0) << endl;
}

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

using namespace std;
int main() {
    int a,b;
    cin>>a>>b;
    if(a==1&&b==2)cout<<3<<endl;
    if(a==1&&b==3)cout<<2<<endl;
    if(a==2&&b==3)cout<<1<<endl;
    if(a==2&&b==1)cout<<3<<endl;
    if(a==3&&b==1)cout<<2<<endl;
    if(a==3&&b==2)cout<<1<<endl;

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

# 入力を各変数に格納
a, b, c, d = map(int, input().split())

# 直接可能
if abs(a - c) <= d:
	print("Yes")
# 間接可能
elif abs(a - b) <= d and abs(b - c) <= d:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3060
#!/usr/bin/env python3

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    s = input()
    print(s.count('+') - s.count('-'))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064