akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{	
	
	string s,t;
	cin>>s>>t;
	if((int)s.length()>(int)t.length())
	{
		string temp = t;
		t=s;
		s=temp;
	}
	int dp[(int)s.length()+1][(int)t.length()+1];
	for(int i=0; i<=(int)s.length(); i++)
	{
		for(int j=0; j<=(int)t.length(); j++)
		{
			if(i==0 || j==0)
			{
				dp[i][j] = 0;
			}else
			{
				if(s[i-1] == t[j-1])
				{
					dp[i][j] = dp[i-1][j-1]+1;
				}else
				{
					dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
				}
			}
		}
	}

	// for(int i=0; i<=s.length(); i++)
	// {
	// 	for(int j=0; j<=t.length(); j++)
	// 	{
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }

	stack<int>stk;
	int i= (int)s.length();
	int j =(int)t.length();
	while(i!=0 && j!=0)
	{
		if(dp[i][j] == dp[i][j-1])
		{
			j--;
		}else if(dp[i][j] == dp[i-1][j])
		{
			i--;
		}
		else if(dp[i][j] == dp[i-1][j-1]+1)
		{
			 //cout<<s[i-1];
			stk.push((int)t[j-1]);
			i--;
			j--;
		}

	}


	while(!stk.empty())
	{
		cout<<(char)stk.top();
		stk.pop();
	}
	
	return 0;
}

Measured memory_bytes: 35456
/*
 * hoge.cpp
 *
 *  Created on: 2014/09/30
 *      Author: eiichi
 */
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<map>
#include<list>
using namespace std;

vector<int> split(string s,char c){
	vector<int> v;string tmp;
	for(int i=0;i<s.size();i++){
		if(s[i]==c){
			v.push_back(stoi(tmp));
			tmp ="";
		}
		else tmp += s[i];
	}
	if(tmp!="")v.push_back(stoi(tmp));
	return v;
}

int main(void){
	int n,m;
	int vvi[2][100][100];
	cin >> n >> m;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin >> vvi[0][i][j];
		}
	}
	for(int i=0;i<m;i++){
		cin >> vvi[1][i][0];
	}

	for(int i=0;i<n;i++){
		int ret = 0;
		for(int j=0;j<m;j++){
			ret += vvi[0][i][j]*vvi[1][j][0];
		}
		cout << ret << endl;
	}

	return 0;
}

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

using namespace std;

long long x,y;

int main(){
	scanf("%lld%lld",&x,&y);

	if(x%y==0)
		printf("-1\n");
	else{
		for(long long i=2;;i++){
			if(i*x%y!=0){
				printf("%lld\n",(long long)i*x);
				return 0;
			}
		}
	}
	return 0;
}

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

using namespace std;

int main() {
    string s;
    cin >> s;

    s.pop_back();
    while (s.size() > 1) {
        if (s.size() % 2 == 0) {
            string front(s, 0, s.size() / 2);
            string latter(s, s.size() / 2);
            if (front == latter) { break; }
        }
        s.pop_back();
    }

    cout << s.size() << endl;

    return 0;
}

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

int main(){

  int n;
  string str;

  while(cin >> str){

    for(int i=0;i<str.size();i++){

      if(str[i]=='@'){
	n=str[i+1]-48;
	for(int j=0;j<n;j++) cout << str[i+2];
	i+=2;
      }

      else cout << str[i];
    }
    cout << endl;
  }
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
#define ll long long
using namespace std;
inline int gi(){
  char ch=getchar();int x=0,q=0;
  while(ch<'0' || ch>'9') ch=='-'?q=1:0,ch=getchar();
  while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
  return q?(-x):x;
}
int d,n,g,ans;
ll p[20],num;
inline int dfs1(int x){
  if (x==g) return 10*(num==d);
    int s=0,tmp;
  if (x==n){
    for (int i=0; i<=9; ++i){
      num+=p[x]*i-p[n-x]*i;
      if (num>d && num-d>=p[x]-1){
	num-=p[x]*i-p[n-x]*i;
	continue;
      }
      else if (num<d && d-num>=p[x]-1){
	num-=p[x]*i-p[n-x]*i;
	continue;
	}
      tmp=dfs1(x-1);
      s+=tmp*(9-i);
      num-=p[x]*i-p[n-x]*i;
    }
  }
  else{
    for (int i=-9; i<=9; ++i){
      num+=p[x]*i-p[n-x]*i;
      if (num>d && num-d>=p[x]-1){
	num-=p[x]*i-p[n-x]*i;
	continue;
      }
      else if (num<d && d-num>=p[x]-1){
	num-=p[x]*i-p[n-x]*i;
	continue;
      }
      tmp=dfs1(x-1);
      if (i>=0) s+=tmp*(10-i);
      else s+=tmp*(10+i);
      num-=p[x]*i-p[n-x]*i;
    }
  }
  return s;
}
inline int dfs2(int x){
  if (x<g) return num==d;
  int s=0,tmp;
  if (x==n){
    for (int i=0; i<=9; ++i){
      num+=p[x]*i-p[n-x]*i;
      if (num>d && num-d>=p[x]-1){
	num-=p[x]*i-p[n-x]*i;
	continue;
      }
      else if (num<d && d-num>=p[x]-1){
	num-=p[x]*i-p[n-x]*i;
	continue;
      }
      tmp=dfs2(x-1);
      s+=tmp*(9-i);
      num-=p[x]*i-p[n-x]*i;
    }
  }
  else{
    for (int i=-9; i<=9; ++i){
      num+=p[x]*i-p[n-x]*i;
      if (num>d && num-d>=p[x]-1){
	num-=p[x]*i-p[n-x]*i;
	continue;
      }
      else if (num<d && d-num>=p[x]-1){
	num-=p[x]*i-p[n-x]*i;
	continue;
      }
      tmp=dfs2(x-1);
      if (i>=0) s+=tmp*(10-i);
      else s+=tmp*(10+i);
      num-=p[x]*i-p[n-x]*i;
    }
  }
  return s;
}
int main(){
  cin>>d;
  p[0]=1;
  for (int i=1; i<=18; ++i) p[i]=p[i-1]*10;
  for (int i=0; i<=17; ++i){
    n=i+1,g=n/2;
    if (p[n]-1<=d) continue;
    if (i&1){
      if (p[g-1]>=d) continue;
      ans+=dfs2(--n);
    }
    else{
      if (p[g]>=d) continue;
      ans+=dfs1(--n);
    }
  }
  cout<<ans;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    static int time = 0;
 
    public static void main(String[] args){
 
        Scanner scan = new Scanner(System.in);
 
        int n = scan.nextInt();
 
        int[][] v = new int[n + 1][n+1];
        int[] d = new int[n + 1];
        int[] f = new int[n + 1];
 
        for (int i = 1; i <= n; i++) {
            int u = scan.nextInt();
            int k = scan.nextInt();
            for (int j = 1; j <= k; j++)
                v[u][j] = scan.nextInt();
        }
 
        for (int i = 1; i <= n; i++) {
            if (d[i] == 0)
                Dsearch(v, d, f, i);
        }
 
        for (int i = 1; i <= n; i++) {
            System.out.println(i + " " + d[i] + " " + f[i]);
        }
 
        scan.close();
        System.exit(0);
    }
 
    private static void Dsearch(int[][] v, int[] d, int[] f, int u) {
        d[u] = ++time;
        for (int i = 1; i < v[u].length-1 && v[u][i] > 0; i++)
            if (d[v[u][i]] == 0)
                Dsearch(v, d, f, v[u][i]);
        f[u] = ++time;
    }
}

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

typedef pair<ll, ll> P;

int main()
{
    int h, n;
    int tmp, sum = 0;
    cin >> h >> n;
    for (int i = 0; i < n; i++) {
        cin >> tmp;
        sum += tmp;
    }
    if (sum >= h) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



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

int main(void){
	int data[2];
	int size_input, size_column, size_row;
	int *input;
	int *column, *row;   //?????????
	int i, j;
	int num_column=0;
	
	
	scanf("%d %d", &data[0], &data[1]);
	size_input = data[0] * data[1];
	size_column = data[0];
	size_row = data[1] + 1;
	
	input = malloc(sizeof(int) * size_input);
	column = malloc(sizeof(int) * size_column);
	row = malloc(sizeof(int) * size_row);
	
	for(i=0 ; i < size_input ; i++){
		scanf("%d", &input[i]);
	}
	
	for(i=0 ; i < size_column ; i++){
		for(j=0 ; j < data[1] ; j++){
			//printf("column[%d] += input[%d]\n", i, data[1]*i + j);
			column[i] += input[data[1]*i + j];
		}	
	}
	
	for(i=0 ; i < size_row - 1 ; i++){
		for(j=0 ; j < data[0] ; j++){
			//printf("row[%d] += input[%d]\n", i, i + j*data[1]);
			row[i] += input[i + j*data[1]];
		}
	}
	for(i=0 ; i < data[0] ; i++){
		row[size_row - 1] += column[i];
	}
			
	for(i=0 ; i < size_input ; i++){
		printf("%d ", input[i]);
		if(i % data[1] == data[1] - 1){
			printf("%d\n", column[num_column]);
			num_column++;
		}
	}
	for(i=0 ; i < size_row ; i++){
		printf("%d", row[i]);
		if(i == size_row - 1){
			printf("\n");
		}
		else{
			printf(" ");
		}
		/*else{
			printf("!");
		}*/
	}
	
	free(input);
	return 0;
}

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

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int a, b;
    vector<int> p(n), q(n);
    for (int& el : p) {
        cin >> el;
    }
    for (int& el : q) {
        cin >> el;
    }
    vector<int> perm(n);
    iota(perm.begin(), perm.end(), 1);
    int it = 1;
    do {
        if (perm == p) {
            a = it;
        }
        if (perm == q) {
            b = it;
        }
        it++;
    } while (next_permutation(perm.begin(), perm.end()));
    cout << abs(a - b) << endl;
    return 0;
}



Measured memory_bytes: 256
H, W = map(int, input().split())
S = [['.'] * (W + 2)] + [['.'] + list(input()) + ['.'] for i in range(H)] + [['.'] * (W + 2)]

for i in range(1, H + 1):
    for j in range(1, W + 1):
        if S[i][j] == '.':
            S[i][j] = str([S[i - 1][j - 1], S[i - 1][j], S[i - 1][j + 1], S[i][j - 1], S[i][j + 1], S[i + 1][j - 1], S[i + 1][j], S[i + 1][j + 1]].count('#'))

for i in range(1, H + 1):
    print(''.join(S[i][1:W + 1]))


Measured memory_bytes: 3188
import Control.Applicative
import Control.Monad
import Data.Tree
import Data.List
import Data.Vector (Vector, (!), (//))
import qualified Data.Vector as V

main :: IO ()
main = do
  n <- readLn
  unless (n == 0) $ do
    solve n <$> replicateM (n - 1) f >>= print
    main
  where
    f = map read <$> words <$> getLine

solve :: Int -> [[Int]] -> Int
solve n abts = let tr = unfoldTree g (0, 1)
               in 2 * lenTree tr - mxTree tr
  where
    v = foldl' f (V.replicate (n + 1) []) abts
    f v [a, b, t] = v // [(a, (b, t) : v ! a), (b, (a, t) : v ! b)]
    g (p, c)
      | p == 0 = ((c, 0), map (\(x, _) -> (c, x)) (v ! c))
      | otherwise = let ([(_, w)], us) = partition (\(x, _) -> x == p) (v ! c)
                    in ((c, w), map (\(x, _) -> (c, x)) us)
        
lenTree :: Tree (Int, Int) -> Int
lenTree (Node _ []) = 0
lenTree (Node (_, x) st) = x + sum (map lenTree st)

mxTree :: Tree (Int, Int) -> Int
mxTree (Node _ []) = 0
mxTree (Node (_, x) st) = x + maximum (map mxTree st)



Measured memory_bytes: 4560
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      int X = sc.nextInt();
      int Y = sc.nextInt();
      int Z = sc.nextInt();
      
      // スワップ
      int A = Z;
      int B = X;
      int C = Y;
      
      // 出力
      System.out.println(A + " " + B + " " + C);
    }

}

Measured memory_bytes: 23252
using System;

class Watch
{
    public static void Main()
    {
        String str = Console.ReadLine();
        int a = int.Parse(str);
        int hour = a / 3600;
        int minute = (a - (hour * 3600)) / 60;
        int second = a - (hour * 3600) - (minute * 60);
        Console.WriteLine("{0}:{1}:{2}", hour, minute, second);
    }
}


Measured memory_bytes: 9256
n, k = map(int, input().split())
d = [0] * k
a = [0] * k
for i in range(k):
    d[i] = int(input())
    a[i] = list(map(int, input().split()))
ans = [0] * n
for i in range(k):
    for j in range(n):
        ans[j] += a[i].count(j+1)
print(ans.count(0))

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

typedef long long ll;

using namespace std;

const int inf=1000000007;

int a[500005], ma[500005];
struct w
{
    int x, y, k, z, c;
}w[500005];
int N;
bool cmp(struct w a,struct w b)
{
    if(a.z==b.z)
    {
        return a.y<b.y;
    }
    return a.z<b.z;
}
bool cmp1(struct w a,struct w b)
{
    return a.k<b.k;
}
int n, q;

int main()
{
    scanf("%d %d",&n,&q);
    N=(int)sqrt(n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(int i=0;i<q;i++)
    {
        w[i].k=i;
        scanf("%d%d",&w[i].x,&w[i].y);
        w[i].z=w[i].x/N;
    }
    sort(w,w+q,cmp);
    int l=1, r=1, se=0;
    ma[a[1]]++;
    se=1;
    for(int i=0;i<q;i++)
    {
        while(r<w[i].y)
        {
            r++;
            ma[a[r]]++;
            if(ma[a[r]]==1)
            {
                se++;
            }
        }
        while(l>w[i].x)
        {
            l--;
            ma[a[l]]++;
            if(ma[a[l]]==1)
            {
                se++;
            }
        }
        while(r>w[i].y)
        {
            ma[a[r]]--;
            if(ma[a[r]]==0)
            {
                se--;
            }
            r--;
        }
        while(l<w[i].x)
        {
            ma[a[l]]--;
            if(ma[a[l]]==0)
            {
                se--;
            }
            l++;
        }
        w[i].c=se;
    }
    sort(w,w+q,cmp1);
    for(int i=0;i<q;i++)
    {
        printf("%d\n",w[i].c);
    }
    return 0;
}


Measured memory_bytes: 17440
#include<stdio.h>

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

int main(){

  int k, sum = 0;
  scanf("%d", &k);

  for(int i=1;i<=k;i++){
    for(int j=1;j<=k;j++){
      for(int l=1;l<=k;l++){
        int tmp = gcd(i, j);
        sum += gcd(tmp, l);
      }
    }
  }
  printf("%d\n", sum);
  return 0;
}

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

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

    long long sums = 0;
    rep(i,N)sums+=s[i];

    sort(s.begin(),s.end());

    if(sums%10 != 0){
        cout << sums << endl;
        return 0;
    }

    rep(i,N){
        if((sums-s[i])%10 != 0){
            cout << sums-s[i] << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 3600
#include<stdio.h>
#include<string.h>

#define M 1000000/* your task*/
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  return 0;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M/* your task */; }
int h2(int key){ return 1+(key%(M-1))/* your task */; }

int find(char str[]){
  int key, i, h;
  key = getKey(str);
  for(i = 0 ; ; i++){
    h = (h1(key) + i * h2(key))%M;
    if(strcmp(H[h], str) == 0 ) return 1;
    else if(strlen(H[h]) == 0 ) return 0;
  }
  return 0;
  /* your task */
}

int insert(char str[]){
  /* your task */
  int key, i, h;
  key = getKey(str);
  for(i = 0 ; ; i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0 ) return 1;
    else if(strlen(H[h]) == 0 ){
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}

  int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';

    scanf("%d", &n);

    for ( i = 0; i < n; i++ ){
      scanf("%s %s", com, str);

      if ( com[0] == 'i' ){
        insert(str);
      } else {
        if (find(str)){
          printf("yes\n");
        } else {
          printf("no\n");
        }
      }
    }

    return 0;
  }



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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    int N, Q;
    std::cin >> N >> Q;

    string S;
    std::cin >> S;

    vector<int> table(S.size(), 0);
    for(size_t i = 1; i < S.size(); i++) {
        table[i] = (S[i - 1] == 'A' && S[i] == 'C') ? table[i - 1] + 1 : table[i - 1];
    }

    REP(qi, Q) {
        int l, r;
        std::cin >> l >> r;
        std::cout << table[r - 1] - table[l - 1] << std::endl;
    }

    return 0;
}


Measured memory_bytes: 1488
fun main(args: Array<String>) {
    val n = readInt()
    val p = readLongList()

    var min = p[0]
    var cnt = 1

    for (i in 1 until n) {
        if (p[i] <= min) cnt++
        if (p[i] < min) min = p[i]
    }

    println(cnt)
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

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


int main() {
    int N;
    cin >> N;
    vector<int> f(N+1);

    for (int i = 1; i <= 100; i++) {
        for (int j = 1; j <= 100; j++) {
            for (int k = 1; k <= 100; k++) {
                if (std::pow(i+j+k, 2) - (i*j + j*k + k*i) <= N) {
                    f[std::pow(i+j+k, 2) - (i*j + j*k + k*i)]++;
                }
            }
        }
    }

    for (int i = 1; i <= N; i++) {
        cout << f[i] << endl;
    }
    return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    ll n,k;
    cin>>n>>k;
    n%=k;
    cout<<min(n,k-n)<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
int main() {
  int n;
  long long min;
  long long max;
  long long sum;
  std::cin >> n;
  std::vector<int> a(n);
  for (int i = 0; i < n; i++) {
    std::cin >> a[i];
    if (i == 0) {
      min = a[0];
      max = a[0];
    }
    if (a[i] <= min) {
      min = a[i];
    }
    if (a[i] >= max) {
      max = a[i];
    }
    sum += a[i];
  }
  std::cout << min << " " << max << " " << sum << std::endl;
  return 0;
}


Measured memory_bytes: 3144
D, G = map(int, input().split())
PC = [0] + [tuple(map(int, input().split())) for _ in range(D)]
def f(G, i):
    if i == 0:
        return 1e9
    n = min(G // (i * 100), PC[i][0])
    s = n * i * 100
    if n == PC[i][0]:
        s += PC[i][1]
    if s < G:
        n += f(G - s, i - 1)
    return min(n, f(G, i - 1))
print(f(G, D))


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

static const int INF=1e9;
static const int MOD=998244353;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int N; cin >> N;
    int d[N];
    map<int,int> ma;
    for(int i=0;i<N;i++){
        cin >> d[i];
        ma[d[i]]++;
    }
    if(d[0]!=0){
        cout << 0 << endl;
        return 0;
    }
    ll ans=1;
    for(int i=1;i<N;i++){
        ans*=ma[d[i]-1];
        ans%=MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 5376
#include <iostream>
#include <algorithm>
using namespace std;
int dp[1001][2000];
int main() {
  ios::sync_with_stdio(false);
  int D, G;
  int p[11], c[11];
  cin >> D >> G;
  for (int i=1; i<=D; i++) {
    cin >> p[i] >> c[i];
  }
  for (int i=1; i<=D; i++) {
    for (int j=0; j<=p[i]; j++) {
      for (int k=0; k<1000; k++) {
        dp[i][k+j] = max(dp[i][k+j], dp[i-1][k+j]);
        int pt = j * i * 100;
        if (j == p[i]) pt += c[i];
        dp[i][k+j] = max(dp[i][k+j], dp[i-1][k] + pt);
      }
    }
  }
  for (int i=1; i<=1000; i++) {
    if (dp[D][i] >= G) {
      cout << i << endl;
      break;
    }
  }
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int len = S.length();
    bool bad = 0;
    REP(i,len-1){
        if(S[i] == S[i+1]) bad = 1;
    }
    if(bad) cout << "Bad" << endl;
    else cout << "Good" << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s;
  cin >> s;
  int H , J , I ;
  H = s / 100; //sの百の位を変数Hに代入する
  s = s % 100; //sの右2桁を新しいsにする
  J = s / 10; //新しいsの十の位を変数Jに代入する
  s = s % 10; //sの右1桁を新しいsにする
  I = s; //新しいsの一の位を変数Iに代入する
 cout<< H + J + I << endl;
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <limits.h>
#include <math.h>

int main(int argc, char *argv[])
{
    int n;
    int h[20];
    int max;
    int i;
    int ans;

    scanf("%d", &n);

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

    ans = 1;
    max = h[0];
    for (i = 1; i < n; i++) {
        if (max <= h[i]) {
            max = h[i];
            ans++;
        }
    }

    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main() {
    int a,b,c;
    cin >> a >> b >> c;

    if(a == b){
       cout << c << endl;
    }
    else if(b == c){
        cout << a << endl;
    }
    else {
        cout << b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import numpy as np


def main(n, a, x):
    X = max(a, max(x))
    NX = X * n
    NX2 = 2 * NX
    dp = np.zeros(shape=(n + 1, NX2 + 1), dtype=int)
    dp[0][NX] = 1
    for j in range(1, len(dp)):
        for t in range(len(dp[j])):
            xj = x[j - 1]
            yj = xj - a
            if 0 <= t - yj <= NX2:
                dp[j][t] = dp[j - 1][t] + dp[j - 1][t - yj]
            else:
                dp[j][t] = dp[j - 1][t]
    return dp[n][NX] - 1


if __name__ == '__main__':
    N, A = map(int, input().split())
    X = list(map(int, input().split()))
    print(main(N, A, X))


Measured memory_bytes: 14868
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LL long long
#define M 8010
using namespace std;
int n,m,p[M],t[M],L[M],R[M]; char s1[M],s2[M];
int pre[M],suf[M],ls[M],rs[M],ct1,ct2,ans; 
bool cmp(int x,int y){return L[x]>L[y]||(L[x]==L[y]&&R[x]<R[y]);}
void upd(int tar,int hd,int rev,int con){
	if(tar>=hd) ans=min(ans,rev*2+tar+con);
	else ans=min(ans,rev*2+(hd*2-tar)+con);
}
int main(){
	scanf("%s%s",s1+1,s2+1),n=strlen(s1+1),ans=n*n;
	for(int i=1;i<=n;i++) p[i]=s1[i]-'0',t[i]=t[i+n]=t[i+n+n]=s2[i]-'0';
	for(int i=1;i<=n;i++) ct1+=p[i],ct2+=t[i];
	if(!ct2){puts(ct1?"-1":"0");return 0;}
	for(int i=1;i<=n+n;i++) if(!t[i]) ls[i]=(ls[i-1]+1);
	for(int i=n+n+n;i>n;i--) if(!t[i]) rs[i]=(rs[i+1]+1);
	for(int k=0;k<=n;k++){
		m=0,memset(pre,0,sizeof(pre)),memset(suf,0,sizeof(suf));
		for(int i=1;i<=n;i++){
			if(p[i]^t[i+k]){
				m++; if(t[i+k]) continue;
				pre[ls[i+n]]=max(pre[ls[i+n]],rs[i+n]);
				suf[rs[i+n]]=max(suf[rs[i+n]],ls[i+n]);
			}
		}
		for(int i=n-1;i>=0;i--) suf[i]=max(suf[i],suf[i+1]),pre[i]=max(pre[i],pre[i+1]);
		for(int i=0;i<n;i++) upd(k,pre[i+1],i,m),upd(n-k,suf[i+1],i,m);
	} printf("%d\n",ans); return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int b[m];
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }

  int count[n];
  for (int i = 0; i < n; i++) {
    count[i] = 0;
  }

  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if (a[j] <= b[i]) {
	count[j]++;
	break;
      }
    }
  }

  int maxi = count[0], maxip = 0;
  for (int i = 1; i < n; i++) {
    if (maxi < count[i]) {
      maxi = count[i];
      maxip = i;
    }
  }

  cout << maxip + 1 << endl;

  return 0;
}

Measured memory_bytes: 3100
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>

//AtCoderC++.cpp

using namespace std;

void Show(vector<vector<int>> Ns) {
	for (int i = 0; i < Ns.size(); i++) {
		for (int j = 0; j < Ns[i].size(); j++) {
			if (j == Ns[i].size() - 1) {
				cout << Ns[i][j] << endl;
			} else {
				cout << Ns[i][j] << ",";
			}			
		}
	}
}


int main() {
	int Width;
	cin >> Width;
	vector<vector<int>> As;//累積和
	As.resize(2);
	for (int i = 0; i < 2; i++) {
		As[i].resize(Width);
		int a;
		for (int j = 0; j < Width; j++) {
			cin >> a;
			if (j == 0)			As[i][j] = a;
			else As[i][j] = As[i][j - 1] + a;
		}
	}
	int Max = 0;
	for (int i = 0; i < Width; i++) {
		if (i == 0) {
			Max = max(Max, As[0][i] + (As[1][Width - 1]));
		} else {
			Max = max(Max, As[0][i] + (As[1][Width - 1] - As[1][i - 1]));
		}
	}
	cout << Max << endl;
}


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

int main() {
  int N,X,Y;
  cin >> N >> X >> Y;
  vector<int>L(N,0);
  for(int i=1;i<N+1;i++){
    for(int j=i+1;j<N+1;j++){
      L.at(min(j-i,abs(j-Y)+abs(i-X)+1))++;
    }
  }
  for(int i=1;i<N;i++){
    cout << L.at(i) << endl;
  }
}

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

int main(){ 
    int n, k;
    cin >> n >> k;
    vector<long long> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];
    int j = 0;
    for(int i = k; i < n; i++) {
        if(v[i] > v[j++]) {
            cout << "Yes\n";
        }
        else {
            cout << "No\n";
        }
    }
}


Measured memory_bytes: 4792
#include <iostream>
#include <stdio.h>

using namespace std;


int main(){
    
    char S[11],T[12];
    
    scanf("%s",S);

    scanf("%s",T);
    
    bool flag=true;
    
    for(int i=0;S[i]!='\0';++i){
        if(S[i]!=T[i]){
            flag=false;
            break;
        }
    }
    if(flag){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    
}

Measured memory_bytes: 3764
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

vector<int> a;
int n, x;
long long lo, hi, mid, y, z, ans;

long long eval (long long b) {
  long long r = 0;
  for (int i = 0; i < n; i++) {
    r += abs(a[i] - b - i+1);
  }
  return r;
}
int main() {
  cin >> n;
  for (int i= 0; i < n; i++) {
    cin >> x;
    a.push_back(x);
  }

  lo = -1000000000;
  hi = 1000000000;
  ans = 	9223372036854775807;
  while (hi - lo > 1) {
    mid = (hi+lo)/2;
    y = eval(mid);
    z = eval(mid+1);
    ans = min(ans, min(y, z));
    if (y > z) {
      lo = mid;
    } else {
      hi = mid;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1400
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
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; }


// ***************************************

struct tpl {
    ll a, b, c;
    tpl(ll a, ll b, ll c) : a(a), b(b), c(c) {};
};
bool operator>(const tpl& x, const tpl& y) { return x.a > y.a; };

using pq_asc = priority_queue<tpl, vector<tpl>, greater<tpl>>;


int main() {
    ll inf = LLONG_MAX;
    int mx = 2500;
    vector<vector<ll>> dist(50, vector<ll>(mx, inf));
    vector<vector<tpl>> tree(50);
    vector<pair<ll, ll>> ex(50);

    int N, M;
    ll S;
    cin >> N >> M >> S;
    chmin<ll>(S, mx - 1);

    int u, v, A;
    ll B;
    REP(i, M) {
        cin >> u >> v >> A >> B;
        u--; v--;

        tree[u].push_back({ v, A, B });
        tree[v].push_back({ u, A, B });
    }

    ll C, D;
    REP(i, N) {
        cin >> C >> D;
        ex[i] = { C, D };
    }

    pq_asc q;
    q.push({ 0, S, 0 });
    dist[0][S] = 0;

    while (!q.empty()) {
        auto [dv, num, v] = q.top(); q.pop();
        if (dist[v][num] < dv) continue;
        auto [coin, time] = ex[v];
        if (num + coin < mx) if (dist[v][num + coin] > dv + time) {
            dist[v][num + coin] = dv + time;
            q.push({ dv + time, num + coin, v });
        }

        for (auto& [to, a, b] : tree[v]) {
            if (num >= a) if (dv + b < dist[to][num - a]) {
                dist[to][num - a] = dv + b;
                q.push({ dv + b, num - a, to });
            }
        }
    }

    FOR(i, 1, N) {
        ll mn = inf;
        for (auto& s : dist[i]) chmin(mn, s);
        cout << mn << endl;
    }

    return 0;
}

Measured memory_bytes: 7268
def alche(n, v):
    if n == 2:
        x = (v[0] + v[1]) / 2
        print(x)
    else:
        v.sort()
        w = []
        w.append((v[0] + v[1]) / 2)
        for i in range(2, n):
            w.append(v[i])
        n -= 1
        alche(n, w)

n = int(input())
v = list(map(int, input().split()))

alche(n, v)


Measured memory_bytes: 3064
n=int(input())
s=[int(input()) for x in range(n)]
total=sum(s)
s.sort()
if total%10==0:
    for i in s:
        if i%10!=0:
            total-=i
            if total%10!=0:
                break
if total%10==0:
    print(0)
else:
    print(total)

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

struct UnionFind
{
  std::vector<int> d;
  UnionFind(int n) : d(n, -1) {}
  int root(int x)
  {
    if (d[x] < 0) return x;
    return d[x] = root(d[x]);
  }
  bool unite(int x, int y)
  {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (d[x] > d[y]) std::swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y)
  {
    return root(x) == root(y);
  }
  int size(int x)
  {
    return -d[root(x)];
  }
};

int rel[100005];
std::vector<int> block[100005];

int main()
{
  int n, m, k;
  std::cin >> n >> m >> k;

  UnionFind uf(n+1);
  while (static_cast<bool>(m--))
  {
    int a, b;
    std::cin >> a >> b;
    ++rel[a];
    ++rel[b];
    uf.unite(a, b);
  }
  while (static_cast<bool>(k--))
  {
    int c, d;
    std::cin >> c >> d;
    block[c].push_back(d);
    block[d].push_back(c);
  }

  for (int i = 1; i <= n; ++i)
  {
    int ans = 0;
    ans = uf.size(uf.root(i)) - 1 - rel[i];

    for (int other : block[i])
    {
      if (uf.same(i, other)) --ans;
    }

    if (i > 1) std::cout << " ";
    std::cout << ans;
  }
  std::cout << std::endl;

  return 0;
}


Measured memory_bytes: 6784
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


    class Program
    {
        static void Main()
        {
        int a = 0, b = 0, c = 0, d = 0, e;
        int Out = 0;

        int value = 1;

        //e = int.Parse(Console.ReadLine());
        e = 1;
        /*
            for (int i = 0; i < e; i++)
            {
                string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
                a = int.Parse(str[0]);  //数値で受け取りたい場合は変換する
                //b = int.Parse(str[1]);
                //c = int.Parse(str[2]);
                //d = int.Parse(str[3]);
            }
            */
        a = int.Parse(Console.ReadLine());
        b = int.Parse(Console.ReadLine());
        
        for(int i = 0;i<a;i++)
        {
            if(value * 2 < value + b)
            {
                value = value * 2;
            }
            else
            {
                value = value + b;
            }
        }

        Console.WriteLine(value);
        }
    }



Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
inline ll mask(const ll &k) { return (1LL << k) - 1LL; }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
template <class T>
int lwb(V<T> &v, const T &x) { return lower_bound(all(v), x) - v.begin(); }
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
//////////////////////////////////////////////INSERT ABOVE HERE
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int T;
    cin >> T;
    while (T--) {
        int n;
        cin >> n;
        V<P> vl, vr;
        ll res = 0;
        for (int i = 0; i < n; i++) {
            ll k, l, r;
            cin >> k >> l >> r;
            res += min(l, r);
            if (l >= r) {
                vl.eb(k - 1, l - r);
            } else {
                vr.eb(k, r - l);
            }
        }
        priority_queue<ll> q;
        sort(all(vl));
        reverse(all(vl));
        int id = 0;
        for (int i = int(vl.size()) - 1; i >= 0; i--) {
            while (id < vl.size() && vl[id].fi >= i) {
                q.emplace(vl[id].se);
                id++;
            }
            if (q.empty()) continue;
            res += q.top();
            q.pop();
        }
        sort(all(vr));
        id = 0;
        while (!q.empty()) q.pop();
        for (int i = int(vl.size()); i < n; i++) {
            while (id < vr.size() && vr[id].fi <= i) {
                q.emplace(vr[id].se);
                id++;
            }
            if (q.empty()) continue;
            res += q.top();
            q.pop();
        }
        cout << res << newl;
    }
}

Measured memory_bytes: 8176
#include<iostream>
#include<vector>
#include<string>
#include<stdlib.h>
#include<algorithm>
#include<math.h>
#include<queue>
using namespace std;

int main(int argc, char* argv[]) {

	int r, D, x;

	cin >> r >> D >> x;

	for (int i = 0; i < 10; i++) {
		x = r * x - D;
		cout << x << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int maxcost = a*x + b*y;
  int xymax = x > y ? x : y;
  for(int usec = 0; usec <= xymax*2; usec += 2){
    int tmp = usec * c;
    int xx = x - usec/2;
    if (xx > 0)
      tmp += xx * a;
    int yy = y - usec/2;
    if (yy > 0)
      tmp += yy * b;
    if (tmp < maxcost)
      maxcost = tmp;
  }
  cout << maxcost << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
#define int long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define YN(f) (f?"YES":"NO")
#define yn(f) (f?"Yes":"No")	
#define INF 123456789123
#define MOD (int)(1e9+7)
#define MAX_N 1
#define MAX_VAL 300

int d[MAX_VAL][MAX_VAL], r[10], R;
int V = MAX_VAL;

void warshall_floyd(){
	for(int k = 0; k < V; k++)
		for(int i = 0; i < V; i++)
			for(int j = 0; j < V; j++) d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
}


int foo(int used[], int s){//cout<<s<<"  "<<endl; 
	int mi = INF, count = 0;
	for(int j = 0; j < R; j++){//cout<<s<<" "<<r[j]<<" -- "<<d[s][r[j]]<<endl;
		if(s == r[j])continue;
		if(used[j] == true) continue;
		used[j] = true;
		//cout<<s<<" "<<r[j]<<" -- "<<d[s][r[j]]<<" "<<c<<" mi == "<<mi<<endl;
		//cout<<s<<" "<<r[j]<<" ---- "<<d[s][r[j]]<<endl;
		mi = min(foo(used, r[j])+d[s][r[j]], mi);
		//cout<<"min = "<<mi<<endl;
		// cout<<mi<<endl;
		used[j] = false;
		count++;
	}
	if(count == 0) return 0;
	return mi;
}

signed main(){
		int N, M, f, t, cost, used[10] = {};
		int ans = INF, num = 0;
		cin>>N>>M>>R;
		
		rep(i,R)cin>>r[i];
	
	
	
		for(int i = 0; i < V; i++)
			for(int j = 0; j < V; j++)if(i==j)d[i][j]=INF;else d[i][j]=INF;
	
	
	
		for(int i = 1; i <= M; i++){
			cin>>f>>t>>cost;
			d[f][t] = d[t][f] = cost;
		}
		
		warshall_floyd();
		
		for(int i = 0; i < R; i++){
			used[i] = true;
			ans = min(foo(used, r[i]), ans);
			used[i] = false;
		}
		// cout<<d[1][2]<<" "<<d[2][3]<<endl;
		
		cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	int n;
	string s,t;
	cin >> n >> s >> t;
	
	rep(i,n+1){
		if(s.substr(i,n-i) == t.substr(0,n-i)){
			cout << n+i << endl;
			return 0;
		}
	}
}



Measured memory_bytes: 256
package main

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

var sc = NewScanner(os.Stdin, 1000000)

var A1 []int
var A2 []int
var N int
var max int

func main() {
	max = 0
	N = sc.readInt()
	A1 = []int{}
	A2 = []int{}
	for i := 0; i < N; i++ {
		A1 = append(A1, sc.readInt())
	}
	for i := 0; i < N; i++ {
		A2 = append(A2, sc.readInt())
	}
	for i := 0; i < N; i++ {
		tmp := try(i)
		if max < tmp {
			max = tmp
		}
	}
	fmt.Println(max)
}

func try(n int) int {
	res := 0
	for i := 0; i <= n; i++ {
		res += A1[i]
	}
	for i := n; i < N; i++ {
		res += A2[i]
	}
	return res
}

type Scanner struct {
	*bufio.Scanner
}

func (scn *Scanner) readInt() int {
	scn.Scanner.Scan()
	i, _ := strconv.Atoi(scn.Scanner.Text())
	return i
}

func NewScanner(r io.Reader, bufSize int) *Scanner {
	buf := make([]byte, bufSize)
	scn := bufio.NewScanner(r)
	scn.Buffer(buf, bufSize)
	scn.Split(bufio.ScanWords)
	return &Scanner{scn}
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#define rep(i, n) for ( int i = 0; i < n; i++ )
#define REP(i, s, e) for ( int i = s; i <= e; i++ )
using namespace std;
#define MAX 100

class Cube{
    public:
    string f[6];
    Cube(){}
    void roll_z(){ roll(1, 2, 4, 3);}
    void roll_y(){ roll(0, 2, 5, 3);}
    void roll_x(){ roll(0, 1, 5, 4);}
    void roll(int i, int j, int k, int l){
	string t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
    }
};

Cube C[MAX];
int n;

bool eq( Cube c1, Cube c2 ){
    rep(i, 6) if ( c1.f[i] != c2.f[i] ) return false;
    return true;
}

bool equal( Cube c1, Cube c2 ){
    rep(i, 6){
	rep(j, 4){
	    if ( eq(c1, c2) ) return true;
	    c1.roll_z();
	}
	if ( i % 2 == 0 ) c1.roll_y();
	else c1.roll_x();
    }
    return false;
}

main(){
    while( cin >> n && n ){
	rep(i, n) rep(j, 6) cin >> C[i].f[j];
	int cnt = 0;
	REP(i,0,n-1) {
	    bool hasSame = false;
	    REP(j, i+1, n-1){
		if ( equal(C[i], C[j] ) ) hasSame = true;
	    }
	    if ( !hasSame ) cnt++;
	}
	cout << n - cnt << endl;
    }
}

Measured memory_bytes: 936
n = int(input())
hs = list(map(int, input().split()))

a, b = 0, abs(hs[1] - hs[0])

for i in range(2, n):
  d1 = a + abs(hs[i] - hs[i-2])
  d2 = b + abs(hs[i] - hs[i-1])
  a, b = b, min(d1, d2)

print(b)

Measured memory_bytes: 13928
N, M = map(int, input().split())
xyzs = []
for i in range(N):
  x, y, z = map(int, input().split())
  xyzs.append((x, y, z))
rs = []
for i in range(8):
  sx = -1 if i&(1<<2) != 0 else +1
  sy = -1 if i&(1<<1) != 0 else +1
  sz = -1 if i&(1<<0) != 0 else +1
  xyzs2 = map(lambda xyz: sx*xyz[0]+sy*xyz[1]+sz*xyz[2], xyzs)
  r = sum(sorted(xyzs2, reverse=True)[:M])
  rs.append(r)
r = max(rs)
print(r)


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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D ;

  if (A + B == C + D) {
    cout << "Balanced" << endl;
  }

  else if (A + B >= C + D) {
    cout << "Left" << endl;
  }
    else   {
    cout << "Right" << endl;
  }
  
}


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

int main() {
    string s;
    cin >> s;
    bool a = s[0] == 'A';
    bool c = count(begin(s) + 2, end(s) - 1, 'C') == 1;
    s[0] = 'a', *find(begin(s) + 2, end(s) - 1, 'C') = 'c';
    bool small = all_of(begin(s), end(s), ::islower);

    cout << (a && c && small ? "AC" : "WA") << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> myds;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define F first
#define S second
#define vec(x) vector<x> 
#define pi(x,y) pair<x,y>
#define pqq(x) priority_queue<x> 
#define min_heap(x) priority_queue<x, vector<x>, greater<x> >
#define all(x) x.begin(),x.end()
#define rep(i,x,y) for(int i=x;i<y;i++)
#define repd(i,x,y,k) for(int i=x;i<y;i+=k)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define rev(x) reverse(all(x))
#define uniq(x) x.resize(distance(x.begin(),unique(all(x))))
#define full(x,a) memset(x,a,sizeof(x))
#define lcm(x,y) ((x*y)/__gcd(x,y))
#define mod 1000000007
#define bitcount __builtin_popcountll
#define pb push_back
#define indexof order_of_key
#define valueat find_by_order

int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
int dxx[8]={0,0,1,-1,-1,-1,1,1};
int dyy[8]={1,-1,0,0,-1,1,1,-1};

int gcdextended(int a,int b,int &x,int &y){if(!a){x=0,y=1;return b;}int x1,y1;int ans=gcdextended(b%a,a,x1,y1);x=y1-(b/a)*x1;y=x1;return ans;}
int inv(int a){int x,y;int ans=gcdextended(a,mod,x,y);return(x%mod+mod)%mod;}
int nCr(int n,int k){int res=1;k=(k>n-k)?n-k:k;rep(i,0,k){res*=(n-i);res/=(i+1);}return res;}
int POW(int x,int y){int res=1;x=x%mod;while(y>0){if(y&1)res=(res%mod*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
//void seive(){prime[0]=0;prime[1]=0;rep(i,2,10002)prime[i]=1;for(int i=2;i*i<=10000;i++){if(prime[i]){for(int j=i*i;j<=10000;j+=i)prime[j]=0;}}} 

string s;

void input(){
	cin>>s;
}

void solve(){
	if(s[2]==s[3] && s[4]==s[5])
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

main(){
	fastio;
	int t=1;
	while(t--){
		input();
		solve();
	}
}

Measured memory_bytes: 256
import java.util.*;

class Main{
   public static void main(String[] args)
   {
      Scanner scan  = new Scanner(System.in);
      int     n     = scan.nextInt();
      int     day   = scan.nextInt();
      int     rest  = scan.nextInt();
      int     count = n + rest;

      int[] shohi = new int[n];
      for(int i = 0; i < n; i++){
          shohi[i] = scan.nextInt();
          count   += (day - 1) / shohi[i];
          }

      System.out.println(count);
   }
}


Measured memory_bytes: 23764
def main():
    from builtins import int, map, list, print
    from bisect import bisect_right
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = (lambda: (sys.stdin.readline()).rstrip())
    input_list = (lambda: input().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    N = input_number()
    ls = [2 ** i for i in range(7)]
    print(ls[bisect_right(ls, N)-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
ab = gets.split.map(&:to_i)
ans = 0

if ab[0] > ab[1]
  ans += ab[0]
  ab[0] -= 1
else
  ans += ab[1]
  ab[1] -= 1
end

if ab[0] > ab[1]
  ans += ab[0]
  ab[0] -= 1
else
  ans += ab[1]
  ab[1] -= 1
end

puts ans


Measured memory_bytes: 3836
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String SA = sc.nextLine();
        String SB = sc.nextLine();
        String SC = sc.nextLine();
        char next = 'a';
        int a = 0;
        int b = 0;
        int c = 0;
        while(true) {
            if(next == 'a'){
                if(a == SA.length()){
                    System.out.println("A");
                    break;
                }else{
                    next = SA.charAt(a);
                    a++;
                }
            }else if(next == 'b'){
                 if(b == SB.length()){
                    System.out.println("B");
                    break;
                }else{
                    next = SB.charAt(b);
                    b++;
                }
            }else{
                 if(c == SC.length()){
                    System.out.println("C");
                    break;
                }else{
                    next = SC.charAt(c);
                    c++;
                }
            }
        }
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 10;
ll n, ans;
struct node{
	ll x, y;
}p[N];
bool cmp1(node a, node b)
{
	return a.x + a.y < b.x + b.y;
}
bool cmp2(node a, node b)
{
	return a.x - a.y < b.x - b.y;
}
bool cmp3(node a, node b)
{
	return a.y - a.x < b.y - b.x;
} 
int main()
{
    std::ios::sync_with_stdio(false);
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> p[i].x >> p[i].y;
    sort(p + 1, p + 1 + n, cmp1);
    ans = max(ans, p[n].x + p[n].y - p[1].x - p[1].y);
    sort(p + 1, p + 1 + n, cmp2);
    ans = max(ans, (p[n].x - p[n].y) - (p[1].x - p[1].y));
    sort(p + 1, p + 1 + n, cmp3);
    ans = max(ans, (p[n].y - p[n].x) - (p[1].y - p[1].x));
    cout << ans << endl;
	return 0;
}


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

int min(int r[100000],int m){
    int i,min;
    min=r[0];
    for(i=0;i<m;i++){
        if(min>r[i]){
            min=r[i];
        }
    }
    return min;
}
int max(int l[100000],int m){
    int i,max;
    max=l[0];
    for(i=0;i<m;i++){
        if(max<l[i]){
            max=l[i];
        }
    }
    return max;
}

int main(){
    int n,m;
    int l[100000];
    int r[100000];
    scanf("%d",&n);
    scanf("%d",&m);
    int i;
    for(i=0;i<m;i++){
        scanf("%d",&l[i]);
        scanf("%d",&r[i]);
    }
    int ret = min(r,m)-max(l,m)+1;
    if(ret<0)ret=0;
    printf("%d\n",ret);
}

Measured memory_bytes: 896