akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
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();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  int N,A,B;
  cin>>N>>A>>B;
  if((B-A)%2==0) co("Alice");
  else co("Borys");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
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; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int a, b, c; cin >> a >> b >> c;
    b /= a;
    cout << min(b, c) << endl;
}

Measured memory_bytes: 256
N = int(input())
XL = [tuple(map(int, input().split())) for _ in range(N)]
XL.sort(key=lambda p:(p[0]+p[1]))
L = -10 ** 10
ans = 0
for x, l in XL:
    if L <= x - l:
        L = x + l
        ans += 1
print(ans)

Measured memory_bytes: 21348
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll A, B, C, D;
  cin >> A >> B >> C >> D;

  while(true){
    C -= B;

    if(C <= 0){
      cout << "Yes" << endl;
      return 0;
    }

    A -= D;

    if(A <= 0){
      cout << "No" << endl;
      return 0;
    }
  }
  
  return 0;
}


Measured memory_bytes: 3636
def examA():
    N = SI()
    ans = "No"
    for s in N:
        if s=="7":
            ans = "Yes"
    print(ans)
    return

def examB():
    N = I()
    ans = 0
    for i in range(1,N+1):
        if i%3==0:
            continue
        if i%5==0:
            continue
        ans += i
    print(ans)
    return

def examC():
    def gcd(x, y):
        if y == 0:
            return x
        while (y != 0):
            x, y = y, x % y
        return x
    K = I()
    ans = 0
    for i in range(1,K+1):
        for j in range(1,K+1):
            cur = gcd(i,j)
            for k in range(1,K+1):
                ans += gcd(cur,k)
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(readline())
def LI(): return list(map(int,readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examC()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 78156
H,W = map(int,input().split())
c = []
dicta = {}
dicta[-1] = 0
for i in range(10):
    c.append(list(map(int,input().split())))
    dicta[i] = 0
c = [i for i in zip(*c)]
for i in range(H):
    a = list(map(int,input().split()))
    for i in a:
        dicta[i] += 1
dicta.pop(-1)
cost = [0 for i in range(10)]
def dijkstra_heap(start,node,cost):
    import heapq
    d = [float('inf') for i in range(node)]
    d[start] = 0
    d2 = [[0,start]]
    heapq.heapify(d2)
    while d2:
        c,v = heapq.heappop(d2)
        if d[v] < c:
            continue
        for j in range(node):
            if d[j] > d[v]+cost[v][j]:
                d[j] = d[v]+cost[v][j]
                heapq.heappush(d2,[d[j],j])
    return d

cost = dijkstra_heap(1,10,c)
ans = 0
for k,v in dicta.items():
    ans += v*cost[k]
print(ans)



Measured memory_bytes: 3188
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

int main() {
  int n, m;
  scanf("%d %d", &n, &m);


  vector<double> A(n);
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    A[i] = (double) a;
  }

  double sum = (double) accumulate(A.begin(), A.end(), 0);
  double bottom = sum / (4  * m);

  int count = 0;
  for (int i = 0; i < n; i++) {
    if (A[i] >= bottom) {
      count++;
    }
  }

  cout << ((count >= m) ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        int h = Integer.parseInt(H);
        int a = Integer.parseInt(A);

        int num = h / a;
        if ((h % a) != 0) {
            num = num + 1;
        }

        System.out.println(num);
    }
}


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

int main(){
  int n,m,c;
  int count=0;
  cin >> n >> m >> c;
  vector<int> b(m);
  vector<int> sum(n,0);
  vector<vector<int>> a(n,vector<int> (m));
  for(int i=0;i<m;i++){
    cin >> b[i];
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin >> a[i][j];
      a[i][j] *= b[j];
        sum[i] += a[i][j];
      }
    }
  for(int i=0;i<n;i++){
    if(sum[i]+c>0){
        count ++;
    }
  }
  cout << count << endl;
}

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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in();
	vector<pair<int,int>> Q(N);
	REP(i,N){
		Q[i].first=in(),Q[i].second=in();
	}
	vector<int> P(8);
	iota(ALL(P),0);
	
	do{
		bool safe=true;
		REP(i,N){
			if(P[Q[i].first]!=Q[i].second){
				safe=false;
				break;
			}
		}
		if(!safe) continue;

		REP(i,8){
			int u=P[i],v=i;
			while(u>0 && v>0){
				if(P[v-1]==u-1){
					safe=false;
					break;
				}
				u--;
				v--;
			}
			u=P[i],v=i;
			while(u<7 && v<7){
				if(P[v+1]==u+1){
					safe=false;
					break;
				}
				u++;
				v++;
			}
			u=P[i],v=i;
			while(u>0 && v<7){
				if(P[v+1]==u-1){
					safe=false;
					break;
				}
				u--;
				v++;
			}
			u=P[i],v=i;
			while(u<7 && v>0){
				if(P[v-1]==u+1){
					safe=false;
					break;
				}
				u++;
				v--;
			}
		}
		if(safe){
			REP(i,8){
				REP(j,8){
					cout << (P[i]==j ? 'Q' : '.');
				}
				out();
			}
			return 0;
		}
	}while(next_permutation(ALL(P)));

	return 0;
}



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

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	string s;
	cin >> s;
	
	int x = 0;
	int ans = 0;
	for(auto itr = s.begin(); itr != s.end(); itr++)
	{
		if(*itr == 'I')
		{
			x++;
		}
		else
		{
			x--;
		}
		
		if(ans < x)
		{
			ans = x;
		}
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))

max_len = 0
num = max(a+[k])
while num > 0:
    num //= 2
    max_len += 1

dp = [[0, 0] for _ in range(max_len)]

for i in range(0, max_len)[::-1]:
    # count one
    one_cnt = 0
    for el in a:
        if el & (1<<i):
            one_cnt += 1
            
    # first 
    if i == max_len-1:
        if k & (1<< i):
            dp[i][0] = one_cnt*(1<<i)
            dp[i][1] = (len(a) - one_cnt)*(1<<i) 
        else:
            dp[i][1] = one_cnt*(1<<i)
        continue
            
    # else
    if k & (1<<i):
        # select one
        dp[i][1] = (len(a) - one_cnt)*(1<<i) + dp[i+1][1]
        dp[i][0] = (len(a) - one_cnt)*(1<<i) + dp[i+1][0]
        # select zero
        dp[i][0] = max(dp[i][0], one_cnt*(1<<i) +  max(dp[i+1][0], dp[i+1][1]))
    else:
        dp[i][0] = max(one_cnt, len(a) - one_cnt)*(1<<i) + dp[i+1][0]
        # select zero
        dp[i][1] = one_cnt*(1<<i) + dp[i+1][1]

print(max(dp[0]))

Measured memory_bytes: 14620
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c,A,B,C,x,i,n;
	cin>>n;
	for(i=0;i<n;i++){
	cin>>a>>b>>c;
	if(a<b)swap(a,b);
	if(a<c)swap(a,c);
	if(b<c)swap(b,c);
	A=a*a;
	B=b*b;
	C=c*c;
	x=B+C;
	if(A==x){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	}
	return 0;
}

Measured memory_bytes: 2976
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, M, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

c = M - N
def f(n):
     return (1 + n) * n // 2

print(f(c) - M)

Measured memory_bytes: 3316
#include <stdio.h>
#include <math.h>

int main (void) {
    int N;
    int a[10000];
    int evenCnt[10000];
    int allOdd = 0;
    int result = 0;

    scanf ("%d", &N);
    int i;
    for (i = 0; i < N; i++) {
        evenCnt[i] = 0;
        scanf ("%d", &a[i]);
        while (a[i] % 2 == 0) {
            a[i] /= 2;
            evenCnt[i]++;
            allOdd++;
        }
    }

    if (allOdd == 0) {
        result = 0;
    } else {
        for (i = 0; i < N; i++) {
            if (evenCnt[i] != 0) result += evenCnt[i];
        }
    }
    
    printf ("%d", result);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdbool.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#define rep(i,n) for(int i=0; i <(n); i++)
int main(){
  char a[100];
  char b[100];
  scanf("%s%s",a,b);
  if(strcmp(a,b)>0){
    printf(">\n");
  }else if(strcmp(a,b)==0){
    printf("=\n");
  }else{
    printf("<\n");
  }
  return 0;
}


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

#define forn(i,n) for(ll i = 0;i<n;i++)
#define forne(i,j,n) for(ll i = j;i<n;i++)
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ll INF = 1000000001;
const ll N = 100001;
const lld PI = 3.141593;
#define F first
#define pb(a) push_back(a)
#define S second
#define pii pair<int,int>
typedef pair<ll,ll> pll;

ll powm(ll base,ll exp) {
	ll ans=1;
	while(exp){
		if(exp&1) ans=(ans*base)%mod;
		exp>>=1,base=(base*base)%mod;
	}
	return ans;
}

// ll dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
// bool valid(ll i, ll j) {
// 	return i >= 1 && i <= n && j >= 1 && j <= m; 
// }
// int maxdepth = INT_MAX;
// vector<int> edgeVector[100000];
// ll minans = 1;
// printf("1 %d D\n",abs(r));
// priority_queue<ll,vector<ll>,greater<ll>> pq;
// ll a[N],b[N];
// vector<vector<ll>> adj(N);
// vector<set<ll>> adjs(N);
// ll adj[1001][1001];
// vector<vector<ll>> ans(1001);
// bool visited[N];
// ll cnt[1001];
// ll h,c,t;
// vector<pair<int, pair<int, int> > > g[300043];



int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output1.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

ll n;
cin>>n;
vector<pll> egdes;
forn(i,n-1){
	ll x,y;
	cin>>x>>y;
	if(x > y) swap(x,y);
	egdes.push_back({x,y}); 
}
ll fa = n*(n+1)*(n+2);
fa/=6;
for(auto i:egdes){
	ll l = i.F,r = i.S;
	ll k = l*(n-r+1);
	fa-=k;
}
cout<<fa<<endl;

}

Measured memory_bytes: 7380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, l, r) for (int i = l; i <= (int)(r); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> v;
    for (int i = 1; i*i <= m; i++){
        if(m%i==0){
            v.emplace_back(i);
            if(i*i!=m) v.emplace_back(m/i);
        }
    }

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

    cout << v[upper_bound(v.begin(), v.end(), m/n) - v.begin()-1] << endl;
    return 0;
}

Measured memory_bytes: 256
S = input()

count = 0
fircnt = 0
before = ''
first = ''

cl = set()

for s in S:
    if s not in cl:
        count += 1
        cl.add(s)
        if first == '':
            first = s
    if first == s:
        fircnt += 1
if count != 2:
    print('No')
elif fircnt == 2:
    print('Yes')
else:
    print('No')


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 100005;
int N;
int A[MAX_N];

signed main()
{
  cin >> N;
  REP(n,N) {
    cin >> A[n];
  }

  int K = 0;
  REP(n,N) {
    K += (n%2 == 0 ? 1 : -1) * A[n];
  }

  int a = K/2;
  REP(n,N) {
    cout << a*2;
    if(n<N-1) cout << " ";
    a = A[n]-a;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 2048
#include <stdio.h>

int main(void)
{
        int a[7]={1,3,5,7,8,10,12},b[4]={4,6,9,11},c=2;
        int s1=0,s2=0,x,y,i;
        scanf("%d%d",&x,&y);
        for(i=0;i<7;i++)
                if(x==a[i] || y==a[i])s1++;
        for(i=0;i<4;i++)
                if(x==b[i] || y==b[i])s2++;
        if(s1==2 || s2==2 || x==2 && y==2)printf("Yes");
        else printf("No");
        return 0;
}


Measured memory_bytes: 1640
#include <iostream>
#include<math.h>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;

int main() {

    int N;
    cin >> N;

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

    int num = 0;
    for (int i = 0; i < N; ++i) {
        num += A[i] - 1;
    }

    cout << num << endl;
    
    return 0;
}

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

int main(){
	string n1, n2;
	cin >> n1;
	cin >> n2;
	if (n1.size() > n2.size()) {
		cout << "GREATER\n";
	}else if (n1.size() < n2.size()) {
		cout << "LESS\n";
	}else {
		bool hay = false;
		for (int i = 0; i < n1.size(); i++) {
			int c1 = (int)n1[i] - '0';
			int c2 = (int)n2[i] - '0';
			if (c1 > c2){
				cout << "GREATER\n";	
				hay = true;
				break;
			} else if (c1 < c2) {
				cout << "LESS\n";
				hay = true;
				break;
			} 
		}
		if (!hay)
			cout << "EQUAL\n";
	}
	return 0;
}

Measured memory_bytes: 256
int main(void){
	int i,n,x,a,b,c,l;
	
	c=0;
	l=0;
	scanf("%d",&n);

	scanf("%d",&a);
	for(x=0;x<n-1;x++){
		scanf("%d",&b);
		if(a==b){
			if(l==0){
				c++;
				l=1;
			}
			else
				l=0;
		}
		else
			l=0;

		a=b;
	}

	printf("%d",c);
	return 0;
}


Measured memory_bytes: 128
#coding utf-8
N=int(input())
A=list(map(int,input().split())) 
B=list(map(int,input().split()))

ans=0
for i in range(N):
  if B[i]<=A[i]:
    ans +=B[i]
  else:
    ans +=A[i]
    B[i]-=A[i]
    if B[i]<=A[i+1]:
      ans +=B[i]
      A[i+1]-=B[i]
    else:
      ans +=A[i+1]
      A[i+1]=0

print(ans)    

Measured memory_bytes: 19116
#include "bits/stdc++.h"

using namespace std;


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

    long long A, B, C, D, lcm_CD;
    int a, b, r;


    cin >> A >> B >> C >> D;

    a = D;
    b = C;

    r = a%b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }

    lcm_CD = C * D / b;
    cout << B-A+1 - (B/C - (A-1)/C) - (B/D - (A-1)/D) + (B/lcm_CD - (A-1)/lcm_CD) << "\n";
    
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define ll         long long
#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

//方針

ll llabs(ll x){
    return x>=0?x:-x;
}

bool hugou(double x){
    return x >= 0;
}
ll A[100000];
int main(){
    int n;
    cin >> n;
    ll sum = 0;
    ll ans1 = 0, ans2 = 0;
    FOR(i, 0, n) cin >> A[i];
    //+-+-...
    int f = 1;//1=+
    FOR(i, 0, n){
        ll a = A[i];
        if(f*(sum+a)<=0){
            ans1 += llabs(sum+a) + 1;
            sum = f;
        }
        else sum += a;
        f *= -1;
    }
    //-+-+...
    f = -1;
    sum = 0;
    FOR(i, 0, n){
        ll a = A[i];
        if(f*(sum+a)<=0){
            ans2 += llabs(sum+a) + 1;
            sum = f;
        }
        else sum += a;
        f *= -1;
    }
    cout << min(ans1, ans2) << endl;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int DFS(int num, int total, int minNum)
{
    if (num == 0 && total == 0)
    {
        return 1;
    }
    
    if (num == 0) //judge the invalid input
    {
        return 0;
    }
    
    if (total < 0)
    {
        return 0;
    }
    
    if (minNum > 9 || minNum > total)
    {
        return 0;
    }
    
    int count1 = DFS (num - 1, total - minNum, minNum + 1);
    int count2 = DFS (num, total, minNum + 1);
    
    return count1 + count2;
    
}


void Solution()
{
    int n, sum;
    
   // int usedNum = 0;
    
    while (cin>>n>>sum)
    {
        if (n == 0 && sum == 0 )
        {
            break;
        }
        
        int count = DFS (n, sum, 0);
   
        cout<<count<<endl;
    }
}

int main()
{
    Solution();
    return 0;
}

//dfs //depth first search
//cnt // count

Measured memory_bytes: 1160
n, x = gets.strip.split.map(&:to_i)

@p_counts = [1]
@b_counts = [0]

n.times do 
  @p_counts.push(@p_counts.last*2+1)
  @b_counts.push(@b_counts.last*2+2)
end
@pb_counts = @p_counts.zip(@b_counts).map {|l, r| l+r }

#p @p_counts
#p @b_counts
#p @pb_counts

def bite_count(dim, count)
  if dim.zero?
    if count <= 0
      return 0
    else
      return 1
    end
  end

  return bite_count(dim-1, count-1) if count <= 1 + @pb_counts[dim-1]
  @p_counts[dim-1] +1 + bite_count(dim-1, count-1-@pb_counts[dim-1]-1)
end

p bite_count(n, x)


Measured memory_bytes: 1788
using System;
using System.Linq;
using System.Collections.Generic;

class P
{
    static void Main()
    {
        //int[] N = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int i = int.Parse(Console.ReadLine());

        Console.WriteLine(new int[] { 1, 2, 4, 8, 16, 32, 64 }.Where(x => x <= i).Max());
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int x,t; cin >> x >>t;
    cout << max(x-t,0) << endl; return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long N;
  cin >> N;
  long long t = 998244353;
  vector<long long> D(N);
  long long max = 0;
  for(long long i = 0; i < N; i++){
    cin >> D.at(i);
    if(max < D.at(i)) max = D.at(i);
  }
  vector<long long> count(max + 1, 0);
  for(long long i = 0; i < N ; i++){
    count.at(D.at(i))++;
  }
  if(N == 1 && D.at(0) == 0){
    cout << 1 << endl;
  }
  else if(D.at(0) != 0){
    cout << 0 << endl;
  }
  else{
  	long long ans = 1;
  	if(count.at(0) != 1){
      cout << 0 << endl;
  	}
  	else{
      int s = 0;
      for(long long i = 1; i < max + 1; i++){
        if(count.at(i - 1) == 0){
          cout << 0 << endl;
          s = 1;
          break;
        }
        else if(count.at(i) != 0){
          for(long long j = 0; j < count.at(i); j++){
            ans *= count.at(i - 1);
            ans = ans % t;
          }
        }
      }
      if(s == 0) cout << ans << endl;
  	}
  }
}

Measured memory_bytes: 1792
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
//19234567892927;
const int mod=1e9+7;
const llint big=1e15+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
int main(void){
	int n,bi,i,j,b,ans=-mod;cin>>n;
	vector<int> mise(n);
	vector<array<int,11>> rieki(n);
	for(i=0;i<n;i++){
		int a=0;
		for(j=0;j<10;j++){
			int x;cin>>x;
			if(x==1){a+=(1<<j);}
		}
		mise[i]=a;
	}
	for(i=0;i<n;i++){for(j=0;j<=10;j++){cin>>rieki[i][j];}}
	for(bi=1;bi<1024;bi++){
		int gen=0;
		for(i=0;i<n;i++){
			int kab=0;
			for(j=0;j<10;j++){
				if((bi&mise[i]&(1<<j))!=0){kab++;}
			}
			gen+=rieki[i][kab];
		}
		maxeq(ans,gen);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <queue>
#include<iomanip>
#include <cmath>
#include <set>
#include <unordered_set>

#define ABS(x) ((x)>0?(x):-(x))
#define MIN(x,y) ((x)>(y)?(y):(x))
#define MAX(x,y) ((x)<(y)?(y):(x))

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

#define INF 1000000000

using namespace std;
typedef long long ll;

ll newton(long long int a, long long int  b)
{
	if(a==b)
		return a;
	while(a != 0 && b != 0)
	{
		if(a > b)
		{
			b += a;
			a = b-a;
			b -= a;
		}
		b %= a;
	}
	return a;
}

struct UnionFind {
	vector<int> p;
	UnionFind(int N):p(N)
	{
		for(int i=0; i< N; i++)
		{
			p[i] = i;
		}
	}
	int root(int x)
	{
		if(p[x] == x)
			return x;
		return p[x] = root(p[x]);
	}
	void unite(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		if(rx == ry) return;
		p[rx] = ry;
	}
	bool issame(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

//大きな数に対する割り算をするとき、MODを指定することで掛け算の値に変換できる

ll div2mul_calc(ll a, ll b, ll m)
{
	if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll d = div2mul_calc(a, b / 2, m);
        return (d * d) % m;
    } else {
        return (a * div2mul_calc(a, b - 1, m)) % m;
    }
}
ll div2mul(ll n, ll mod)
{
	return div2mul_calc(n, mod-2, mod);
}

ll twoRow(ll a, ll b, ll mod)
{
	ll ret = 1;
	for(ll i = 1 ;i <= a+b;++i)
	{
		ret *= i;
		ret %= mod;
	}
	for(ll i = 1 ;i <= a;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	for(ll i = 1 ;i <= b;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	return ret;
}

struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(ret.begin(), ret.end());
  return (ret);
}
/*
小数の桁数を指定する
	cout << setprecision(8)<< mp[0]-mx << endl;
*/
ll nx[2000000] = {0};
ll cur[2000000] = {0};

void print(int M, int N) {
	char c[16];
	c[N]='\0';
	for(int i=0;i<N;++i)
	{
		c[N-i-1] = 'a'+M%10;
		M /= 10;
	}
	cout << c << endl;;
}
void saiki(int n, int t, int T, int N, int mn) {
	for(int i=0;i<=MIN(t,mn+1);++i)
	{
		if(t+1==N)
		{
			print(n+i, N);
		}
		else
		{
			saiki(n+i*T,t+1,T/10,N,MAX(i,mn));
		}
	}
}
int main()
{
	int N,T=1, M;
	cin >> N;
	for(int i=1;i<N;++i)
	{
		T *= 10;
	}
	saiki(0,0,T,N,0);

	return 0;
}




















Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define lp(i, n) for (int i = 0; i < (n) ; ++i)
#define lpp(i, n) for (int i = 1; i <= (n) ; ++i)
#define lpi(i, j, n)    for(int i=(j);i<=(int)(n);++i)
#define lpd(i, j, n)    for(int i=(j);i>=(int)(n);--i)
#define sz(v) (int)(v).size()
#define clr(v, d)       memset(v, d, sizeof(v))
#define mod 1000000007
#define ll long long

#define vi std::vector<int>
int cx[] = {1, 0, -1, 0};
int cy[] = {0, 1, 0, -1};


struct ans
{
    ll hi ;
    ll idx ;
};

bool gr(ans a , ans b ) {
    return a.idx < b.idx ;
}

void solve() {
    string x , y ;
    cin >> x >> y ;
    x = "0" + x;
    y = "0" + y;
    std::vector<vi> dp(x.size() + 1, vi(y.size() + 1, 0));
    lpp(i, x.size() - 1) {
        lpp(j, y.size() - 1) {
            if (x[i] == y[j]) {dp[i][j] = dp[i - 1][j - 1] + 1;}
            else {
                dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
            }
        }
    }
    int pre = 0;
    string ans = "";
    for (int i = x.size()-1,j = y.size()-1; i > 0 && j>0 ; ) {
            if (x[i] == y[j]) {ans+=x[i]; ; i--;j--;continue;}
            else {
                if (dp[i][j] == dp[i][j - 1]) {
                    j--;
                }
                if (dp[i - 1][j] == dp[i][j]) {
                    i--;
                };
        }
    }
    reverse(all(ans));
    cout << ans ;

}


























int main() {

    std::ios_base::sync_with_stdio(false);
    int t = 1;
    //cin >> t ;
    while (t--) {
        solve();
    }
    return 0 ;



}


Measured memory_bytes: 35584
#include <stdio.h>

int main(void)
{
    char str[10];
    int num[10];
    int tmp;
    int i,j;

    while (scanf("%s", str) != EOF){
        for (i = 0; i < 10; i++){
            num[i] = str[i] - '0';
        }
        for (i = 0; i < 9; i++){
            for (j = 0; j < 9 - i; j++){
                tmp = num[j] + num[j+1];
                num[j] = tmp % 10;
            }
        }
        printf("%d\n", num[0]);
    }

    return (0);
}


Measured memory_bytes: 1976
#include<iostream>
using namespace std;
int main(){
  int N, K;
  cin >> N >> K;
  int L = 0;
  
  for(int i = 0; i < N; i++){
  int x;
  cin >> x;
  if(2*(K - x) > 2*x){
  L +=2 * x;
  }
  else{
    L +=2 * (K - x);
  }
   
  }
 	cout << L << endl;
}

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

int main() {
    string s;
    cin >> s;
    int q;
    cin >> q;
    deque<char> Q;
    for(char c : s) Q.push_back(c);
    bool flip = false;
    for(int i = 0; i < q; i++) {
        int t;
        cin >> t;
        if (t == 1) {
            flip = !flip;
        }
        if (t == 2) {
            int f;
            cin >> f;
            char c;
            cin >> c;
            if (flip) {
                f = 3 - f;
            }
            if (f == 1) {
                Q.push_front(c);
            }
            if (f == 2) {
                Q.push_back(c);
            }
        }
    }
    if (flip) reverse(Q.begin(), Q.end());
    string ans;
    for (char c : Q) ans += c;
    cout << ans << endl;
    return 0;
}

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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;

using namespace std;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 
	
	int r , g , b;
	cin >> r >> g >> b;
	int n = r * 100 + g * 10 + b;
	if(n % 4 == 0)dier("YES");
	cout << "NO";

	return 0;
}

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

const int INF = 10010;

int main(void){
  int a, b;
  cin >> a >> b;
  int ans = INF;
  for(int i = 1; i < 1005; i++){
    if(floor(i*8/100) != a) continue;
    if(floor(i*10/100) != b) continue;
    ans = min(ans, i);
  }
  if(ans == INF) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main(){

  int N, K;
  cin >> N >> K;
  int x[N];
  for(int i=0;i<N;i++) cin >> x[i];

  int ans = 0;
  for(int i=0;i<N;i++){
  	ans += min(x[i], K - x[i]);
  }

  cout << 2*ans <<endl;

  
  return 0;
}









Measured memory_bytes: 256
import functools

def gcd(num1, num2):
    r = num1 % num2
    while (r > 0):
        num1 = num2
        num2 = r
        r = num1 % num2
    return num2

n = int(input())
a = list(map(int, input().split()))

max_koyaku_num = functools.reduce(gcd, a)

print(max_koyaku_num)

Measured memory_bytes: 14596
import sys
N, K, Q = map(int, input().split())
A = (int(x) for x in sys.stdin.read().split())
score = [K - Q] * (N + 1)
for a in A:
  score[a] += 1
ans =  "\n".join('Yes' if s > 0 else 'No' for s in score[1:])
print(ans)

Measured memory_bytes: 12624
N= int(input())
H= int(input())
W = int(input())
if N!=H:
    if N!=W:
        print('{}'.format((N-H+1)*(N-W+1)))
    else:
        print('{}'.format((N-H+1)))
elif N!=W:
    print('{}'.format((N-W+1)))
else:
    print('{}'.format((1)))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(b - a == c - b)  cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
def many_medians(N: int, X: list) -> list:
    """必要なのはXをソート(降順)したとき N/2 番目と
    N/2 + 1 番目(ともに 1-indexed)の値。
    N/2 番目の値を x 、N/2 + 1 番目の値を y とする。
    xi >= x の時は y、xi < x の時は x が答え。
    """
    x, y = sorted(X, key=lambda a: -a)[N//2-1:N//2+1]
    return [x if xi < x else y for xi in X]


if __name__ == "__main__":
    N = int(input())
    X = list(map(int, input().split()))
    ans = many_medians(N, X)
    for b in ans:
        print(b)


Measured memory_bytes: 25228
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<long long>v(n+1,1e5);
	for(int i=0;i<n-1;i++){
		cin>>v[i+1];
	}
	
	vector<long long>a(n);
	for(int i=0;i<n;i++){
		a[i]=min(v[i],v[i+1]);
	}
	
	long long sum=0;
	for(int i=0;i<n;i++){
		sum+=a[i];
	}
	cout<<sum<<endl;
}

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

int main() {
  //入力値取得
  int N;	cin >> N;
  vector<int> toNumber(N+1);	//0番目は使用しない
  for(int i=1; i<N+1; i++){
    cin >> toNumber.at(i);
  }
  
  //入力確認
  //cout << N << endl;
  //for(int i=1; i<N+1; i++){
  //  cout << i << ':' << toNumber.at(i) << endl;
  //}
  
  //フラグ宣言
  vector<int> hasPush(N+1, false);
  int nowButton = 1;
  int counter = 0;
  
  while(1){
    if(nowButton == 2){
      cout << counter << endl;
      return 0;
    }
    
    if(hasPush.at(nowButton)){
      cout << -1 << endl;
      return 0;
    }
    else {
      hasPush.at(nowButton) = 1;
      nowButton = toNumber.at(nowButton);	counter++;
    }
  }
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

void solve(){
    int n,m;
    cin>>n>>m;
    vector<modint998244353> a(n),b(m);
    {
        ll t;
        for(auto&i:a) cin>>t,i=t;
        for(auto&i:b) cin>>t,i=t;
    }
    for(auto&i:convolution(a,b)) cout<<i.val()<<" ";
    cout<<'\n';
}

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

Measured memory_bytes: 19028
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int P = 2019;
        final char[] str = in.nextLine().toCharArray();
        final int N = str.length;
        final int[] digits = new int[N];
        for (int i = 0; i < N; i++) {
            digits[i] = Character.getNumericValue(str[i]);
        }
        final int[] remainders = new int[P];
        remainders[0] = 1;
        int sum = 0;
        int shift = 1;
        long ans = 0;
        long tt = 0;
        for (int pos = N - 1; pos >= 0; pos--) {
            sum = (sum + shift * digits[pos]) % P;
            ans += remainders[sum];
            remainders[sum]++;
            shift = (shift * 10) % P;
        }
        for (int l : remainders) {
            tt += l * (l - 1) / 2;
        }
        System.out.println(tt);
    }
}


Measured memory_bytes: 42300
<?php
    list($n, $m) = explode(' ', trim(fgets(STDIN)));
	
	$favoriteFood = explode(' ', trim(fgets(STDIN)));
	array_shift($favoriteFood);
	for ($i = 1; $i < $n; $i++) {
      	$nextFavoriteFood = explode(' ', trim(fgets(STDIN)));
      	array_shift($nextFavoriteFood);
    	$favoriteFood = array_intersect($favoriteFood, $nextFavoriteFood);
    }

	echo count($favoriteFood), PHP_EOL;

Measured memory_bytes: 4856
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll gcd(int a,int b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(int a,int b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll INFS=1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);

int main() {
  int k;
  cin>>k;
  int ans=0;
  for(int i=1;i<=k;i++){
    for(int j=1;j<=k;j++){
      for(int l=1;l<=k;l++){
        ans+=gcd(i,gcd(j,l));
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define mmp(a,b) make_pair(a,b);
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
const int MN = 100100;
pl so[MN],ok[MN];
ll wa[MN],wb[MN];
ll fa[MN],fb[MN];
map<ll,ll> ap,bp;
int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	ll n;
	cin >> n;
	for(int i=0;i<n;i++) {
		ll t;cin >> t;
		so[i].second = t;
	}
	for(int i=0;i<n;i++) {
		ll t;cin >> t;
		so[i].first = t;
	}
	sort(so,so+n);
	for(int i=0;i<n;i++) {
		wa[i] = so[i].second;
		wb[i] = so[i].first;
		fa[i] = wa[i];
		fb[i] = wb[i];
		ok[i] = mmp(wa[i],i);
	}
	sort(fa,fa+n);
	sort(fb,fb+n);
	sort(ok,ok+n);
	bool poss = true,mp = false;
	for(int i=0;i<n;i++) {
		if(fa[i] > fb[i]) {
			poss = false;
		}
	}
	if(!poss) {
		cout << "No\n";return 0;
	}
	for(int i=0;i<n;i++) {
		int id = lower_bound(fb,fb+n,fa[i])-fb;
		if(id < i) {
			mp = true;
		}
	}
	if(mp) {
		cout << "Yes\n";return 0;
	}
	int ctr = 1;
	int pt = ok[0].second;
	while(pt != 0) {
		pt = ok[pt].second;
		ctr++;
	}
	if(ctr < n) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}


Measured memory_bytes: 6528
#include <iostream>

using namespace std;

int main()
{
    int ans = 0;
    string s;
    cin >> s;
    int i = 0 , j = s.size() - 1;
    while(i < j) {
        if(s[i] != s[j])
            ans ++;
        i ++;
        j --;
    }
    cout << ans;
}


Measured memory_bytes: 256
from heapq import heapify, heappop, heappush

# 次の桁の生成ルール ex. 1 -> 10, 11, 12
def next_num(n):
    if n == 0:
        return [0, 1]
    elif n == 9:
        return [8, 9]
    else:
        return [n-1, n, n+1]

K = int(input())
queue = [1, 2, 3, 4, 5, 6, 7, 8, 9]  # とりあえず 1 桁の Lunlun Number を初期値にとる
heapify(queue)

for _ in range(K-1):
    now = heappop(queue)  # 最小値を取り出す
    # 取り出した値を使って次の桁の値を生成し queue に投げる
    for next_i in next_num(now%10):
        heappush(queue, now*10 + next_i)

print(queue[0])  # K 回目に取り出す最小値

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

#define ll long long
#define pb push_back
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cerr << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);

void solve() {
    int n, m, k;
    cin >> n >> m >> k;
    char a[n][m];
    int white = 0;
    int black = 0;
    for(int i = 0; i<n; i++) {
        for(int j = 0; j<m; j++) {
            cin >> a[i][j];
            if(a[i][j] == '.') white ++;
            else black ++;
        }
    }
    vector<vector<int>> r, c;
    for(int i = 0; i<(1<<n); i++) {
        vector<int> v;
        for(int j = 0; j<n; j++) {
            if(i & (1 << j)) {
                v.pb(j);
            }
        }
        r.pb(v);
    }
    for(int i = 0; i<(1<<m); i++) {
        vector<int> v;
        for(int j = 0; j<m; j++) {
            if(i & (1 << j)) {
                v.pb(j);
            }
        }
        c.pb(v);
    }


    int ans = 0;
    for(int i = 0; i<int(r.size()); i++) {
        for(int j = 0; j<int(c.size()); j++) {
            int done[n][m] = {};
            int B = 0;
            for(auto it: r[i]) {
                for(int col = 0; col < m; col ++) {
                    done[it][col] = 1;
                    if(a[it][col] == '#') B ++;
                }
            }
            for(auto it: c[j]) {
                for(int row = 0; row < n; row ++) {
                    if(done[row][it] == 1) continue;
                    if(a[row][it] == '#') B ++;
                    done[row][it] = 1;
                }
            }
            int currBlack = black - B;
            if(currBlack == k) {
                ans ++;
//                debug2(i, j);
            }
        }
    }
    cout << ans << '\n';
}

int main() {_
    int t = 1;
    //cin >> t;
    //Please remember to uncomment for taking test cases
    for(int i = 1; i<=t; i++) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3616
function Main(input) {
    input = input.trim().split(" ");
    var W = parseInt(input[0], 10);
    var H = parseInt(input[1], 10);
    var x = parseInt(input[2], 10);
    var y = parseInt(input[3], 10);

    var S = W * H / 2;
    var flag;
    if (x == W / 2 && y == H / 2) {
        flag = 1;
    }
    else {
        flag = 0;
    }

    console.log(S + " " + flag);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int main()
{
    int a[3];
    rep(i, 3)cin >> a[i];
    qsort(a, sizeof(a) / sizeof(int), sizeof(int),asc);
    cout << abs(a[0] - a[1]) + abs(a[1] - a[2]) << endl;
    return 0;
}

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

#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

#if __cplusplus >= 201402L
#include <shared_mutex>
#endif

using namespace std;

int main() {
    long long q, h, s, d;
    scanf("%lld %lld %lld %lld", &q, &h, &s, &d);
    long long n;
    scanf("%lld", &n);

    h = min(2 * q, h);
    s = min(2 * h, s);
    d = min(2 * s, d);

    cout << (n >> 1) * d + (n & 1) * s << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

typedef long long LL;
const int MN = 5005;

int A, B, N, pos[MN];
LL f[MN * 2], g[MN * 2];

int main() {
	scanf("%d%d%d", &N, &A, &B);
	for (int i = 1, x; i <= N; ++i)
		scanf("%d", &x), pos[x] = i;
	for (int i = 1; i <= N; ++i) {
		for (int j = 1; j <= N * 2 + 1; ++j)
			g[j] = j & 1 ? j > 1 ? std::min({g[j - 2], f[j - 1], f[j]}) : f[1] : g[j - 1];
		for (int j = 1; j <= N * 2 + 1; ++j)
			g[j] += j > 2 * pos[i] ? A : j < 2 * pos[i] ? B : 0;
		std::swap(f, g);
	}
	printf("%lld\n", *std::min_element(f + 1, f + 2 * N + 2));
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	long N, M;
	while (cin >> N >> M && N != 0 || M != 0)
	{
		vector< pair<int,int> > dp(N);
		long long  ans = 0;
		for (int i = 0; i < N; i++)
		{
			cin >> dp[i].second >> dp[i].first;
			//ans += dp[i].second * dp[i].first;
		}
		sort(dp.begin(), dp.end());
		reverse(dp.begin(), dp.end());

		for (int i = 0; i < N; i++)
		{
			if (M <= 0)break;
			if (M >= dp[i].second)
			{
				M -= dp[i].second;
				//ans -= dp[i].second * dp[i].first;
				dp[i].second = 0;
			}
			else
			{
				dp[i].second -= M;
				//ans -= M * dp[i].first;
				M = 0;
			}
		}
		for (int i = 0; i < N; i++)
		{
			ans += dp[i].second * dp[i].first;
		}
		cout << ans << endl;



	}
	return 0;
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}
lint lcm(lint a,lint b){
      return a/__gcd(a,b)*b;
  }
 
  int main(){
  lint N;
  cin>>N;
  lint A[N+1];
  A[N]=-1;
  rep(i,N){
      cin>>A[i];
  }
  sort(A,A+N);
  vector<lint>x;
  rep(i,N){
      lint k=1;
      x.push_back(A[i]);
    while(1){
        if(A[i]!=A[i+1]){
            x.push_back(k);
            break;
        }
        k++;
        i++;
    }
  }
  lint ans=0;
  rep(i,x.size()-1){
     if(x[i]<x[i+1])ans+=(x[i+1]-x[i]);
     else if(x[i]>x[i+1])ans+=x[i+1];
     i++;
  }
  cout<<ans;
  }


Measured memory_bytes: 3188