akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll max(ll a, ll b){
    if(a > b) return a;
    else return b;
}
 
ll min(ll a, ll b){
    if(a < b) return a;
    else return b;
}

int main(void){
    int A,B,C; cin >> A >> B >> C;
    cout << max(0, C - (A - B)) << endl;
}

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

int main(){
    int n,l;
    int aji;
    ll sum;
    cin >> n >> l;
    int mi=300;
    sum=(l+(l+n-1))*n/2;
    rep(i,n){
        aji=l+i;
        if(abs(mi)>abs(aji)) mi=aji;
    }
    cout << sum-mi << endl;
    return 0;
}

Measured memory_bytes: 256
L = int(input())

N = 1
l = L
while l // 2 >= 1:
    N += 1
    l //= 2

G = [[] for _ in range(N + 1)]

for i in range(1, N):
    G[i].append([i + 1, 0])
    G[i].append([i + 1, 2 ** (N - 1 - i)])

M = 2 * (N - 1)
tmp = 2 ** (N - 1)

for i in range(N - 2, -1, -1):
    if (L >> i) & 1:
        G[1].append([N - i, tmp])
        tmp += 2 ** i
        M += 1

if N > 20 or M > 60:
    print ('error')

print (N, M)
for i in range(1, N):
    for j in G[i]:
        print (i, *j)

Measured memory_bytes: 3064
a,b = map(int,input().split())
A = max(a,b)
B = min(a,b)
res = 16
while True:
  A -= 1
  res -= 1
  B -= 1
  res -= 1
  if B == 0: break
    
if A <= res//2:
  print("Yay!")
else:
  print(":(")

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

typedef long long ll;
typedef pair<ll, ll> P;


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);

int main() {
    string s;
    cin >> s;
    ll ans = 0, tmp = 0;
    rep(i, s.size()) {
        if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') tmp++;
        else {
            tmp = 0;
        }
        if(ans < tmp) ans = tmp;
    }
    
    cout << ans << endl;
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        ret %= MOD;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,n) for(int (i) = (a);(i) < (n);(i)++)
typedef long long ll;

using namespace std;

int main(){
	int n,m,t[100],p[100],p_num[100],memo = 0;
	
	cin >> n;
	rep(i,0,n){
		cin >> t[i];
	}
	cin >> m;
	rep(i,0,m){
		cin >> p_num[i] >> p[i];
	}
	
	rep(i,0,m){
		memo = 0;
		rep(j,0,n){
			if(p_num[i]-1 == j){
				memo += p[i];
			}
			else{
				memo += t[j];
			}
		}
		cout << memo << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>

using namespace std;
using lli = long long int;
// #define DEBUG
#ifdef DEBUG
#define debug(var) cout << (#var) << ": " << (var) << endl;
template<class T> void dump_array_impl(const T& a) {
  bool first = true;
  for (auto&& x : a) {
    if (!first) { cout << ", "; first = false; }
    cout << x;
  }
}
#define debug_array(a) cout<<(#a)<<": ";dump_array_impl(a);cout<<endl
#else
#define debug(var) {}
#define debug_array(a) {}
#endif
template<class T> void read_n(vector<T>& v, size_t n) {
  v = vector<T>(n);
  for (lli i=0; i<n; ++i) cin >> v[i];
}


int main() {
  lli n, m, x, y;
  cin >> n >> m >> x >> y;
  vector<lli> xs(n+1), ys(m+1);
  xs[n] = x; ys[m] = y;
  for (int i=0;i<n;++i) cin >> xs[i];
  for (int i=0;i<m;++i) cin >> ys[i];
  sort(begin(xs), end(xs));
  sort(begin(ys), end(ys));
  bool res = xs[n] < ys[0];
  cout << (res ? "No War" : "War") << endl;
  return 0;
}


Measured memory_bytes: 256
nmax = 2001
mod = 10**9+7

fac = [1]*nmax
finv = [1]*nmax
inv = [1]*nmax
def ncr_pre():
    for i in range(2,nmax):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod%i] * (mod//i) %mod
        finv[i] = finv[i-1] * inv[i] %mod

def ncr(n,r):
    if n<r:
        return 0
    if n<0 or r<0:
        return 0
    return fac[n]* (finv[r] * finv[n-r] %mod) %mod
ncr_pre()
n,k = map(int,input().split())
for i in range(1,k+1):
    print((ncr(n-k+1,i)*ncr(k-1,i-1))%mod )


Measured memory_bytes: 3572
n = int(input())
if n % 2:
    print(((n - 1) * (n - 2) + (n - 1)) // 2)
else:
    print(n * (n - 2) // 2)
for i in range(n):
    for j in range(i + 1, n):
        if i + j != n - 2 + (0 if n % 2 else 1):
            print(i + 1, j + 1)


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

int main(){
	int n;
	int sequence[5000];
	int ans;
	int sum;

	while(cin >> n, n){
		for(int i=0; i < n; i++){
			cin >> sequence[i];
		}
		ans = sequence[0];

		for(int i=0; i < n; i++){
			sum = 0;
			for(int j=i; j < n; j++){
				sum += sequence[j];
				ans = max(sum, ans);
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1176
#include<iostream>
#include<string>
int main()

{
    std::string s; 
    std::cin >> s;

    if (s[2]==s[3] && s[4]==s[5]){
     std::cout <<  "Yes"  << std::endl;  
    }
    else{
     std::cout << "No" << std::endl; 
    }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;

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

int main(){
    vector<int> a(3);
    for(int i=0; i<3; i++) cin>>a[i];
    sort(a.begin(), a.end());
    cout << a[0]*a[1]/2 << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<map>
#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
	int n;
	cin>>n;
	int x;
	x=n/3;
	cout<<x<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vec> mat;
int main(){
    int n,A[18],B[18],ans=1e9;
    cin>>n;
    rep(i,n) cin>>A[i];
    rep(i,n) cin>>B[i];
    rep(i,pow(2,n)){
        vec X;
        int p=i;
        rep(j,n) X.push_back(p%2),p/=2;
        vector<P> Y;
        rep(j,n){
            int a=A[j];
            if(X[j]==1) a=B[j];
            Y.push_back(P(a,j));
        }
        sort(Y.begin(),Y.end());
        int z=1;
        rep(j,n){
            if(abs(Y[j].second-j)%2!=X[Y[j].second]){
                int k=1;
                while(true){
                    if(j<n-k&&Y[j].first==Y[j+k].first) swap(Y[j],Y[j+k]);
                    else break;
                    if(abs(Y[j].second-j)%2==X[Y[j].second]) break;
                    k++;
                }
                if(abs(Y[j].second-j)%2!=X[Y[j].second]) z=0;
            }
        }
        if(z){
            vec Z;
            rep(j,n) Z.push_back(Y[j].second);
            int c=0;
            rep(j,n){
                rep(k,n-j-1) if(Z[j]>Z[k+j+1]) c++;
            }
            ans=min(c,ans);
        }
    }
    if(ans==1e9) cout<<-1;
    else cout<<ans;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

// conversion
//------------------------------------------
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();
}

// math
//-------------------------------------------
template <class T> inline T sqr(T x) { return x * x; }

// typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

// container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#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 SORT(c) sort((c).begin(), (c).end())

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

// constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

// clear memory
#define CLR(a) memset((a), 0, sizeof(a))

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                                               \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \
       << " " << __FILE__ << endl;

void solve(long long X, long long A) {
  if(X<A)cout<<0<<endl;
  else cout<<10<<endl;
}

int main() {
  long long X;
  scanf("%lld", &X);
  long long A;
  scanf("%lld", &A);
  solve(X, A);
  return 0;
}


Measured memory_bytes: 256
# https://onlinejudge.u-aizu.ac.jp/courses/library/4/CGL/all/CGL_2_B
# この問題は後の点の内包に繋がります
from math import sqrt


class Vector:
    def __init__(self, ls):
        '''
        ls ... list
        '''
        self.vec = ls

    def __len__(self):
        return len(self.vec)

    def __getitem__(self, idx):
        return self.vec[idx]

    def __repr__(self):
        return f'Vector({self.vec})'

    def add(self, vec):
        '''
        vec ... vector class
        '''
        assert len(self) == len(vec)
        ret = [a + b for a, b in zip(self.vec, vec.vec)]
        return Vector(ret)

    def sub(self, vec):
        '''
        vec ... vector class
        '''
        assert len(self) == len(vec)
        ret = [a - b for a, b in zip(self.vec, vec.vec)]
        return Vector(ret)

    def mul(self, vec):
        '''
        vec ... vector class
        '''
        assert len(self) == len(vec)
        ret = [a * b for a, b in zip(self.vec, vec.vec)]
        return Vector(ret)

    def norm(self):
        tmp = sum([x * x for x in self.vec])
        return sqrt(tmp)


def norm(vec):
    '''
    vec ... Vector class
    '''
    return vec.norm()


def cross(a, b):
    '''
    Outer product for 2d
    a,b ... Vector class
    '''
    assert len(a) == 2 and len(b) == 2
    first = a[0] * b[1]
    second = a[1] * b[0]
    return first - second


def dot(a, b):
    return sum(a.mul(b))


EPS = 1e-10


def ccw(p0, p1, p2):
    '''
    問題を解くための関数
    引数はすべてVector
    '''
    a = p1.sub(p0)
    b = p2.sub(p0)
    if cross(a, b) > EPS:
        # 'COUNTER_CLOCKWISE'
        return 1
    elif cross(a, b) < -EPS:
        # 'CLOCKWISE'
        return -1
    elif dot(a, b) < 0:  # 同一直線状でa,bが逆を向いている
        # 'ONLINE_BACK'
        return 2
    elif a.norm() < b.norm():  # a,bが同じ方向を向いて かつ bがaよりも長い
        # 'ONLINE_FRONT'
        return -2
    else:
        # 'ON_SEGMENT'
        return 0


def is_intersect(args: list):
    x0, y0, x1, y1, x2, y2, x3, y3 = args
    p0 = Vector([x0, y0])
    p1 = Vector([x1, y1])
    p2 = Vector([x2, y2])
    p3 = Vector([x3, y3])
    return (ccw(p0, p1, p2) * ccw(p0, p1, p3) <= 0) and (ccw(p2, p3, p0) * ccw(p2, p3, p1) <= 0)


# load data
N = int(input())
for _ in range(N):
    if is_intersect(list(map(int, input().split()))):
        print(1)
    else:
        print(0)



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

#define REP(i,s,n) for(int i=s; i<n; ++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

typedef long long ll;
typedef pair<int, int> ii;

int main(){
  int x, y, z;
  cin >> x >> y >> z;
  cout << z << " " << x << " " << y << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<algorithm>
using namespace std;
#define C(x) (x*x*x)
int main()
{
	long long x,y,z,r;
	while(cin>>z,z)
	{
		r=LLONG_MAX;
		for(x=1;C(x)<=C(z);++x)for(y=x;C(x)+C(y)<=C(z);++y)r=min(r,C(z)-C(x)-C(y));
		cout<<r<<endl;
	}
	return 0;
}

Measured memory_bytes: 864
# -*- coding: utf-8 -*-
S=raw_input()
l=len(S)

dp=[ [ 0 for j in range(13)] for i in range(l+1) ]
dp[0][0]=1

mod=10**9+7
keta=pow(10,l-1,13)

for i in range(1,l+1):
	for j in range(13):
		if dp[i-1][j]!=0:
			if S[i-1]=="?":
				for k in range(10):
					dp[i][ (k*keta+j)%13 ]+=dp[i-1][j]
					dp[i][ (k*keta+j)%13 ]%=mod
			else:
				k=int(S[i-1])
				dp[i][ (k*keta+j)%13 ]+=dp[i-1][j]
				dp[i][ (k*keta+j)%13 ]%=mod

	keta=(keta*4)%13	#フェルマーの小定理より 10*(10**(p-1))=1(mod p)   p=13　なので、10**11(mod13)が、10の逆元

print dp[-1][5]


Measured memory_bytes: 50332
import java.util.Scanner;

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

		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), d = sc.nextInt();

		System.out.println(Math.max(a * b, c * d));
	}
}


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

h,w = list(map(int,input().split()))
maze = [list(input()) for i in range(h)]
for i in maze:
    i.insert(0,"#")
    i.append("#")
maze.insert(0,["#"]*(w+2))
maze.append(["#"]*(w+2))


import copy
def clear_maze(maze,target=0):
    con = False
    for r,v1 in enumerate(maze):
        for c,v2 in enumerate(v1):
            if v2==target:
                con = True
                if maze[r-1][c]==".":
                    maze[r-1][c]=target+1
                if maze[r+1][c]==".":
                    maze[r+1][c]=target+1
                if maze[r][c-1]==".":
                    maze[r][c-1]=target+1
                if maze[r][c+1]==".":
                    maze[r][c+1]=target+1
    if con:
        return clear_maze(maze,target+1)
    else:
        return target - 1
ret = 0
for i in range(h+1):
    for j in range(w+1):
        if maze[i][j]==".":
            m = copy.deepcopy(maze)
            m[i][j]=0
            ret = max(ret,clear_maze(m))

print(ret)

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n,q,c,up,low,t,x,y,arr[4],a,b;
string str,str1;
bool f;

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


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
//#define endl '\n'

using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 100 + 5, LG = 19, MOD = 1e9 + 7;
const int SQ =225;
const string INIT = "codeforces";

int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif


  int x;
  cin >> x;

  int cnt = 1;
  while(cnt * x % 360)cnt++;
  cout << cnt << endl;


  return 0  ;
}


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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll a, b, c; cin >> a >> b >> c;
  cout << (((a<c&&c<b) || (a>c&&c>b)) ? "Yes" : "No") << endl;

  return 0;
}



Measured memory_bytes: 3556
import math

def input_number():
    return int(input())

def input_1line_list(number_of_input):
    return [input() for i in range(number_of_input)]

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

# def print_unique_length(input_list):
#     print(len(set(input_list)))

def main():
    x = input_number()
    year = 0
    money = 100
    while money < x:
        money += money//100
        year += 1
    print(year)

if __name__ == '__main__':
    main()

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

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	string a[105];
	int h, w;
	cin >> h >> w;
	rep(i, h){
		cin >> a[i];
		a[i] = "#" + a[i] + "#";
	}

	rep(i, w+2){
		s += "#";
	}

	cout << s << endl;

	rep(i, h){
		cout << a[i] << endl;
	}

	cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)
#define F first
#define S second

using namespace std;
int n,key[110];
string s;
char alp[52] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
              'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};

int main() {
  while(1){
    cin>>n;
    if(n==0) break;
    REP(i,0,n) cin>>key[i];
    cin>>s;
    REP(i,0,s.size()){
      int pos=-1;
      REP(j,0,52){
        if(alp[j]==s[i]){
          pos = j;
          break;
        }
      }
      cout<<alp[(pos - key[i%n] + 52*10000)%52];
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 3192
def main():
    N = int(input())
    a = [None for _ in range(N)]
    b = [None for _ in range(N)]
    c = [None for _ in range(N)]
    for i in range(N):
        a[i], b[i], c[i] = map(int, input().split())
    dp = [None for _ in range(N)]
    dp[0] = [a[0], b[0], c[0]]
    for i in range(1, N):
        dp[i] = [None for _ in range(3)]
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i]
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i]
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i]
    print(max(dp[-1]))


if __name__ == "__main__":
    main()


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

int a1[4] = {1, 0, -1, 2};
int a2[4] = {-1, 0, 1, -2};

int main(){

    int N, x; cin >> N >> x;
    if(x == 1 || x == 2*N - 1){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
        vector<int> ans(2*N - 1);
        for(int i = 0; i < 2*N - 1; i++) ans[i] = i + 1;

        if(x == 2){
            
            for(int j = 0; j < 4; j++){
                int idx = N - j;
                for(int k = 0; k < 2*N - 1; k++){
                    if(ans[k] == x + a1[j]){
                        swap(ans[idx], ans[k]);
                        break;
                    }
                }
            }

        }else{

            for(int j = 0; j < 4; j++){
                int idx = N - j;
                for(int k = 0; k < 2*N - 1; k++){
                    if(ans[k] == x + a2[j]){
                        swap(ans[idx], ans[k]);
                    }
                }
            }
        }

        for(int j = 0; j < 2*N - 1; j++) cout << ans[j] << endl;
    
    }

    return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;


int main(){  
  int n;
  cin >> n;
  int a=0,b=0,c=0;
  rep(i,n){
    int x; cin >> x;
    if(x%4==0){ a++; continue; }
    if(x%2==0){ b++; continue; }
    c++;
  }
  if(a>=c){ cout << "Yes" << endl; return 0;}
  if(a+1>=c && b==0 ){ cout << "Yes" << endl; return 0;}
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

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

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    long[] a = sc.nextLongArray(n);
    int q = sc.nextInt();
    long[] b = new long[q];
    long[] c = new long[q];
    for (int i = 0; i < q; i++) {
      b[i] = sc.nextLong();
      c[i] = sc.nextLong();
    }
    long sum = 0;
    for (long ai: a) sum += ai;
    Map<Long, Long> counts = new HashMap<>();
    for (long ai: a) counts.merge(ai, 1L, Long::sum);
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < q; i++) {
      if (sb.length() > 0) sb.append("\n");
      if (counts.containsKey(b[i])) {
        long diff = c[i] - b[i];
        long bCount = counts.get(b[i]);
        sum += diff * bCount;
        counts.merge(c[i], bCount, Long::sum);
        counts.remove(b[i]);
      }
      sb.append(sum);
    }
    System.out.println(sb.toString());
  }
}

Measured memory_bytes: 59396
#include<iomanip>
#include<iostream>
#include<cstring>
#include<cmath>
#include<string>
#include<set>
using namespace std;
int s[200005],c[200005]={1};
char str[200005];
long long ans=0;
int main(){
	cin>>(str+1);
	int n=strlen(str+1); 
	for(int i=n,t=1;i>=1;i--,t=t*10%2019){
		s[i]=(s[i+1]+(str[i]-'0')*t)%2019;
		ans+=c[s[i]];
		//cout<<s[i]<<' '<<c[s[i]]<<endl;
		c[s[i]]++;
	}
	cout<<ans;
    return 0;
}


Measured memory_bytes: 4580
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 3010
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
#define INF 1000000000000
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
    int n;
    cin>>n;
    vector<int> l(n);
    REP(i,n){
        cin>>l[i];
    }
    sort(ALL(l));
    ll ans=0;
    REP(i,n-1){
        for(int j=i+1;j<n;j++){
            int p=lower_bound(ALL(l),(l[i]+l[j]))-l.begin()-1;
            int q=upper_bound(ALL(l),abs(l[j]-l[i]))-l.begin();
            ans+=p-q+1;
            if(l[q]<=l[i]&&l[i]<=l[p]) ans--;
            if(l[q]<=l[j]&&l[j]<=l[p]) ans--;
        }
    }
    ans/=3;
    OUT(ans);
    return 0;
}

Measured memory_bytes: 256
s = gets.chomp.split("")


def switch_tile(n)
    n == 0 ? 1 : 0
end

def diff_cnt(left_array, right_array)
    raise RuntimeError.new("size not match #{left_array}:#{right_array}") unless left_array.size == right_array.size
    res = 0
    left_array.each_with_index do |i, idx|
        res += 1 if left_array[idx] != right_array[idx]
    end
    return res
end

def generate_tiles(l, first_zero = true)
    current = 1
    current = 0 if first_zero
    res = ""
    l.times do 
        res += current.to_s
        current = switch_tile(current)
    end
    return res
end

cand_a = generate_tiles(s.size, false).split("")
cand_b = generate_tiles(s.size, true).split("")

diff_a = diff_cnt(cand_a, s)
diff_b = diff_cnt(cand_b, s)

puts [diff_a, diff_b].min

Measured memory_bytes: 108924
#include <iostream>
#include <algorithm>
using namespace std;
using ll=long long;
using R=double;
// Combination Table
ll C[51][51]; // C[n][k] -> nCk
void comb_table(int N){
    for(int i=0;i<=N;++i){
        for(int j=0;j<=i;++j){
            if(j==0 or j==i){
              C[i][j]=1LL;
            }else{
              C[i][j]=(C[i-1][j-1]+C[i-1][j]);
            }
        }
    }
}

int main(void){
  int N,A,B;
  cin>> N>>A>>B;
  constexpr int NMAX=50;
  ll v[NMAX];
  for(int i=0;i<N;++i){
    cin >> v[i];
}
  comb_table(N);
  sort(v,v+N);
  reverse(v,v+N);
  R max_average=0.0;
  for(int i=0;i<A;++i){
    max_average+=v[i];
  }
  max_average/=A;
  int a_th_val_num=0,a_th_val_pos=0;
  for(int i=0;i<N;++i){
    if(v[i]==v[A-1]){
      a_th_val_num++;
      if(i<A){
        a_th_val_pos++;
      }
    }
  }
  ll cnt=0LL;
  if(a_th_val_pos==A){
    for(a_th_val_pos=A;a_th_val_pos<=B;++a_th_val_pos){
      cnt+=C[a_th_val_num][a_th_val_pos];
    }
  }else{
    cnt+=C[a_th_val_num][a_th_val_pos];
  }
  cout.precision(20);
  cout << fixed << max_average << endl;
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import Counter


N = int(input())
lstA = list(map(int, input().split()))
mod = 10**9 + 7
countA = Counter(lstA)
ans = 0

if N % 2:
    if countA[0] == 1 and all(countA[i] == 2 for i in range(2, N, 2)):
        ans = pow(2, N//2) % mod
else:
    if all(countA[i] == 2 for i in range(1, N, 2)):
        ans = pow(2, N//2) % mod


print(ans)


Measured memory_bytes: 14820
# coding: utf-8
# Your code here!

#数学オリンピック_〇×スタンプ

kosu=int(input())

stamp=input()

i=0;
ans=0;

while i<len(stamp)-1:
    if stamp[i]!=stamp[i+1]:
        ans+=1
        i+=2
    else:
        i+=1

print(ans)


Measured memory_bytes: 5792
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	rep(i,n) std::cin >> a[i];
	int app = true;
	rep(i,n) if(a[i]%2==0 && a[i]%3!=0 && a[i]%5!=0) app = false;
	if(app) print("APPROVED");
	else print("DENIED");
	return 0;
}


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

using namespace std;
#define ll long long
int dp[11][11][2];
string s;

int solve(int indx, int last, bool f) {
    if (indx == s.size()) return last != 10;
    int &ret = dp[indx][last][f];
    if (ret != -1) return ret;
    ret = 0;

    for (int i = 0; i <= 9; i++) {
        if (!f && i > s[indx] - '0') break;
        if (last != 10 && abs(last - i) > 1) continue;
        if (!i && last == 10) ret = solve(indx + 1, 10, 1);
        else {
            ret += solve(indx + 1, i, f | (i < s[indx] - '0'));
        }
    }

    return ret;
}

int check(ll m) {
    s = to_string(m);
    memset(dp, -1, sizeof(dp));
    return solve(0, 10, 0);

}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int k;
    cin >> k;
    ll s = 1, e = 3234566667, ans = 3234566667;

    while (s <= e) {
        ll mid = (s + e) >> 1LL;
        if (check(mid) >= k) e = mid - 1, ans = mid;
        else s = mid + 1;
    }
    cout << ans << endl;
    return 0;
}

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


lint key(const V<>& v) {
  lint res = 0;
  for (int i = 0; i < 4; ++i) {
    lint curr = 0;
    for (int j = 0; j < 4; ++j) curr += static_cast<lint>(v[i + j & 3]) << 10 * j;
    res = max(res, curr);
  }
  return res;
}

int coeff(lint key) {
  V<> v(4);
  for (int i = 0; i < 4; ++i) {
    v[i] = key & 1023;
    key >>= 10;
  }
  if (v[0] == v[2] and v[1] == v[3]) {
    if (v[0] == v[1]) return 4;
    return 2;
  }
  return 1;
}

int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n; cin >> n;
  VV<> c; assign(c, n, 4, 0);
  for (int i = 0; i < n; ++i) for (int j = 0; j < 4; ++j) cin >> c[i][j];
  map<lint, lint> mp;
  for (int i = 0; i < n; ++i) ++mp[key(c[i])];
  lint res = 0;
  for (int d = 0; d < n; ++d) for (int u = d + 1; u < n; ++u) {
    --mp[key(c[d])], --mp[key(c[u])];
    for (int dir = 0; dir < 4; ++dir) {
      V<lint> keys(4);
      for (int i = 0; i < 4; ++i) keys[i] = key({c[u][dir - i & 3], c[u][dir - i - 1 & 3], c[d][i + 1 & 3], c[d][i]});
      sort(begin(keys), end(keys));
      int bit = 0;
      for (int i = 0; i < 3; ++i) if (keys[i] == keys[i + 1]) bit |= 1 << i;
      auto f = [&](const V<>& v) -> lint {
        lint res = 1;
        for (int i = 0; i < 4; ++i) res *= coeff(keys[i]) * (mp[keys[i]] - v[i]);
        return res;
      };
      switch (bit) {
        case 0b000: res += f({0, 0, 0, 0}); break;
        case 0b001: res += f({1, 0, 0, 0}); break;
        case 0b010: res += f({0, 0, 1, 0}); break;
        case 0b011: res += f({0, 1, 2, 0}); break;
        case 0b100: res += f({0, 0, 0, 1}); break;
        case 0b101: res += f({0, 1, 0, 1}); break;
        case 0b110: res += f({0, 0, 1, 2}); break;
        case 0b111: res += f({0, 1, 2, 3}); break;
      }
    }
    ++mp[key(c[d])], ++mp[key(c[u])];
  }
  cout << res / 3 << '\n';
}

Measured memory_bytes: 80128
K = int(input())
A = [int(i) for i in input().split()]

A.reverse()

mi, ma = 2, 2

for a in A:
    if ma < ((mi + a - 1) // a) * a:
        print(-1)
        exit()
    mi = (mi + a - 1) // a * a
    ma = (ma // a + 1) * a - 1

print(mi, ma)

Measured memory_bytes: 14252
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		for(int i=0; i<n; i++){
			a[i] = sc.nextLong() - i - 1;
		}
		Arrays.sort(a);
		long b = 0;
		if(n%2==0)b = (a[n/2-1]+a[n/2])/2;
		else b = a[n/2];
		long sum = 0L;
		for(int i=0; i<n; i++){
			sum += Math.abs(a[i]-b);
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 85248
/***

   Author : Md. Jashim Uddin
   From   : RMSTU

 ***/
#include<bits/stdc++.h>
using namespace std;
#define     sf(a)           scanf("%d",&a)
#define     sff(a,b)        scanf("%d %d",&a,&b)
#define     sfff(a,b,c)     scanf("%d %d %d",&a,&b, &c)
#define     pb              push_back
#define     ll              long  long int
#define     fast            ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define     pi              2*acos(0)
#define     sp              fixed<<setprecision
#define     lcm(a,b)        (a*b)/gcd(a,b)
#define     gcd(a,b)        _gcd(a,b)
#define     forn(i,n)       for(int i=1;i<=n;i++)
#define      mx               10001
int main()
{
     string s;
     cin>>s;
    ll k=0,p=0,n=0;

     for(int i=0;i<s.size();++i)
     {
         if(s[i]=='a')k++;
         else if(s[i]=='b')p++;
         else if(s[i]=='c')n++;
     }
    
     if(k==1 && p==1 && n==1)cout<<"Yes"<<endl;
     else cout<<"No"<<endl;


    return 0;
}


Measured memory_bytes: 256
n, s = map(int, raw_input().split())
values = list(map(int, raw_input().split()))
found = False
for pos in range(n - 1):
    if values[pos] + values[pos + 1] >= s:
        found = True
        break
if not found:
    print('Impossible')
    import sys
    sys.exit()
    
result = (n - 1) * [ None ]
result[n - 2] = pos + 1
ix = n - 3
for i in range(pos - 1, -1, -1):
    result[ix] = i + 1
    ix -= 1
for i in range(pos + 1, n - 1):
    result[ix] = i + 1
    ix -= 1
print('Possible')
print('\n'.join(map(str, result)))


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

int main(void)
{
    int n, k;
    cin >> n >> k;

    vector<int> l(n);
    for (int i = 0; i < n; i++)
    {
        cin >> l[i];
    }
    sort(l.begin(), l.end(), greater<int>());
    
    int ans = 0;
    for (int i = 0; i < k; i++)
    {
        ans += l.at(i);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
long long mod=1e9+7;
long long INF=1e7;
double EPS = 1e-12;
const long long lim = 3e5+100;
typedef long long int lld;
typedef long long ll;

#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define mset(a, v) memset(a, v, sizeof(a))
#define Error(x...) { cout << "(" << #x << ")" << " = ( "; printIt(x); }
template <typename T1> void printIt(T1 t1) { cout << t1 << " )" << endl; }
template <typename T1, typename... T2>
void printIt(T1 t1, T2... t2) { cout << t1 << " , "; printIt(t2...); }
 
 
#define popcount __builtin_popcountll
 
ll powP(ll x, ll y) {
    ll ans = 1, po = x % mod;
    while(y > 0) {
        if(y & 1) ans = ans * po % mod;
        y >>= 1; po = po * po % mod;
    }
    return ans;
}

vector<ll> Ans, Adj[lim];
ll Array[lim], Vis[lim];
pair<ll,ll> P[lim];

ll dfs(ll node,ll Vis[]) {
    Vis[node]=1;
    for(auto i:Adj[node]) {
        if(!Vis[i]) dfs(i,Vis); 
    }

    return 0;
}

int main(){

    ios::sync_with_stdio(0);
    cin.tie(0);

    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    
    lld T,i,p,j,l,e,r,b,c,k,m,q,a,d,w,x,y,u,v,z,t,curr,prev,sum=0,val,countA=0,indicator=0,pos,h,minA,maxA,type,n,ans=0,left,right;
    string A,B;
    A = "Yes", B="No";
    cin>>n;
    rep(i,1,n) {
        cin>>x;
        ans = (ans+x*sum)%mod;
        sum = (sum+x)%mod;
    }

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

Measured memory_bytes: 10700
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i, c) for(long long i=0; i<(long long)c; i++)
const ll INF=1000000000000001;
int main() {
	ll a,b,c,d;
	cin >>a>>b>>c>>d;
	vector<ll>x(2);
	x[0]=a;
	x[1]=b;
	vector<ll>y(2);
	y[0]=c;
	y[1]=d;
	ll z=-9223372036854775808;
	for(int i=0;i<=1;i++){
		for(int j=0;j<=1;j++){
			if ((x[i]*y[j])>z) z=x[i]*y[j];
		}
	}
	cout <<z<<endl;
	return 0;
}


Measured memory_bytes: 3628
MOD = 998244353

N = int(input())
D = list(map(int,input().split()))

cnt = [0] * N
for i in range(N):
	cnt[D[i]] += 1

if D[0] != 0 or cnt[0] > 1:
	print(0)
	exit()

ans = 1
for i in range(1, max(D) + 1):
	ans = (ans * pow(cnt[i - 1], cnt[i], MOD)) % MOD
print(ans)

Measured memory_bytes: 83568
N = int(input())
S = [input() for _ in range(N)]

E = [set() for _ in range(N)]
for i in range(N):
  for j in range(N):
    if S[i][j] == '1':
      E[i].add(j)

C = [0 for _ in range(N)]
def dfs(v,c):
  C[v] = c
  for u in E[v]:
    if C[u] == c:
      return False
    if C[u] == 0 and not dfs(u,-c):
      return False
  return True

if not dfs(0,1):
  print(-1)
  exit()

G = [[float('inf') for _ in range(N)] for _ in range(N)]
for i in range(N):
  G[i][i] = 0
for i in range(N):
  for j in range(N):
    if S[i][j] == '1':
      G[i][j] = 1

for k in range(N):
  for i in range(N):
    for j in range(N):
      G[i][j] = min(G[i][k]+G[k][j],G[i][j])
ans = 0
for g in G:
  mx = max(g)
  ans = max(ans,mx)
print(ans+1)

Measured memory_bytes: 68572
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	string s1, s2, s3;
	cin >> n >> s1 >> s2 >> s3;
	int ans = 0;
	for(int i = 0; i < n; i++)
	{
		if(s1[i] != s2[i] && s1[i] != s3[i] && s2[i] != s3[i])
			ans += 2;
		else if(s1[i] == s2[i] && s2[i] == s3[i])
			ans += 0;
		else ans++;
	}
	cout << ans << endl;
	return 0;
}

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

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


Measured memory_bytes: 256
N = int(input())

dp = [[0 for _ in range(3)] for _ in range(N)]
dp[0] = list(map(int, input().split()))
for i in range(1, N):
    a, b, c = list(map(int, input().split()))
    dp[i][0] = max(dp[i-1][1] + a, dp[i-1][2] + a)
    dp[i][1] = max(dp[i-1][2] + b, dp[i-1][0] + b)
    dp[i][2] = max(dp[i-1][0] + c, dp[i-1][1] + c)

print(max(dp[N-1][0], dp[N-1][1], dp[N-1][2]))


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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define EACH(begin, end) for(auto itr = (begin); itr != (end); itr++)

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;



ll N = 0;
ll H, W;
int ret = 0;
char table[2005][2005];
int _left[2005][2005];
int _right[2005][2005];
int _up[2005][2005];
int _down[2005][2005];


void input() {
  IN(H);
  IN(W);
  char tmp;
  REP(i, H) {
    REP(j, W) {
      IN(tmp);
      table[i][j] = tmp;
      _left[i][j] = 0;
      _right[i][j] = 0;
      _up[i][j] = 0;
      _down[i][j] = 0;
    }
  }
}

void solve() {
  /* left */
  REP(i, H) {
    REP(j, W) {
      if (table[i][j] == '.') {
        if (j > 0) {
          _left[i][j] = _left[i][j-1] + 1;
        } else {
          _left[i][j] = 1;
        }
      }
    }
  }
  /* right */
  REP(i, H) {
    REP(j, W) {
      if (table[H-1-i][W-1-j] == '.') {
        if (j > 0) {
          _right[H-1-i][W-1-j] = _right[H-1-i][W-j] + 1;
        } else {
          _right[H-1-i][W-1-j] = 1;
        }
      }
    }
  }
  /* up */
  REP(i, H) {
    REP(j, W) {
      if (table[i][j] == '.') {
        if (i > 0) {
          _up[i][j] = _up[i-1][j] + 1;
        } else {
          _up[i][j] = 1;
        }
      }
    }
  }
  /* down */
  REP(i, H) {
    REP(j, W) {
      if (table[H-1-i][W-1-j] == '.') {
        if (i > 0) {
          _down[H-1-i][W-1-j] = _down[H-i][W-1-j] + 1;
        } else {
          _down[H-1-i][W-1-j] = 1;
        }
      }
    }
  }

  REP(i, H) {
    REP(j, W) {
      int light = _left[i][j] + _right[i][j] + _up[i][j] + _down[i][j] - 3;
      ret = max(ret, light);
    }
  }
  PRINT(ret);
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 67072
// 2010/12/21 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int te[5];
		cin >> te[0];
		if(te[0]==0)
			break;
		for(int i=1; i<5; i++)
			cin >> te[i];

		int gu = 0;
		int ch = 0;
		int pa = 0;
		for(int i=0; i<5; i++)
			if(te[i]==1)
				gu++;
			else if(te[i]==2)
				ch++;
			else
				pa++;

		if(gu==5||ch==5||pa==5||gu*ch*pa!=0)
			for(int i=0; i<5; i++)
				cout << 3 << endl;
		else if(gu==0)
			for(int i=0; i<5; i++)
				if(te[i]==2)
					cout << 1 << endl;
				else
					cout << 2 << endl;
		else if(ch==0)
			for(int i=0; i<5; i++)
				if(te[i]==3)
					cout << 1 << endl;
				else
					cout << 2 << endl;
		else
			for(int i=0; i<5; i++)
				if(te[i]==1)
					cout << 1 << endl;
				else
					cout << 2 << endl;
	}

	return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		char[] s = sc.next().toCharArray();
		
		for (int i = 0; i < a; i++) {
			if (!(s[i] - '0' >= 0 && s[i] - '0' <= 9)) {
				System.out.println("No");
				return;
			}
		}
		if (s[a] != '-') {
			System.out.println("No");
			return;
		}
		for (int i = a + 1; i < a + b; i++) {
			if (!(s[i] - '0' >= 0 && s[i] - '0' <= 9)) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    priority_queue<long long int> A;
    long long int a;
    for (int i = 0; i < N; i++) {
        cin >> a;
        A.push(a);
    }

    for (int i =  0; i < M; i++) {
        a = A.top();
        A.pop();
        A.push(a / 2);
    }

    long long int value = 0;
    while (!A.empty()) {
        value += A.top();
        A.pop();
    }

    cout << value << endl;
}

Measured memory_bytes: 1400
def get_gcd(a, b):
  m = max(a, b)
  n = min(a, b)
  while(True):
    if n == 0:
      break
    r = m % n
    m = n
    n = r
  return m


A, B, K = list(map(int, input().split()))

gcd = get_gcd(A, B)

cd_list = []
for i in range(1, gcd+1):
  if gcd % i == 0:
    cd_list.append(i)

cd_list.sort(reverse=True)
print(cd_list[K-1])
  
  

Measured memory_bytes: 3064
import numpy as np
c_vec1 = list(map(int, input().split(" ")))
mat_size = len(c_vec1)
c_mat = np.asarray([c_vec1] + [list(map(int, input().split(" "))) for i in range(mat_size-1)])

flag1 = len(set(c_mat[0] - c_mat[1])) == 1 and len(set(c_mat[1] - c_mat[2])) == 1 and len(set(c_mat[2] - c_mat[0])) == 1
flag2 = len(set(c_mat[:, 0] - c_mat[:, 1])) == 1 and len(set(c_mat[:, 1] - c_mat[:, 2])) == 1 and len(set(c_mat[:, 2] - c_mat[:, 0])) == 1
flag = flag1 and flag2
out_txt = "Yes" if flag else "No"

print(out_txt)

Measured memory_bytes: 12448
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(0);
    
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;

    if (s == u) {
        --a;
    } else {
        --b;
    }

    cout << a << ' ' << b << endl;

    return 0;
}


Measured memory_bytes: 256
from sys import stdin, stdout
from collections import defaultdict
import math

def chai(a):
    ans = defaultdict(int)
    i = 2
    while i <= int(math.sqrt(a)):
        while a % i == 0:
            ans[i] += 1
            a //= i
        i += 1
    if a != 1:
        ans[a] += 1
    return ans
    
n, p = map(int, stdin.readline().strip().split())

tmp = chai(p)
ans = 1
for key, value in tmp.items():
    while value >= n:
        ans *= key
        value -= n
stdout.writelines(str(ans) + '\n')



Measured memory_bytes: 38512
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


int d[3] = {-1,0,1};
int main(){
    int w,a,b;cin>>w>>a>>b;
    if(a<=b && b<=a+w)cout<<0;
    else if(a<=b+w && b+w<=a+w)cout<<0;
    else {
        cout<<min(abs(b-a+w),abs(a-b+w));
    }
}



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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

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
#include <bits/stdc++.h>
using namespace std;

#define fa(x,v) for(auto x:v)
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define spc " "
#define endl '\n'
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(s) (ll)int(s.length())
#define sz(v) (ll)int(v.size())
#define MOD 1000000007

void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef rsd511
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    #endif
    #ifndef rsd511
    #define trace(...) {}
    #define cotra(...) {}
    #endif
} 

// Code Here

int main()
{
    Fast_IO();
    ll dx[4] = {0,0,1,-1};
    ll dy[4] = {1,-1,0,0};
    ll magicx[20] = {-2,-2,-2,-2,-2,-1,-1,-1,-1,0,0,1,1,1,1,2,2,2,2,2};
    ll magicy[20] = {-2,-1,0,1,2,-2,-1,1,2,-2,2,-2,-1,1,2,-2,-1,0,1,2};
    ll n, m; cin >> n >> m;
    ll xs, ys, xe, ye; cin >> xs >> ys >> xe >> ye;
    xs--; ys--; xe--; ye--;
    char a[n][m]; f(i,0,n-1) f(j,0,m-1) cin >> a[i][j];
    ll dist[n][m];
    f(i,0,n-1) f(j,0,m-1) dist[i][j] = -1;
    dist[xs][ys] = 0;
    priority_queue < pair<ll, pair<ll,ll> >, 
    vector < pair<ll, pair<ll,ll> > >, 
    greater < pair<ll, pair<ll,ll> > > > dq;
    dq.push(mp(dist[xs][ys],mp(xs,ys)));
    while(!dq.empty()) {
    	auto u = dq.top(); dq.pop();
    	ll x = u.ss.ff, y = u.ss.ss;
    	if(u.ff != dist[x][y]) continue;
    	f(_,0,3) {
    		ll nx = x + dx[_], ny = y + dy[_];
    		if(nx < 0 || nx >= n || ny < 0 || ny >= m) continue;
    		if(a[nx][ny] == '#') continue;
    		if(dist[nx][ny] == -1 || dist[nx][ny] > dist[x][y]) {
    			dist[nx][ny] = dist[x][y];
    			dq.push(mp(dist[nx][ny],mp(nx,ny)));
    		}
    	}
    	f(_,0,19) {
    		ll nx = x + magicx[_], ny = y + magicy[_];
    		if(nx < 0 || nx >= n || ny < 0 || ny >= m) continue;
    		if(a[nx][ny] == '#') continue;
    		if(dist[nx][ny] == -1 || dist[nx][ny] > dist[x][y] + 1) {
    			dist[nx][ny] = dist[x][y] + 1;
    			dq.push(mp(dist[nx][ny],mp(nx,ny)));
    		}
    	}
    }
    cout << dist[xe][ye];
    return 0;
}

Measured memory_bytes: 12544