akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

const int N = (int)1e5 + 5;
const long long inf = (long long)1e18 + 18;

int n,w[105],v[105],W,sum_value;

long long ans;

int main(){
	cin >> n >> W;
     for(int i = 1; i <= n; i++){
     	cin >> w[i] >> v[i];
     	sum_value += v[i];	
     }
     vector<long long> dp(sum_value + 1,inf);
     dp[0] = 0;
     /// dp[i] -> the minimum total weight of items with total value exactly i
     for(int i = 1; i <= n; i++){
     	for(int value_already = sum_value - v[i]; value_already >= 0; value_already--){
     		dp[value_already + v[i]] = min(dp[value_already + v[i]],dp[value_already] + w[i]);
     	}
     }
     for(int i = 0; i <= sum_value; i++){
     	if(dp[i] <= W){
     		ans = max(ans,(long long)i);
     	}
     }
     cout << ans;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define f(i,a,b) for(int i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define all(a) a.begin(),a.end()
#define size(s) s.size()
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using si = stack<LL>;
using pi = pair<LL, LL>;
using v_pi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50
bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

/*****************************************************************************/
int n, m;
LL ans = 0;
void dfs(int v) {
	f(i, 0, n) {
		visited[v] = true;
		if (graph[v][i] == false)continue;
		if (visited[i] == true)continue;
		dfs(i);
	}
	return;
}

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

	cin >> n >> m;
	vi a(m), b(m);
	link(a, b, m);
	f(i, 0, m) {
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
		f(j, 0, n) {
			visited[j] = false;
		}
		dfs(0);
		bool bridge = false;
		f(j, 0, n) {
			if (visited[j] == false) {
				bridge = true;
			}
		}
		if (bridge) {
			ans++;
		}
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;

	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
L = list(map(int,input().split()))

import itertools
L.sort()
cL = list(itertools.combinations(L,3))

ans = 0
for tri in cL:
    if len(set(tri)) != 3:
        continue
    if tri[0] + tri[1] > tri[2]:
        ans += 1
print(ans)

Measured memory_bytes: 20616
#include<bits/stdc++.h>
#define rep(i, x, n) for(int i = x; i < n; i++)
#define repr(i, x, n) for(int i = x; i > n; i--)
#define pii pair<int,int>
#define ll long long
const long long iinf = 1e18;
const int inf = 1e9;
const int MOD = (1e6+3);
int dir4[4][2] = {{1,0},{-1,0},{0,1},{0,-1}};
int knight[8][2] = {{2,1},{2,-1},{-2,1},{-2,-1},{1,2},{-1,2},{1,-2},{-1,-2}};

using namespace std;

void solve()
{
    int n; cin >> n;
    map<string, int> mp;
    for(int i = 1; i <= n; i++){
        string s; cin >> s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << "\n";
    cout << "WA x " << mp["WA"] << "\n";
    cout << "TLE x " << mp["TLE"] << "\n";
    cout << "RE x " << mp["RE"] << "\n";
    
}
//new line is printed in main()

int main()
{
    int t = 1;
        // cin >> t; // comment out if no test case is required
    int i = 1;
    while(t--){
        //cout << "Case " << i++ << ": ";
        solve();
        // printf("\n");
    }
    return 0;
}


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

int main() {
  int N, K, a, b, o;
  o = 1;
  cin >> N >> K;
  for (int i = 0; i < N; i ++){
    a = o * 2;
    b = o + K;
    if (a < b){
      o = a;
    }else{
      o = b;
    }
  }
  cout << o << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<set>
using namespace std;

int main(){
    string s,t;
    set<string> S;
    int n1,n2,n;
    int k=0;
    cin>>s>>t;
    n1=s.length();
    n2=t.length();
    n=n1-n2;
    if(n<0){
        cout<<"UNRESTORABLE"<<endl;
        return 0;
    }
    for(int i=0;i<=n;i++){
        string ss(s);
        bool check=true;
        for(int j=0;j<n2;j++){
            if((s[i+j]!=t[j])&&(s[i+j]!='?')) check=false;
        }
        if(check){
            for(int j=0;j<n2;j++){
                ss[i+j]=t[j];
            }
            for(int j=0;j<n1;j++){
                if(ss[j]=='?')ss[j]='a';
            }  
            S.insert(ss);
        }
    }
    if(S.size()==0)cout<<"UNRESTORABLE"<<endl;
    else cout<<*S.begin()<<endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define read(a) scanf("%d", &a)
#define readl(a) scanf("%lld", &a)
#define reads(a) scanf("%s", a)
#define readf(a) scanf("%lf", &a)
#define readc(a) scanf("%c", &a)
#define debug(a, b) printf("%s = %d\n", a, b)
#define debug1(a, i, b) printf("%s[%d] = %d", a, i, b)
#define show(a) putchar(a)
#define pb emplace_back
#define mk make_pair
#define _rand mt19937 RAND(time(0))
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define mem(a) memset(a, 0, sizeof(a))
#define Buff ios::sync_with_stdio(false)
typedef long long ll;
typedef long long LL;
typedef int Int;
typedef double db;
using namespace std;
const int INF = 1e9 + 7;
const int N = 2e5 + 7;
const int M = 5e6 + 7;
const ll mod = 998244353;
pair<int, int> a[N];
#define lson rt << 1
#define rson rt << 1 | 1
template<class T>
class SegTree
{
public:
    T Max[N << 2];
    inline void pushup(int rt)
    {
        Max[rt] = max(Max[lson], Max[rson]);
    }

    void update(int rt, int l, int r,int pos, T val)
    {
        if(l == r)
        {
            Max[rt] = val;
            return;
        }
        int mid = l + r >> 1;
        if(pos <= mid) update(lson, l, mid, pos, val);
        else          update(rson, mid + 1, r, pos, val);
        pushup(rt);
        return;
    }

    T query(int rt, int l, int r, int L, int R)
    {
        if(L <= l && r <= R) return Max[rt];
        int mid = l + r >> 1;
        T ans = 0;
        if(L <= mid) ans = max(ans, query(lson, l, mid, L, R));
        if(R > mid)  ans = max(ans, query(rson, mid + 1, r, L, R));
        return ans;
    }
};
SegTree<int> tree;
ll dp[N];
int b[N], R[N];
signed main()
{
    int n;
    read(n);
    for(int i = 1; i <= n; i++)
        read(a[i].first), read(a[i].second);
    sort(a + 1, a + n + 1);
    for(int i = 1; i <= n; i++)
        b[i] = a[i].first;

    mem(tree.Max);

    dp[n+1] = 1;
    for(int i = n; i; i--)
    {
        int id = upper_bound(b + 1, b + n + 1, a[i].first+a[i].second-1) - b;
        if(id == i + 1) R[i] = i;
        else    R[i] = tree.query(1, 1, n, i + 1, id - 1);
        tree.update(1, 1, n, i, R[i]);

        dp[i] = (dp[i+1] + dp[R[i]+1]) % mod;
    }

    printf("%lld\n", dp[1]);
    return 0;
}
/**

**/



Measured memory_bytes: 8064
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, M, A;

  std::cin >> N >> M;

  std::priority_queue<int> pq;

  for (int i = 0; i < N; i ++) {
    std::cin >> A;

    pq.push(A);
  }

  for (int i = 0; ! pq.empty() && i < M; i ++) {
    int x = pq.top(); pq.pop();

    if (x > 1)
      pq.push(x / 2);
  }

  long long s = 0;

  while (! pq.empty()) {
    int x = pq.top(); pq.pop();

    s += x;
  }

  std::cout << s << std::endl;
  
  return 0;
}


Measured memory_bytes: 892
import java.util.Scanner;

public class Main {
	static int time = 0;

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		Path a = new Path(n);

		for (int i = 0; i < n; i++) {
			int u = scan.nextInt();
			int k = scan.nextInt();
			for (int j = 0; j < k; j++)
				a.addPath(u, scan.nextInt(), scan.nextInt());
		}
		a.setPath(0);

		for (int i = 0; i < n; i++)
			System.out.println(i + " " + a.getResult(i));

		scan.close();
		System.exit(0);
	}
}

class Path {
	int[][] cost;
	int[] reach;

	public Path(int n) {
		reach = new int[n];
		for (int i = 0; i < n; i++)
			reach[i] = -1;

		cost = new int[n][n];
		for (int x = 0; x < n; x++)
			for (int y = 0; y < n; y++)
				cost[x][y] = -1;
	}

	public int getResult(int i) {
		return reach[i];
	}

	public void setPath(int from) {
		reach[from] = 0;
		setP(from);
	}

	private void setP(int from) {
		for (int to = 0; to < cost[from].length; to++)
			if (cost[from][to] > 0) {
				int d = reach[from] + cost[from][to];
				if (reach[to] == -1 || reach[to] > d) {
					reach[to] = d;
					setP(to);
				}
			}
	}

	public void addPath(int from, int to, int c) {
		cost[from][to] = c;
	}

}



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

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<typename T> void view(T cont) {std::cout << cont << std::endl;}
template<typename T> void view(T* cont, ll sz) {rep(i, sz) std::cout << cont[i] << " "; std::cout << std::endl;}
template<typename T> void view(const std::vector<T>& v) {for (const auto& f: v) std::cout << f << " "; std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v: vv) {view(v);}}
const long long INF = 1LL<<60;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

// Constraints
const int MAX_H = 1000;
const int MAX_W = 1000;
const int MOD = 1e9+7;

// Input
int H, W;
vector<vector<char> > a(MAX_H, vector<char>(MAX_W, ' '));
// DP table
vector<vector<int> > dp(MAX_H, vector<int>(MAX_W, 0));

void do_DP(int x, int y, int H, int W) {
    for (int i = 1; i < H; i++) {
        for (int j = 1; j< W; j++) {
            if (a[i][j] == '.') {
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
            } else {
                dp[i][j] = 0;
            }
        }
    }
}

int main(){
    cin >> H >> W;
    rep(i, H) {
        rep(j, W) {
            cin >> a[i][j];
        }
    }
    // Initialize dp table
    dp[0][0] = 1;
    for (int i = 1; i < MAX_H; i++) {
        if (a[i][0] == '#') {
            dp[i][0] = 0;
        } else {
            dp[i][0] = dp[i - 1][0];
        }
    }
    for (int j = 1; j < MAX_W; j++) {
        if (a[0][j] == '#') {
            dp[0][j] = 0;
        } else {
            dp[0][j] = dp[0][j - 1];
        }
    }

    // for (int i = 0; i < H; i++) {
    //     for (int j = 0; j < W; j++) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    do_DP(0, 0, H, W);
    // for (int i = 0; i < H; i++) {
    //     for (int j = 0; j < W; j++) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    cout << dp[H-1][W-1] << endl;
    // cout << "The number of path: " << path_number << endl;
}

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

int main() {
	int M,D;
	cin >> M >> D;
  int ans = 0;
  for(int m =1;m<=M;m++)for(int d = 1;d<=D;d++){
    int d10 = d /10;
    int d1 = d %10;
    if(d10 >= 2 && d1 >= 2 && d1* d10 == m){
      ans += 1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
program ddd
implicit none

integer :: n, k, r, s, p, i, res
character(10**5) :: t

read*, n, k
read*, r, s, p
read*, t

res = 0

do i = 1, n
	if (t(i:i)=='r') res=res + p
    if (t(i:i)=='s') res=res + r
	if (t(i:i)=='p') res=res + s
end do

do i = k + 1, n
	if (t(i:i)==t(i-k:i-k)) then
    	if (t(i:i)=='r') then
        res = res - p
        t(i:i) = 'q'
    	else if (t(i:i)=='s') then
		res = res - r
        t(i:i) = 'q'
        else if (t(i:i)=='p') then
        res = res - s
        t(i:i) = 'q'
        end if
	end if
end do

print*, res

end program

Measured memory_bytes: 700
#include "stdio.h"
#include "math.h"
int main(int argc, char const *argv[])
{
	int count,i,j;
	int score[1000];
	double hensa[10000];
	double avg,sum1,sum2,number;
	for(i=0;;i++){
		scanf("%lf",&number);
		if(number == 0){
			count = i;
			break;
		}
		avg = 0.0;
		sum1 = 0.0;
		for(j=0;j<number;j++){
			scanf("%d",&score[j]);
			sum1 = sum1 + score[j];
		}
		avg = sum1/(double)number;
		sum2 = 0.0;
		for(j=0;j<number;j++){
			sum2 = sum2 + pow ( (score[j]-avg) , 2.0 );   
		}
		hensa[i] = sqrt( sum2 / (double)number );
	}

	for(i=0;i<count;i++)
		printf("%lf\n",hensa[i]);
	return 0;
}


Measured memory_bytes: 664
#from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


yes = "Yes"
no = "No"


def main():
    a = ii()
    ans = ['pon','pon','hon','bon','hon','hon','pon','hon','pon','hon']
    print(ans[a%10])










main()




Measured memory_bytes: 10028
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def prime_decomposition(n): #素因数分解
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(int(n))
  return table

def make_divisors(n): #約数列挙
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors



n,k = m()

a = l()

p = sum(a)

d = make_divisors(p)

ans = 0

for i in d:
    kkk = [0] * n
    for j in range(n):
        kkk[j] = a[j] % i
    kkk.sort()
    kkkk = sum(kkk)
    nw = 0
    for j in range(n):
        nw += kkk[j]
        nn = kkkk - nw
        if nw <= k and (n-j-1)*i - nn <= k and nw == (n-j-1)*i - nn:
            ans = i
            break
print(ans)



Measured memory_bytes: 42092
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20)
#define int long long
#define double long double
const int INF = 1e18, MOD = 1e9 + 7;

int n, a, b;

signed main() {
    INCANT;
    cin>>n;
    vector<int> v;
    int res = 0;
    for (int i = 0; i < n; i++) {
        cin>>a>>b;
        res -= b;
        v.push_back(a + b);
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    for (int i = 0; i < (n + 1) / 2; i++) {
        res += v[i * 2];
    }
    cout<<res<<endl;
}

Measured memory_bytes: 1400
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <iostream>
#define REP(i,a,b)for (int i=a;i<=b;++i)
#define PER(i,a,b)for (int i=a;i>=b;--i)
#define RVC(i,S)for (int i=0;i<S.size();++i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long LL;
typedef pair<int,int> pii;
typedef vector<int> VI;

const int N = 100005;
int n,m,S,T,tote,fst[N];
LL dis[2][N],ans[N];

struct Edge{
	int to,nxt;
	LL w[2];
} ed[N*2];

void ae(int u,int v,int a,int b){
	ed[++tote]=(Edge){v,fst[u],{a,b}};
	fst[u]=tote;
}

priority_queue<pair<LL,int>,vector<pair<LL,int> >,greater<pair<LL,int> > >pq;

void dijk(int s,int t){
	REP(i,1,n)dis[t][i]=1ll<<60;
	dis[t][s]=0;
	pq.push(mp(0,s));
	while(!pq.empty()){
		pair<LL,int> p=pq.top();
		pq.pop();
		LL d=p.fi;
		int u=p.se;
		if(d!=dis[t][u])continue;
		for(int i=fst[u];i;i=ed[i].nxt)
			if(d+ed[i].w[t]<dis[t][ed[i].to]){
				dis[t][ed[i].to]=d+ed[i].w[t];
				pq.push(mp(dis[t][ed[i].to],ed[i].to));
			}
	}
}

int main(){
	scanf("%d%d%d%d",&n,&m,&S,&T);
	REP(i,1,m){
		int u,v,a,b;
		scanf("%d%d%d%d",&u,&v,&a,&b);
		ae(u,v,a,b);
		ae(v,u,a,b);
	}
	dijk(S,0);
	dijk(T,1);
	const LL init=(LL)1e15;
	ans[n]=init-dis[0][n]-dis[1][n];
	PER(i,n-1,1)ans[i]=max(ans[i+1],init-dis[0][i]-dis[1][i]);
	REP(i,1,n)printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 9844
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt64)
}

func readInt() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func main() {
	x, y, z := readInt(), readInt(), readInt()
	fmt.Println((x - z) / (y + z))
}


Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(int a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
static inline int Max(int a,int b){return a>b?a:b;}
static inline int Min(int a,int b){return a<b?a:b;}
#define rep(i,n) FOR(i,0,n-1)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
const int INF=0x7f7f7f7f;
int k,n,sqrtn=0,dat[500000],buk[707]={0},lazy[707]={0},lazyflag[707]={0};
static inline void init(int x)
{
  n=x;
  while(sqrtn*sqrtn<=n){sqrtn++;}
  k=(n+sqrtn-1)/sqrtn;
  rep(i,n){dat[i]=i;}
}
static inline void eval(int b)
{
  if(!lazyflag[b]){return;}
  lazyflag[b]=0;
  FOR(i,sqrtn*b,sqrtn*(b+1)-1){dat[i]=lazy[b];}
}
static inline void update(int l,int r,int x)
{
  rep(b,k)
  {
    int p=sqrtn*b,q=sqrtn*(b+1);
    if(q<=l||r<=p){continue;}
    if(l<=p&&q<=r){buk[b]=p-x;lazyflag[b]=1;lazy[b]=x;}
    else
    {
      eval(b);
      FOR(i,Max(l,p),Min(r,q)-1){dat[i]=x;}
      buk[b]=INF;
      FOR(i,p,q-1){buk[b]=Min(buk[b],i-dat[i]);}
    }
  }
}
static inline int query(int l,int r)
{
  int ret=INF;
  rep(b,k)
  {
    int p=sqrtn*b,q=sqrtn*(b+1);
    if(q<=l||r<=p){continue;}
    if(l<=p&&q<=r){ret=Min(ret,buk[b]);}
    else{eval(b);FOR(i,Max(l,p),Min(r,q)-1){ret=Min(ret,i-dat[i]);}}
  }
  return ret;
}
int main(void)
{
  int H=IN(),W=IN();
  init(W);
  rep(i,H)
  {
    int l=IN()-1,r=IN(),u=-INF;
    if(l>0){int b=(l-1)/sqrtn;eval(b);u=dat[l-1];}
    update(l,r,u);
    int ans=query(0,W);
    if(ans>=INF){ans=-1;}else{ans+=i+1;}
    OUT(ans);
  }
}

Measured memory_bytes: 2412
#include <stdio.h>
#include <map>
#include <algorithm>
#include <vector>
#include <queue>

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

int abs(int x){
  return x > 0 ? x : -x;
}

int length(char c[]){
  int cnt=0;
  for(cnt=0;c[cnt]!='\0';cnt++){
  }
  return cnt;
}


int a,b,c,x;

int main(){
  scanf("%d %d %d %d",&a,&b,&c,&x);
  int sum = 0;
  REP(i,a+1)REP(j,b+1)REP(k,c+1){
    if(500*i+100*j+50*k==x) sum++;
  }
  printf("%d\n",sum);
}


Measured memory_bytes: 128
import numpy as np
n=int(input())
ab=[list(map(int,input().split())) for _ in range(n)]
ab.sort(key=lambda x:x[1])
b=np.array([ab[i-1][1] if i>0 else 0 for i in range(n+1)])
ruisekiA=np.zeros(n+1)
for i in range(n):
    ruisekiA[i+1]=ruisekiA[i]+ab[i][0]
# print(ab)
# print(b)
# print(ruisekiA)
if len(ruisekiA[ruisekiA>b])==0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 63936
#include <stdio.h>
int Euclidean_alg (int x, int y);//recursive function

int main(){
    int x,y;

    scanf("%d%d", &x, &y);
    if(x > y)
	printf("%d\n", Euclidean_alg(x, y));
    else
	printf("%d\n", Euclidean_alg(y, x));

    return 0;
}

int Euclidean_alg (int x, int y){//exept the first,x is quotient, y is remainder
    if (y == 0)
	return x;
    else
	return Euclidean_alg(y, x % y);
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b ? a:b;}
ll min(ll a, ll b) {return a<b ? a:b;}

ll moP(ll x, ll n) {
    ll res=1;
    while(n>0) {
        if(n&1) moC(res, *, x);
        moC(x, *, x);
        n>>=1;
    }
    return res;
}


int main() {
    ll N;
    cin >> N;
    ll i;
    ll all=1;
    for(i=1; i<=N; i++) all=i*all%MOD;
    
    ll s[MAX]={};
    for(i=1; i<=N; i++)
        s[i]=(s[i-1]+moP(i, MOD-2))%MOD;
    
    ll ans=0;
    for(i=0; i<N; i++) {
        ll a;
        cin >> a;
        moC(ans, +, (s[i+1]+s[N-i]-1)*all%MOD*a%MOD);
    }
    
    pt(ans);
    
}


Measured memory_bytes: 1024
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	g := make([][]int, n)
	var x, y, z int
	for i := 0; i < m; i++ {
		fmt.Scan(&x, &y, &z)
		x--
		y--
		g[x] = append(g[x], y)
		g[y] = append(g[y], x)
	}

	done := make(map[int]bool)

	var dfs func(v int)
	dfs = func(v int) {
		if done[v] {
			return
		}
		done[v] = true
		for _, u := range g[v] {
			dfs(u)
		}
	}

	ans := 0
	for i := 0; i < n; i++ {
		if done[i] {
			continue
		}
		dfs(i)
		ans++
	}
	fmt.Println(ans)
}


Measured memory_bytes: 39808
#include <iostream>
using namespace std;
int main() {
  int N, M, C;
  cin >> N >> M >> C;
  int B[M];
  for (int i = 0; i < M; i++)
  {
	cin >> B[i];
  }
  int A[N][M];
  int result = 0;
  for (int i = 0; i < N; i++)
  {
    int comp_result = 0;
	for (int j = 0; j < M; j++)
    {
      cin >> A[i][j];
      comp_result += A[i][j] * B[j];
    }
    comp_result += C;
    if (comp_result > 0)
    {
      result++;
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int xcomp(vector<LL>& a, vector<LL>& b) {
	return a[0] < b[0];
}

#define XSORT(c) sort((c).begin(),(c).end(),xcomp)

#define ALL(x) (x).begin(),(x).end()
LL mod = 1000000007;



LL pow2(LL a) {
	LL sum = 1;
	REP(i, a) {
		sum *= 2;
	}
	return sum;
}

int main() {
	vector < vector<LL>> nCm(200, vector<LL>(200, -9999999));

	REP(i, 102) {
		REP(j, i + 1) {
			if (i == 0) {
				nCm[i][j] = 1;
			}
			else {
				if (j == 0 || j == i) {
					nCm[i][j] = 1;
				}
				else {
					nCm[i][j] = nCm[i - 1][j] + nCm[i - 1][j - 1];
				}
			}
		}
	}

	LL N, P;
	cin >> N >> P;

	LL a = 0;
	LL b = 0;
	REP(i, N) {
		LL c;
		cin >> c;
		if (c % 2 == 0) {
			a++;
		}
		else {
			b++;
		}
	}

	if (P == 0) {
		LL sum = 0;
		REP(i, b + 1) {
			if (i % 2==0) {
				sum += nCm[b][i];
			}
		}
		sum *= pow2(a);
		cout << sum << endl;
	}
	else {
		LL sum = 0;
		REP(i, b + 1) {
			if (i % 2 == 1) {
				sum += nCm[b][i];
			}
		}
		sum *= pow2(a);
		cout << sum << endl;
	}

}


Measured memory_bytes: 512
#include <iostream>
#include <array>

int main()
{
    int first = 0;
    int second = 0;
    int third = 0;
    std::array<int, 10> arr;

    for (int i = 0; i < 10; i++) {
        std::cin >> arr.at(i);
        if (arr.at(i) >= first) {
            third = second;
            second = first;
            first = arr.at(i);
        } else if (arr.at(i) >= second) {
            third = second;
            second = arr.at(i);
        } else if (arr.at(i) >= third) {
            third = arr.at(i);
        }
    }

    std::cout << first << std::endl
              << second << std::endl
              << third << std::endl;
    return 0;
}

Measured memory_bytes: 3044
#include <bits/stdc++.h>
#define FOR(i, n) for(int i = 0;i <n;i++)
#define RFOR(i, n) for(int i = n;i >= 0;i--)
#define REP(i, m, n) for(int i = m;i < n;i++)
#define RREP(i, m, n) for(int i = m;i >= n;i--)
#define INF 999999999

using namespace std;
int main()
{
int H,W,h,w;
cin>>H>>W>>h>>w;
cout<<(H-h)*(W-w)<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		
		int pow = 0;
		int ans = 1;
		for (int i = 1; i < n; i++) {
			for (int j = 2; j < n; j++) {
				pow = (int) Math.pow(i, j);
				if (pow <= n) {
					ans = Math.max(ans, pow);
				}
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 17;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

ll n,a[100010];
ll gcd(int x,int y){return y?gcd(y,x%y):x;}
int main(){
    scanf("%lld",&n);
    int cnt=0; ll tmp = 2e9; ll ans=0;
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
        if(a[i]<0) cnt++;
        tmp= min(tmp,(ll)abs(a[i])); ans+= abs(a[i]);
    }
    if(cnt%2){
        printf("%lld\n",ans-2*tmp);
    }
    else {
        printf("%lld\n",ans);
    }


    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cfenv>
#include <cmath>
#include <cstdlib>
using namespace std;
#define rep(i,n) for(int i = 0;i < n;i++)
#define INF 0x3f //plus infinite

typedef struct item{
  string name;
  int number;
  int money;
}item;

int main(){
  string n;
  cin >> n;
  if(n[0] == '7' || n[1] == '7' || n[2] == '7')
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
  
}

/*文字列の辞書順について
 *C++の順序では'0'～'9'→'A'～'Z'→'a'～'z'の順に
 *                       なっていることに注意しましょう。
 */

/*行単位での入力
 * getline(cin,文字列変数);
 */


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

class Program {


    static void Main(string[] args) {


        int[] ary1 = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        int[] ary2 = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

        int mx = ary1[1], ttl = 0;
        Array.Sort(ary2);

        for (int i = 0; i < mx; i++) {
            ttl += ary2[i];
        }


        Console.WriteLine(ttl);

    }
}



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

using vi=vector<int>;
using vvi=vector<vi>;
using ll=long long;

int main() {
  string ABCD; cin >>ABCD;
  vi abcd(4);
  rep(i,0,4) {
    abcd[i]=ABCD[i]-'0';
  }

  int all=1<<3;

  rep (bit,0,all) {
    int sum=abcd[0];
    string formula="";
    formula+=ABCD[0];
    rep(i,0,3) {
      if (bit>>i&1) {
        sum+=abcd[i+1];
        formula+='+';
      } else {
        sum-=abcd[i+1];
        formula+='-';
      }
      formula+=ABCD[i+1];
    }
    if (sum==7) {
      cout <<formula <<"=7" <<endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3632
n,k = map(int,input().split())
mod = 10**9+7
v = [0]*(k+1)
ans = 0
for i in range(k,0,-1):
    if v[i] == 0:
        v[i] =  (pow(k//i,n,mod)-sum(v[i::i])) % mod
        ans += (v[i]*i) % mod
        ans %= mod
print(ans)

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	int A, B, C, K;
	cin >> A >> B >> C >> K;
	int ans = 0;
	ans += min(A, K);
	K = max(0LL, K - A);
	K = max(0LL, K - B);
	ans -= min(C, K);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> A(100001);
  int a;
  for(int i = 0;i < n;i++){
    cin >> a;
    A[a]++;
  }
  int even = 0;
  int odd = 0;
  for(int i = 0;i < 100001;i++){
    if(A[i] % 2 == 0 && A[i] > 0)even++;
    else if(A[i] > 0)odd++;
  }
  int ans = odd + even - (even%2);
  cout << ans << endl;
}
    
    


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
 
int main() {
    int N, M;
    cin >> N >> M;

    int wa=0;
    int ac=0;

    vector<int> WA(N,0);
    vector<int> AC(N,false);

    for(int i=0; i<M; i++){
        int q;
        string kekka;
        cin >> q >> kekka;
        if(AC.at(q-1)) continue;
        else{
            if(kekka == "AC"){
                AC.at(q-1) = true;
                ac++;
                wa += WA.at(q-1);
            }
            else{
                WA.at(q-1)++;
            }
        }
    }
    cout << ac << " " << wa << endl;


}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define N 21
using namespace std;
int h,w;
string mp[N];

int used[N][N][N][N],mem[N][N][N][N];
int dfs(int y,int x,int Y,int X){
  int &res=mem[y][x][Y][X];
  if(y>Y||x>X) return 0;
  if(used[y][x][Y][X]++) return res;
   
  set<int> S;
  for(int i=y;i<=Y;i++)
    for(int j=x;j<=X;j++){
      if(mp[i][j]=='X')continue;
      int a=dfs(y,x,i-1,j-1);
      int b=dfs(y,j+1,i-1,X);
      int c=dfs(i+1,x,Y,j-1);
      int d=dfs(i+1,j+1,Y,X);
      S.insert(a^b^c^d);
    }
  while(S.count(res))res++;
  return res;
}

int main(){
  cin>>h>>w;
  for(int i=0;i<h;i++)cin>>mp[i];
  cout <<(dfs(0,0,h-1,w-1)!=0? "First":"Second")<<endl;
  return 0;
}

Measured memory_bytes: 4648
// Package main provides
//
// File:  d.go
// Author: ymiyamoto
//
// Created on Tue Dec 25 03:29:25 2018
//
package main

import "fmt"

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

	arr := make([]int, N)
	for i := range arr {
		fmt.Scan(&arr[i])
	}

	ans, sum, l, r := 0, 0, 0, 0
	for i := range arr {
		for sum&arr[i] != 0 && l <= i {
			sum &= ^arr[l]
			l++
		}
		sum |= arr[i]
		r = i
		ans += r - l + 1
	}

	fmt.Println(ans)
}


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

int main()
{

        int N;
        cin >> N;
        string W[N];
        char tmp;
        char last = 0;
        for (int i = 0; i < N; ++i) {
                cin >> W[i];
                int len = W[i].length();
                if (i != 0) {
                        if (W[i][0] != last) {
                                cout << "No" << endl;
                                exit(0);
                        }
                }
                last = W[i][len-1];
        }

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

                for (int j = 0; j < N; ++j) {

                        if (i == j) continue;

                        if (W[i] == W[j]) {
                                cout << "No" << endl;
                                exit(0);
                        }
                }
        }


        cout << "Yes" << endl;



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int MOD = 1e9 + 7;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	string s;
	cin >> s;
	int cnt = 0; int ans = 0;
	for(int i = 0; i < s.length(); i++)
	{
		if(s[i] == 'g')
		{
			if(cnt == 0)
			{
				cnt++;
			}
			else
			{
				cnt--; ans++;
			}
		}
		else
		{
			if(cnt == 0)
			{
				cnt++; ans--;
			}
			else
			{
				cnt--;
			}
		}
	}
	cout<<ans;
}


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

int main() {
    string str;
    while(true) {
        cin >> str;
        if(str == "0") {
            break;
        }
        int ans=0;
        for(int i=0; i<str.size(); ++i) {
            ans += str[i]-'0';
        }
        cout << ans << endl;
    }
    return 0;
}


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

int main(){
    int N;cin>>N;
    vector<int> h(N);
    rep(i,N) cin>>h[i];

    vector<int> dp(N+1);
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    
    for(int i=2;i<=N;i++){
            dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[N-1]<<endl;
}

Measured memory_bytes: 3964
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<queue>

using namespace std;

typedef pair<int,int> pii;
#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)

int main(){
	int n,m,a,b,s,f;
	scanf("%d%d",&n,&m);
	s=m;f=1;
	rep(i,n){
		scanf("%d%d",&a,&b);
		m=m+a-b;
		if(m<0)f=0;
		s=max(s,m)*f;
	}
	printf("%d\n",s);
	return 0;
}

Measured memory_bytes: 1188
#include <stdio.h>
int main(void){
	int n;
	scanf("%d",&n);
	if(n<2){
		printf("1");
	}else if(n<4){
		printf("2");
	}else if(n<8){
		printf("4");
	}else if(n<16){
		printf("8");
	}else if(n<32){
		printf("16");
	}else if(n<64){
		printf("32");
	}else{
		printf("64");
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int M = 20 + 50;
int a[M],b[M],c[M];
int main(){
	int n;
	scanf("%d",&n);
	for(int i = 0 ; i < n; i++){
		scanf("%d",a+i);
	}
	for(int i = 1 ; i <= n; i++){
		scanf("%d",b+i);
	}
	for(int i = 1 ; i < n; i++){
		scanf("%d",c+i);
	}
	int ans = 0;
	for(int i = 0; i < n; i++){
		ans+=b[a[i]];
		if(i && a[i] == a[i-1]+1){
			ans+=c[a[i-1]];
		}
	}
	printf("%d\n",ans);
	return 0;
} 

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

using namespace std;

int main(){
    int n;
    cin >> n;
    long long scoreA = 0, scoreB = 0;
    while(n--){
        int a, b;
        cin >> a >> b;
        if(scoreA == scoreB && !scoreA){
            scoreA = a;
            scoreB = b;
            continue;
        }
        long long time = max(scoreA / a + !!(scoreA % a), scoreB / b + !!(scoreB % b));
        scoreA = a * time;
        scoreB = b * time;
    }
    cout << scoreA + scoreB << "\n";
}

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

int main(){
  char b;
  
  cin >> b;
  
  if(b == 'A') cout << 'T' << endl;
  if(b == 'T') cout << 'A' << endl;
  if(b == 'C') cout << 'G' << endl;
  if(b == 'G') cout << 'C' << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <stack>

using namespace std;

int mapToNum(char c)
{
	switch (c) {
	case '#':
			return -1;
	case '.':
			return 0;
	case '@':
			return 1;
	default:
			return -2;
	}
}

int main()
{
	while (1) {
		int w, h;
		
		cin >> w >> h;
		
		if (w == 0 && h == 0) break;
		
		stack< pair<int, int> > stk;
		vector< vector<int> > tiles(h + 2, vector<int>(w + 2));
		char c;
		
		for (int i = 0; i < w + 2; ++i) tiles.at(0).at(i) = tiles.at(h + 1).at(i) = -1;
		
		for (int i = 1; i < h + 1; ++i) {
			tiles.at(i).at(0) = tiles.at(i).at(w + 1) = -1;
			for (int j = 1; j < w + 1; ++j) {
				cin >> c;
				tiles.at(i).at(j) = mapToNum(c);
				if (c == '@') stk.push(make_pair(i, j));
			}
		}
		
		int num = 1;
		
		while (!stk.empty()) {
			pair<int, int> p = stk.top();
			stk.pop();
			int x = 1, y = 0, t;
			
			for (int i = 0; i < 4; ++i) {
				if (tiles.at(p.first + x).at(p.second + y) == 0) {
					tiles.at(p.first + x).at(p.second + y) = -1;
					stk.push(make_pair(p.first + x, p.second + y));
					++num;
				}
				
				t = -y;
				y = x;
				x = t;
			}
		}
		
		cout << num << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1224
import numpy as np

A = []
B = []
N, M, C = (int(x) for x in input().split())
for x in input().split():
    B.append(int(x))
for i in range(N):
    temp = []
    for x in input().split():
        temp.append(int(x))
    A.append(temp)

def Function(i):
    ret = C
    for k in range(M):
        ret += A[i][k] * B[k]
    return ret

ans = 0
for i in range(N):
    if Function(i) > 0:
        ans += 1
print(ans)

Measured memory_bytes: 12440
//https://beta.atcoder.jp/contests/abc113/tasks/abc113_b
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main() {
    int N,T,A,X;
    cin >> N >> T >> A;
    int res = 0;
    int INF = 1<<30;
    for(int i=1;i<=N;i++){
        cin >> X;
        int a = (T*1000 - X*6) - A*1000;
        if(a<0) a=-a;
        if(INF>a) INF=a,res=i;
    }
    cout << res << endl;
}

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

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

    int A[2][110];

    int sum1;
    int sum2;

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

    int i = 0;
    int j, k;
    int num = 0;
    for(int i = 0; i < N ;i++) {
      	sum1 = 0;
      	sum2 = 0;
        //1列側の和
        for(j = 0; j <= i; j++) {
            sum1 += A[0][j];
        }
        //2列側の和
        for(k = i; k < N; k++) {
            sum2 += A[1][k];
        }
        num = max(num, sum1 + sum2);
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
inline long long in(){long long x=0;char c=getchar();bool neg=false;while(c!='-'&&('0'>c||c>'9')) c=getchar();if(c=='-') neg=true,c=getchar();while('0'<=c&&c<='9') x=10*x+c-'0',c=getchar();if(neg) x=-x;return x;}
inline void out(long long x){if(x<0) putchar('-'),x=-x;if(x>9) out(x/10);putchar(x%10+'0');}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define task "b"
#define fastio ios_base::sync_with_stdio(false),cin.tie(nullptr);
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))
#define _ putchar(' ')
#define __ putchar('\n')
#define int long long
const int N=200010;
int h,n,kq;
int a[N],s[N];
void solve()
{
    forinc(i,1,n+1) s[i]=s[i-1]+a[i];
    forinc(i,1,n)
    {
        int l=i-1,r=n-i;
        if(l>r) l=r+1;
        else    r=l;
        kq=max(kq,(s[i-1]-s[i-1-l])*2+(h*r-s[i+r]+s[i])*2+h-a[i]);
    }
}
main()
{
    fastio;
    //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);
    cin>>h>>n;
    forinc(i,1,n) cin>>a[i];
    solve();
    forinc(i,1,n) a[i]=h-a[i];
    forinc(i,1,n/2) swap(a[i],a[n-i+1]);
    solve();
    cout<<kq;
}


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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
ll LCM(int a, int b){
    return a*b/gcd(a,b);
}

int main(void)
{
    int n,m;
    cin>>n>>m;
    vector<ll> a(n);
    map<int,int> mp;
    rep(i,0,n){
        int k;
        cin>>k;
        rep(j,0,k){
            int in;
            cin>>in;
            mp[in]++;
        }
    }
    int ans=0;
    for(auto i:mp){
        if(i.second==n)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
n = int(input())
A = [int(e)for e in sys.stdin]
cnt = 0
G = [int((2.1**i-1)/1.1)for i in range(19,0,-1)]
G = [v for v in G if v <= n]
def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
for g in G:
    insertionSort(A, n, g)
print(len(G))
print(*G)
print(cnt)
print(*A,sep='\n')


Measured memory_bytes: 53328
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 65;
const int mod = 1000000007;

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  ll n,a,b;
  cin>>n>>a>>b;
  ll c = a + b;
  ll tt = n/c;
  ll ret = tt * a;
  ll tmp =  n%c;
  tmp = min(tmp, a);
  cout<<ret+tmp<<endl;
  return 0;
}


Measured memory_bytes: 256
/*
//A
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while(true)

int main() {
	int A, B;
	cin >> A >> B;
	cout << A * B - A - B + 1 << endl;
	return 0;
}
*/

/*
//B
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while(true)

int main() {
	int N;
	cin >> N;
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		if (i % 2 == 0) continue;
		int tmp = 0;
		for (int j = 1; j <= i; j++) {
			if (i % j == 0) tmp++;
		}
		if (tmp == 8) ans++;
	}
	cout << ans << endl;
	
	return 0;
}
*/


//C
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while(true)

int main() {
	string S;
	cin >> S;
	long long K;
	cin >> K;
	for (long long i = 0; i < S.size(); i++) {
		if (S[i] != '1') {
			cout << S[i] << endl;
			return 0;
		}
		if (i == K-1) {
			cout << 1 << endl;
			return 0;
		}
	}

	return 0;
}

/*
//D
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while(true)

int main() {

return 0;
}
*/


Measured memory_bytes: 256