akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
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 long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << min(a,b) + min(c,d) << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=1e5+9;
int main()
{
    FASTINOUT;
    int x,y;
    cin>>x>>y;
    cout<<((x*y)&1?"Odd":"Even");
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
class Main {
    public static void main(String[] args) {
        try {
			final BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
			final String key = input.readLine();
			int count = 0;
			boolean flag = true;
			String[] strs;
			while(flag){
			    strs = input.readLine().split(" ");
			    for(final String str : strs){
			    	if (str.equals("END_OF_TEXT")) {
			    		flag = false;
			    	} else if(str.equalsIgnoreCase(key)){
			            count++;
			        }
			    }
			}
			System.out.println(count);
		} catch (Exception e) {
			e.printStackTrace();
		}
    }
}

Measured memory_bytes: 16912
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int H = cin.nextInt();
        int W = cin.nextInt();
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                if (cin.next() == "snuke") Console.WriteLine("{0}{1}", (char)('A' + j), i + 1);
            }
        }
    }




}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 11220
def half_and_half(a,b,c,x,y):
    z = x   if x > y else y
    can = []
    
    for n in range(z+1):
        p = x - n if x > n else 0
        q = y - n if y > n else 0
        amount = p*a + q*b + n*c*2
        #print("%d = %d x %d + %d x %d + %d x %d " %(amount,p,a,q,b,n,c))
        can.append(amount)

    #print(sorted(can,reverse=True))
    print(min(can))
    #print('')
if __name__ == '__main__':
    a,b,c,x,y = map(int,input().split())
    #a,b,c,x,y = 1500,2000,1600,3,2
    #print(a,b,c,x,y)
    half_and_half(a,b,c,x,y)


Measured memory_bytes: 7096
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include <algorithm>
#include <map>
#include <string>
#include <set>
#include<vector>

using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define ll long long
#define rn(i,n) for(int i=1;i<=n;i++)
#define INF 1000000010
const int mo=1e9+7;


ll N, K;
ll a[5000 + 10];

ll dp[5000 + 10][5000 + 10];

int main() {
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
  
	sort(a, a + N);

	dp[0][0] = 1;
  
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < K; j++) {
			dp[i + 1][j] += dp[i][j];
			if (j + a[i] < K) {
				dp[i + 1][j + a[i]] += dp[i][j];
			}
		}
	}

	int ans = N;
	for (int i = 0; i < N; i++) {

		ll dplast[5000 + 10] = {};
    
		for (int j = 0; j < K; j++)dplast[j] = dp[N][j];
    
		for (int j = 0; j < K; j++) {
			//dpを一回さし戻す
			if (j + a[i] < K)dplast[j + a[i]] -= dplast[j];
			if (j >= K - a[i] && dplast[j]) {
				ans--;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 196096
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;

int main(){

  int N;
  cin >> N;
  ll ans = 0;

  for (int i = 1; i <= N; i++) {
    if(i%3 == 0 && i%5 == 0){
    } else if (i%3 == 0){
    } else if (i%5 == 0){
    } else {
      ans += i;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

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

    int A, P;
    cin >> A >> P;

    cout << (A * 3 + P) / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
s = input().rstrip().split(' ')
a = int(s[0])
b = int(s[1])
base = a / b
c = math.floor(base)
d = a % b
e = Decimal(str(base)).quantize(Decimal('0.00001'), rounding=ROUND_HALF_UP)
print(str(c) + " " + str(d) + " " + str(e))


Measured memory_bytes: 6456
#include <iostream>

using namespace std;

int main() {

	int x,y;
	while(1){
    cin >> x >> y;
    if ( x == 0 && y == 0 ) break;  

	if(x < y){
		cout << x << " " << y << endl;
	} else {
		cout << y << " " << x << endl;
	}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int N=1407,K=38;
vector<int> w[1507]; int X=K;
int main(){
	printf("%d %d\n",N,K);
	for(int i=1;i<=K;i++) w[i].push_back(1);
	for(int i=2;i<=X;i++) w[1].push_back(i);
	for(int i=2;i<=K;i++)
		for(int j=1;j<K;j++)
			w[(i-1)*(K-1)+1+j].push_back(i);
	for(int i=2,gp=0;i<=K;i++,gp++){
		for(int j=2;j<=K;j++){
			w[i].push_back(++X);
			for(int t=2,p=j-1;t<=K;t++,p+=gp,p=(p%(K-1)==0? K-1:p%(K-1)))
				w[(t-1)*(K-1)+1+p].push_back(X);
		}
	}
	for(int i=1;i<=N;i++){
		for(int j=0;j<w[i].size();j++)
			printf("%d ",w[i][j]);
		puts("");
	}

}

Measured memory_bytes: 896
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    B = list(map(int, input().split()))

    res = []
    for i in range(n):
        L = len(B)
        for j in reversed(range(L)):
            if j + 1 == B[j]:
                res.append(B[j])
                B.pop(j)
                break
        else:
            print(-1)
            exit()

    res = res[::-1]
    for i in res:
        print(i)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <time.h>
#include <stdlib.h>

void dice_set(int dice1[], int dice2[])
{
	int i;

	for (i = 0; i < 6; i++) {
		dice2[i] = dice1[i];
	}
}

void dice_north(int d[], int b[])	//北側に回転
{
	int i;
	
	for (i = 0; i < 6; i++) {
		b[i] = d[i];
	}
	d[0] = b[1];
	d[1] = b[5];
	d[2] = b[2];
	d[3] = b[3];
	d[4] = b[0];
	d[5] = b[4];
}

void dice_south(int d[], int b[])
{
	int i;

	for (i = 0; i < 6; i++) {
		b[i] = d[i];
	}
	d[0] = b[4];
	d[1] = b[0];
	d[2] = b[2];
	d[3] = b[3];
	d[4] = b[5];
	d[5] = b[1];
}

void dice_east(int d[], int b[])
{
	int i;

	for (i = 0; i < 6; i++) {
		b[i] = d[i];
	}
	d[0] = b[3];
	d[1] = b[1];
	d[2] = b[0];
	d[3] = b[5];
	d[4] = b[4];
	d[5] = b[2];
}

void dice_west(int d[], int b[])
{
	int i;

	for (i = 0; i < 6; i++) {
		b[i] = d[i];
	}
	d[0] = b[2];
	d[1] = b[1];
	d[2] = b[5];
	d[3] = b[0];
	d[4] = b[4];
	d[5] = b[3];
}

int main(void)
{
	int dice[5];
	int box[5];
	int redice[5];
	int n;
	int i;
	int ue, mae;
	char kaiten[4] = { 'N', 'S', 'E', 'W' };
	int ans;

	srand(time(NULL));
	ans = rand() % 4;

	for (i = 0; i < 6; i++) {
		scanf("%d", &dice[i]);
	}

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		dice_set(dice, redice);
		scanf("%d %d", &ue, &mae);
		while (1) {
			ans = rand() % 4;
			if (kaiten[ans] == 'N')
				dice_north(redice, box);
			else if (kaiten[ans] == 'S')
				dice_south(redice, box);
			else if (kaiten[ans] == 'W')
				dice_west(redice, box);
			else if (kaiten[ans] == 'E')
				dice_east(redice, box);
			if ((redice[0] == ue) && (redice[1] == mae)) {
				printf("%d\n", redice[2]);
				break;
			}
		}
	}

	
	
	return 0;
}


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

int main(){
  long N, A, B;
  cin >> N >> A >> B;
  long ans;
  if((B-A)%2==0){
    ans = (B-A)/2;
  }
  else if((A-1)>=(N-B)){
    ans = N-B;
    A+=N-B;
    B=N;
    if((B-A)%2==0){
      ans += (B-A)/2;
    }else{
      ans += (B-A)/2+1;
    }
  }else{
    ans = A-1;
    B-=A-1;
    A=1;
    if((B-A)%2==0){
      ans += (B-A)/2;
    }else{
      ans += (B-A)/2+1;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import Data.List as L
next :: Int -> Int
next a = floor $ (realToFrac (a::Int)) * (1.01::Double)

solve :: Int -> Int -> Int -> Int
solve current x count = case current >= x of
  True -> count
  False -> solve (next current) x ( count + 1 )

main=do
  (x:_)<-L.map read . words<$>getLine::IO[Int]
  print $ solve 100 x 0

Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long LL;

int main(){
	int n;
	cin >> n;
	pair<int,int> s[2*n];
	for(int i = 0; i < n; i++){
		cin >> s[i].first;
		s[i].second = -1;
	}
	for(int i = 0; i < n; i++){
		cin >> s[i+n].first;
		s[i+n].second = 1;
	}
	sort(s,s+2*n);
	LL ans = 1;
	LL cur = 0;
	for(int i = 0; i < 2*n; i++){
		if(abs(cur+s[i].second) < abs(cur)){
			ans *= abs(cur);
			ans %= MOD;
		}
		cur += s[i].second;
	}
	cout << ans << endl;


}


Measured memory_bytes: 1920
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	//long long N;
	//cin >> N;

	string s;
	cin >> s;

	//int A[5]
	//sort(A, A + 5);

	long long a = 0;

	for (long long i = 0; i < s.length(); i++)
	{
		a += s[i] - '0';
	}

	if (a % 9 == 0)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

int main()
{
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n) cin >> c[i];
    ssort(a); ssort(b); ssort(c);
    vector<ll> upc(n), acu_upc(n);
    rep (i, n) {
        auto it = upper_bound(c.begin(), c.end(), b[i]);
        int cnt = c.end() - it;
        if (cnt < 0) cnt = 0;
        upc[i] = cnt;
    }
    acu_upc[n - 1] = upc[n-1];
    rrepSE (i, n - 2, -1) {
        acu_upc[i] = acu_upc[i+1] + upc[i];
    }
    ll ans = 0;
    rep(i,n) {
        auto it = upper_bound(b.begin(), b.end(), a[i]);
        int j = it - b.begin();
        if (j<=n-1) {
            ans += acu_upc[j];
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 5864
#include "bits/stdc++.h"
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define debug(var) std::cout << #var << " : " << var << std::endl;
using ll = long long;
using ull = unsigned long long;
using vint = std::vector<int>;
using vvint = std::vector<std::vector<int>>;
using namespace std;
ll mod = 1e9 + 7;


int main() {


	string S; cin >> S;
	int ans = 0;
	rep(i, S.size()) {
		if (S[i] == '+')ans++;
		else ans--;
	}

	cout << ans;


	return 0;
}

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

p1 = sum(x) // len(x)
p2 = p1 + 1

sum1 = sum([(item - p1) ** 2 for item in x])
sum2 = sum([(item - p2) ** 2 for item in x])
print(min(sum1, sum2))

Measured memory_bytes: 38384
#include <stdio.h>
#include <stdbool.h>
//T -- 0 A -- 1 G -- 2 C -- 3
long mod = 1e9+7;

long add(long a, long b) {
    return (a + b) % mod;
}

bool ng(int a, int b, int c) {
    return (a == 1 && b == 2 && c == 3);
}

void solve(int n) {
    int i, a, b, c, d;
    long ans;
    long dp[n+2][4][4][4];
    for(i = 0; i <=n; ++i) {
        for(a = 0; a < 4; ++a){
            for(b = 0; b < 4; ++b) {
                for(c = 0; c < 4; ++c) {
                    if(i == 0 && a == 0 && b == 0 && c == 0) {
                        dp[i][a][b][c] = 1;
                    }
                    else { dp[i][a][b][c] = 0; }
                }
            }
        }
    }
    for(i = 0; i <n; ++i) {
        for(a = 0; a < 4; ++a) {
            for(b = 0; b < 4; ++b) {
                for(c = 0; c < 4; ++c) {
                    for(d = 0; d < 4; ++d) {
                        if(ng(b,c,d) || ng(c,b,d) || ng(b,d,c)) { continue; }
                        if(ng(a,c,d) || ng(a,b,d)) { continue; }
                        dp[i+1][b][c][d] = add(dp[i+1][b][c][d], dp[i][a][b][c]);
                    }
                }
            }
        }
    }
    ans = 0L;
    for(a = 0; a < 4; ++a) {
        for(b = 0; b < 4; ++b) {
            for(c = 0; c < 4; ++c) {
                ans = add(ans, dp[n][a][b][c]);
            }
        }
    }
    //printf("mod: %d\n", 1000000009);
    printf("%ld\n", ans);
}

int main(void) {
    int n;
    scanf("%d", &n);
    solve(n);
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static long f(long b, long n){
        if(n < b)
            return n;
        return f(b, n / b) + ( n % b);
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long s = sc.nextLong();
        if (n < s)
            System.out.println(-1);
        else if(n == s)
            System.out.println(n + 1);
        else{
            ArrayList<Long> divisors = new ArrayList<>();
            long diff = n - s;
            long index = 1;
            while(index * index <= diff){
                if(diff % index == 0){
                    divisors.add(index);
                    if(diff / index != index)
                        divisors.add(diff / index);
                }
                index += 1;
            }
            Collections.sort(divisors);
            for(long div: divisors){
                if(f(div + 1, n) == s){
                    System.out.println(div + 1);
                    return;
                }
            }
            System.out.println(-1);
        }
    }
}


Measured memory_bytes: 24020
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


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


def f(x, y, z):
    return x**2 + y**2 + z**2 + x * y + y * z + z * x


def count(x, y, z):
    if x == y == z:
        return 1
    elif x == y or y == z:
        return 3
    else:
        return 6


def solve(n):
    x = 1
    ans = 0
    Z_MAX = int(n**0.5) + 1
    while f(x, x, x) <= n:
        y = x
        while f(x, y, y) <= n:
            z_min = y
            z_max = Z_MAX
            while z_max - z_min > 1:
                # print(z_max, z_min)
                t = (z_max + z_min) // 2
                if f(x, y, t) < n:
                    z_min = t + 1
                elif f(x, y, t) > n:
                    z_max = t
                else:
                    z_min = t
            if f(x, y, z_min) == n:
                ans += count(x, y, z_min)

            y += 1
        x += 1

    return ans


def main():
    N = int(input())
    for i in range(1, N + 1):
        print(solve(i))

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 71880
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

long long a[100010][3]; 
long long dp[100010][3];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) 
      for (int j = 0; j < 3; ++j) 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;
                chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }
    long long res = 0;
    for (int j = 0; j < 3; ++j) chmax(res, dp[N][j]);
    cout << res << endl;
}

Measured memory_bytes: 8284
a=str(input())
b=str(input())
ans=0
c=[]
l=0
for x in range(len(a)-len(b)+1):
    ans=0
    for i in range(len(b)):
       if a[i+l]!=b[i]:
           ans+=1
    l+=1
    c.append(ans)
print(min(c))

Measured memory_bytes: 9004
from collections import deque
h, w = map(int, input().split())
a = [input() for _ in range(h)]
memo = [[-1 if j=="." else 0 for j in list(i)] for i in a]

q = []
for i in range(h):
    for j in range(w):
        if a[i][j]=="#":
            q.append([i, j])
q = deque(q)
while q:
    x, y = q.popleft()
    for s, t in [[1,0],[-1,0],[0,1],[0,-1]]:
        if 0<=x+s and 0<=y+t and x+s<h and y+t<w:
            if memo[x+s][y+t]<0:
                memo[x+s][y+t]=memo[x][y]+1
                q.append([x+s,y+t])
print(max(max(i) for i in memo))

Measured memory_bytes: 156168
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define int long long int
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define INF 1e9+7
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
int mpow(int base, int exp);
void ipgraph(int m);
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
const int mod = 1e9 + 7;
const int N = 1e5+5, M = N;
//=========================================

vector<int> adj[N];
int dp[N][2];

// dp[node][0] --> number of ways to build a valid subtree if node is white
// dp[node][1] --> number of ways to build a valid subtree if node is black

void dfs(int v, int par = -1){
    dp[v][0] = dp[v][1] = 1;
    for(int u : adj[v]){
        if(u == par) continue;
        dfs(u, v);
      	// if the current node is white then the color of the child doesn't matter
        dp[v][0] = (dp[v][0] * ((dp[u][0] + dp[u][1]) % mod)) % mod;
        // if the current node is painted black then each child must be white.
      	dp[v][1] = (dp[v][1] * dp[u][0]) % mod;
    }
}

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    for(int i = 0; i < n - 1; ++i){
        int x, y; cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    
    // calling dfs on the root of the tree
    dfs(1, -1);

    cout << (dp[1][0] + dp[1][1]) % mod << endl;

    return 0;
}


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

using namespace std;

int main(void){
    string s;
    cin >> s;
    for(int i = 1; i < s.size(); i++){
        if(s[i] == s[i-1]){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  bool flag = false;
  if (s.at(0) != s.at(1))
    flag = true;
  if (s.at(1) != s.at(2))
    flag = true;
  if (s.at(2) != s.at(0))
    flag = true;
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
//This code was made by Chinese_zjc_.
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<map>
#include<queue>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
int n,k,a[200002],b[200002];
signed main()
{
	std::ios::sync_with_stdio(false);
	cin>>n>>k;
	for(int i=1;i<=n;++i)
	{
		cin>>a[i];
	}
	for(int j=1;j<=k;++j)
	{
		for(int i=1;i<=n;++i)
		{
			++b[max(1ll,i-a[i])];
			--b[min(n+1,i+a[i]+1)];
		}
		for(int i=1;i<=n;++i)
		{
			a[i]=b[i]+a[i-1];
			b[i]=0;
		}
		bool flag=true;
		for(int i=1;i<=n;++i)
		{
			if(a[i]!=n)
			{
				flag=false;
				break;
			}
		}
		if(flag)
		{
			break;
		}
	}
	for(int i=1;i<=n;++i)
	{
		cout<<a[i]<<' ';
	}
	return 0;
}



Measured memory_bytes: 6752
#pragma GCC optimize ("-O3")
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define f(i,x,n) for(ll i=x;i<n;i++)
#define pb push_back
#define mp make_pair
#define debug(x) cout<<x<<"\n";
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define MOD 1000000007

int main() {
	
	int t;
	t=1;
	//cin >> t;
	
	while(t--){
	  
	 int n;
	 cin>>n;
	 ll ans=0;
	 for(int i=1;i<n;i++)
	 { 
	    if(n%i==0)
	    {
	    	ans+=(n/i)-1;
		}
		else
		{
			ans+=(n/i);
		}
		
	 }
	 cout<<ans<<endl;
	 
	 
	}
	
	return 0;
}  
	
	
	
	
	
	
	
	
	
	
	

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

struct Union_Find_Tree{
    vector<int> par, rank, num;
    
    Union_Find_Tree(int N){
        par.assign(N, -1);
        rank.assign(N, 0);
        num.assign(N, 1);
    }
    
    int root(int x){
        if(par[x] < 0 || par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    
    void unite(int x, int y){
        x = root(x), y = root(y);
        if(x == y) return;
        elif(rank[x] < rank[y]) par[x] = y, num[y] += num[x];
        else{
            par[y] = x, num[x] += num[y];
            if(rank[x] == rank[y]) rank[x]++;
        }
    }
    
    int size(int x) {return num[root(x)];}
    
    bool same(int x, int y){
        return root(x) == root(y);
    }
    
    void clear(){
        fill(all(par), -1);
        fill(all(rank), 0);
        fill(all(num), 1);
    }
};

int main(){
    int N, K, L;
    cin >> N >> K >> L;
    Union_Find_Tree uf(2*N);
    rep(i, K){
        int u, v; cin >> u >> v; u--, v--;
        uf.unite(u, v);
    }
    rep(i, L){
        int u, v; cin >> u >> v; u--, v--;
        uf.unite(N+u, N+v);
    }
    pii p[N];
    map<pii, int> mp;
    rep(i, N){
        mp[p[i] = pii(uf.root(i), uf.root(N+i))]++;
    }
    rep(i, N){
        cout << mp[p[i]] << ' ';
    }
    cout << endl;
}

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

int main()
{
	string S;
	cin >> S;
	int result = S.size();

	for(int i = 1;i < S.size();i++)
	{
		if(S[i] != S[i - 1])
		{
			result = min(result , max(i,(int)S.size() - i));
		}
	}

	cout << result << endl;
	return 0;
}


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

int main(){
  int a, b, x, y;
  cin >> a >> b >> x >> y;
  int c = x - a;
  int d = y - b;
  cout << a + c - d << " " << b + d + c << " " << a - d << " " << b + c << endl;
  //cout << ans << endl;
}

Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()　#小さい順位欲しいとき
    return divisors

## [[2, 3], [3, 1]]
##  24 = 2^3 * 3^1
n=int(input())
a=make_divisors(n)
cnt=0
use=set()
for k in a[1:]:
    t=n
    while t%k==0:
        t//=k
    if t%k==1:
        use.add(k)
b=make_divisors(n-1)
for i in b[1:]:
    use.add(i)
print(len(use))


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    string s;
    cin >> s;
    ll ans = 0, cnt_white = 0;
    for(int i = s.size()-1; i >= 0; i--) {
        if (s[i] == 'W') {
            cnt_white += 1;
        } else {
            ans += cnt_white;
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 720
s = input()


pre = "R"
r_cnt = 1
l_cnt = 0
res = []
for idx_,x in enumerate(s[1:]):
    idx = idx_+1
    if pre == "R":
        if pre != x:
            pre = "L"
        else:
            r_cnt += 1
            res.append(str(0))
    if pre == "L":
        if pre != x:
            # 集計
            res.append( str((r_cnt+1)//2 + l_cnt//2) )
            res.append( str(r_cnt//2 + (l_cnt+1)//2) )
            for i in range(l_cnt-1):
                res.append(str(0))
            pre = "R"
            r_cnt = 1
            l_cnt = 0
        else:
            l_cnt += 1

        if idx == len(s)-1:
            res.append( str((r_cnt+1)//2 + l_cnt//2) )
            res.append( str(r_cnt//2 + (l_cnt+1)//2) )
            for i in range(l_cnt-1):
                res.append(str(0))

print(" ".join(res))

Measured memory_bytes: 49956
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, x; 
  cin >> N >> x;

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  int ans = 0;
  if(A[0] > x){
    ans += A[0]-x;
    A[0] = x;
  }

  FOR(i, 1, N){
    if(A[i]+A[i-1] > x){
      ans += A[i]-(x-A[i-1]);
      A[i] = x-A[i-1];
    }
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

ll a[100010], dp[100010];

int main()
{
	ll N, M;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> a[i];
	}
	a[M] = mod;	
	int j = 0;
	if (a[0] == 1) {
		dp[1] = 0;
		j++;
	}
	else dp[1] = 1;
	dp[0] = 1;
	for (int i = 2; i <= N; i++) {
		if (i == a[j]) {
			dp[i] = 0;
			j++;
		}
		else {
			dp[i] = dp[i - 2] + dp[i - 1];
		}
		dp[i] %= mod;
	}
	cout << dp[N] << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    int N,K;cin>>N>>K;
    vector<int>vec(N);
    REP(i,N){
        cin>>vec[i];
        K-=vec[i];
    }
    int ans=N;
    sort(vec.begin(),vec.end());
    cout<<ans+(K/vec[0])<<endl;
}


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

using namespace std;

const int N = 1e5+5;

int n,m;
vector <int> v[N];
deque <int> d;
int poc1,poc2;
int bio[N];

int main () {
	
	cin >> n >> m;
	for (int i = 0;i < m;i++) {
		int a,b;
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
		if (poc1 == 0) {
			poc1 = a;
		}
		if (poc2 == 0) {
			poc2 = b;
		}
	}
	
	bio[poc1] = 1;
	bio[poc2] = 1;
	
	while (1) {
		int zas = 1;
		if (d.size() == 0) {
			d.push_front(poc1);
			d.push_back(poc2);
			zas = 0;
		}
/*		cout <<"bio: ";
		for (int i = 1;i <= n;i++) {
			cout << bio[i] << " ";
		}cout << endl;
*/		
			poc1 = d.front();
			poc2 = d.back();
//			cout << "." << poc1 << endl;
			for (int i = 0;i < v[poc1].size();i++) {
//				cout << v[poc1][i] << " ";
				if (bio[v[poc1][i]]) continue;
				bio[v[poc1][i]] = 1;
				zas = 0;
				d.push_front(v[poc1][i]);
				break;		
			}//cout << endl;
//			cout << "." << poc2 << endl;
			for (int i = 0;i < v[poc2].size();i++) {
//				cout << v[poc2][i] << " ";
				if (bio[v[poc2][i]]) continue;
				bio[v[poc2][i]] = 1;
				zas = 0;
				d.push_back(v[poc2][i]);
				break;
			}
//			cout <<endl << endl;;
		if (zas == 1) break;
	}
	cout << d.size() << endl;
	for (int i = 0;i < d.size();i++) {
		cout << d[i] << " ";
	}cout << endl;
	
	
	return 0;
}

Measured memory_bytes: 7040
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#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 <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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;  cin >> n;
    int ans = 0;
    rep(i, n) {
      int a;  cin >> a;
      ans += a - 1;
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;

 
int32_t main()
{


    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    IOS 



   string s;
   cin >> s;

   int sum = 0;

   for(int i = 0; i < s.size(); i++)
   {
    sum += (s[i]-'0');
   }


   if(sum%9 ==0)
   {
    cout << "Yes";
   }
   else
   {
    cout << "No";
   }





    return 0;
}


Measured memory_bytes: 3780
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))

vector<int> sorted(vector<int> v) {
	sort(v.begin(), v.end());
	return v;
}

int main()
{
	int N;
	cin >> N;
	vector<int> p(N);
	rep(i, N)cin >> p[i];
	auto tgt = sorted(p);

	bool res = false;
	if (p == tgt) res = true;
	else {
		rep(r, N)rep(l, r) {
			swap(p[l], p[r]);
			if (p == tgt)res = true;
			swap(p[l], p[r]);
		}
	}

	cout << (res ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 256
// Starting with the name of Allah

#include <bits/stdc++.h>
#define ll long long
#define nl endl
#define Nayon ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define gcd(a,b)         __gcd(a,b)
#define lcm(a,b)         (a/gcd(a,b))*b
#define v_sum(a)         accumulate(a.begin(),a.end(),0)
#define v_max(a)         *max_element(a.begin(),a.end())
#define v_min(a)         *min_element(a.begin(),a.end())
#define v_uni(a)         a.erase(unique(a.begin(),a.end()),a.end())

using namespace std;





int main()
{
	Nayon;
	int n;
	cin>>n;
	if(n==1){
		cout<<0;
	}
	else{
		cout<<1;
	}
	return 0;
}


//Happy Coding........

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int n = sc.nextInt();
			if (n == 0) {
				break;
			}
			int m = sc.nextInt();
			char[] s = sc.next().toCharArray();
			int ioi = 0;
			int ans = 0;
			for(int i=0;i<m;i++) {
				if (ioi % 2 == 0 && s[i] == 'I') {
					ioi++;
					if (ioi/2 >= n) {
						ans++;
					}
				}else if(ioi % 2 == 1 && s[i] == 'O') {
					ioi++;
				}else{
					if (s[i] == 'I') {
						ioi = 1;
					}else{
						ioi = 0;
					}
				}
			}
			System.out.println(ans);
		}
	}

}

Measured memory_bytes: 32592
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; 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;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int N, M;
int s[10];
int c[10];
int ans[4];

int main()
{
    rep(i, 0, 4)
    {
        ans[i] = 10;
    }
    cin >> N >> M;
    rep(i, 0, M)
    {
        cin >> s[i] >> c[i];
        if (ans[s[i] - 1] != 10 && ans[s[i] - 1] != c[i])
        {
            cout << -1 << endl;
            return 0;
        }
        ans[s[i] - 1] = c[i];
    }
    if (N == 1)
    {
        if (ans[0] == 10)
        {
            cout << 0 << endl;
            return 0;
        }
        cout << ans[0] << endl;
        return 0;
    }

    if (ans[0] == 10)
    {
        cout << 1;
    }
    else
    {
        if (ans[0] == 0)
        {
            cout << -1 << endl;
            return 0;
        }
        cout << ans[0];
    }

    rep(i, 1, N)
    {
        if (ans[i] == 10)
        {
            cout << 0;
        }
        else
        {
            cout << ans[i];
        }
    }
}

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

int n, max_weight,*arr;

int max(int x, int y)
{
    return x>y ? x : y;
}

int knapsack()
{
    int i,j,mem[max_weight+1];

    memset(mem,0,sizeof(mem));

    for(i=0; i<=max_weight; i++)
    {
        for(j=0; j<n; j++)
        {
            if(i >= arr[n+j]) mem[i] = max(mem[i],mem[i-arr[n+j]]+arr[j]);
        }
    }
    return mem[max_weight];
}

int main()
{
    //freopen("input.txt","r",stdin);
    scanf("%d %d",&n,&max_weight);

    arr = (int*)malloc(sizeof(int)*n*2);

    for(int i=0; i<n; i++)
    {
        scanf("%d %d",&arr[i],&arr[i+n]);
    }
    
    printf("%d\n",knapsack());

    free(arr);
    return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

ll mod = 1000000007;

signed main()
{
    ll x;
    cin >> x;
    ll a = x / 11;
    ll b = x % 11;
    if (b == 0)
    {
        cout << 2 * a << endl;
    }
    else
    {
        if (b <= 6)
        {
            cout << 2 * a + 1 << endl;
        }
        else
        {
            cout << 2 * a + 2 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3616
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <ctime>
using namespace std;
typedef long long ll;

const int INF = 100000000;
const int MAX_N = 100;
const int MAX_M = 1000;
const int MAX_W = 100000;
const int MAX_V = 100;
const int MAX_K = 100000;

typedef pair<int, int> P;

int n, K;
int a[MAX_N], m[MAX_N];
int dp[MAX_K+1];




int main(int argc, char *args[]) {
	int A, B, K;
	cin >> A >> B >> K;
	int N;
	if (A >= B)N = B;
	else N = A;
	int counter = K;
	for (int i = N; i >=1; i--) {
		if (A%i == 0 && B%i == 0) {
			counter = counter-1;
		}
		if (counter == 0) {
			cout << i << endl;
			break;
		}
	}
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string S;
	cin>>S;
	int N;
	N=S.size();
	string ans="Yes";
	for(int i=0; i<N; i++)
	{
		if(S[i]!=S[N-1-i])
        ans="No";	
		
	}
	for(int i=0; i<(N-1)/2; i++)
	{
		if(S[i]!=S[N-1-i])
		ans="No";
	}
	for(int i=0; i<(N-1)/2; i++)
	{
		if(S[(N+1)/2+i]!=S[N-1-i])
		ans="No";
	}
	cout<<ans;
	

	return 0;
}

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

# define Rep(i,a,b) for(int i=a;i<=b;i++)
# define _Rep(i,a,b) for(int i=a;i>=b;i--)
# define RepG(i,u) for(int i=head[u];~i;i=e[i].next)

typedef long long ll;

const int N=2e5+5;

template<typename T> void read(T &x){
   x=0;int f=1;
   char c=getchar();
   for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
   for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+c-'0';
    x*=f;
}

int n;
int a[N],cnt;
int sum0,sum1;

int Qpow(int base,int ind,int p){
    int res=1;
    while(ind){
        if(ind&1)res=1ll*res*base%p;
        base=1ll*base*base%p;
        ind>>=1;
    }
    return res;
}

int solve(int x){
    if(!x)return 1;
    int t=x,count=0;
    while(t){
        if(t&1)count++;
        t/=2;
    }
    return solve(x%count)+1;
}

int main()
{
    read(n);
    Rep(i,1,n)scanf("%1d",&a[i]),cnt+=a[i];
    if(cnt==1){
        Rep(i,1,n)sum0+=a[i]*Qpow(2,n-i,cnt+1),sum0%=(cnt+1);
        Rep(i,1,n)
            if(!a[i])printf("%d\n",solve((sum0+Qpow(2,n-i,cnt+1)+cnt+1)%(cnt+1)));
            else puts("0");
        return 0;
    }
    Rep(i,1,n){
        sum0+=a[i]*Qpow(2,n-i,cnt+1),sum0%=(cnt+1);
        sum1+=a[i]*Qpow(2,n-i,cnt-1),sum1%=(cnt-1);
    }
    Rep(i,1,n)
        if(a[i])printf("%d\n",solve((sum1-Qpow(2,n-i,cnt-1)+(cnt-1))%(cnt-1)));
        else printf("%d\n",solve((sum0+Qpow(2,n-i,cnt+1)+cnt+1)%(cnt+1)));
    return 0;
}

Measured memory_bytes: 4540
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int N;
  scanf("%d", &N);
  
  if(N == 1){
    printf("%s\n", "Hello World");
  }
  else{
    int A, B;
    scanf("%d%d", &A, &B);
    printf("%d\n", A+B);
  }
  return 0;
}


Measured memory_bytes: 128
def gcd(a, b):
    """Calculate the Greatest Common Divisor of a and b.

    Unless b==0, the result will have the same sign as b (so that when
    b is divided by it, the result comes out positive).
    """
    while b:
        a, b = b, a%b
    return a



n = int(input())

print((2*n)//gcd(2,n))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();

		char[][] ans = new char[100][100];
		for (int i = 0; i < 50; i++) {
			for (int j = 0; j < 100; j++) {
				ans[i][j] = '.';
			}
		}
		for (int i = 50; i < 100; i++) {
			for (int j = 0; j < 100; j++) {
				ans[i][j] = '#';
			}
		}

		a--;
		int x = 99;
		int y = 0;
		while (a > 0) {
			ans[x][y] = '.';
			y += 2;
			if (y >= 100) {
				y = 0;
				x -= 2;
			}
			a--;
		}

		b--;
		x = 0;
		y = 0;
		while (b > 0) {
			ans[x][y] = '#';
			y += 2;
			if (y >= 100) {
				y = 0;
				x += 2;
			}
			b--;
		}

		System.out.println("100 100");
		for (int i = 0; i < 100; i++) {
			System.out.println(ans[i]);
		}
	}
}


Measured memory_bytes: 22228
#include <iostream>
using namespace std;
int main (){
    int n, a[100], i, k; 

    /*入力*/
    cin >> n;
    for (i = 0; i < n; i += 1){
        cin >> a[i] ;
    }
    
    /*配列の逆から出力*/
    for (k = n - 1; k >= 0; k -= 1){ 
        if (k != n - 1) cout << " ";
        cout << a [k] ;
    }
    cout << endl;
 }


Measured memory_bytes: 3088
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def kaibun(s):
    flg=1
    if len(s)==1:
        pass
    else:
        for i in range(len(s)//2):
            if s[i]==s[len(s)-i-1]:
                pass
            else:
                flg=0
    return flg
    
def do():
    s=STR()
    n=len(s)
    s1=s[0:n//2]
    s2=s[n//2+1:n]
    flg=kaibun(s1)*kaibun(s2)*kaibun(s)
    if flg==1:
        print('Yes')
    else:
        print('No')
    
    
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))
sys.setrecursionlimit(10 ** 7)

def main():
    s = ns()
    n = len(s)
    
    cnt = 0
    for i in range(n//2):
        # print(s[i],s[-i-1])
        if s[i] != s[-i-1]:
            cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064