akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =998244353;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void 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;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 
    


  int main(){
     lint n;
     cin>>n;
     lint a[n];
     rep(i,n)cin>>a[i];
     lint ans=0;
     rep(i,n)ans^=a[i];
     rep(i,n){
         ans^=a[i];
         cout<<ans<<" ";
         ans^=a[i];
     }
     }
     

  
 
  
      
      
    
 
  
          
  

Measured memory_bytes: 5248
#include <cstdio>
#include <cmath>
#include <utility>
using Point = std::pair<float, float>;
using Line = std::pair<Point, Point>;

Point add(Point p1, Point p2){
    Point np;
    np.first = p1.first + p2.first;
    np.second = p1.second + p2.second;
    return np;
}
Point rotate60FromOrign(Point p){
    const float sin = std::sqrt(3) / 2.f;
    const float cos = 0.5f;
    Point np;
    np.first = p.first * cos - p.second * sin;
    np.second = p.first * sin + p.second * cos;
    return np;
}
void operate(int i, int n, Line line){
    if(i == n){
        std::printf("%0.8f %0.8f\n", line.first.first, line.first.second);
        return;
    }
    Point newPoint[3];
    std::pair<float, float> vec1;
    vec1.first = (line.second.first - line.first.first) / 3.f;
    vec1.second = (line.second.second - line.first.second) / 3.f;
    newPoint[0] = add(line.first, vec1);
    newPoint[1] = add(newPoint[0], rotate60FromOrign(vec1));
    newPoint[2] = add(newPoint[0], vec1);

    Line newLine[4];
    newLine[0].first = line.first;
    newLine[0].second = newPoint[0];
    newLine[1].first = newPoint[0];
    newLine[1].second = newPoint[1];
    newLine[2].first = newPoint[1];
    newLine[2].second = newPoint[2];
    newLine[3].first = newPoint[2];
    newLine[3].second = line.second;

    operate(i+1, n, newLine[0]);
    operate(i+1, n, newLine[1]);
    operate(i+1, n, newLine[2]);
    operate(i+1, n, newLine[3]);
}

int main(){
    int n;
    std::scanf("%d", &n);
    Line line;
    line.first.first = 0.0f;
    line.first.second = 0.0f;
    line.second.first = 100.0f;
    line.second.second = 0.0f;
    operate(0, n, line);
    printf("%0.8f %0.8f\n", line.second.first, line.second.second);
    return 0;
}


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

stack<int> st;

int solve(string str) {
  int b = st.top();
  st.pop();
  int a = st.top();
  st.pop();
  if(str == "+")
    return a + b;
  else if(str == "-")
    return a - b;
  else if(str == "*")
    return a * b;
  else if(str == "/")
    return a / b;
}

int main() {
  string str;
  while(cin >> str) {
    if(str == "+" or str == "-" or str == "*" or str == "/") {
      st.push(solve(str));
    } else {
      st.push(atoi(str.c_str()));
    }
    if(getchar() == '\n') {
      cout << st.top() << endl;
      return 0;
    }
  }
}



Measured memory_bytes: 3148
import sys
input = sys.stdin.readline


def main():
    N, M = [int(x) for x in input().split()]
    k = []
    s = [[] for _ in range(M)]
    for i in range(M):
        A = [int(x) for x in input().split()]
        k.append(A[0])
        s[i].extend(A[1:])

    p = [int(x) for x in input().split()]

    ans = 0
    for i in range(2 ** N):
        switch = bin(i)
        switch = switch[2:]
        switch_len = len(switch)
        switch = '0' * (N - switch_len + 1) + switch
        for j in range(M):
            total = 0
            for l in s[j]:
                total += int(switch[l])
            if total % 2 != p[j]:
                break
            if j == M - 1:
                ans += 1

    print(ans)




if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,m,ans;
    scanf("%lld",&n);
    if(n<=2)
    {
        printf("0\n");
        return 0;
    }
    ans=0;
    for(m=1;m*m<n;m++)
    if(n%m==0&&n/m-1>m)
        ans=ans+n/m-1;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 10e9;
void RGBCards(){
	
	int r, g, b;
	cin >> r >> g >> b;
	cout << ((r * 100 + g * 10 + b) % 4 == 0 ? "YES" : "NO") << endl;
}

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, m;
  cin >> n >> m;
  vl cum(n + 1, 0);
  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    cum[a]++;
    cum[b]--;
  }
  bool ans = true;
  rep(i, n) {
    cum[i + 1] += cum[i];
    if(cum[i + 1] % 2) ans = false;
  }
  cout << (ans ? "YES" : "NO") << endl;
}

Measured memory_bytes: 4036
package main

import "fmt"

var (
	s string
)

func main() {
	fmt.Scan(&s)
	fmt.Println(solve(s) - 1)
}

func solve(s string) int {
	pre := rune(s[0])
	count := 1

	for _, v := range s {
		if pre != v {
			count++
			pre = v
		}
	}

	return count
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

int binpow(int a, int b) {
    if (b == 0)
    {
        return 1;
    }
    ll res = binpow(a, b / 2);
    res*=res;
    if (b % 2)
    {
        return res * a;
    }
    return res;
}

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

string to_upper(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
    return a;
}
 
string to_lower(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
    return a;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    ll ans=0;
    cin>>n;
    int a[n];
    map<int,int> m;
    for (int i=0;i<n;++i)
    {
        cin>>a[i];
        ans+=m[a[i]];
        ++m[a[i]];
    }
    for (int i=0;i<n;++i)
    {
        cout<<ans-(m[a[i]]-1)<<"\n";
    }
    return 0;
}

Measured memory_bytes: 8320
#include <stdio.h>
 
int main()
{
int a, b;
 
scanf ("%d %d", &a, &b);
 
if (a+b == 15 ){
printf ("+\n");
}
 
else if ( a*b == 15){
printf ("*\n");
}
 
else {
printf ("x\n");
}
 
return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(){
    int a,b,c,x,count=0;
    cin >> a >> b >> c >> x;
    for(int i=0; i<=a; i++){
        for (int j=0;j<=b;j++){
            for (int k=0;k<=c;k++){
                if(500*i + 100 * j + 50 * k == x){
                    count++;
                }
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 888
#include<stdio.h>

int main(){
   int N;
   char S[N];
   scanf("%d",&N);
   scanf("%s",S);
   int count=0;
    for(int i = 0; i < N - 2; i++){
      if (S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C'){
        count++;
      }
    }
  printf("%d",count);
  return 0;
}


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

using namespace std;

#define debug(x) '[' << #x << " is: " << x << "] "
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	ll n;
	cin>>n;
	cout << n*(n-1)/2 << endl;
}

Measured memory_bytes: 256
import math
N = int(input())
As =   list(map(int,input().split(" ")))

Asorted = As[:]
Asorted.sort()
diff = 0
for i in range(N):
    if Asorted[i] != As[i]:
        diff += 1
if diff == 0 or diff == 2:
    print("YES")
else:
    print("NO")



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

int main() {
  string a;
  cin >> a;
  if (a[0] == a[1])
    cout << "Bad" << endl;
  else if (a[1] == a[2])
    cout << "Bad" << endl;
  else if (a[2] == a[3] )
    cout << "Bad" << endl;
  else cout << "Good" << endl;
  
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        final double MOD = 1000000007;

        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt(); //1 <= N <= 100000

        double power = 1;
        for (int i = 1; i <= N; i++) {
           power = i * power % MOD;
        }
        System.out.printf("%.0f\n", power);
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

typedef long long int ll;

const int N = 1 << 17;
ll dat[N * 2 - 1] = { 0 }, n, m;

void update(int i, ll val) {
	i += m - 1;
	dat[i] = val;
	while(i > 0) {
		i = (i - 1) / 2;
		dat[i] = max(dat[i * 2 + 1], dat[i * 2 + 2]);
	}
	return;
}

ll getval(int a, int b, int k, int l, int r) {
	if (r <= a || b <= l) return 0;
	if (a <= l && r <= b) return dat[k];
	else{
		ll vl = getval(a, b, k * 2 + 1, l, (l + r) / 2);
		ll vr = getval(a, b, k * 2 + 2, (l + r) / 2, r);
		return max(vl, vr);
	}
}

int main(){
	ll a, v;
	double p, ip = 0.0, fp;
	cin >> n;
	p = log2(n);
	fp = modf(p, &ip);
	if(fp == 0.0) {
		m = 1 << int(p);
	}
	else{
		m = 1 << (int(p) + 1);
	}
	for(int i = 0;i < n;++i){
		cin >> a;
		v = getval(0, a, 0, 0, m);
		update(a - 1, a + v); // 0-indexedにしたいので
	}
	cout << n * (n + 1) / 2 - dat[0] << endl;
	return 0;
}


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

int main() {
  int a;
  cin >> a;
  
  if(a < 1200){
    cout << "ABC" << endl;
  }
  
  else if(a < 2800){
    cout << "ARC" << endl;
  }
  
  else{
    cout << "AGC" << endl;
  }
}
  
  


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout << fixed << setprecision(n)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main()
{
	int k = in(), s = in();
	int ans = 0;
	REP(x, k + 1) {
		REP(y, k + 1) {
			int z = s - x - y;
			if (0 <= z && z <= k) {
				++ans;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
    int A, B;
    cin >>A>>B;

    if ((A >= 1  && A <= 9) && (B >= 1  &&  B <= 9))
        cout << A*B<<endl;
     else
        cout << "-1"<<endl;
}

Measured memory_bytes: 3448
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int SIZE=1001;
//int arr[SIZE]={};
//ここまでテンプレ
int main(){
	char s[4];
	cin>>s;
	if(s[0]==s[2])
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,m;
  cin>>N;
  vector<int> vec(N);
  m=10000000000;
  for(int i=0;i<N;i++)
  cin>>vec[i];
for(int t=0;t<N;t++){
  int a=0,b=0,c=0;
for(int i=0;i<t;i++){
  a+=vec[i];
}
for(int j=t;j<N;j++){
  b+=vec[j];
}
  c=abs(a-b);
  m=min(c,m);
}
cout<<m<<endl;}
  


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


int main()
{
    long long k, m;
    queue <long long> q;
    cin >> k;
    for (int i=1;i<=9;i++)
        q.push(i);
    while (k--)
    {
        m=q.front();
        q.pop();
        if (m%10!=0) q.push(10*m+m%10-1);
        q.push(10*m+m%10);
        if (m%10!=9) q.push(10*m+m%10+1);
    }
    cout << m;
}


Measured memory_bytes: 1792
import Control.Monad
import Data.List

main :: IO ()
main = do
  [n, h] <- readInts
  ks <- replicateM n readInts
  print $ solve h ks

readInts :: IO [Int]
readInts = map read . words <$> getLine

solve :: Int -> [[Int]] -> Int
solve h ks = solve' h 0 a bs
  where
    a = maximum [ _a | [_a, _] <- ks ]
    bs = sortOn negate $ [ b | [_, b] <- ks, b > a ]

solve' :: Int -> Int -> Int -> [Int] -> Int
solve' h n a []
  | h <= 0 = n
  | otherwise = solve' (h - a) (n + 1) a []
solve' h n a (b:bs)
  | h <= 0 = n
  | otherwise = solve' (h - b) (n + 1) a bs



  


Measured memory_bytes: 155004
//code by lynmisakura.wish to be accepted!
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(void){
    int a,b,c;scanf("%d %d %d",&a,&b,&c);
    if(a+b >= c){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
A = []
A.append( [ int(x) for x in input().split() ] )
A.append( [ int(x) for x in input().split() ] )
A.append( [ int(x) for x in input().split() ] )

N = int( input() )
for nn in range(N):
    b = int( input() )
    for ii in range(3):
        for jj in range(3):
            if( A[ii][jj] == b ):
                A[ii][jj] = 0

ans = False
# tate
for ii in range(3):
    if( sum( A[ii] ) == 0 ):
        ans = True
# yoko
for jj in range(3):
    tmp = 0
    for ii in range(3):
        tmp += A[ii][jj]
    if( tmp == 0 ):
        ans = True
# naname        
if( A[0][0]+A[1][1]+A[2][2] == 0 ):
    ans = True  
if( A[2][0]+A[1][1]+A[0][2] == 0 ):
    ans = True        

# out            
if( ans ):
    print('Yes')        
else:
    print('No')   

Measured memory_bytes: 3064
N,M=map(int,input().split())
AB=[]
for i in range(N):
    AB.append(list(map(int,input().split())))
AB.sort(key=lambda x: x[0])

max_=0
for i in AB:
    if max_<i[0]:
        max_=i[0]

dp=[0]*(max_+M)
max_=0
for i in AB:
    for j in range(M)[::-1]:
        dp[j+i[0]] = max(dp[j+i[0]],dp[j]+i[1])
        
print(max(dp))

Measured memory_bytes: 45928
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}

int main(void){
	long long n=llin(),k=llin(),a,b,s=0,f[100001]={},i;
	for(i=0;i<n;i++){
		a=in();
		b=in();
		f[a]+=b;
	}
	for(i=0;i<=100000;i++){
		s+=f[i];
		if(s>=k){
			llprint(i);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 896
#include <iostream>

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

  return 0;
}


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

typedef long long int ll;

int main()
{
	ll n,ac=0,wa=0,tle=0,re=0;
	scanf("%lld",&n);
	for(ll i=0;i<n;i++)
	{
		string str;;
		cin>>str;
		if(str[0]=='A')
			ac++;
		if(str[0]=='W')
			wa++;
		if(str[0]=='T')
			tle++;
		if(str[0]=='R')
			re++;
	}
	printf("AC x %lld\n",ac);
	printf("WA x %lld\n",wa);
	printf("TLE x %lld\n",tle);
	printf("RE x %lld\n",re);
}



Measured memory_bytes: 3784
#include<stdio.h>
int main(void){
	int n,m;
	int a[200200],b[200200];
	int i;
	int h,tmp,flg;

	scanf("%d%d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d%d",&a[i],&b[i]);
	}
	h=m;flg=1;
	while(h>1||flg){
		if(h>1) h=h/1.3;
		if(h==10||h==9) h=11;
		flg=0;
		for(i=0;i<m-h;i++){
			if(b[i]>b[i+h]){
				tmp=b[i];
				b[i]=b[i+h];
				b[i+h]=tmp;
				tmp=a[i];
				a[i]=a[i+h];
				a[i+h]=tmp;
				flg=1;
			}
		}
	}
	tmp=0;
	flg=0;
	for(i=0;i<m;i++){
		if(tmp<a[i]){
			tmp=b[i]-1;
			flg++;
		}
	}
	printf("%d\n",flg);
	return 0;
}


Measured memory_bytes: 2500
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 998244353;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll c(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
int main(void) {
	int H, W, a = 0, b = 0, c = 0;
	cin >> H >> W;
	vector<string> s(H);
	rep(i, 0, H)cin >> s[i];
	map<char, int> mp;
	rep(i, 0, H)rep(i2, 0, W)mp[s[i][i2]]++;
	for (auto m : mp) {
		if (m.second % 4 == 1)a++;
		else if (m.second % 4 == 3)a++, b++;
		else if (m.second % 4 == 2)b++;
		else c++;
	}
	if (H % 2 && W % 2) {
		if (a == 1 && b <= (W + H - 2) / 2)puts("Yes");
		else puts("No");
	}
	else if (H % 2 == 0 && W % 2 == 0) {
		if (a + b == 0)puts("Yes");
		else puts("No");
	}
	else {
		if (H % 2)swap(W, H);
		if (a == 0 && b <= H / 2)puts("Yes");
		else puts("No");
	}
	return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
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; }

int n;
void func(string s){
    if(s.size() == n){
        cout << s << ln;
        return;
    }
    char ch;
    for(ch='a'; ch <= 'z'; ch++){
        auto iter = find(all(s), ch);
        if(iter == s.end()) break;
    }

    for(char c='a'; c <= ch; c++){
        s.push_back(c);
        func(s);
        s.pop_back();
    }
}

int main(){
   cin >> n;
   func("a");
}

Measured memory_bytes: 1536
#include<iostream>
#include<deque>
#include<iterator>
#include<list>
#include<queue>
#include<stack>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<math.h>
#include<utility>
#include<functional>
const int MOD = 1e9 + 7;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;

int main() {
    string s;
    cin >> s;
    int size = s.size();
    int sum = 0;
    if (size %2 == 0) {
        for (int i = 0; i < size/2; i++) {
            if (s.at(i) != s.at(size-1-i)) {
                sum++;
            }
        }
    }
    else {
        int sized = size - 1;
        for (int i = 0; i < sized/2; i++) {
            if (s.at(i) != s.at(size-1-i)) {
                sum++;
            }
        }
    }
    cout << sum << endl;
}

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

#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

using namespace std;

typedef long long int lli;

int main () {
    int N, M, Q;
    cin >> N >> M >> Q;
    vector<vector<int>> m(N + 1, vector<int>(M + 1, 0));
    REP (i, 1, N + 1) {
        REP (j, 1, M + 1) {
            char c;
            cin >> c;
            m[i][j] = c - '0';
        }
    }
    vector<int> x1(Q);
    vector<int> x2(Q);
    vector<int> y1(Q);
    vector<int> y2(Q);
    REP (i, 0, Q) cin >> y1[i] >> x1[i] >> y2[i] >> x2[i];
    vector<vector<int>> sum(N + 1, vector<int>(M + 1, 0));
    REP (i, 0, N) {
        REP (j, 0, M) {
            sum[i + 1][j + 1] = sum[i + 1][j] + sum[i][j + 1] - sum[i][j] + m[i + 1][j + 1];
        }
    }

    vector<vector<int>> edgec(N + 1, vector<int>(M + 1, 0));
    REP (i, 0, N) {
        REP (j, 0, M) {
            edgec[i + 1][j + 1] = edgec[i + 1][j] + edgec[i][j + 1] - edgec[i][j] + (m[i + 1][j + 1] && m[i + 1][j]);
        }
    }

    vector<vector<int>> edger(N + 1, vector<int>(M + 1, 0));
    REP (i, 0, N) {
        REP (j, 0, M) {
            edger[i + 1][j + 1] = edger[i + 1][j] + edger[i][j + 1] - edger[i][j] + (m[i + 1][j + 1] && m[i][j + 1]);
        }
    }

    REP (q, 0, Q) {
        cout << sum[y2[q]][x2[q]] - sum[y2[q]][x1[q] - 1] - sum[y1[q] - 1][x2[q]] + sum[y1[q] - 1][x1[q] - 1]
             - (edgec[y2[q]][x2[q]] - edgec[y2[q]][x1[q]] - edgec[y1[q] - 1][x2[q]] + edgec[y1[q] - 1][x1[q]])
             - (edger[y2[q]][x2[q]] - edger[y2[q]][x1[q] - 1] - edger[y1[q]][x2[q]] + edger[y1[q]][x1[q] - 1])
             << endl;
    }
    return 0;
}


Measured memory_bytes: 68480
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
double comb(ll n,ll k){
    double res=1;
    rep(i,k){
        res*=n-i;
        res/=i+1;
        res/=4;
    }
    return res;
}
int main(){
    ll n,m;cin >> n >>m;
    vl x(n),y(m);
    rep(i,n)cin >> x[i];
    rep(i,m)cin >> y[i];
    sort(all(x));sort(all(y));
    ll cumx=0;
    rep(i,n-1){
        ll l=i,r=i+1;
        ll res=(l+1)*(n-r);
        res%=MOD;
        res*=x[r]-x[l];
        res%=MOD;
        cumx+=res;
        cumx%=MOD;
    }
    ll cumy=0;
    rep(i,m-1){
        ll l=i,r=i+1;
        ll res=(l+1)*(m-r);
        res%=MOD;
        res*=y[r]-y[l];
        res%=MOD;
        cumy+=res;
        cumy%=MOD;
    }
    cout << (cumx*cumy)%MOD <<endl;
}

Measured memory_bytes: 1792
// =========
use std::cmp::{max, min};
use std::collections::{HashMap, HashSet};
use std::process::exit;

const MOD: usize = 1000000007;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    // var... 変数の識別子, $t...型を一つよむ
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        //ここで繰り返し
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    //
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    // 配列の最後のNestではここで型が指定されてparseされる
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
// =========

fn main() {
    input! {
        n: usize,
        s: String,
        t: String,
    }
    let s: Vec<char> = s.chars().collect();
    let t: Vec<char> = t.chars().collect();
    let mut res = String::new();
    for i in 0..n {
        res.push(s[i]);
        res.push(t[i]);
    }
    println!("{}", res);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <cstdlib>
#include <set>
#include <map>
#define INT long long
#define MOD 1000000007
#define oo 1987654321

using namespace std;

string s;
int m = 0;
int main()
{
    cin>>s;
    for(int i = 0 ; i < s.size() ; i++ )
    {
        if( !m and s[i] == 'C' ) m++;
        if( m and s[i] == 'F' ) m++;
    }
    if( m > 1 ) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 384
//2019.7.27 by ljz
//email 573902690@qq.com
//if you find any bug in my code
//please tell me
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f
#define eps 1e-10
#define RG register
#define db double
#define lb long db
#define pc(x) __builtin_popcount(x)
typedef pair<int,int> Pair;
#define mp make_pair
#define fi first
#define se second
#define pi acos(-1.0)
#define pb push_back
#define gc getchar
#define Pi 2.0*acos(-1.0)
//inline char gc() {
//    static char buf[100000],*p1,*p2;
//    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
inline int read() {
    res s=0,ch=gc();
    while(ch<'0'||ch>'9')ch=gc();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
    return s;
}
//inline int read() {
//    res s=0,ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc();
//    while(ch<'0'||ch>'9')ch=gc();
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline void write(RG __int128 x){
//    if(x>10)write(x/10);
//    putchar(x%10+'0');
//}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N=50+10;
namespace MAIN{
    int n;
    int a[N];
    inline void MAIN(){
        n=read();
        for(res i=1;i<=n;i++)a[i]=read();
        res ret=0;
        for(res i=1;i<=n;i++)if(a[i]!=i)ret++;
        if(ret==2||ret==0)puts("YES");
        else puts("NO");
    }
}
int main(){
//    freopen("compound1.in","r",stdin);
//    freopen("compound.out","w",stdout);
    MAIN::MAIN();
    return 0;
}

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


int n;
ll a[100010][3];
ll dp[100010][3];


int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n;
    cin >> n;
    
    rep(i,n){
        rep(j,3) cin >> a[i][j];
    }
    
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(j == k) continue;
                dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }
    
    ll res = 0;
    
    for(int j = 0; j < 3 ; j++){
        res = max(res,dp[n][j]);
    }
    
    cout << res << endl;
}


Measured memory_bytes: 4992
#include<iostream>
#include<map>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<n;i++)
int main (){
ll a,b,c,d;
cin >>a>>b>>c>>d;
if(abs(b-a)<=d&&abs(c-b)<=d)
cout <<"Yes";
else if(abs(c-a)<=d)
cout <<"Yes";
else
cout <<"No";
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // [b,c) イテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

int64_t N; cin >> N;
VI X(N); rep(i, 0, N) cin >> X[i];
VI Y = X;
sort(ALL(Y));
VI Xmed{Y[N/2 - 1], Y[N/2]};

rep(i, 0, N){
    if (X[i] <= Xmed[0]) cout << Xmed[1] << "\n";
    else cout << Xmed[0] << "\n";
}

}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



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

int main() {
  int N, M; cin >> N >> M;
  vector<int> A(M), B(M), C(M, 0);
  for (int i = 0; i < M; i++) {
    cin >> A.at(i) >> B.at(i);
    for (int j = 0; j < B.at(i); j++) {
      int c; cin >> c;
      c--;
      C.at(i) += (1 << c);
    }
  }
  int INF = 1000000000;
  vector<vector<int>> dp(M+1, vector<int>((1 << N), INF));
  dp.at(0).at(0) = 0;
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < (1 << N); j++) {
      dp.at(i+1).at(j) = min(dp.at(i+1).at(j), dp.at(i).at(j));
      int nj = j | C.at(i);
      dp.at(i+1).at(nj) = min(dp.at(i+1).at(nj), dp.at(i).at(j) + A.at(i));
    }
  }
  if (dp.at(M).at((1 << N) - 1) < INF) cout << dp.at(M).at((1 << N) - 1) << endl;
  else cout << -1 << endl;
}

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

typedef pair<int,int> ii;

const int N = 100009;

int n, a, b, h[N]={};

bool good(long long p){
    long long left = p;
    for(int i=1; i<=n; i++)
        if(h[i] - b * p > 0) left -= (int)round(ceil((h[i] - b * p) / (double)(a - b)));
    return left >= 0;
}

int main(){
    scanf("%d %d %d", &n, &a, &b);
    for(int i=1; i<=n; i++)
        scanf("%d", &h[i]);

    long long ans = 0, l = 1, r = 2e9;
    while(l <= r){
        long long mid = (l + r) >> 1;
        if(good(mid)){
            ans = mid;
            r = mid-1;
        }else l = mid+1;
    }

    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define Fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Freed freopen ("0in.txt","r",stdin);
#define Fout freopen ("0out.txt","w",stdout);
#define pi acos(-1.0)
#define ll long long
#define pb push_back
#define Mod 1000000007
#define limit 1000008
using namespace std;

void solve(int t)
{
    int a,b,c,k,i,j,n,sum=0,mx=0,ind,ct=1;
    cin >> a >> b >> c;
    cin >> k;
    while(k && a>=b)
    {
        b *= 2;
        k--;
    }
    while(k && b>=c)
    {
        c *= 2;
        k--;
    }
    if(a<b && b<c)
        cout <<"Yes\n";
    else
        cout <<"No\n";
}
int  main()
{
//    Fast
//    Freed
//    Fout
    int t,tt=1;
  //  cin >> tt;
    for(t=1; t<=tt; t++)
        solve(t);
  return 0;
}




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

int main(){
vector<char> a(3);
  vector<char> b(3);
  rep(i,3) cin >>a.at(i);
  rep(i,3) cin >>b.at(i);
  int ans =0;
  if(a.at(0)==b.at(0)) ans ++;
  if(a.at(1) == b.at(1)) ans ++;
  if(a.at(2) == b.at(2)) ans ++;
  cout <<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;//typo用
using uintl = unsigned long long;
using itn = int;//typo用
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl//1次元配列の出力
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl//二次元配列の出力
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) {a = b; return true;} return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) {a = b; return true;} return false; }
intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); }
intl lcm(intl a,intl b){ return a / gcd(a, b) * b; }
intl kai(intl k){//k!を求める関数,
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl digit10(intl a){//aを10進数で表したときの桁数を求める関数
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}

signed main(){
    cout << fixed << setprecision(10);
    intl n;
    cin >> n;
    intl a[n];
    rep(i,n)cin >> a[i];
    sort(a, a + n);
    vector<intl> v;
    intl cnt = 0;
    rep(i,n){
        intl i0 = a[i];
        bool f = true;
        for(intl j = 1; j * j <= i0; j++){
            if(!(i0 % j)){
                f = !binary_search(all(v),j);
                if(f)f = !binary_search(all(v),(i0 / j));
            }
            if(!f)break;
        }
        //if(f)debug(i0);
        if(i < n - 1)if(a[i] == a[i+1])f = false;
        cnt += f;
        v.pb(i0);
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 6924
#include<stdio.h>
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int N,i,b,sum=0;
    cin>>N;
    string aa;
    vector<string> data(50);
    vector<int> time(50);
    for(i=0;i<N;i++){
        cin>>data.at(i)>>time.at(i);
    }
cin>>aa;
for(i=0;i<N;i++){
    if(data.at(i)==aa){
b=i+1;
break;
    }
}
for(i=b;i<N;i++){
sum=time.at(i)+sum;
}
cout<<sum<<endl;
}

Measured memory_bytes: 384
package main

import (
  "fmt"
)

func main(){
  var N int
  var Y int
  fmt.Scan(&N, &Y)

  for i:=0; i<=N; i++{
    // 10000円札がi枚
    for j:=0; j<= N-i; j++{
      // 5000円札がj枚
      k:= N-i-j // 1000円札k枚
      if 10000*i+5000*j+1000*k == Y{
        fmt.Printf("%d %d %d",i,j,k)
        return
      }
    }
  }
  fmt.Println("-1 -1 -1")
}


Measured memory_bytes: 512
from numba import njit
import numpy as np
@njit
def dfs(v,c,h,stay):
    # hを更新
    x,y=divmod(v,n)
    for dx,dy in ((0,1),(0,-1),(1,0),(-1,0)):
        nx,ny=x+dx,y+dy
        if 0<=nx<n and 0<=ny<n:
            nv=nx*n+ny
            if h[nv]>c:
                h[nv]=c
                dfs(nv,c+stay[nv],h,stay)

@njit
def main(n,p):
    h=[min(i//n,n-i//n-1,i%n,n-i%n-1) for i in range(n**2)]
    h=np.array(h)
    stay=np.full(n**2,1)
    ans=0

    for v in p:
        c=h[v]
        ans+=c
        stay[v]=0
        dfs(v,c,h,stay)
    print(ans)

    #for i in range(n):
    #    print(h[i*n:(i+1)*n])
if __name__=='__main__':
    n=int(input())
    p=np.array(list(map(int,input().split())),np.int32)
    p-=1
    main(n,p)

Measured memory_bytes: 168212
def kaibun(s):
    if s==s[::-1]:
        return True
    else:
        return False
s = input()
n = len(s)
if kaibun(s) and kaibun(s[0:(n-1)//2]) and kaibun(s[(n+3)//2-1:n]):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n;
  int a,b;
  cin>>a>>b;
  int res = b%a==0?a+b:b-a;
  cout<<res;
  

  return 0;
}


Measured memory_bytes: 256
from collections import Counter


n = int(input())

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

c = Counter(a)


res = []

for i in range(1, n+1):
    m  = c.get(i, 0)
    res.append(m * (m-1) // 2)

s = sum(res)


for i in range(1, n+1):
    x = a[i-1]
    l = c.get(x, 0)


    print(s - res[x-1] + (l-1) * (l-2) // 2)




Measured memory_bytes: 26908
import java.util.Scanner;

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

        if(inputString.contains("A") && inputString.contains("B")){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21204
function main(input){
  input = input.split("\n");
  const n = parseInt(input[0]);
  var a = input[1].split(" ").map(x => parseInt(x))
  var b = input[2].split(" ").map(x => parseInt(x))
  var cnt = 0;
//  console.log(n);


  
  for (var i = 0; i < n; i++) {
    // a[i]とb[i]の比較
    if (a[i] > b[i]) {
      cnt += b[i];
      a[i] -= b[i];
      b[i] = 0;      
    }else {
      cnt += a[i];
      b[i] -= a[i];
      a[i] = 0;
    }

    // a[i+1]とb[i]の比較
    if (a[i+1] > b[i]) {
      cnt += b[i];
      a[i+1] -= b[i];
      b[i] = 0;      
    }else {
      cnt += a[i+1];
      b[i] -= a[i+1];
      a[i+1] = 0;
    }
    
  }
  
//  console.log(a);
// console.log(b);

  console.log(cnt);

}
  
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 30764
/*
    Author - Param Kothari
    Ah shit, here we go again
*/

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

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair

typedef long long ll;
typedef long double ld;

void solve(){
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    auto check = [&](ll x)->bool{
        ll res = 0;
        for(int i = 0; i < n; i++){
            res += ((a[i] + x - 1) / x) - 1;
        }
        return res <= k;
    };
    ll low = 1, high = 1000000001, mid = 0, res = 0;
    while(low <= high){
        mid = low + (high - low) / 2;
        if(check(mid)){
            high = mid - 1;
            res = mid;
        }
        else{
            low = mid + 1;
        }
    }
    cout << res << "\n";
    return;
}

int main(){
    IOS;
    int t = 1;
    // cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
    return 0;
}

Measured memory_bytes: 4744
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			int num = stdIn.nextInt();
			if(num == 0) break;
			int[] data = new int[num + 1];
			int sum = 0;
			int ans = Integer.MIN_VALUE;
			for(int r = 0; r < num; r++) {
				int input = stdIn.nextInt();
				sum += input;
				data[r + 1] = sum;
				ans = Math.max(ans, input);
			}
			for(int r = 0; r <= num; r++) {
				for(int c = r + 1; c <= num; c++) {
					ans = Math.max(ans, data[c] - data[r]);
				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 26372
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

void output(const vi& a)
{
	repi(i,1,a.size())
		printf("%d%c",a[i],i==a.size()-1?'\n':' ');
}

void solve(vi& a,int remain)
{
	if(remain==0){
		output(a);
		return;
	}
	int left=a.back();
	a.push_back(0);
	for(int i=min(left,remain);i;i--){
		a.back()=i;
		solve(a,remain-i);
	}
	a.pop_back();
}

int main()
{
	for(int n;cin>>n,n;){
		vi a(1,INT_MAX);
		solve(a,n);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(void){
    int n; //審判の数

    while(true){
        int s[1010]; //各審判のつけた点数
        cin >> n;
        if(n == 0) break;

        for(int i = 0; i < n; i++)
            cin >> s[i];

        int max = 0, min = 1000; //点数の最小値、最大値
        for(int i = 0; i < n; i++){
            if(s[i] > max) max = s[i];
            if(s[i] < min) min = s[i];
        }

        int sum = 0; //最高点と最低値を除いた点数たちの和
        int mean; //最高点と最低値を除いた点数の平均値
        for(int i = 0; i < n; i++){
            sum += s[i];
        }
        mean = (sum - max - min) / (n - 2);

        cout << mean << endl;
    }
}



Measured memory_bytes: 3056
#include <cstdio>
#include <algorithm>
using namespace std;
int n,nn,i,j,c,r[505*505];
pair<int,int> a[505];
int main() {
  scanf("%d",&n); nn=n*n;
  for (i=0; i<n; i++) {
    scanf("%d",&a[i].first);
    a[i].second=i+1;
  }
  sort(a,a+n);
  for (i=0, j=1; i<n; i++) {
    for (c=1; j<=nn && c<a[i].second; j++) if (r[j]==0) {
      r[j]=a[i].second;
      c++;
    }
    if (j>nn || c<a[i].second || r[a[i].first]!=0) { puts("No"); return 0; }
    r[a[i].first]=a[i].second;
  }
  reverse(a,a+n);
  for (i=0, j=nn; i<n; i++) {
    for (c=0; j>0 && c<n-a[i].second; j--) if (r[j]==0) {
      r[j]=a[i].second;
      c++;
    }
    if (j<a[i].first || c<n-a[i].second) { puts("No"); return 0; }
  }
  puts("Yes");
  for (i=1; i<=nn; i++) printf("%d%c",r[i],(i==nn)?'\n':' ');
  return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n, m;
	cin >> n >> m;
	
	vector<int> L(m), R(m);
	for(int i = 0; i < m; ++i) {
		cin >> L[i] >> R[i];
		L[i]--;
		R[i]--;
	}
	
	int Lmax = *max_element(L.begin(), L.end());
	int Rmin = *min_element(R.begin(), R.end());
	
	int ans = 0;
	for(int i = 0; i < n; ++i) {
		if( i >= Lmax && i <= Rmin ) ans++;
	}
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#define errOut(s) \
  { std::cerr << __LINE__ << ":" << #s << ":" << (s) << std::endl; }

#include <bits/stdc++.h>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
//#include <boost/multi_array.hpp>
//#include <boost/optional.hpp>
//#include <boost/range/adaptors.hpp>
//#include <boost/range/algorithm.hpp>
//#include <boost/range/irange.hpp>
#pragma clang diagnostic pop

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  uint64_t a;
  std::cin >> a;
  uint64_t b = 0;
  while (true) {
    char ch;
    std::cin >> ch;
    if (!std::cin || ch == '\n') {
      break;
    }
    if (ch == '.') {
      continue;
    }
    b *= 10;
    b += ch - '0';
  }
  auto const res = a * b / 100;
  std::cout << res << std::endl;
  return 0;
}


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

using namespace std;

const int MAX = 100000;

long long int A[300];

int main(int argc, char *argv[])
{
  int N, ans = 0;
  cin >> N;

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if ((4*i + 7*j) == N) {
        puts("Yes");
        return 0;
      } else if ((4*i + 7*j) > N) {
        break;
      }
    }
  }

  puts("No");
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Dictionary - Map: Delete
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_8_B&lang=jp

"""
d = dict()
for _ in range(int(input())):
    op, key, x = (input() + ' 1').split()[:3]
    if op == '0':
        d[key] = x
    elif op == '1':
        print(d.get(key, 0))
    elif key in d:
        del d[key]



Measured memory_bytes: 41864