akhauriyash/Code-Regression huggingface dataset:
#include <cstring>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <string>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <list>
#include <climits>
#include <cctype>
#include <bitset>
using namespace std;

#define PI 3.14159265359
#define all(v) v.begin(),v.end()
#define sortva(v) sort(all(v))
#define sortvd(v) sort(v.rbegin(),v.rend())
#define sortaa(a,n) sort(a,a+n)
#define sortad(a,n) sort(a,a+n),reverse(a,a+n)
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define sfstr(v) scanf("%s", v);
#define sz(v) (int)v.size()
#define ndl puts("")
#define SS stringstream
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

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

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

void PLAY() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cout << fixed << setprecision(10);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}


int main() {
	//PLAY();

	int n, h;
	cin >> n >> h;
	vector<pair<ll, int>> v;
	int x;
	for (int i = 0; i < n; i++)  {
		cin >> x;
		v.push_back({ x, 1 });
		cin >> x;
		v.push_back({ x, 0 });
	}
	sortvd(v);
	ll res = 0;
	for (int i = 0; i < sz(v); i++) {
		if (v[i].second == 1) {
			res += h / v[i].first;
			h %= v[i].first;
			if (h > 0) res++;
			break;
		}
		else {
			res++;
			h -= v[i].first;
		}
		if (h <= 0) break;
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 6384
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  
  int n;
  cin>>n;
  int v[n];
  REP(i,n){
    cin>>v[i];
  }
  
  map<int,int> mpe,mpo;
  for(int i=0;i<n;i+=2){
    mpe[v[i]]++;
  }
  for(int i=1;i<n;i+=2){
    mpo[v[i]]++;
  }
  
  int cnte=0,cnto=0;
  int cntes=0,cntos=0;
  int max_e,max_o;
  for(auto p:mpe){
    if(cnte==0){
      cnte = p.second;
      max_e = p.first;
    }else if(cnte<p.second){
      cntes = cnte;
      cnte = p.second;
      max_e = p.first;
    }else if(cntes<p.second){
      cntes = p.second;
    }else{
      continue;
    }
  }
  for(auto p:mpo){
    if(cnto==0){
      cnto = p.second;
      max_o = p.first;
    }else if(cnto<p.second){
      cntos = cnto;
      cnto = p.second;
      max_o = p.first;
    }else if(cntos<p.second){
      cntos = p.second;
    }else{
      continue;
    }
  }
  int ans;
  if(max_e==max_o){
    ans = min(n-cnte-cntos,n-cntes-cnto);
  }else{
    ans = n-cnte-cnto;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int n;
  cin >> n;
  REP(i, 50001) {
    if (floor(i * 1.08) == n) {
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
}


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

int main(void){
    double w,h,x,y;
    cin >> w >> h >> x >> y;
    printf("%.20f %d\n", w*h/2.0, ((w/2.0 == x && h/2.0 == y) ? 1 : 0));
    return 0;
}


Measured memory_bytes: 256
l = []

for i in range(3):
    l.append(list(map(int, input().split())))

if l[0][1] - l[0][0] == l[1][1] - l[1][0] == l[2][1] - l[2][0]:
    if l[0][2] - l[0][0] == l[1][2] - l[1][0] == l[2][2] - l[2][0]:
        print("Yes")
        exit()
print("No")

Measured memory_bytes: 3064
import java.io.*;
import java.util.*;

public class Main {
    
    class Answer {
        int oldR, newR;
        
        public int solve() {
            return newR*2-oldR;
        }
        
        public void main(FastScanner in, PrintWriter out) {
            oldR = in.nextInt();
            newR = in.nextInt();
            out.println( solve() );
        }
        
        public void p(Object o) { System.out.print(o); }
        public void pl(Object o) { System.out.println(o); }
        public void arp(int[] o) { pl( Arrays.toString(o) ); }
        public void arpp(int[][] o) { 
            for (int i = 0; i < o.length; i++) {
                for (int j = 0; j < o[0].length; j++) { p(o[i][j] + " "); }
                pl("");
            }
        }
        public void ck(Object o1, Object o2) { pl(o1 + " " + o2); }
        public void ckk(Object o1, Object o2, Object o3) { pl(o1 + " " + o2 + " " + o3); }
        public void ckkk(Object o1, Object o2, Object o3, Object o4) { 
            pl(o1 + " " + o2 + " " + o3 + " " + o4);
        }
    }

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Main problem = new Main();
        Answer ans = problem.new Answer();
        ans.main(in, out);
        out.close();
        in.close();
    }
    
    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        public FastScanner(InputStream in) { br = new BufferedReader(new InputStreamReader(in)); }
        public int nextInt() { return Integer.parseInt(next()); }
        public long nextLong() { return Long.parseLong(next()); }
        public double nextDouble() { return Double.parseDouble(next()); }
        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try { st = new StringTokenizer(br.readLine()); } 
                catch (IOException e) { e.printStackTrace(); }
            }
            return st.nextToken();
        }
        public String nextLine() {
            String str = "";
            try { str = br.readLine();
            } catch (IOException e) { e.printStackTrace(); }
            return str;
        }
        public void close() throws IOException { br.close(); }
    }
}

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

using namespace std;

#define ll long long
#define N 2010

int res[N];

void lineC(int cl, int tc) {
  int cd = tc / 2;
  for (int i = 1; i <= cl; i++) {
    res[i + 1]++;
    for (int j = 2; j < cd; j++) {
      res[i + j] += 2;
    }
    if (cd >= 2) {
      if (tc % 2 == 1) res[i + cd] += 2;
      else res[i + cd] += 1;
    }
  }
}

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  int tc = y - x + 1;
  int me = x - 1;
  int md = n - y;
  int cd = tc / 2;
  for (int i = 1; i < cd; i++) {
    res[i] += tc;
  }
  if (tc % 2 == 0) res[cd] += tc/2;
  else res[cd] += tc;
  
  int lc = me + md + 2;
  for (int i = 1; i < lc; i++) {
    res[i] += lc - i;
  }

  res[1]--;



  lineC(me, tc);


  lineC(md, tc);

  for (int vi = 0; vi < n-1; vi++) {
    cout << res[vi+1] << " ";
  }
  cout << "\n";
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <tuple>
#include <queue>
#include <functional>
#include <list>
#include <algorithm>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i = (a); i < (b); i++)

const int MAX_NODE_NUM = 10005;
const int MAX_EDGE_NUM = 100005;

namespace Prim {
	static list<tuple<int, int>> adjLists[MAX_NODE_NUM];
	static bool isNodeInST[MAX_NODE_NUM];
	void run() {
		int n, m;
		cin >> n >> m;
		REP(i, m) {
			int w, s, t;
			cin >> s >> t >> w;
			adjLists[s].push_back(make_tuple(w, t));
			adjLists[t].push_back(make_tuple(w, s));
		}

		using EdgeType = tuple<int, int>;
		priority_queue<EdgeType, vector<EdgeType>, greater<EdgeType>> q;
		long long cost = 0;
		int stNodeNum = 0;
		int newNode = 0;
		int newCost = 0;
		q.push(make_tuple(newCost, newNode));
		while (stNodeNum < n) {
			tie(newCost, newNode) = q.top();
			q.pop();
			if (isNodeInST[newNode] == false) {
				isNodeInST[newNode] = true;
				cost += newCost;
				stNodeNum++;
				for (auto t : adjLists[newNode]) {
					q.push(t);
				}
			}
		}

		cout << cost << endl;

		return;
	}
};

namespace Kruskal {
	static tuple<int, int, int> edges[MAX_EDGE_NUM];
	static int parent[MAX_NODE_NUM];
	int root(int a) { return (a == parent[a]) ? a : (parent[a] = root(parent[a])); }
	bool unite(int a, int b) {
		int x = root(a), y = root(b);
		if (x == y) return false;
		parent[x] = y;
		return true;
	}
	void run() {
		int n, m;
		int s, t, w;
		cin >> n >> m;
		REP(i, m) {
			cin >> s >> t >> w;
			edges[i] = tie(w, s, t);
		}
		sort(edges, edges + m);
		REP(i, n) {
			parent[i] = i;
		}
		long long cost = 0;
		REP(i, m) {
			tie(w, s, t) = edges[i];
			if (unite(s, t)) {
				cost += w;
			}
		}
		cout << cost << endl;
	}
};

int main() {
//	Prim::run();
	Kruskal::run();

	return 0;
}

Measured memory_bytes: 4440
R = lambda: map(int, input().split())
sq = lambda x: int(x ** 0.5) ** 2 == x
d2 = lambda x, y: sum((u - v) ** 2 for u, v in zip(x, y)) 
n, d = R()
a = [tuple(R()) for _ in range(n)]
print(sum(sq(d2(a[i], a[j])) for i in range(n) for j in range(i)))


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

using namespace std ;

const int MAX = 1e5 + 10 ;

vector<int>tree[4 * MAX] ;
int arr[MAX] ;

void build(int node , int l , int r)
{
	if(l == r)
	{
		tree[node].push_back(arr[l]) ;
		return ;
	}
	int mid = (l + r) >> 1 ;
	build(node << 1 , l , mid) ;
	build(node << 1 | 1 , mid + 1 , r) ;
	merge(tree[node << 1].begin(), tree[node << 1].end(), tree[node << 1 | 1].begin(), tree[node << 1 | 1].end(), inserter(tree[node], tree[node].begin()));
}

int query(int node , int l , int r , int from , int to , int x)
{
	if(from > r || to < l)
		return 0 ;
	if(l >= from && r <= to)
	{
		int idx = upper_bound(tree[node].begin() , tree[node].end() , x) - tree[node].begin() ;
		return (tree[node].size() - idx) ;
	}
	int mid = (l + r) >> 1 ;
	int a = query(node << 1 , l , mid , from  , to , x) ;
	int b = query(node << 1 | 1 , mid + 1 , r , from , to , x) ;
	return (a + b) ;
}

int readInt () {
	bool minus = false;
	int result = 0;
	char ch;
	ch = getchar();
	while (true) {
		if (ch == '-') break;
		if (ch >= '0' && ch <= '9') break;
		ch = getchar();
	}
	if (ch == '-') minus = true; else result = ch-'0';
	while (true) {
		ch = getchar();
		if (ch < '0' || ch > '9') break;
		result = result*10 + (ch - '0');
	}
	if (minus)
		return -result;
	else
		return result;
}

int main()
{
	int n ;
	n = readInt() ;
	for(int i = 1 ; i <= n ; ++i)
		arr[i] = readInt() ;
	build(1 , 1 , n) ;
	long long ans = 0ll ;
	for(int i = 1 ; i <= n ; ++i)
	{
		int l = i , r = n ;
		int a = i , c = i;
		while(l <= r)
		{
			int mid = (l + r) >> 1 ;
			int x = query(1 , 1 , n , i , mid , arr[i]) ;
			if(x <= 1)
			{
				l = mid+1 ;
				if(x == 1)
					a = mid ;
			}
			else
				r = mid - 1;
		}
		l = i , r = n ;
		while(l <= r)
		{
			int mid = (l + r) >> 1 ;
			int x = query(1 , 1 , n , i , mid , arr[i]) ;
			if(x == 0)
			{
				l = mid+1 ;
				c = mid ;
			}
			else
				r = mid - 1;
		}
		l = 1 , r = i ;
		int b = i , d = i;
		while(l <= r)
		{
			int mid = (l + r) >> 1 ;
			int x = query(1 , 1 , n , mid , i , arr[i]) ;
			if(x <= 1)
			{
				r = mid-1 ;
				if(x == 1)
					b = mid ;
			}
			else
				l = mid + 1;
		}
		l = 1 , r = i ;
		while(l <= r)
		{
			int mid = (l + r) >> 1 ;
			int x = query(1 , 1 , n , mid , i , arr[i]) ;
			if(x == 0)
			{
				r = mid-1 ;
				d = mid ;
			}
			else
				l = mid + 1;
		}
		long long x1 = (i - d + 1ll) * 1ll ;
		long long x2 = (a - c) * 1ll ;
		x1 = max(x1 , 0ll) ;
		x2 = max(x2 , 0ll) ;
		ans += (x1 * x2) * arr[i] * 1ll ;
		x1 = (d - b) * 1ll ;
		x2 = (c - i + 1ll) * 1ll ;
		x1 = max(x1 , 0ll) ;
		x2 = max(x2 , 0ll) ;
		ans += (x1 * x2) * arr[i] * 1ll ;
	}
	return printf("%lld\n" , ans) , 0 ;
}


Measured memory_bytes: 25144
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        int max = Math.max(a,Math.max(b,c));
        int min = Math.min(a,Math.min(b,c));
        int middle;
        if (a != max && a !=min) {
            middle = a;
        } else if (b != max && b !=min) {
            middle = b;
        } else {
            middle = c;
        }
        
        System.out.println(min + " " + middle + " " + max);
    }
}


Measured memory_bytes: 26340
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;
 
#define Endl endl
 
map<string, string> mp, mpg,mpa;
 
/*--------------------template--------------------*/
 
int main()
{
	cin >> n;
	vi v(n);
	ll even = 0, odd = 0;
	REP(i, n)
	{
		cin >> v[i];
		if (v[i] % 2 == 0) {
			even++;
		} else {
			odd++;
		}
	}
	if (n == 1) {
		if (v[0] % 2 == 0) {
			cout << 1 << endl;
			return 0;
		} else {
			cout << 2 << endl;
			return 0;
		}
	}
	ll minus = 1;
	REP(i, v.size())
	{
		if (v[i] % 2 == 0) {
			minus *= 2;
		} else {
			minus *= 1;
		}
	}
	ans = pow(3, v.size()) - minus;
	cout << ans << endl;
}

Measured memory_bytes: 384
//     . .. ... ..... be naame khodaa ..... .... ... .. .     \\

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

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
#define pb push_back

inline int in(){int x, y; y = scanf("%d", &x); return x;}

const int N = 1200021, MOD = 1e9 + 7;

ll fact[N], g[N];

ll pw(ll a, ll b)
{
	if(!b)
		return 1;
	ll c = pw(a, b/2);
	c = c * c % MOD;
	return c * (b % 2 ? a : 1) % MOD;
}

ll c(int k, int n)
{
	if(n >= k)
		return fact[n] * pw(fact[k], MOD - 2) % MOD * pw(fact[n - k], MOD - 2) % MOD;
	return 0;
}

int main()
{
	int n = in();
	fact[0] = 1;
	for(int i = 1; i < N; i++)
		fact[i] = fact[i - 1] * i % MOD;
	if(n == 2)
		cout << 1 << endl;
	else
	{
		n--;
		ll ans  = 0;
		cerr << n << endl;
		for(int k = 2; k <= n; k++)
		{
			g[k] = fact[n - k] * fact[k] % MOD * c(n - k, k - 1) % MOD; // f[n - k][n - 2]
			ans += (g[k] - g[k - 1] + MOD) % MOD * k % MOD;
			ans %= MOD;
		}
		cout << ans << endl;
	}
}



Measured memory_bytes: 18944
n = int(input())
list_B = list(map(int, input().split()))
list_A = [list_B[0]]
for i in range(len(list_B)-1):
  list_A.append(min(list_B[i], list_B[i+1]))
list_A.append(list_B[-1])
print(sum(list_A))

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

typedef long long ll;

ll f(ll n, ll x) {
  if (n == -1) {
    return 0;
  } else {
    return n / x + 1;
  }
}

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

  cout << f(b, x) - f(a-1, x) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
int main(void){
  int i,j,k,n,s;
  char ca[201],can[201];
 
  while(1){
    scanf("%s\n%d", ca, &n);
    if(!strcmp(ca, "-")) break;
    
    for(i=0;i<n;i++){
      scanf("%d", &s);
      for(j=s;ca[j]!='\0';j++)
        can[j-s] = ca[j];
      for(k=0;k<s;k++)
        can[j-s+k] = ca[k];
      
      for(j=0;ca[j]!='\0';j++)
        ca[j] = can[j];
    }
 
    printf("%s\n", ca);
  }
 
  return 0;
}


Measured memory_bytes: 2112
import java.util.ArrayList;
import java.util.Scanner;

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

        int n;
        n = cin.nextInt();

        ArrayList<Integer> x  = new ArrayList<>();

        for (int i = 0; i < n; i++) {
            x.add(cin.nextInt());
        }

        int xSquareMin = 1000000000;

        for (int i = 0; i < 101; i ++) {
            int sum = 0;
            for (int j = 0; j < n; j++) {
                sum += (x.get(j) - i) * (x.get(j) - i);
            }
            if (sum < xSquareMin) {
                xSquareMin = sum;
            }
        }
        System.out.println(xSquareMin);
    }
}


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

#define inf 0x3f3f3f3f
#define INF 1000111000111000111LL
#define mod 1000000007
#define pi acos(-1.0)
#define eps 1e-8
#define endl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fi first
#define se second
#define all(cc) (cc).begin(),(cc).end()
using lli = long long int ;
using pii = pair<int, int> ;
using vi = vector<int> ;
using vb = vector<bool> ;
using vvi = vector<vector<int>> ;
using vlli = vector<long long int> ;
using vpii = vector<pair<int, int>> ;

int n, m, u, v, ans, dp[100005] ;
bool visit[100005] ;
vvi adj(100005) ;

void dfs(int u)
  {
    visit[u]=true ;
    for(auto v:adj[u])
      {
        if(!visit[v]) dfs(v) ;
        dp[u]=max(dp[u], dp[v]+1) ;
      }
    ans=max(dp[u], ans) ;
  }

int main()
  {
    ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
    cin>> n >> m ;
    for(int i=1 ; i<=m ; i++)
      {
        cin>> u >> v ;
        adj[u].pb(v) ;
      }
    for(int i=1 ; i<=n ; i++) if(!visit[i]) dfs(i) ;
    cout<< ans ;
  }


Measured memory_bytes: 8320
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int n;
int a[100010];
int s;

int main(){
	scanf("%d" , &n);
	repp(i,0,n){
		scanf("%d" , a + i);
	}
	LL x = 0 ,y = 0;
	s = 0;
	repp(i,0,n){
		s += a[i];
		if(i%2==0){
			if(s<=0){
				x += 1-s;
				s = 1;
			}
		} else {
			if(s>=0){
				x += s+1;
				s = -1;
			}
		}
	}
	s = 0;
	repp(i,0,n){
		s += a[i];
		if(i%2==1){
			if(s<=0){
				y += 1-s;
				s = 1;
			}
		} else {
			if(s>=0){
				y += s+1;
				s = -1;
			}
		}
	}
	printf("%lld\n" , min(x,y));
	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
int main(){
	int n,x;
	int i,j,k;
	int c;
	while(1){
		c=0;
		scanf("%d %d",&n,&x);
		if(!n&&!x)break;
		for(i=1;i<=n;i++){
			for(j=1;j<i;j++){
				for(k=1;k<j;k++){
					if(i+j+k==x)c++;
				}
			}
		}
		printf("%d\n",c);
	}
}

Measured memory_bytes: 600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        int[] a = { 0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0 };
        var n = ReadLine().Split().Select(x => int.Parse(x) - 1).ToArray();
        WriteLine(a[n[0]] == a[n[1]] ? "Yes" : "No");
    }
}


Measured memory_bytes: 19100
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

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

def calc(n):
    s = sum(map(int, str(n)))
    return n / s

def main():
    k = ri()
    cand = list(range(1, 10))
    last = 9
    for n in range(1, 15):
        pow10n = pow(10, n)
        for d in range(1, 10):
            lim = (d+1)*pow10n
            e = 0
            while True:
                e1 = d*pow10n+e*(last+1)+last
                if e1 >= lim:
                    break
                e2 = e1 + (last+1)
                if calc(e1) > calc(e2):
                    last = last*10+9
                    e = 0
                    continue
                cand.append(e1)
                e += 1
    cand = sorted(list(set(cand)))
    print("\n".join(map(str, cand[:k])))


if __name__ == '__main__':
    main()

"""
1 1.0
2 1.0
3 1.0
4 1.0
5 1.0
6 1.0
7 1.0
8 1.0
9 1.0
19 1.9
29 2.6363636363636362
39 3.25
49 3.769230769230769
59 4.214285714285714
69 4.6
79 4.9375
89 5.235294117647059
99 5.5
199 10.473684210526315
299 14.95
399 19.0
499 22.681818181818183
599 26.043478260869566
699 29.125
799 31.96
899 34.57692307692308
999 37.0
1099 57.8421052631579
1199 59.95
1299 61.857142857142854
1399 63.59090909090909
1499 65.17391304347827
1599 66.625
1699 67.96
1799 69.1923076923077
1899 70.33333333333333
1999 71.39285714285714
2999 103.41379310344827
3999 133.3
4999 161.25806451612902
5999 187.46875
6999 212.0909090909091
7999 235.26470588235293
8999 257.1142857142857
9999 277.75
10999 392.82142857142856
11999 413.7586206896552
12999 433.3
13999 451.5806451612903
14999 468.71875
15999 484.8181818181818
16999 499.97058823529414
17999 514.2571428571429
18999 527.75
19999 540.5135135135135
20999 724.1034482758621
21999 733.3
22999 741.9032258064516
23999 749.96875
24999 757.5454545454545
25999 764.6764705882352
26999 771.4
27999 777.75
28999 783.7567567567568
29999 789.4473684210526
39999 1025.6153846153845
49999 1249.975
59999 1463.3902439024391
69999 1666.642857142857
79999 1860.4418604651162
89999 2045.4318181818182
99999 2222.2
109999 2972.945945945946
119999 3157.8684210526317
129999 3333.3076923076924
139999 3499.975
149999 3658.512195121951
159999 3809.5
169999 3953.4651162790697
179999 4090.8863636363635
189999 4222.2
199999 4347.804347826087
209999 5526.289473684211
219999 5641.0
229999 5749.975
239999 5853.634146341464
249999 5952.357142857143
259999 6046.488372093023
269999 6136.340909090909
279999 6222.2
289999 6304.326086956522
299999 6382.95744680851
309999 7948.692307692308
319999 7999.975
329999 8048.756097560976
339999 8095.214285714285
349999 8139.511627906977
359999 8181.795454545455
369999 8222.2
379999 8260.847826086956
389999 8297.851063829787
399999 8333.3125
499999 10204.061224489797
599999 11999.98
699999 13725.470588235294
799999 15384.596153846154
899999 16981.11320754717
999999 18518.5
"""



Measured memory_bytes: 3064
n,k=map(int,input().split())
dislike=list(map(int,input().split()))


while 1:
    for i in range(len(str(n))):
        if int(str(n)[i]) in dislike:
            break
        if i==len(str(n))-1:
            print(n)
            exit()
    n+=1

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n+1],b[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	int index=1;
	int N=n;
	for(int i=n;i>=1;)
	{
		if(a[i]==i)
		{
			b[index]=a[i];
			index++;
			for(int j=i;j<=n;j++)
			{
				a[j]=a[j+1];
			}
			n--;
			i=n;
		}
		else
		{
			i--;
		} 
	}
	if(index-1==N)
	{
		for(int i=N;i>=1;i--)
		{
			cout<<b[i]<<endl;
		}
	}
	else
	{
		cout<<"-1"<<endl;
	}
	return 0;
} 

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

//昇順ソート
int qs(const void *n1, const void *n2){
    if(*(int *)n1 > *(int *)n2){
        return -1;
    }else if(*(int *)n1 < *(int *)n2){
        return 1;
    }else{
        return 0;
    }
}

//gcd計算
int gcd(int *x, int *y){
    int px = *x;
    int py = *y;
    while(1){
        int q = px % py;
        if(q==0){
            return py;
        }else{
            px = py;
            py = q;
        }
    }
}

int main(void){
    char str[4];
    int N;
    long count = 0;
    fgets(str, sizeof(str), stdin);
    sscanf(str, "%d", &N);

    for(int a=1; a<N+1; a++){
        for(int b=1; b<N+1; b++){
            for(int c=1; c<N+1; c++){
                int L[3];
                int M[2];
                L[0]=a;L[1]=b;L[2]=c;
                qsort(L, sizeof(L)/sizeof(int), sizeof(int), qs);
                int Fgcd = gcd(&L[0], &L[1]);
                M[0]=Fgcd;M[1]=L[2];
                qsort(M, sizeof(M)/sizeof(int), sizeof(int), qs);
                count += gcd(&M[0], &M[1]);
            }
        }
    }
    printf("%lu\n",count);
}

Measured memory_bytes: 1772
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
int n,m; ll a[5555],b[5555][5555],qzh[5555][5555];
inline void add(int x1,int y1,int x2,int y2,ll v)
{
	++x2; ++y2;
	qzh[x1][y1]+=v; qzh[x2][y2]+=v;
	qzh[x1][y2]-=v; qzh[x2][y1]-=v;
}
int L[5555],R[5555];
void work(ll*x)
{
	static int st[5555]; int sn=0;
	for(int i=1;i<=n;++i)
	{
		while(sn&&x[st[sn]]<=x[i]) --sn;
		L[i]=st[sn]+1; st[++sn]=i;
	}
	sn=0;
	for(int i=n;i>=1;--i)
	{
		while(sn&&x[st[sn]]<x[i]) --sn;
		R[i]=sn?(st[sn]-1):n; st[++sn]=i;
	}
	for(int i=1;i<=n;++i)
		add(L[i],i,i,R[i],x[i]);
}
int main()
{
	scanf("%d%d",&n,&m);
	int S=sqrt(n);
	for(int i=2;i<=n;++i)
		scanf("%lld",a+i),a[i]+=a[i-1];
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			scanf("%lld",&b[j][i]);
	for(int j=1;j<=m;++j) work(b[j]);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j)
			qzh[i][j]+=qzh[i][j-1]+qzh[i-1][j]-qzh[i-1][j-1];
	ll ans=0;
	for(int i=1;i<=n;++i)
		for(int j=i;j<=n;++j)
		{
			ll s=qzh[i][j]-(a[j]-a[i]);
			ans=max(ans,s);
		}
	printf("%lld\n",ans);
}


Measured memory_bytes: 229632
using System;
class Program
{
  static void Main(string[] args)
  {
    int s = int.Parse(Console.ReadLine());
    int a = s/1000;
    int b = (s%1000)/100;
    int c = (s%100)/10;
    int d = (s%10);
    Console.WriteLine((a==b) || (b==c) || (c==d) ? "Bad" : "Good");
  }
}

Measured memory_bytes: 13140
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int N = s.nextInt();
        int Vn[] = new int[N];
        int Cn[] = new int[N];
        //Vn,Cnに値を取り込む
        for (int i = 0; i < N; i++) {
            Vn[i] = s.nextInt();
        }
        for (int i = 0; i < N; i++) {
            Cn[i] = s.nextInt();
        }
        //計算して＋の時だけ足す
        int ans = 0;
        int check = 0;
        for (int i = 0; i < N; i++) {
            check = Vn[i] - Cn[i];
            if (check > 0) {
                ans +=check;
            }
            check = 0;
        }
        //ansを出力する
        System.out.print(ans);
    }
}

Measured memory_bytes: 23764
def dfs(x, count):
    ret = 0
    if used[x]:
        return ret
    used[x] = 1
    for y in path[x]:
        ret += dfs(y, count + 1)
    used[x] = 0
    if count == N:
        return ret + 1
    else:
        return ret

if __name__ == '__main__':
    N, M = map(int, input().split())
    path = {i + 1: set() for i in range(N)}
    for _ in range(M):
        a, b = map(int, input().split())
        path[a].add(b)
        path[b].add(a)
    used = [0] * (N + 2)
    print(dfs(1, 1))


Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
using namespace std;
int main(void)
{
  int n;
  int a,b,c;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a >> b >> c;
    if( sqrt(a*a) == sqrt(b*b+c*c) ||
	sqrt(b*b) == sqrt(a*a+c*c) ||
	sqrt(c*c) == sqrt(a*a+b*b) ) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=100001 ;
ll n,a,b,c ;
ll dp[N][4][4][4] ;
string s[N] ;
ll fun(ll i,ll j,ll k,ll l)
{
    if(i==n) return 1 ;

    else if(dp[i][j][k][l]!=-1) return dp[i][j][k][l] ;

    else
    {
        ll ans=0 ;
        if(s[i]=="AB")
        {
            if(j>=1)
            {
                ans|=fun(i+1,j-1,min(k+1,(ll)3),l) ;

            }
            if(k>=1)
            {
                ans|=fun(i+1,min(j+1,(ll)3),k-1,l) ;
            }
        }
        else if(s[i]=="AC")
        {
            if(j>=1)
            {
                ans|=fun(i+1,j-1,k,min(l+1,(ll)3)) ;

            }
            if(l>=1)
            {
                ans|=fun(i+1,min(j+1,(ll)3),k,l-1) ;
            }

        }
        else
        {
            if(k>=1)
            {
               ans|=fun(i+1,j,k-1,min(l+1,(ll)3)) ;

            }
            if(l>=1)
            {
                ans|=fun(i+1,j,min(k+1,(ll)3),l-1) ;
            }
        }

        return dp[i][j][k][l]=ans ;
    }
}
void fun1(ll i,ll j,ll k,ll l)
{
    if(i==n) return ;

    else
    {
        if(s[i]=="AB")
        {
            if(j>=1&&fun(i+1,j-1,min(k+1,(ll)3),l))
            {
                cout<<"B"<<endl ;
                fun1(i+1,j-1,min(k+1,(ll)3),l) ;

            }
            else if(k>=1&&fun(i+1,min(j+1,(ll)3),k-1,l))
            {
               cout<<"A"<<endl ;
               fun1(i+1,min(j+1,(ll)3),k-1,l) ;
            }
        }
        else if(s[i]=="AC")
        {
            if(j>=1&&fun(i+1,j-1,k,min(l+1,(ll)3)))
            {
                cout<<"C"<<endl ;
                fun1(i+1,j-1,k,min(l+1,(ll)3)) ;

            }
            else if(l>=1&&fun(i+1,min(j+1,(ll)3),k,l-1))
            {
              cout<<"A"<<endl ;
              fun1(i+1,min(j+1,(ll)3),k,l-1) ;

            }

        }
        else
        {
            if(k>=1&&fun(i+1,j,k-1,min(l+1,(ll)3)))
            {

                cout<<"C"<<endl ;
                fun1(i+1,j,k-1,min(l+1,(ll)3)) ;

            }
            else if(l>=1&&fun(i+1,j,min(k+1,(ll)3),l-1) )
            {
                cout<<"B"<<endl ;
                fun1(i+1,j,min(k+1,(ll)3),l-1) ;

            }
        }


    }
}
int main()
{
   fast ;
   for(ll i=0;i<N;i++)for(ll j=0;j<4;j++)for(ll k=0;k<4;k++)for(ll l=0;l<4;l++) dp[i][j][k][l]=-1 ;


   cin>>n>>a>>b>>c ;
   a=min(a,(ll)3) ;
   b=min(b,(ll)3) ;
   c=min(c,(ll)3) ;
   for(ll i=0;i<n;i++) cin>>s[i] ;


   ll fl=fun(0,a,b,c) ;
   if(fl)
   {
       cout<<"Yes"<<endl ;
       fun1(0,a,b,c) ;
   }
   else
   {
       cout<<"No"<<endl ;
   }


}



Measured memory_bytes: 61428
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<set>
#define sqr(x) (x)*(x)
using namespace std;
int n,m,i,j,num[500005];
string st,st1;
set<string> s;
int main()
{
	cin>>st>>n;
	for (i=0;i<st.length();i++)
	{
		st1="";
		for (j=1;i+j-1<st.length();j++)
		{
			st1.push_back(st[i+j-1]);
			s.insert(st1);
			if (s.size()>n) s.erase(--s.end());
		}
	}
	cout<<*(--s.end());
	return 0;
}

Measured memory_bytes: 256
x=[int(input()) for i in range(5)]
y=[x[i] for i in range(5) if x[i]%10 != 0]
if y==[]:
    print(sum(x))
else:
    print(sum([-(-1*x[i]//10)*10 for i in range(5)])-10+min([x[i]%10 for i in range(5) if x[i]%10 != 0 ]))


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int x, a, b;
	cin >> x >> a >> b;
	if (abs(x - a) < abs(x - b)) {
		cout << "A" << endl;
	}
	else {
		cout << "B" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
// Problem : E - Count Median
// Contest : AtCoder - AtCoder Beginner Contest 169
// URL : https://atcoder.jp/contests/abc169/tasks/abc169_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int INF = 0x3f3f3f3f, N = 200003, M = N << 1;

int n, m;
struct Node
{
	LL l, r;
} a[N];

inline bool cmp(Node x, Node y)
{
	return x.l < y.l;
}

inline bool cmp1(Node x, Node y)
{
	return x.r > y.r;
}

int main()
{
	//File("");
    n = gi();
    for (int i = 0; i < n; i+=1)
    {
    	a[i].l = gl(), a[i].r = gl();
    }
    LL ans = 0;
    if (n & 1)
    {
    	sort(a, a + n, cmp);
    	ans = a[n / 2].l;
    	sort(a, a + n, cmp1);
    	ans = a[n / 2].r - ans + 1;
    }
    else 
    {
    	sort(a, a + n, cmp);
    	ans = a[n / 2 - 1].l + a[n / 2].l;
    	sort(a, a + n, cmp1);
    	ans = a[n / 2 - 1].r + a[n / 2].r - ans + 1;
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6768
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,x;
    cin >> a >> b >> c >> x;
    int ans = 0;
    for(int i = 0; i <= a; i++){
        for(int j = 0; j <= b; j++){
            for(int k = 0; k <=c; k++){
                if(x==(500*i+100*j+50*k)){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


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

	int kkt = 89;
	while (kkt) {
		int n; scanf("%d", &n); if (n == 0) break;
		vector<ll> cnt(26);
		bool flag = false;
		ll res = -1;
		char cc;
		for (int i = 0; i < n; i++) {
			char c; cin >> c;
			cnt[c - 'A']++;
			vector<pair<ll, char>> a(26);
			for (int i = 0; i < 26; i++) {
				a[i].first = cnt[i];
				a[i].second = (char)('A' + i);
			}
			sort(a.rbegin(), a.rend());
			if (a[0].first > a[1].first + n - 1 - i) {
				flag = true;
				if (res == -1) res = i + 1, cc = a[0].second;
			}
		}
		if (!flag) puts("TIE");
		else cout << cc<<" "<<res << "\n";
	}
	return 0;

}



Measured memory_bytes: 3156
var Triangle;
(function (Triangle) {
    var RightAngle = (function () {
        function RightAngle(a, b, c) {
            this.a = a;
            this.b = b;
            this.c = c;
        }
        RightAngle.prototype.isRightAngle = function () {
            var values = [this.a, this.b, this.c].sort(function (a, b) {
                return b - a;
            });
            return Math.pow(values[0], 2.0) == (Math.pow(values[1], 2.0) + Math.pow(values[2], 2.0));
        };
        return RightAngle;
    })();
    Triangle.RightAngle = RightAngle;
})(Triangle || (Triangle = {}));
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk) {
    chunk.trim().split('\n').forEach(function (line) {
        var items = line.trim().split(' ');
        if (items.length == 3) {
            var r = new Triangle.RightAngle(+items[0], +items[1], +items[2]);
            if (r.isRightAngle()) {
                console.log("YES");
            } else {
                console.log("NO");
            }
        }
    });
});

Measured memory_bytes: 10544
h,w=map(int,input().split())
a=[input() for _ in range(h)]
from collections import defaultdict
d=defaultdict(lambda:0)
for ai in a:
    for aij in ai:
        d[aij]+=1
if h%2==0 and w%2==0:
    print('Yes' if all(v%4==0 for v in d.values()) else 'No')
elif h%2==0 and w%2==1:
    c=0
    for v in d.values():
        if v%4==0:
            pass
        elif v%2==0:
            c+=1
        else:
            print('No')
            exit()
    print('Yes' if c<=h//2 else 'No')
elif h%2==1 and w%2==0:
    c=0
    for v in d.values():
        if v%4==0:
            pass
        elif v%2==0:
            c+=1
        else:
            print('No')
            exit()
    print('Yes' if c<=w//2 else 'No')
else:
    ce=0
    co=0
    for v in d.values():
        if v%4==0:
            pass
        elif v%2==0:
            ce+=1
        else:
            co+=1
    print('Yes' if ce<=h//2+w//2 and co==1 else 'No')


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

#define NDEBUG
#ifdef DEBUG
#include "cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

int sim(int N, int M) {
    vvi a(N, vi(M, 0));
    rep(r,N) rep(c,M) {
        for (int j=-1; j<=1; ++j) {
            for (int i=-1; i<=1; ++i) {
                int y = r+j, x = c+i;
                if (IN(y,0,N-1) && IN(x,0,M-1)) {
                    ++a[y][x];
                }
            }
        }
    }
    int cnt = 0;
    rep(r,N) {
        rep(c,M) {
            // printf("%d", a[r][c]);
            if (a[r][c] % 2) ++cnt;
        }
        // printf("\n");
    }
    return cnt;
}

int main() {
    // for (int n=1; n<=10; ++n) {
    //     for (int m=1; m<=10; ++m) {
    //         printf("N=%d M=%d : %d\n", n, m, sim(n, m));;
    //     }
    // }
    int N, M; cin >> N >> M;
    cout << ((ll)abs(N-2) * abs(M-2)) << endl;
    return 0;
}


Measured memory_bytes: 764
#include<stdio.h>
int main(){
    int n, k, c;
    int r[2<<17];
    scanf("%d %d %d",&n,&k,&c);
    char s[2<<17];
    scanf("%s",s);
    int p = k;
    for(int i = n; i-->0;){
        if(s[i] == 'o'){
            r[i] = p--;
            i -= c;
        }
    }
    p = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'o'){
            if(r[i] == ++p)
                printf("%d\n",i+1);
                i += c;
        }
    }
    return 0;
}

Measured memory_bytes: 2432
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func newScanner() *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return scanner
}

var sc = newScanner()

func scanInt() int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func scanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func scanString() string {
	if sc.Scan() {
		return sc.Text()
	}
	panic(sc.Err())
}

func main() {
	n := scanInt()
	answer := countAnagram(n)
	fmt.Println(answer)
}

func debug(a ...interface{}) {
	// fmt.Println(a...)
}

func countAnagram(n int) int {
	strList := make([]string, n)
	for i := 0; i < n; i++ {
		s := scanString()
		strList[i] = SortString(s)
	}
	sort.Strings(strList)
	count := 0
	for i := 0; i < n-1; {
		j := i + 1
		for ; j < n; j++ {
			debug(i, j)
			if strList[i] != strList[j] {
				break
			}
		}
		c := j - i
		count += c * (c - 1) / 2
		i = j
	}
	return count
}

type sortRunes []rune

func (s sortRunes) Less(i, j int) bool {
	return s[i] < s[j]
}

func (s sortRunes) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func (s sortRunes) Len() int {
	return len(s)
}

func SortString(s string) string {
	r := []rune(s)
	sort.Sort(sortRunes(r))
	return string(r)
}

func sameMap(m0, m1 map[byte]int) bool {

	for k := range m0 {
		v, ok := m1[k]
		if !ok {
			return false
		}
		if v != m0[k] {
			return false
		}
	}

	for k := range m1 {
		_, ok := m0[k]
		if !ok {
			return false
		}
	}
	return true
}


Measured memory_bytes: 5760
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
char S[200011];
int sums[200011];

void MAIN() {
    scanf("%d%s", &N, S);
    REP (i, N) {
	sums[i+1] = sums[i] + (S[i] == '#'? 1: 0);
    }

    int ans = 1<<29;
    REP (i, N+1) {
	amin(ans, sums[i] + (N-i) - (sums[N] - sums[i]));
    }
    printf("%d\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 1280
import sys
read = sys.stdin.buffer.read
input = sys.stdin.readline
input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')


#import numpy as np

def main():
	n,m=MI()
	A=LI()
	A.sort(reverse=True)

	ans="Yes"

	if A[m-1]*4*m<sum(A):
		ans="No"

	print(ans)














if __name__ == "__main__":
	main()

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


int main() {
  string S, T;
  cin >> S >> T;
  string ans="No";
  for (int i=0; i<S.size(); ++i) {
    S = S.erase(0, 1) + S.at(0);
    if (S == T) {
      ans = "Yes";
      break;
    }
  }
  cout << ans << endl;
}




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

int a[100][100]={};

void del(int x,int y){
  a[x][y]=0;
  for(int i=-1;i<=1;i++){
    for(int t=-1;t<=1;t++){
      if(a[x+i][y+t]==1){del(x+i,y+t);}
    }}
}

int main(){

  while(1){
    
    int w,h;
  cin>>w>>h;
  if(w==0 && h==0){break;}

  for(int i=1;i<=h;i++){
    for(int t=1;t<=w;t++){
      cin>>a[i][t];
    }}

  int count=0;
  for(int i=1;i<=h;i++){
    for(int t=1;t<=w;t++){
      if(a[i][t]==1){del(i,t); count++;}
    }}
  
  cout<<count<<endl;
  }
  
  return 0;
}



Measured memory_bytes: 3240
#include <iostream>
using namespace std;
int main(void){
while (true){
   int a;
   int b;
   cin >> a;
   cin >> b;
  if (a==0 && b==0){
       break;
   }
   if (a<b){
       cout << a <<" "<< b;
   }
    else {
        cout << b <<" "<<a;
    }
    cout << endl;
}
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
ll a[200005],b[200005];
int main()
{
    /*int  d,t,s;
    cin >> d >> t>> s;
    int dis = s*t;
    if(dis>=d)
        cout << "Yes\n";
    else
        cout << "No\n";*/
    /*string s,t;
    int mn = 1e9;
    cin >> s>> t;
    int n = (int)s.size();
    int m = (int)t.size();
    for(int i=0;i<n-m+1;i++)
    {
        int cur=0,lol=0;
        for(int j=i;j<i+m;j++)
        {
            if(s[j]!=t[cur])
                lol++;
            cur++;
        }
        mn = min(lol,mn);
    }
    cout << mn << endl;*/
    ll n;
    cin >> n;
    for(ll i=1;i<=n;i++)
        {
            cin >> a[i];
            b[i] = a[i];
            b[i]+=b[i-1];
        }
    ll sum=0;
    for(ll i=1;i<n;i++)
    {
        ll num = b[n]-b[i];
        //cout << num << endl;
        num = num%mod;
        sum = (sum+ num*a[i])%mod;
    }
    cout << sum << endl;

}


Measured memory_bytes: 6720
#include <cstdio>

const int N = 100000 + 10;

char s[N];

int main() {
  scanf(" %s", s);
  int ans = 0;
  int g = 0, p = 0;
  for (char *i = s; *i; ++i) {
    if (*i == 'g') {
      if (p + 1 <= g) ++p, ++ans; else ++g;
    } else {
      if (p + 1 <= g) ++p; else ++g, --ans;
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
// --https://kenkoooo.com/atcoder/#/table/soma62jp
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>

using namespace std;


int main(int argc, char* argv[]) {

	int n;
	int ans = 0;

	cin >> n;

	for(int i=0 ; i <= n / 4 ; i++){
		for(int j=0 ; j <= n / 7 ; j++){
			if(4*i+j*7==n) ans++;
		}
	}

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

}

Measured memory_bytes: 256