akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
const double PI = 3.14159265358979323846264338327950;
inline int newline() { putchar('\n'); return 0; }

int main() {
    int x;
    cin(x);

    if (x >= 30) {
        print("Yes");
    } else {
        print("No");
    }

    return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;
import java.util.Arrays;

class Main {
	public static void main(String args[]) {
		run();
	}
	public static void run() {
		Scanner scanner = new Scanner(System.in);
		int  num = scanner.nextInt();//要素数
		Node[] nodes = new Node[num];
		boolean[] root = new boolean[num];
		Arrays.fill(root, true);
		
		//要素ごとの親と子の関係構築
		for(int i = 0; i < num; i ++ ){
			int id = scanner.nextInt();
			int left = scanner.nextInt();
			int right = scanner.nextInt();
			if (left != -1){
				root[left] = false;
			}
			if (right != -1){
				root[right] = false;
			}
			nodes[id] = new Node(id, left, right);
		}
		
		//ノードごとにデータ作成
		for( int i = 0; i < num ; i ++ ){
			if( root[i] ){
				Binarytree( nodes, -1, i, 0 );
				break;
			}
		}		
		
		output(nodes);//出力関数
		
		scanner.close();
	}
	
	public static void output(Node[] nodes){
	   //出力
	   StringBuilder sb = new StringBuilder("");
		for (Node node: nodes) {
			sb.append("node ").append(node.id);
			sb.append(": parent = ").append(node.parent);
			sb.append(", sibling = ").append(node.sibling);
			sb.append(", degree = ").append(node.degree);
			sb.append(", depth = ").append(node.depth);
			sb.append(", height = ").append(node.height);
			sb.append(", ").append(node.type);
			sb.append("\n");
		}
		System.out.print(sb);
	}
	//ツリー作成
	public static int Binarytree(Node[] nodes, int parent, int id, int depth){ 
		if (id == -1) {	//根の判定
			return -1;
		}
		
		Node node = nodes[id];
		node.parent = parent;
		
		//子供判定
		if (node.left != -1) {
			nodes[node.left].sibling = node.right;
		}
		if (node.right != -1) {
			nodes[node.right].sibling = node.left;
		}
		
		//深さと高さ
		node.degree = ((node.left == -1) ? 0 : 1) + ((node.right == -1) ? 0 : 1);
		node.depth = depth;
		node.height = Math.max(Binarytree(nodes, id, node.left, depth + 1), 
			Binarytree(nodes, id, node.right, depth + 1)) + 1;
		
		//種類付け
		if (node.parent == -1) {
			node.type = "root";
		}else if (node.left == -1 && node.right == -1) {
			node.type = "leaf";
		}else {
			node.type = "internal node";
		}
 
		return node.height;
	}
}
class Node{
	public int id;
	public int parent;
	public int sibling = -1;
	public int degree;
	public int depth;
	public int height;
	public String type;
	public int left;
	public int right;
	
	public Node(int id, int left, int right) {
		this.id = id;
		this.left = left;
		this.right = right;
	}
	
}



Measured memory_bytes: 26404
def main():
    N,A,B=map(int,input().split())
    count=(N//(A+B))
    if (A+B)*10**100 <= N:
        print(A*10**100)
        return 0
    ans=count*A
    left_ball=N-(A+B)*count
    if A>=left_ball:
        ans+=left_ball
        print(ans)
    else:
        print(ans+A)
        
main()

Measured memory_bytes: 3060
import math


def check(m, A, V):
    # whether we can get `m` for mean of values
    cnt, x = 0, 0
    for v in V[:A]:
        x += v - m
        cnt += 1
    return x >= 0


def comb(n, k):
    if k > n - k:
        return comb(n, n - k)
    return math.factorial(n) // math.factorial(k) // math.factorial(n - k)


def main():
    N, A, B = list(map(int, input().split(' ')))
    V = list(map(int, input().split(' ')))
    V.sort(reverse=True)
    # calculate max average value by binary search
    eps = 10 ** (-15)
    ok, ng = 0, 10 ** 16
    while (ng - ok) / ng > eps:
        mid = (ok + ng) / 2
        if check(mid, A, V):
            ok = mid
        else:
            ng = mid
    ans_v = ok
    # calculate pattern number
    min_target_v = V[A - 1]
    target_v_cnt = sum([1 if v == min_target_v else 0 for v in V])
    selected_target_v_cnt = sum([1 if v == min_target_v else 0 for v in V[:A]])
    ans_pattern = comb(target_v_cnt, selected_target_v_cnt)
    if V[0] == min_target_v:  # V[0] == ... == V[A - 1]
        # the average does not change if we add another item with min_target_v
        for i in range(1, B - A + 1):
            if target_v_cnt < selected_target_v_cnt + i:
                break
            ans_pattern += comb(target_v_cnt, selected_target_v_cnt + i)
    # answer
    print(ans_v)
    print(ans_pattern)


if __name__ == '__main__':
    main()

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

#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

int H,W,N;
vector<string>fld;

void down(){
    rep(j,W){
        int t=0;
        rep(i,H){
            if(isalpha(fld[i][j])){
                fld[t++][j]=fld[i][j];
            }
        }
        reps(i,t,H)fld[i][j]='.';
    }
}
bool is_del[33][33];

bool del(){
    memset(is_del,0,sizeof(is_del));
    bool sc=false;
    rep(i,H){
        rep(j,W-N+1){
            if(fld[i][j]=='.')continue;
            bool ok=true;
            rep(k,N)if(fld[i][j]!=fld[i][j+k])ok=false;
            if(ok)rep(k,N)is_del[i][j+k]=true;
            sc|=ok;
        }
    }

    rep(j,W){
        rep(i,H-N+1){
            if(fld[i][j]=='.')continue;
            bool ok=true;
            rep(k,N)if(fld[i][j]!=fld[i+k][j])ok=false;
            if(ok)rep(k,N)is_del[i+k][j]=true;
            sc|=ok;
        }
    }
    rep(i,H)rep(j,W)if(is_del[i][j])fld[i][j]='.';
    return sc;
}

bool check(){
    down();
    while(del())down();
    rep(i,H)rep(j,W)if(fld[i][j]!='.')return false;
    return true;
}

signed main(){
    cin>>H>>W>>N;
    vector<string>in;
    in.resize(H);
    rep(i,H)cin>>in[H-1-i];

    rep(i,H)rep(j,W-1){
        fld=in;
        swap(fld[i][j],fld[i][j+1]);
        if(check()){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 3184
#include<stdio.h>

int main(){
	
	int ans=0,i;
	char s[10];
	
	scanf("%s",s);
	
	
	for(i=0;i<3;i++){
	if(s[i]=='1'){
		ans++;
	}
	}
	
	printf("\n\n%d\n\n",ans);
	
	return 0;
}

Measured memory_bytes: 128
N,K=map(int,input().split())
A=list(map(int,input().split()))
B=[0]*(N+1)
for i in range(N):
    B[i+1]=(B[i]+A[i]-1)%K
r=0
from collections import defaultdict
d=defaultdict(int)
for i in range(N+1):
    r+=d[B[i]]
    d[B[i]]+=1
    if K-1<=i:
        d[B[i-K+1]]-=1
print(r)

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

int a[100];

int cmp(const void *s,const void *b){
return (*(int *)b)-(*(int *)s);
}


int main(void){
int n,m,k;
int i,j;
while(scanf("%d",&n)!=EOF){
m=0;
for(i=0;i<n;i++){
scanf("%d",&a[i]);
}
qsort(a,n,sizeof(int),cmp);
for(i=1;i<=n;i++){
m+=a[i-1]*i;
}

printf("%d\n",m);
}
return 0;}

Measured memory_bytes: 604
#include <iostream>
#include <vector>

using namespace std;

void solve() {
	int n;
	cin >> n;
	vector<int> a(n+1);

	int current = 0;
	int ans = 1;

	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		if (i == 1)
			continue;
		if (current == 0) {
			if (a[i-1] < a[i])
				current = -1;
			else if (a[i-1] > a[i])
				current = 1;
		} else {
			if (a[i-1] != a[i] && (a[i-1] - a[i]) / abs(a[i-1] - a[i]) != current) {
				++ans;
				current = 0;
			}
		}
	}
	cout << ans << "\n";
}

int main() {
	int tests = 1;

	for (;tests; --tests) {
		solve();
	}
}

Measured memory_bytes: 640
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner();
        int A = in.nextInt();
        int B = in.nextInt();

        if (A+B>=10)
        {
            System.out.println("error");
        }
        else
            {
                System.out.println(A+B);
            }

    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return null;
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}


Measured memory_bytes: 21204
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Prob0004
{
    class Program
    {
        const char splitBy = ' ';

        static void Main(string[] args)
        {
            string line;
            while (!string.IsNullOrEmpty(line = System.Console.ReadLine()))
            {
                double[] param = Array.ConvertAll(line.Split(splitBy), e => double.Parse(e));
                solve(param);
            }
        }

        static void solve(double[] param)
        {
            double x;
            double y;

            if (param[0] != 0.0 && param[3] != 0.0)
            {
                double a = param[3] / param[0];
                y = (param[5] - param[2] * a) / (param[4] - param[1] * a);
                x = (param[2] - param[1] * y) / param[0];
            }
            else
            {
                double a = param[4] / param[1];
                x = (param[5] - param[2] * a) / (param[3] - param[0] * a);
                y = (param[2] - param[0] * x) / param[1];
            }

            Console.WriteLine("{0:F3} {1:F3}", x, y);


        }


    }
}

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

#define int long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (int)(1000000007)
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 9999999999999999
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 3005
#define mxnn 2000005
int dp[mxn][mxn];
int32_t main(){
sp;
int n,m;
cin >>n >>m;
char mat[n+2][m+2];
memset(mat,'#',sizeof mat);
for(int i = 1;i<=n;i++) for(int j = 1;j<=m;j++) cin >>mat[i][j];
dp[1][1] = 1;
for(int i = 2;i<=n;i++){
    if(mat[i][1] =='#') dp[i][1] = 0;
    else dp[i][1] = dp[i-1][1];
}
for(int i = 2;i<=m;i++){
    if(mat[1][i] =='#') dp[1][i] = 0;
    else dp[1][i] = dp[1][i-1];
}
for(int i = 2;i<=n;i++){
    for(int j = 2;j<=m;j++){
        if(mat[i][j] =='.') dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
        else dp[i][j] = 0;
    }
}
cout<<dp[n][m];
return 0;
}


Measured memory_bytes: 24832
#include <stdio.h>
#define MAX 101

int A[MAX][MAX];
int G[MAX];
void DJP(int);
 
int main(){
  int n, i, j;
  
  scanf("%d", &n);

  for(i = 0; i < n; i++){
     for(j = 0; j < n; j++){
       scanf("%d", &A[i][j]);
    }
  }
   DJP(n);
   return 0;
}

void DJP(int n){
  int i, j, k = 1;
  int B[MAX];
  int sz, min, out = 0;

  B[0] = 0;
  G[0] = 1;
  for(i = 1; i < n; i++){
    G[i] = 0;
  }

  while(1){
    sz = 2001;

    for(i = 0; i < k; i++){
      for(j = 0; j < n; j++){
        if(A[B[i]][j] < sz && A[B[i]][j] != -1 && G[j] != 1){
          sz = A[B[i]][j];
          min = j;
        }
      }
    }

    if(k != n){
      B[k] = min;
      G[min] = 1;
      out += sz;    
      k++;
    }
    else break;
  }
  printf("%d\n", out);
}

Measured memory_bytes: 640
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


n, p = map(int, input().split())

res = 1
maxcnt = 0

for m, cnt in factorize(p):
    while cnt >= n:
        res *= m
        cnt -= n
        

print(res)
    
    
    


Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

debug = True
#debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

class UnionFind:

    def __init__(self, n):
        self.parents = [i for i in range(n)]

    def merge(self, i, j):
        rooti = self.findroot(i)
        rootj = self.findroot(j)
        self.parents[rooti] = rootj

    def issame(self, i, j):
        rooti = self.findroot(i)
        rootj = self.findroot(j)
        return rooti == rootj

    def findroot(self, i, followed_indices=None):

        if i == self.parents[i]:
            return i
        else:
            root = self.findroot(self.parents[i])
            self.parents[i] = root # 経路圧縮
            return root
    pass

def solve():
    # np.set_printoptions(suppress=True)
    # n = int(input())
    n, k, l = map(int, input().split())
    uf1 = UnionFind(n)
    uf2 = UnionFind(n)

    for ki in range(k):
        p, q = map(int, input().split())
        uf1.merge(p-1, q-1)

    for li in range(l):
        p, q = map(int, input().split())
        uf2.merge(p-1, q-1)

    ans = {}
    key_list = []
    for i in range(n):
        root1 = uf1.findroot(i)
        root2 = uf2.findroot(i)

        key = str(root1) + "_" + str(root2)
        key_list.append(key)

        if key in ans.keys():
            ans[key] += 1
        else:
            ans[key] = 1

    for i in range(n):
        print(ans[key_list[i]], end=' ')

solve()

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

#define M 1000000007
#define FOR(i, s, n) for (ll i = (s); i < (n); ++i)
#define FORALL(i, n) for (ll i = 0; i < (n); ++i)
#define MOD 1000000007
#define ff first
#define ss second
#define pll pair<long long, long long>
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(false)
#define countbits(x) __builtin_popcount(x)
#define pb(x) push_back((x))
#define vll vector<ll>
#define all(x) x.begin(),x.end()
#define print(x) cout << x << endl
#define debug print("reaching\n")
#define mll map<ll,ll>
#define lsb(i) i&(-i)
#define printv(x) \
	FORALL(i, x.size()) \
	{ \
		cout << x[i] << ' '; \
	} \
	cout << endl \
;
#define printm(m) \
	for(auto i: m){\
		cout<<i.ff<<' '<<i.ss<<endl; \
	}\
;
// vector<map<ll,ll>> m(2);
long long binpow(long long a, long long b) {
	if(b<=0) return 1;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}



template <typename T>
T extGcd(T a, T b, T &x, T &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	else
	{
		int g = extGcd(b, a % b, y, x);
		y -= a / b * x;
		return g;
	}
}

template <typename T>
T modInv(T a, T m)
{
	T x, y;
	extGcd(a, m, x, y);
	return (x % m + m) % m;
}


ll lcm(ll a, ll b){
	return ((a)/__gcd(a,b))*b;
}


int main()
{
	fast;
	// cin.tie(0);
	// cout.tie(0);
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// // freopen("output.txt", "w", stdout);
	// #endif

	int t=1;
	// cin>>t;
	ll tot=t;
	while(t--){
		ll n,m;
		cin>>n>>m;
		vector<set<ll>> g(n+1);
		FORALL(i,m){
			ll x,y;
			cin>>x>>y;
			g[x].insert(y);
			g[y].insert(x);
		}
		vll vis(n+1, 0);
			ll maxo = 0;

		FORALL(i, n+1){
			if(i==0 or vis[i]) continue;
			queue<ll> q;
			q.push(i);
			ll ans = 0;
			while(q.size()){
				ll temp = q.front();
				q.pop();
				if(vis[temp]) continue;
				vis[temp] = 1;
				ans++;
				for(auto u : g[temp]){
					if(vis[u])  continue;
					q.push(u);
				}
			}
			maxo = max(maxo, ans);
		}
		print(maxo);
	}
	return 0;
}


Measured memory_bytes: 33380
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {     
    int n;
    cin >> n;
    vector<vector<int>> v(2, vector<int>(n, 0));
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < n; j++) {
            int t = 0;
            cin >> t;
            v[i][j] = t;
            if (j > 0) {
                v[i][j] = max(v[i][j], v[i][j - 1] + t);
            }
            if (i > 0) {
                v[i][j] = max(v[i][j], v[i - 1][j] + t);
            }
        }
    }
    cout << v[1][n-1] << endl;
}




Measured memory_bytes: 3612
#include <iostream>
using namespace std;
int main() {
    //std::cout << "Hello, World!" << std::endl;
    int n,h,w,i,ans=0;
cin>>n>>h>>w;
int a[n],b[n];
for(i=0;i<n;i++){
    cin>>a[i]>>b[i];
}
for(i=0;i<n;i++){
    if(a[i]>=h&&b[i]>=w)ans++;
}
cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	string s,t;
	cin>>s>>t;
	sorts(s)
	sorts(t)
	reverses(t)
	if(s<t){
		ce("Yes")
	}else{
		ce("No")
	}
}

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

int N, Q;
vector<int> G[201010];
ll num[201010];
ll sum[201010];

void solve(int v, int prev, ll s) {
    int ret = 0;
    s += num[v];
    for (int u : G[v]) {
        if (u == prev) continue;
        solve(u, v, s);
    }
    sum[v] = s;
}

int main() {
    int N, Q;
    cin >> N >> Q;
    rep(i, N-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    //solve(0, -1);

    ll ans = 0;
    rep(i, Q) {
        int a;
        ll x;
        cin >> a >> x;
        a--;
        num[a] += x;
    }

    solve(0, -1, 0);

    rep(i, N) cout << sum[i] << " ";
    cout << endl;
}


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


int main() {
	int N;
	cin >> N;

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

	int min_idx = 0;
	int min_diff = 1000000;
	for(int i=0;i<N;i++) {
		int diff = abs(s - a[i] * N);
		if(diff < min_diff) {
			min_diff = diff;
			min_idx = i;
		}
	}
	cout << min_idx << endl;

	return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
L = N - K
MOD = 10**9 + 7
dp = [[0 for j in range(N + 2)] for i in range(N + 2)]
dp[0][0] = 1
for i in range(1, N+2):
    for j in range(i, N+2):
        dp[i][j] = (dp[i-1][j-1] + dp[i][j-1]) % MOD
for i in range(1, K+1):
    ans = dp[i][K] * (dp[i-1][L] + 2 * dp[i][L] + dp[i+1][L]) % MOD
    print(ans)


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

int main() {
    int edge[8][8];
    int N, M, a, b, count = 0;
    cin >> N >> M;
    for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) edge[i][j] = 0;
    for (int i = 0; i < M; i++) {
        cin >> a >> b;
        edge[a - 1][b - 1] = edge[b - 1][a - 1] = 1;
    }
    vector<int> v;
    for (int i = 0; i < N; i++) v.push_back(i);

    do {
        if (v[0] != 0) continue;
        bool flag = false;
        for (int i = 1; i < v.size(); i++) {
            if (edge[v[i - 1]][v[i]] != 1) {
                flag = true;
                break;
            }
        }
        if (flag) continue;
        count++;
    } while (next_permutation(v.begin(), v.end()));

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> swi(M);
  for (int i = 0; i < M; ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      int s;
      cin >> s;
      --s;
      swi[i].push_back(s);
    }
  }
  vector<int> p(M);
  for (int i = 0; i < M; ++i) cin >> p[i];
  
  int ans = 0;
  for (int bit = 0; bit < (1 << N); ++bit) {
    set<int> S;
    for (int i = 0; i < N; ++i) {
      if (bit & (1 << i)) S.insert(i);
    }
    bool judge = true;
    for (int i = 0; i < M; ++i) {
      int cnt = 0;
      for (int j : swi[i]) {
        if (S.count(j)) ++cnt;
      }
      if (cnt % 2 != p[i]) judge = false;
    }
    if (judge) ++ans;
  }
  
  cout << ans << endl;
  return 0;
}

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


int main(){
  ll n; cin >> n;
  vl takoyaki(n);
  
  rep(i,n){
    ll x; cin >> x;
    takoyaki.at(i) = x;
  }
  
  ll sum = 0;
  rep(i,n){
    rep(j,n){
      if(i!=j) sum += takoyaki.at(i)*takoyaki.at(j);
    }
  }
  
  cout << sum/2 << endl;
}
      

Measured memory_bytes: 256
/*
  2テヲツャツ。テ・ツ?ε」ツつーテ」ツδェテ」ツδε」ツδ嘉」ツ?ァテ」ツ?ッテ」ツ?ェテ」ツ?湘・ツ」ツ?」ツ?古・ツ?・テ・ツ環崚」ツ?ィテ」ツ?療」ツ?ヲテ、ツクツ偲」ツ?暗」ツつ嘉」ツつ古」ツつ凝」ツ??
  テ・ツ青?」ツつーテ」ツδェテ」ツδε」ツδ嘉」ツ?ォテ」ツ??」ツ?敕」ツ?禿」ツ?凝」ツつ?テヲツ鳴ケテ・ツ青妥」ツ?敕」ツつ古」ツ?榲」ツつ古」ツ?ォテァツァツサテ・ツ仰陛・ツ渉ッティツδステ」ツ?凝」ツ?ゥテ」ツ??」ツ?凝」ツ?ョテヲツδ?・ツ?アテ」ツつ津ヲツ個?」ツ?淌」ツ?崚」ツつ凝」ツ??
  テ」ツ?づ」ツ?ィテ」ツ?ッテ」ツ?禿」ツ?ョテ」ツつーテ」ツδェテ」ツδε」ツδ嘉」ツつ津」ツつづ」ツ?ィテ」ツ?ォBFSテ」ツつ津」ツ?凖」ツつ凝」ツ??
 */

#include <stdio.h>

// queue begin

#define QUEUE_SIZE 100000

typedef struct _point {
  int x, y;
} point;

point que[QUEUE_SIZE];
int head, tail;

void init() {
  head = tail = 0;
}

void push(point elm) {
  que[tail] = elm;
  tail = (tail+1) % QUEUE_SIZE;
}

point pop() {
  point elm = que[head];
  head = (head+1) % QUEUE_SIZE;
  return elm;
}

int empty() {
  return head == tail;
}

// queue end

#define MAXH 31
#define MAXW 31
#define INF (1<<28)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
int W, H;

// G[y][x][d]: テ、ツスツ催ァツスツョ(x,y)テ」ツ?凝」ツつ嘉ヲツ鳴ケテ・ツ青租テ」ツ?ォテァツァツサテ・ツ仰陛」ツ?古・ツ渉ッティツδステ」ツ?凝」ツ?ゥテ」ツ??」ツ??
// dテ」ツ?ッテ、ツクツ甘」ツ?ョテゥツ?催・ツ按妖x, dyテ」ツ?ョテヲツキツサテ・ツュツ療」ツ?ォテ・ツッツセテ・ツソツ愿」ツ?療」ツ?ヲテ」ツ??」ツつ凝」ツ??
int G[MAXH][MAXW][4];
int cost[MAXH][MAXW];

int bfs(int sx, int sy, int gx, int gy) {
  int i, j;
  point p = {sx, sy};
  point np;

  if(sx == gx && sy == gy) return 0;

  for(i = 0; i < H; ++i) {
    for(j = 0; j < W; ++j) {
      cost[i][j] = INF;
    }
  }
  cost[sy][sx] = 0;
  init();
  push(p);
  while(!empty()) {
    p = pop();
    for(i = 0; i < 4; ++i) {
      if(G[p.y][p.x][i]) {
        np.x = p.x + dx[i];
        np.y = p.y + dy[i];
        if(cost[np.y][np.x] == INF) {
          push(np);
          cost[np.y][np.x] = cost[p.y][p.x] + 1;
          if(np.x == gx && np.y == gy) {
            return cost[np.y][np.x];
          }
        }
      }
    }
  }
  return INF;
}

int main() {
  int i, j, k, a, ans;
  while(scanf("%d %d", &W, &H) != EOF) {
    if(W == 0 && H == 0) break;
    for(i = 0; i < H; ++i) {
      for(j = 0; j < W; ++j) {
        for(k = 0; k < 4; ++k) {
          G[i][j][k] = 0;
        }
      }
    }
    for(i = 0; i < H*2-1; ++i) {
      if(i % 2 == 0) {
        for(j = 0; j < W-1; ++j) {
          scanf("%d", &a);
          if(a == 0) {
            G[i/2][j][0] = G[i/2][j+1][2] = 1;
          }
        }
      } else {
        for(j = 0; j < W; ++j) {
          scanf("%d", &a);
          if(a == 0) {
            G[i/2][j][1] = G[i/2+1][j][3] = 1;
          }
        }
      }
    }
    ans = bfs(0,0,W-1,H-1);
    if(ans == INF) ans = 0;
    else ++ans;
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 1052
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    int n;
    int mi = 1000, ma = 0;

    cin >> n;
    REP(i, n)
    {
        int a;
        cin >> a;

        mi = min(mi, a);
        ma = max(ma, a);
    }

    cout << ma - mi << endl;

    return 0;
}

Measured memory_bytes: 256
/*
ID:xmydada1
LANG:C++
TASK:
*/
#include<bits/stdc++.h>
#define reg register

using namespace std;

long long m,n,ans=0,sum=0,p,a[100001];

inline long long read() {
reg long long s = 0, t = 0; reg char ch = getchar();
while(ch > '9' || ch < '0') t |= ch == '-', ch = getchar();
while(ch >= '0' && ch <= '9') s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
return t ? -s : s;
}

int main() {
    long long H, W, x, y;
    cin >> W >> H >> x >> y;
    printf("%.8lf ", 1.0 * H * W / 2.0);
    if (x * 2 == W && y * 2 == H) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef  pair<int,int> P;
typedef long long LL;

const int INF=1<<30;
const LL MOD=1000000007;

LL gcd(LL a,LL b){
    if(b==0)return a;

    return gcd(b,a%b);
}

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

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

int main(){
  string S;
  cin >> S;
  if(S=="SUN"){
    cout << "7" << endl;
  }else if(S=="MON"){
    cout << "6" << endl;
  }else if(S=="TUE"){
    cout << "5" << endl;
  }else if(S=="WED"){
    cout << "4" << endl;
  }else if(S=="THU"){
    cout << "3" << endl;
  }else if(S=="FRI"){
    cout << "2" << endl;
  }else{
    cout << "1" << endl;
  }
  return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    string s;
    cin >> s;
    char ans[] = {s[0], ' ', s[1], ' ', s[2], ' ', s[3], '=', '7', '\0'};
    int a[4] = {s[0] - '0', s[1] - '0', s[2] - '0', s[3] - '0'}, e;
    rep(i, 1 << 3) {
        e = a[0];
        rep(j, 3) {
            if (i & (1 << j)) e -= a[j + 1], ans[j * 2 + 1] = '-';
            else e += a[j + 1], ans[j * 2 + 1] = '+';
        }
        if (e == 7) break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
A, B, K = list(map(int, input().split()))

if A >= K:
    A = A - K
    A = str(A)
    B = str(B)
    print(A+" "+B)
else:
    K = K - A
    if B <= K:
        print("0 0")
    if B > K:
        B = B - K
        A = "0"
        B = str(B)
        print(A+" "+B)

Measured memory_bytes: 3060
#include<cstdio>
#include<string.h>
#include<stdlib.h>

int main(){
    int s[6];
    int t[6];
    char h[4] = {'N','S','W','E'};
    int a,b,n;
    for(int i = 0;i < 6;i++){
        scanf("%d",&s[i]);
    }
    scanf("%d",&n);
    for(int i = 0;i < n;i++){
        scanf("%d %d",&a,&b);
        while(1){
            int k = rand() % 4;
                if(h[k] == 'N'){
                    t[4] = s[0];
                    t[0] = s[1];
                    t[1] = s[5];
                    t[5] = s[4];
                    t[2] = s[2];
                    t[3] = s[3];
                }
                if(h[k] == 'S'){
                    t[0] = s[4];
                    t[1] = s[0];
                    t[5] = s[1];
                    t[4] = s[5];
                    t[2] = s[2];
                    t[3] = s[3];
                }
                if(h[k] == 'W'){
                    t[0] = s[2];
                    t[2] = s[5];
                    t[5] = s[3];
                    t[3] = s[0];
                    t[1] = s[1];
                    t[4] = s[4];
                }
                if(h[k] == 'E'){
                    t[2] = s[0];
                    t[5] = s[2];
                    t[3] = s[5];
                    t[0] = s[3];
                    t[1] = s[1];
                    t[4] = s[4];
                }
                for(int j = 0;j < 6;j++){
                    s[j] = t[j];
                }
                if(s[0] == a && s[1] == b){
                    break;
                }
            
            if(s[0] == a && s[1] == b){
                    break;
            }
            
            
        }
        printf("%d\n",s[2]);
    }
    
}


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

typedef std::pair<int,int> Point;

int x,y;
std::vector<std::vector<char> >v;
std::vector<std::vector<int> >count;

int bfs(int sx,int sy,int gx,int gy){
	for(int i=0;i<count.size();i++){
		for(int j=0;j<count[i].size();j++){
			count[i][j]=-1;
		}
	}
	std::queue<Point>que;
	que.push(Point(sx,sy));
	count[sy][sx]=0;

	while(que.size()){
		Point po=que.front();
		que.pop();
		if(po.first==gx&&po.second==gy)break;

		int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
		for(int i=0;i<4;i++){
			int nx=po.first+dx[i],ny=po.second+dy[i];
			if(nx>=0&&nx<x&&ny>=0&&ny<y&&v[ny][nx]!='X'&&count[ny][nx]==-1){
				que.push(Point(nx,ny));
				count[ny][nx]=count[po.second][po.first]+1;
			}
		}
	}
	return count[gy][gx];
}

int main(){
	int n,res=0;
	std::cin>>y>>x>>n;
	std::vector<Point>factory(n+1);
	for(int i=0;i<y;i++){
		v.push_back(std::vector<char>());
		count.push_back(std::vector<int>());
		for(int j=0;j<x;j++){
			char a;
			std::cin>>a;
			if(a=='S')factory[0]=Point(j,i);
			if(a!='S'&&a!='X'&&a!='.')factory[a-'0']=Point(j,i);
			v[i].push_back(a);
			count[i].push_back(-1);
		}
	}
	for(int i=0;i<n;i++)res+=bfs(factory[i].first,factory[i].second,factory[i+1].first,factory[i+1].second);
	std::cout<<res<<std::endl;
	return 0;
}

Measured memory_bytes: 6288
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int min = Integer.MAX_VALUE;
		int max = Integer.MIN_VALUE;
		for(int i=0;i<3;i++) {
			int a = in.nextInt();
			if(a<min) min=a;
			if(a>max) max=a;
		}
		System.out.println(max-min);
		in.close();
	}

}


Measured memory_bytes: 22996
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] nums=new int[100001];
        for(int i=0;i<n;i++){
            nums[sc.nextInt()]++;
        }
        int odd=0;
        int even=0;
        for(int i=0;i<100001;i++){
            if(nums[i]%2==1)odd++;
            else if(nums[i]>0)even++;
        }
        System.out.println(odd+(even%2==0?even:even-1));
    }
    
    
}

Measured memory_bytes: 50408
#include<stdio.h>
int main(void)
{
	char a;
	scanf("%s",&a);

	if (a=='A')	printf("T\n");
	
	else  if(a=='G') printf("C\n");
	
	else  if(a=='T') printf("A\n");
	
	else  if(a=='C') printf("G\n");
	

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,H;
  cin >>N >>H;
  vector<int> a(N,0);
  vector<int> b(N,0);
  for(int i=0; i<N; i++){
    int A,B;
    cin>>A >>B;
    a[i]=A;
    b[i]=B;
  }
  sort(a.begin(), a.end(), greater<int>());
  sort(b.begin(), b.end());
  auto it= lower_bound(b.begin(), b.end(), a[0]);
  int z= it -b.begin();
  int ans=0;
  for(int i=N-1; i>=z; i--){
    H-=b[i];
    ans++;
    if(H<=0)
      break;
  }
  if(H>0 && H%a[0]!=0)
    ans++;
  if(H>0)
    ans+=H/a[0];
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  int L = a + b;

  int R = c + d;

  if (L > R)
  {
    cout << "Left" << endl;
  }
  else if (L < R)
  {
    cout << "Right" << endl;
  }
  else
  {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 3644
#include <iostream>
#include <stdio.h>
#include <map>
using namespace std;

typedef long long LL;

bool ask(LL n) {
    printf("? %lld\n",n);
    fflush(stdout);
    char ans;
    scanf(" %c", &ans);
    if (ans == 'Y') return true;
    else return false;
}

int Sz(LL x) {
    int ret=0;
    while (x>0) {
        ret++;
        x/=10;
    }
    return ret;
}

LL pow(LL a,LL n) {
    LL ret=1;
    for (int i=0;n>i;i++) ret*=a;
    return ret;
}

int main () {
    //cout<<("11" < "110" )<<endl;
    LL haha=100000LL * 1000000LL;
    LL now=0;
    int lastR=0;
    for (int i=1;10>=i;i++) {
        //test the i-th digit
        now*=10;
        int L=-1,R=10;
        haha/=10;
        while (R-L!=1) {
            int mid=(L+R)>>1;
            if(i==1 && mid==0) {
                R=1;
                L=0;
                break;
            }
            if (ask((now+mid)*haha + (haha-1))) R=mid;
            else L=mid;
        }
        now+=R;
        //lastR = R;
    }
    map<LL,bool> mp;
    int _=0;
    for (LL i=1;;i*=10) {
        _++;
        mp[i]=1;
        if (_>11) break;
    }
    //cout<<"now = "<<now<<endl;
    while (1) {
        if (now%10 != 0) break;
        //deal with 999 and 9990 first
        if (mp[now/10+1] == true) {
            if (ask(now/10+1) == true) break;
            else now/=10;
        }
        else if (ask( pow(10,Sz(now)-1) - 1) == true) now/=10;
        else break;
    }
    int ans=now;
    printf("! %d\n",ans);
    fflush(stdout);
    return 0;
}



Measured memory_bytes: 596
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from bisect import bisect_left
from itertools import accumulate

n = ni()
oneton = [i for i in range(10**4)]
acc = list(accumulate(oneton))

maxp = bisect_left(acc, n)
for p in range(1,maxp+1):
    if p == acc[maxp] - n:
        continue
    print(p)

Measured memory_bytes: 4212
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
S = 0
for i in range(N, 0, -1):
  A[i-1][0] += S
  A[i-1][0] %= A[i-1][1]
  if A[i-1][0] != 0:
    S += A[i-1][1] - A[i-1][0]
print(S)

Measured memory_bytes: 27380
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> p(n);
    for(int i = 0; i < n; i++) cin >> p[i];
    sort(p.begin(),p.end());
    int ans = 0;
    for(int i = 0; i < k; i++) ans += p[i];
    cout << ans << endl;
    return 0;
}

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

struct Query{
    int l, cnt;
};

const int MAXN = 305, MOD=1e9+7;
vector<Query> qs[MAXN];
int n, m, dp[MAXN][MAXN][MAXN];
bool valid[MAXN][MAXN][MAXN];

int add(int a, int b){
    a += b;
    if(a >= MOD)
        a -= MOD;
    return a;
}

int f(int i, int j, int k){
    int mxpos = max({i,j,k});
    if(mxpos==n)return 1;

    int &r=dp[i][j][k]; 
    if(r!=-1)return r;

    r=0;
    if(valid[mxpos+1][j][k])
        r=add(r, f(mxpos+1,j,k));
    if(valid[i][mxpos+1][k])
        r=add(r, f(i,mxpos+1,k));
    if(valid[i][j][mxpos+1])
        r=add(r, f(i,j,mxpos+1));
    return r;
}

int main(){
    memset(dp, -1, sizeof(dp));
    cin >> n >> m;
    for(int i=0; i<m; i++){
        int l, r, x;
        cin >> l >> r >> x;
        qs[r].push_back(Query{l, x});
    }
    for(int i=0; i<=n; i++)
        for(int j=0; j<=n; j++)
            for(int k=0; k<=n; k++){
                int mxpos = max({i,j,k}), can = 1;
                for(auto q : qs[mxpos]){
                    int cnt = q.l <= i && i <= mxpos;
                    cnt += q.l <= j && j <= mxpos;
                    cnt += q.l <= k && k <= mxpos;
                    can &= cnt == q.cnt;
                }
                valid[i][j][k] = can;
            }
    cout << f(0, 0, 0) << "\n";
}

Measured memory_bytes: 138880
#include <bits/stdc++.h>
using namespace std;
const int M = 110;
char s[M];
int main(){
    scanf("%s", s + 1);
    int len = strlen(s + 1);
    int flag1, flag2, flag3;
    flag1 = flag2 = flag3 = 0;
    for(int l = 1, r = (len - 1) / 2; l < r; l++, r--) {
        if(s[l] != s[r]) flag1 = 1;
    }
    for(int l = (len + 3) / 2, r = len; l < r; l++, r--) {
        if(s[l] != s[r]) flag2 = 1;
    }
    for(int l = 1, r = len; l < r; l++, r--) {
        if(s[l] != s[r]) flag3 = 1;
    }
    if(!flag1 && !flag2 && !flag3) printf("Yes\n");
    else printf("No\n");
    return 0;
}


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

using namespace std;
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,k,h) for(int i = k; i < h; ++i)
#define rep3(i,k,h) for(int i = k; i <= h; ++i)
#define INF LONG_LONG_MAX // long long INF
#define inf INT_MAX // int inf

typedef pair<int,int> int_pair;
typedef pair<string,string> string_pair;


int main() {
    string s;
    cin >> s;
    int sl = s.size();
    for(int i = 1;i < s.size()/2;i++)
    {
        sl -= 2;
        if(s.substr(0,sl/2) == s.substr(sl/2,sl/2))
        {
            break;
        }
    }
    cout << sl << endl;
    return 0;
}



Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a1, a2, b1, b2, c, d, tmp, m, h, w, x, y, sum, k, q, t1, t2,
    tmpp;

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

  cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
  tmp = t1 * a1 + t2 * a2;
  tmpp = t1 * b1 + t2 * b2;
  ll sa1 = t1 * a1 - t1 * b1;
  ll sa2 = t2 * a2 - t2 * b2;
  ll sa = sa1 + sa2;
  if (sa == 0) {
    Cout("infinity");
    return 0;
  }
  int a, b;
  if (sa1 > 0)
    a = 1;
  else
    a = 2;
  if (sa >= 0)
    b = 1;
  else
    b = 2;
  if (a == b) {
    c = 1;
    //assert(c != 1);
    Cout(0);
  } else {
    // Cout(sa1);
    if (sa1 < 0) sa1 *= -1;
    if (sa < 0) sa *= -1;
    ans = sa1 / sa;
    if (sa1 % sa != 0) ans++;
    ans *= 2;
    if (sa1 % sa == 0) ans++;
    Cout(max(ans - 1, 0LL));
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int ans=0;	
		int N=sc.nextInt();	
		int A=sc.nextInt();	
		int B=sc.nextInt();	
		ans=Math.min(B,N*A);
	System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include<cstdio>
using namespace std;

int D;

int main(){
	scanf("%d", &D);
	if(D == 25) printf("Christmas\n");
	else if(D == 24) printf("Christmas Eve\n");
	else if(D == 23) printf("Christmas Eve Eve\n");
	else if(D == 22) printf("Christmas Eve Eve Eve\n");
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
 
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = (n) - 1; i >= 0; i--)
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define CHINO(a,n) int n, *a; scanf("%d", &n); a = (int *)malloc(sizeof(int) * n); for(int i = 0; i < n; i++) scanf("%d", a + i)
 
int main(){
	char ch[120];
	bool table[26];
	REP(i, 26) table[i] = 0;
	int ans = 1145141919, count = 0, ren = 0;
	bool flag;
	scanf("%s", ch);
	for(int i = 0; ch[i]; i++){
		table[ch[i] - 'a'] = 1;
	}
	REP(i, 26) if(table[i]){
		count = 0; ren = 0;
		for(int j = 0; ch[j]; j++){
			if(ch[j] == i + 'a'){
				ren = 0;
			}else{
				ren++;
				if(ren > count) count = ren;
			}
		}
		if(count < ans) ans = count;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
	long int a, b;
	int k;
	long int ans1,ans2;
	int i, j;

	scanf("%ld %ld %d", &a, &b, &k);
	ans2 = b;
	for (i = 0; i < k; i++)
	{
		ans1 = a + i;
		if (ans1 > ans2) continue;
		printf("%ld\n", ans1);
	}
	for (j = k-1; j >=0; j--)
	{
		ans2 = b -j;
		if (ans2 <= ans1) continue;
		printf("%ld\n", ans2);
	}
	return 0;
}

Measured memory_bytes: 128
N,M=map(int,input().split())
B=[1]+[1]+[0]*(N-1)
for j in range(M):
    a=int(input())
    B[a]=-1
    if a==1:
        B[a]=0
i=2
while i<=N:
    if B[i]==-1:
        B[i]=0
    else:
        B[i] = (B[i - 1] + B[i - 2]) % (10 ** 9 + 7)
    i+=1
print(B[N])

Measured memory_bytes: 75600
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def bisection(l,r,f,left=True,discrete=True):
    eps=1 if discrete else 10**-12
    if((not left)^f(r)): return r if left else r+1
    elif(left^f(l)): return l-1 if left else l
    while(r-l>eps):
        h=(l+r)//2 if discrete else (l+r)/2
        if((not left)^f(h)): l=h
        else: r=h
    return (l+r)/2 if not discrete else l if left else r

class RollingHash(object):
    from random import randint
    __MASK30=(1<<30)-1
    __MASK31=(1<<31)-1
    __MOD=(1<<61)-1
    __base=randint(129,__MASK31)

    def __init__(self,s:str):
        n=len(s)
        b=self.__base
        H=[0]*(n+1); P=[1]*(n+1)
        for i in range(n):
            H[i+1]=self.__modulo(self.__multiple(H[i],b)+ord(s[i]))
            P[i+1]=self.__multiple(P[i],b)
        self.__H=H; self.__P=P

    def __multiple(self,a,b):
        au=a>>31
        ad=a&self.__MASK31
        bu=b>>31
        bd=b&self.__MASK31
        m=ad*bu+au*bd
        mu=m>>30
        md=m&self.__MASK30
        return self.__modulo(2*au*bu+mu+(md<<31)+ad*bd)

    def __modulo(self,x):
        x=(x&self.__MOD)+(x>>61)
        if(x>self.__MOD): x-=self.__MOD
        return x

    def hash(self,l,r):
        H=self.__H; P=self.__P
        return self.__modulo(H[r]+self.__MOD*3-self.__multiple(H[l],P[r-l]))

def resolve():
    n=int(input())
    s=input()
    rh=RollingHash(s)
    def check(d):
        J={rh.hash(i,i+d):-1 for i in range(n-d+1)}
        for i in range(n-d+1):
            h=rh.hash(i,i+d)
            if(J[h]!=-1):
                if(i-J[h]>=d): return True
            else: J[h]=i
        return False
    print(bisection(0,n,check))
resolve()

Measured memory_bytes: 54104