akhauriyash/Code-Regression huggingface dataset:
#! /usr/bin/env python3

N = int(input())
A = list(map(int, input().split()))
B = sorted([x for x in A if x % 2 == 0])
cnt = 0
for i in B:
    while i % 2 == 0:
        i //= 2
        cnt += 1
print(cnt)

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

using namespace std;

int main(){
    int N, D;
    cin >> N >> D;
    int res =0 ;
    long long dis = (long long)D * D;
    for (int i = 0; i < N; i++){
        long long X, Y;
        cin >> X >> Y;
        if (X * X + Y * Y <= dis) res++;
    }
    cout << res << endl;
    return 0;
}

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

int main(){
  int a,b;  cin>>a>>b;
  int ans=-1;
  for (int i=1; i<11000; i++){
    if ((int)(i*0.08)==a && (int)(i*0.10)==b){
      ans=i;
      break;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# モジュールのインポート
from collections import defaultdict, deque

# 標準入力を取得
N, M = list(map(int, input().split()))
G = defaultdict(set)
for m in range(M):
    A_i, B_i = list(map(int, input().split()))
    G[A_i - 1].add(B_i - 1)
    G[B_i - 1].add(A_i - 1)

# 求解処理
seen = [False for i in range(N)]

ans = 0
for i in range(N):
    if seen[i]:
        continue
    friends = 0
    que = deque()

    seen[i] = True
    que.append(i)
    friends += 1

    while len(que) > 0:
        v = que.popleft()
        for w in G[v]:
            if not seen[w]:
                seen[w] = True
                que.append(w)
                friends += 1

    ans = max(ans, friends)

# 結果出力
print(ans)


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

int main()
{
	int ans;
	int n, m;

	cin >> n >> m;

	int time = 1900 * m + 100 * (n - m);
	int r = 1;
	for( int i = 0; i < m; i++ ) {
		r *= 2;
	}
	ans = r * time;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	Scanner sc = new Scanner(System.in);
	int kin=0;

	public void syori(){
		int ku = sc.nextInt();
		int su = sc.nextInt();

		switch(ku){
		case 1:
			kin = 6000 * su;
			break;
		case 2:
			kin = 4000 * su;
			break;
		case 3:
			kin = 3000 * su;
			break;
		case 4:
			kin = 2000 * su;
			break;
		}

	}

	public void out(){
		System.out.println(kin);
	}


	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Main m = new Main();

		for(int r=0;r<4;r++){
			m.syori();
			m.out();
		}

	}
}

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

int main() {
  string S;
  cin >> S;
  if (S == "abc" || S == "acb" || S == "bac" || S == "bca" || S == "cab" || S == "cba") {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
import heapq
import sys
from io import StringIO
import unittest

n, m = map(int, input().split())
a = list(map(lambda x: int(x) * (-1), input().split()))
heapq.heapify(a)

for _ in range(m):
    tmp_min = heapq.heappop(a)
    heapq.heappush(a, (-1) * (-tmp_min // 2))
print(-sum(a))

Measured memory_bytes: 27600
def main():
    N, K = tuple(int(i) for i in input().split())
    R, S, P = tuple(int(i) for i in input().split())
    T = input()

    points = {
        'r': P,
        's': R,
        'p': S,
    }

    # print(N, K)
    # print(R, S, P)
    # print(T)

    history = []
    total = 0

    for i in range(N):
        v = T[i]
        if i < K:
            history.append(v)
            total += points[v]
        elif history[i - K] == v:
            history.append('x')
        else:
            history.append(v)
            total += points[v]
    print(total)


if __name__ == '__main__':
    main()


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int s[1000] = {0};
    s[0] = a;
    for (int i = 1; i < 1000; i++) s[i] += s[i - 1] + a;

    rep(i, 1000) {
        if (s[i] % b == c) {
            cout << "YES" << endl;
            return 0;
        }
    }

    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define all(n)      (n).begin(), (n).end()
#define ll long long

void solve() {
	int a, b, c, d; cin >> a >> b >> c >> d;
	bool turn  = 1;

	while (a > 0 && c > 0) {
		if (turn) {
			c -= b;
			turn = 0;
		} else {
			a -= d;
			turn = 1;
		}
	}
	if (a > 0) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}


}


int main () {

	ios::sync_with_stdio(0);
	cin.tie(0);
	//Write from here.
	solve();

	return 0;
}

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

int bubbleSort(int A[],int N){
    int sw=0;
    bool flag=1;  
    for (int i=0; flag; i++) {
        flag=0;
        for (int j=N-1; j>=i+1; j--) {
            if (A[j]<A[j-1]) {
                swap(A[j], A[j-1]);
                flag=1;
                sw++;
            }
        }
    }
    
   
    return sw;
}


int main(int argc, const char * argv[]) {
    int N,sw;
    int A[105];
    cin>>N;
    for (int i=0; i<N; i++) {
        cin >>A[i];
    }
    sw=bubbleSort(A, N);
    for (int i=0; i<N; i++) {
        if (i<N-1) {
            cout <<A[i]<<" ";
        } else {
            cout <<A[i]<<endl;
        }
    }
    cout <<sw<<endl;
    
    
    return 0;
}



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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(x) x.begin(), x.end()

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}

const int MOD = 1e9 + 7;

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

int sub(int a, int b) {
	a -= b;
	if (a < 0)
		a += MOD;
	return a;
}

int mul(int a, int b) {
	return (ll) a * b % MOD;
}

int binpow(int a, int n) {
	if (n == 0) return 1;
	if (n & 1) {
		return mul(a, binpow(a, n - 1));
	} else {
		return binpow(mul(a, a), n / 2);
	}
}

int inv(int a) {
	return binpow(a, MOD - 2);
}

const int MAXN = 1e6 + 10;
int fact[MAXN], rfact[MAXN];

void build() {
	fact[0] = rfact[0] = 1;
	for (int i = 1; i < MAXN; i++) {
		fact[i] = mul(fact[i - 1], i);
		rfact[i] = inv(fact[i]);
	}
}

int c_n_k(int n, int k) {
	return mul(fact[n], mul(rfact[n - k], rfact[k]));
}

int n;
vector<int> g[MAXN];

void read() {
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}	
}

int merge(int a, int sz_a, int b, int sz_b) {
	int ans = mul(a, b);
	ans = mul(ans, c_n_k(sz_a + sz_b, sz_a));
	return ans;
}

int dp[MAXN];
int sz[MAXN];
void dfs_down(int v, int p) {
	sz[v] = 1;
	for (auto i : g[v]) {
		if (i == p) continue;
		dfs_down(i, v);
		sz[v] += sz[i];
	}

	int sz_now = 0;
	dp[v] = 1;
	for (auto i : g[v]) {
		if (i == p) continue;
		dp[v] = merge(dp[v], sz_now, dp[i], sz[i]);
		sz_now += sz[i];
	}
}

int ans[MAXN];

void dfs_up(int v, int p) {
	if (p != -1) {
		int val_p = dp[p];
		int sz_p = n - sz[v] - 1;
		
		val_p = mul(val_p, inv(dp[v]));
		//cout << inv(dp[v]) << endl;
		val_p = mul(val_p, inv(c_n_k(n - 1, sz[v])));
		//cout << inv(c_n_k(sz_p + sz[v, sz[v]))
		//cout << "help = " << endl;
		//cout << val_p << " " << sz_p << endl;

		dp[v] = merge(dp[v], sz_p + 1, val_p, sz[v] - 1);
	}

	for (auto i : g[v]) {
		if (i != p) {
			dfs_up(i, v);
		}
	}
}

void run() {
	build();
	dfs_down(0, 0);
	//cout << dp[0] << endl;
	//exit(0);
	dfs_up(0, -1);
}

void write() {
	for (int i = 0; i < n; i++) {
		cout << dp[i] << "\n";
	}
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	read();
	run();
	write();
	return 0;
}

Measured memory_bytes: 50164
#!/usr/bin/env python3
 
import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
 
n = I()
a = LI()
L = [1]
if a[-1] > 2**n:
    print(-1)
    quit()
if n == 0:
    if a[0] == 0:
        print(-1)
        quit()
L2 = [a[-1]]
for i in range(n)[::-1]:
    L2.append(min(L2[-1] + a[i], 2**i))
L2 = L2[::-1]
ans = 0
for i in range(n+1):
    if i == 0:
        tmp = 1
    else:
        tmp = (L[-1] - a[i-1]) * 2
    if tmp <= 0:
        print(-1)
        quit()
    ans += min(tmp, L2[i])
    L.append(tmp)
if L[-1] - a[-1] < 0:
    print(-1)
    quit()
print(ans)


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

ll inf=1ll<<60,mod=1e9+7;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	cout<<a[0]+a[1];
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  map<string, int> MA;
  string S;
  while (cin >> S) MA[S]++;
  for (auto s : {"AC", "WA", "TLE", "RE"}) cout << s << " x " << MA[s] << "\n";
}

Measured memory_bytes: 3636
N = int(input())
A = [int(i) for i in input().split()]
count = {}
for a in A:
    count.setdefault(a, 0)
    count[a] += 1
m = 0
for k in count:
    c = count[k]
    if k-1 in count:
        c += count[k-1]
    if k+1 in count:
        c += count[k+1]
    m = max(m, c)
print(m)

Measured memory_bytes: 19824
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<vector<pair<int, int>>> G(n);
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        G[i].resize(a);
        for (int j = 0; j < a; ++j) {
            cin >> G[i][j].first >> G[i][j].second;
            G[i][j].first--;
        }
    }
    int ans = 0;
    for (int i = 1; i < (1 << n); ++i) {
        int ok = 1;
        for (int j = 0; j < n; ++j) {
            if(i & (1 << j)){
                for (auto &&k : G[j]) {
                    if(((i >> k.first) & 1) != k.second){
                        ok = 0;
                    }
                }
            }
        }
        if(ok) ans = max(ans, __builtin_popcount(i));
    }
    cout << ans << "\n";
    return 0;
}

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

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

int main() {
	std::string in;
	while (std::getline(std::cin,in)) {
		for (std::string::iterator itr = in.begin(); itr != in.end(); itr++) {
			if ('a' <= *itr && *itr <= 'z') {
				*itr = *itr - 'a' + 'A';
			}
		}
		std::cout << in << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3152
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define alli(a, n, k) (a + k), (a + n + k)
#define FP(i, a, b, k) for (__typeof(a) i = a; i < b; i += k)
#define FS(i, a, b, k) for (__typeof(a) i = a; i > b; i -= k)
#define IT(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template <class T>
inline T gcd(T x, T y)
{
	if (!y)
		return x;
	return gcd(y, x % y);
}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
	return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
	assert(__gcd(a, m) == 1);
	ll m0 = m;
	ll y = 0, x = 1;

	if (m == 1)
		return 0;

	while (a > 1)
	{
		ll q = a / m;
		ll t = m;

		m = a % m, a = t;
		t = y;

		y = x - q * y;
		x = t;
	}

	if (x < 0)
		x += m0;

	return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
	if (y == 0)
		return 1LL;
	else if (y == 1)
		return x;
	else
	{
		ll ans = modPow(x, y / 2, m) % m;
		if (y & 1)
		{
			return (((ans * ans) % m) * x) % m;
		}
		else
		{
			return (ans * ans) % m;
		}
	}
}

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	double m;
	cin>>n>>m;
	double tot=0;
	vector<double> arr(n);
	for(auto &x:arr){
		cin>>x;
		tot+=x;
	}
	int c=0;
	for(auto x:arr)
	{
		if(x>=tot/(4*m))
		c++;
	}
	if((double)(c)>=m)
	cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{

    string s,t;
    cin>>s>>t;
    int l1,l2,i,j;
    sort(s.begin(),s.end());
    //cout<<s<<" "<<t<<endl;
    sort(t.begin(),t.end());
    //cout<<s<<" "<<t<<endl;
    reverse(t.begin(),t.end());
    //cout<<s<<" "<<t<<endl;
    char temp;
    int ind;
    l1=s.size();
    l2=t.size();
    //cout<<s<<" "<<t<<endl;
    int l=max(l1,l2);
    for(i=0;i<=l;i++)
    {
            if(i==l2)
            {
                printf("No\n");
                return 0;
            }
            if(i==l1)
            {
                printf("Yes\n");
                return 0;
            }

            if(s[i]<t[i])
            {
                printf("Yes\n");
                return 0;
            }
            if(s[i]>t[i])
            {
                printf("No\n");
                return 0;
            }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <iomanip>
using namespace std;

int main(){
   int a, b;
   cin >> a >> b;
   if (a+b==15) cout << "+" << endl;
   else if (a*b==15) cout << "*" << endl;
   else cout << "x" << endl;
}


Measured memory_bytes: 384
#include<cstdio>
int n,m,a[100010];
long long f[200010];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)scanf("%d",a+i);
	long long sum=0;
	for(int i=1;i<n;i++){
		int l=a[i-1],r=a[i];
		if(r<l)r+=m;
		f[l+2]++;f[r+1]-=r-l;f[r+2]+=r-l-1;
		sum+=r-l;
	}
	long long ans=sum;
	for(int t=2;t--;)
		for(int i=1;i<=m*2;i++)f[i]+=f[i-1];
	for(int i=1;i<=m;i++)
		if(sum-(f[i]+=f[i+m])<ans)ans=sum-f[i];
	printf("%lld\n",ans);
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i = 0; i < n; i++)
#define rep2(i,start,end) for(ll i = start; i < end; i++)
#define dwn(i,n) for(int i = n; i >= 0; i--)
#define dwn2(i,start,end) for(ll i = start; i >= end; i--)
#define pll pair<ll,ll>
#define mk(x,y) make_pair(x,y)
#define pdl pair<double, ll>
const ll N = 4e5 + 200;
const ll INF = 0x3f3f3f3f;
const ll mod = 1e9 + 7;

ll a[N];
int main(){
	int n;
	cin>>n;
	rep(i,n-1){
		int x;
		cin>>x;
		a[x]++;
	}
	for(int i = 1; i <= n; i++){
		cout<<a[i]<<endl;
	}



	return 0;
}






Measured memory_bytes: 5148
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

int n;
long long a[105];

long long gcd(long long m, long long q)
{
	if(q == 0) return m;
	return gcd(q, m % q);
}
int main()
{
	long long ans = 1;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%lld", &a[i]);
	sort(a + 1, a + 1 + n);
	long long pp;
	for(int i = 1; i <= n; i++)
	{
		pp = gcd(a[i], ans);
		ans = (a[i] / pp) * (ans / pp) * pp;
	}
	/*ans = a[n];
	for(int i = n - 1; i >= 1; i--)
	{
		if(a[n] % a[i] == 0) continue;
		else {
			pp = gcd(a[n], a[i]);
			ans = ans * (a[i] / pp);
		}
	}
	int t = 0;
	while(true)
	{
		t++;
		if(t > 100 || t == ans) break;
		for(int i = 1; i <= n; i++)
		{
			if((ans / t) % a[i] != 0) break;
			if(i == n) ans = ans / t;
		}
	}*/
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,t,count=0,k,i,x,j,sum;

    cin>>a>>b>>c>>t;

    for(i=0; i<=a; i++)
    {
        for(j=0; j<=b; j++)
        {
           for(k=0; k<=c; k++)
           {
               sum=(i*500)+(j*100)+(k*50);

               if(sum==t)
               {
                   count++;
                   break;
               }
           }
        }
    }
    cout<<count<<endl;

    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
    var sc = bufio.NewScanner(os.Stdin)
    sc.Split(bufio.ScanWords)
    sc.Scan()
    a, _ := strconv.Atoi(sc.Text())
    sc.Scan()
    b, _ := strconv.Atoi(sc.Text())
    fmt.Println(a*b,2*(a+b))
}


Measured memory_bytes: 1060
def factor(N):
    arr=[]
    for i in range(1,int(N**0.5)+1):
        if(N%i==0):
            arr.append(i)
            if(N//i!=i):
                arr.append(N//i)
    return arr

N=int(input())
li=factor(N)
fac=factor(N-1)
res=len(fac)-1
for i in range(len(li)):
    if(li[i]==1):
        continue
    tmp=N
    while(tmp%li[i]==0):
        tmp//=li[i]
    if(tmp%li[i]==1):
        res+=1
print(res)

Measured memory_bytes: 39152
#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
const int M = 1000000007;

const int inv = 576923081;

int main() {
    int n, m;
    string s;
    cin >> n >> m >> s;
    int len = s.length();
    vector<long long> bases(len);
    bases[0] = 1;
    for (int i = 1; i < len; ++i)
        bases[i] = bases[i - 1] * 26 % M;

    vector<vector<long long>> hs(n);
    long long h = s[0] - 'a';
    int l = 0, r = 1;
    for (int i = 0; i < m; ++i) {
        string q;
        cin >> q;
        if (q[0] == 'L') {
            if (q[1] == '+') {
                h = (h - (s[l] - 'a') + M) * inv % M;
                ++l;
                hs[r - l - 1].push_back(h);
            }
            else {
                h = (h * 26 + s[l - 1] - 'a') % M;
                --l;
                hs[r - l - 1].push_back(h);
            }
        }
        else {
            if (q[1] == '+') {
                h = (h + (s[r] - 'a') * bases[r - l]) % M;
                ++r;
                hs[r - l - 1].push_back(h);
            }
            else {
                h = (h - (s[r - 1] - 'a') * bases[r - l - 1] % M + M) % M;
                --r;
                hs[r - l - 1].push_back(h);
            }
        }
    }
    int ans = 0;
    for (auto& a : hs) {
        if (!a.size()) continue;
        sort(a.begin(), a.end());
        ans += unique(a.begin(), a.end()) - a.begin();
    }
    cout << ans << "\n";
    return 0;
}



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

int main()
{
    int n,ans=0;
    string s;
    cin >> n >> s;
    vector<int> x(27);
    vector<vector<int>> y(n+1,vector<int>(n+1));
    x[0] = 1000508759;
    x[1] = 1000508983;
    x[2] = 1000509113;
    x[3] = 1000509281;
    x[4] = 1000509817;
    x[5] = 1000509997;
    x[6] = 1000510177;
    x[7] = 1000510363;
    x[8] = 1000511341;
    x[9] = 1000511651;
    x[10] = 1000511851;
    x[11] = 1000512031;
    for(int i = 12 ; i < 26 ; i += 1){
        x[i] = rand()%902365214;
    }
    for(int i = 0 ; i < n ; i += 1){
        long long val = 1;
        for(int j = i ; j < n ; j += 1){
            if((j-i)%2 == 0){
                val *= x[s[j]-'a'];
                val %= 1000112123;
                y[i][j] = val;
            }else{
                val += x[s[j]-'a'];
                val %= 1000000007;
                y[i][j] = val;
            }
        }
    }
    for(int i = 0 ; i < n-1 ; i += 1){
        for(int j = i+1 ; j < n ; j += 1){
            if(s[i] != s[j]){
                continue;
            }
            int first = 0 , last = min(j-i-1,n-j-1);
            while(last - first > 1){
                int mid = (first + last)/2;
                if(y[i][i+mid] == y[j][j+mid]){
                    first = mid;
                }else{
                    last = mid;
                }
            }
            if(y[i][i+last] == y[j][j+last]){
                first = last;
            }
            ans = max(ans,first+1);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 100096
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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; }

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int x = 0;
  rep(i, n) {
    cin >> a[i];
    x ^= a[i];
  }
  int ans = 0;
  for (int i = 30; i >= 0; i--) {
    if (x & 1<<i) {
      rep(j, n) {
        int t = a[j]^a[j]-1;
        if (t == (1<<i+1)-1) { //各ビットは最大1回しか変更しないので選ぶ山の重複は起こらない
          x ^= t;
          ans++;
          break;
        }
      }
    }
  }
  if (x)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int main(void)
{
        int cards[128][14]={{0}};
        int i,N;
        scanf("%d",&N);
        for(i=0; i<N; i++){
            char c;
            int cn;
            scanf("%c",&c);
            scanf("%c %d",&c,&cn);
            cards[c][cn] = 1;
        }
        for(i=1; i<=13; i++){
            if(cards['S'][i]==0){
                printf("S %d\n",i);
            }
        }
        for(i=1; i<=13; i++){
             if(cards['H'][i]==0){
                printf("H %d\n",i);
            }
        }
        for(i=1; i<=13; i++){
            if(cards['C'][i]==0){
                printf("C %d\n",i);
            }
        }
        for(i=1; i<=13; i++){
            if(cards['D'][i]==0){
                printf("D %d\n",i);
            }
        }
        
    return 0;
    
    
}


Measured memory_bytes: 2084
N = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(N):
    case = str(input())
    if case == 'AC':
        ac += 1
    elif case == 'WA':
        wa += 1
    elif case == 'TLE':
        tle += 1
    elif case == 'RE':
        re += 1
        
print('AC x {}'.format(ac))
print('WA x {}'.format(wa))
print('TLE x {}'.format(tle))
print('RE x {}'.format(re))

Measured memory_bytes: 9208
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

d,g = LI()
pc = [LI() for _ in range(d)]
ans = inf
for i in range(1<<d):
    tmp = -1
    count = 0
    score = 0
    flag = True
    for j in range(d):
        if i >> j & 1:
            count += pc[j][0]
            score += pc[j][1] + pc[j][0]*(j+1)*100
        else:
            tmp = max(tmp,j)
    if tmp != -1:
        if score >= g:
           pass 
        elif g - score - (pc[tmp][0]-1)*(tmp+1)*100 > 0:
            flag = False
        else:
            count += (g-score-1)//((tmp+1)*100) + 1
    else:
        if score < g:
            flag = False
    if flag:
        ans = min(ans, count)
print(ans)    

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

const int MAX = 105;
int is_visited[MAX];
int dist[MAX];
int am[MAX][MAX];
queue<int> Q;
int t, n;
int ns[MAX];

int next(int u) {
  for (int i = ns[u]; i < n; i++) {
    ns[u] = i + 1;
    if (am[u][i] == 1) {
      return i;
    }
  }
  return -1;
}

void bfs_visit(int r) {
  int current = r;

  dist[current] = 0;
  is_visited[r] = 1;
  for (int i = 0; i < n; i++) {
    if (am[current][i] == 1) {
      Q.push(i);
      dist[i] = dist[current] + 1;
      is_visited[i] = 1;
    }
  }

  while (!Q.empty()) {
    current = Q.front();
    Q.pop();
    for (int i = 0; i < n; i++) {
      if (am[current][i] == 1 && is_visited[i] == 0) {
        Q.push(i);
        dist[i] = dist[current] + 1;
        is_visited[i] = 1;
      }
    }
  }
}

int main() {
  int u, k, v;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> u >> k;
    for (int j = 0; j < k; j++) {
      cin >> v;
      am[u-1][v-1] = 1;
    }
  }

  for (int i = 0; i < n; i++) {
    dist[i] = -1;
  }

  bfs_visit(0);

  for (int i = 0; i < n; i++) {
    if (dist[i] == MAX) {
      dist[i] = -1;
    }
    cout << i+1 << " " << dist[i] << endl;
  }
}



Measured memory_bytes: 3132
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  while(true){
    int n, m;
    scanf("%d %d", &n, &m);
    if(n == 0 && m == 0){
      break;
    }

    vector<int> a;
    int tmp;
    REP(i,n){
      scanf("%d", &tmp);
      a.pb(tmp);
    }

    REP(i,m){
      scanf("%d", &tmp);
      a.pb(tmp);
    }

     if(n + m == 1){
      printf("%d\n", a[0]);
      continue;
    }

    SORTV(a);
    int ans = a[0];
    REP(i,m+n-1){
      ans = max(ans, a[i+1] - a[i]);
    }
    printf("%d\n", ans);
  }
  return 0;
}




Measured memory_bytes: 3288
#include<bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for (int i=0;i<(n);i++)
#define PI 3.14159265358979323846264338327950L
using namespace std;
using P = pair<int,int>;
using ll = long long;
using namespace std;
int main(void){
    int n;
    cin >> n;
    bool bin = false;
    rep(i,10){
        rep(j,10){
            if(n == i*j){bin = true;}
        }
    }
    if(bin){cout << "Yes";}
    else{cout << "No";}
    return 0;
}

Measured memory_bytes: 3536
s=input().split("LR")
for i in range(1,len(s)):
    s[i-1]+="L"
    s[i]="R"+s[i]
def f(s):
    L=[0]*len(s)
    r=s.count("R")
    l=len(s)-r
    n,m=r//2+r%2+l//2,l//2+l%2+r//2
    L[r-1]=n
    L[r]=m
    return L
g=[]
for i in s:
    g.extend(f(i))
print(*g)

Measured memory_bytes: 9372
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
int n,m,k,a,b;
int par[100001],sz[100001];
vector<int> fri[100001],adj[100001];
int root(int x){
    if (par[x]==x) return x;
    return par[x]=root(par[x]);
}
void connect(int x,int y){
    int rx=root(x);
    int ry=root(y);
    if (rx!=ry){
        par[rx]=ry;
        sz[ry]+=sz[rx];
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>m>>k;
    for (int i=1;i<=n;i++){
        par[i]=i;
        sz[i]=1;
    }
    for (int i=0;i<m;i++){
        cin>>a>>b;
        connect(a,b);
        fri[a].pb(b);
        fri[b].pb(a);
    }
    for (int i=0;i<k;i++){
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    for (int i=1;i<=n;i++){
        int lols=root(i);
        int ans=sz[lols]-fri[i].size();
        for (auto j:adj[i]){
            if (root(i)==root(j)){
                ans--;
            }
        }
        cout<<ans-1<<' ';
    }
}

Measured memory_bytes: 13176
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
using namespace std;
int main() {
	int a, b, h, m, x ;
	double y,z;
	cin >> a >> b >> h >> m;
	x = 60 * h + m;
	y = (11.0 / 360.0) * PI * x;
	z = sqrt(a*a+b*b-2*a*b * cos(y));
	cout << fixed << setprecision(15) << z << endl;
	return (0);
}

Measured memory_bytes: 4232
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define REP(i,x) for(ll i = 1;i<=x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
#define mp make_pair
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const dou pi = 3.14159265358;
const ll mod = 1000000007LL;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
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;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return a / gcd(a,b) * b;
}

//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logm)
ll modpow(ll n,ll m,ll MOD){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}
//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N,M;
    cin >> N >> M;
    vector<ll> sx(N),sy(N),cx(M),cy(M);
    rep(i,N)cin >> sx[i] >> sy[i];
    rep(i,M)cin >> cx[i] >> cy[i];
    rep(i,N){
        ll cnt = INF,ans = 0;
        rep(j,M){
            if(abs(sx[i] - cx[j]) + abs(sy[i] - cy[j]) < cnt){
                ans = j + 1;
                //cout << cnt << "\n";
                cnt = abs(sx[i] - cx[j]) + abs(sy[i] - cy[j]);
            }
        }
        cout << ans << "\n";
    }
}

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

int main() {
  int n;
  cin>>n;
  int sn = 0;
  int m = n;
  while (m > 0) {
    sn += m % 10;
    m /= 10;
  }
  if (n % sn == 0) {
    cout<<"Yes"<<endl;
  } else {
    cout<<"No"<<endl;
  }
}

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

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

  for(int i =0; i<2; i++){
    int cnt=0;
    for(int j=0; j<S.size(); j++){
      if(j%2==0 && S[j]!=(char)(i+'0')) cnt++;
      if(j%2==1 && S[j]==(char)(i+'0')) cnt++;
    }
    ans =min(ans, cnt);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Solve.Answer();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var n = IO.ReadInt;

            int ans = 0;
            for (int i = n; i > 0; i--)
            {
                double root = Sqrt(i);
                if ((int)root * (int)root == i)
                {
                    ans = i;
                    break;
                }
            }
            WriteLine(ans);
        }

        public class IO
        {
            #region Input
            public static string ReadString => ReadLine();
            public static int ReadInt => int.Parse(ReadLine());
            public static long ReadLong => long.Parse(ReadLine());
            public static double ReadDouble => double.Parse(ReadLine());

            public static List<string> ReadSplitString => ReadLine().Split().ToList();
            public static List<int> ReadSplitInt => ReadLine().Split().Select(s => int.Parse(s)).ToList();
            public static List<long> ReadSplitLong => ReadLine().Split().Select(s => long.Parse(s)).ToList();
            public static List<double> ReadSplitdouble => ReadLine().Split().Select(s => double.Parse(s)).ToList();
            #endregion

            #region Output
            public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
            public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");

            #endregion
        }

        public class Mod
        {
            #region
            private readonly static long M = 1000000007;

            public static long Add(long a, long b) => (a * b) % M;
            public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
            public static long Multi(long a, long b) => (a * b) % M;
            #endregion
        }

        public static long GCD(long x, long y)
        {
            #region
            if (x < y)
            {
                var tmp = x;
                x = y;
                y = tmp;
            }
            while (true)

            {
                if (x % y == 0)
                {
                    return y;
                }
                else
                {
                    var tmp = x;
                    x = y;
                    y = tmp % y;
                }
            }
            #endregion
        }

        public static long Choice2(long n)
        {
            #region
            if (n <= 1)
                return 0;
            if (n == 2)
                return 1;
            else
                return n * (n - 1) / 2;
            #endregion
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;

vector<int> cntn(200);

int main(){
    rep(i,200){
        cntn[i] = (i*(i+1))/2;
    }
    ll n;
    cin >> n;
    map<ll,int> mp;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            mp[i] = 0;
            while(n%i==0){
                mp[i] ++;
                n /= i;
            }
        }
    }
    if(n > 1){
        mp[n] = 1;
    }
    ll cnt = 0;
    for(auto p:mp){
        int id = 0;
        rep(i,200){
            if(cntn[i] > p.second){
                id = i-1;
                break;
            }
        }
        cnt += id;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3632
import sys
def p(*a):
  s=" ".join(map(str,a))
  #print(s)
  sys.stderr.write(s+"\n")
#-------------------------------------------------------------------
N, M = map(int, input().split())

G=[[] for _ in range(N+1) ]			#=> [[], [], [], [], [], [], [], []]
for _ in range(M):
	u,v = map(int, input().split())
	G[u].append(v)

S, T = map(int, input().split())

#p("N,M",N,M)
#p("G",G)
#p("S,T",S,T)


# 訪問済み＆移動数の記録用マップ、Visitedを作る。未訪問は-1
V=[ [-1,-1,-1] for _ in range(N+1) ]			#=> [ [-1,-1,-1], [-1,-1,-1], ... [-1,-1,-1] ]
V[S][0]=0

# キューに行き先候補を入れて、
from collections import deque
Q = deque()
Q.append([S,0])

while Q:
	FM = Q.popleft()
	
	fm = FM[0]
	l =  FM[1]
	
	for to in G[fm]:
		nl = (l+1)%3
		b = (V[to][nl]==-1)							# 未訪問である
		#b = b or (V[to]>(V[fm]+1))	# より短いステップ数である(＝既存の方が大きい)
		if b:
			V[to][nl] = V[fm][l]+1		# 訪問ステップ数の記録
			Q.append([to,nl])			# 次の訪問先として、キューに追加

ans = V[T][0]
if ans > -1: ans //= 3
print(ans)


Measured memory_bytes: 38036
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define fo(i,a,n) for (i = a; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;



void solve(){
    int a, b;
    string s, t ,u;
    cin>>s>>t>>a>>b>>u;
    if(u == s)cout<<a-1<<" "<<b;
    else cout<<a<<" "<<b-1;
}

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


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;

int main() {

    ll W,H,x,y;
    int ans;
    double s;

    cin >> W >> H >> x >> y;

    s = (double)W * (double)H / 2.0;
    if((double)x==(double)W/2.0 && (double)y==(double)H/2.0){
        ans = 1;
    }else{
        ans = 0;
    }

    cout << s << " " << ans << endl;

    return 0;
}


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

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	rep(i, N) cin >> A[i];
	for (int i = K; i < N; i++){
		if (A[i-K] < A[i]) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	//cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 4048
#include <stdio.h>

typedef struct{
  int p;
  int l;
  int r;
}Tree;

Tree T[100000];
int n, D[100000], H[100000];

void setDepth(int u, int d){
  if(u==-1)return;
  D[u]=d;
  setDepth(T[u].l, d+1);
  setDepth(T[u].r, d+1);
}

int setHeight(int u){
  int h1=0, h2=0;
  if(T[u].l!=-1){
    h1=setHeight(T[u].l)+1;
  }
  if(T[u].r!=-1){
    h2=setHeight(T[u].r)+1;
  }
  if(h1>h2)H[u]=h1;
  else H[u]=h2;
  return H[u];
}

int getSibling(int u){
  if(T[u].p==-1)return -1;
  if(T[T[u].p].l!=u && T[T[u].p].l!=-1) return T[T[u].p].l;
  if(T[T[u].p].r!=u && T[T[u].p].r!=-1) return T[T[u].p].r;
  return -1;
}

int main(){
  int i,v,l,r,root=0,deg;
  scanf("%d", &n);
  for(i=0;i<n;i++){
    T[i].p=-1;
    T[i].l=-1;
    T[i].r=-1;
  }
  for(i=0; i<n; i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].l=l;
    T[v].r=r;
    if(l!=-1)T[l].p=v;
    if(r!=-1)T[r].p=v;
  }
  for(i=0; i<n; i++){
    if(T[i].p==-1)root=i;
  }
  setDepth(root, 0);
  setHeight(root);

  for(i=0; i<n; i++){
    printf("node %d: parent = %d, sibling = %d, ",i,T[i].p,getSibling(i));
    deg = 0;
    if(T[i].l!=-1)deg++;
    if(T[i].r!=-1)deg++;
    printf("degree = %d, depth = %d, height = %d, ",deg, D[i], H[i]);
    if(T[i].p==-1)printf("root\n");
    else if(T[i].l==-1 && T[i].r==-1)printf("leaf\n");
    else printf("internal node\n");
  }
  return 0;
}

Measured memory_bytes: 624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;


int main()
{
    string s;
    cin >> s;
    for(int bit = 0; bit < (1<<3); bit++){
        int tmp = s[0] - '0';

        for(int i = 0; i < 3; i++){
            if(bit & (1<<i)){
                tmp += (s[i+1]-'0');
            }else{
                tmp -= (s[i+1]-'0');
            }
        }
        if(tmp == 7){
            cout << s[0];
            for(int i = 0; i < 3; i++){
                if(bit & (1<<i)){
                    cout << '+';
                    cout << s[i+1];
                }else{
                    cout << '-';
                    cout << s[i+1];
                }
            }
            cout << "=7";
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int matrix[100][100],i,j,input,n,m,matrix1[100],sum=0;
    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&matrix[i][j]);
        }
    }
    for(i=0;i<m;i++){
        scanf("%d",&matrix1[i]);
    }
    for(i=0;i<n;i++){
        sum=0;
        for(j=0;j<m;j++){
            sum+=matrix[i][j]*matrix1[j];
        }
        printf("%d\n",sum);
    }
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  int A=S[0]-'0',B=S[1]-'0',C=S[2]-'0',D=S[3]-'0';
  
  for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
      for(int k=0;k<2;k++){
        int x = A;
        if(i) x += B;
        else x -= B;
        if(j) x += C;
        else x -= C;
        if(k) x += D;
        else x -= D;
        
        if(x==7){
          cout << A;
          if(i) cout << "+";
          else cout << "-";
          cout << B;
          if(j) cout << "+";
          else cout << "-";
          cout << C;
          if(k) cout << "+";
          else cout << "-";
          cout << D << "=7" << endl;
          return 0;
        }
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int i,j;//Aの本数、Bの本数
	int A, B, X;//1000mL、500mL、必要量
	int check;//会計
	int min_check=1000000;//最終的な会計（最小値）
	
	scanf("%d%d%d",&A,&B,&X);
	
	for(i=0;i<=20;i++)//ループによる全探索
	{
		for(j=0;j<=40;j++)
		{
			check=A*i+B*j;
			if( (check<min_check) && (1000*i+500*j>=X) )
			{
				min_check = check;
			}
		}
	}
	printf("%d\n",min_check);
	return 0;
}



Measured memory_bytes: 2104
#include <stdio.h>

#define MAX_LEN 5
#define ATOZ 26

int main(void)
{
	char S[MAX_LEN];
	int alpha[ATOZ] = {0};
	int i, count = 0;
	scanf("%s", S);

	for (i = 0; i < MAX_LEN; i++) {
		char c;
		c = S[i];
		alpha[c - 'A']++;
	}

	for (i = 0; i < ATOZ; i++)
		if (alpha[i] == 2)
			count++;
	puts(count == 2 ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int a = Integer.parseInt(br.readLine());
        int b = Integer.parseInt(br.readLine());
        System.out.println(problem148a(a, b));
    }

    private static int problem148a(int a, int b) {
        return ((1 + 2 + 3) - a - b);
    }
}

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

int main() {
  int N;
  cin >> N;
  
  double sum = 0.000000;
  for (int i = 0; i < N; i++) {
    if ((i + 1) % 2 != 0) {
      sum = sum + 1.000000;
    }
  }
  
  double ans = 0.000000;
  ans = sum / N;
  cout << ans << endl;
}


Measured memory_bytes: 3780
#include<iostream> 
using namespace std; 
int main() {
	int N, K, X, Y; 
	cin >> N >> K >> X >> Y;  
	if (N<=K)
	{
		cout << N * X << "\n";
	} 
	else
	{
		cout << (K*X) + (N - K)*Y << "\n";
	}
	
}

Measured memory_bytes: 256
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a,b,c;
    cin >> a >> b >>c;
    cout << a*b/2;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;

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; }
void SWAP(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void SWAP(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


class D {
	int n, ma{ -INTMAX }, mi{ INTMAX };
	int ma_i{ -1 }, mi_i{ -1 };
	vi a;
public:
	D()
	{
		cin >> n;
		a.resize(n);

		REP(i, n)
		{
			int tmp;
			cin >> tmp;
			if (chmax(ma, tmp))
				ma_i = i;
			if (chmin(mi, tmp))
				mi_i = i;
			a[i] = tmp;			
		}
	}

	void solve()
	{
		vvi ans;
		int m{ 0 };

		if ((ma ^ mi) < 0)
		{
			if (-mi > ma)
			{
				// make all negative
				ma = -1;
				REP(i, n)
				{
					if (i != mi_i)
					{
						ans.emplace_back(vi{ mi_i + 1, i + 1 });
						++m;
					}
				}
			}
			else
			{
				// make all positive
				mi = 0;
				REP(i, n)
				{
					if (i != ma_i)
					{
						ans.emplace_back(vi{ ma_i + 1, i + 1 });
						++m;
					}
				}
			}
		}

		if (ma < 0)
		{
			for (int i{ n - 1 }; i >= 1; i--)
			{
				ans.emplace_back(vi{ i + 1 , i });
				++m;
			}
		}

		else
		{
			REP(i, n - 1)
			{
				ans.emplace_back(vi{ i + 1, i + 2 });
				++m;
			}
		}

		cout << m << endl;
		REP(i, m)
			cout << ans[i][0] << " " << ans[i][1] << endl;
	}
};


int main()
{
	D solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256