akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define N 200009
using namespace std;

int n,len,f[N]; ll l,r,ans[26]; char s[N];
int calc1(ll m,int p){
	int i,t=m%n; m/=n;
	for (i=1; i<=n; i++) ans[s[i]-'a']+=p*m;
	for (i=1; i<=t; i++) ans[s[i]-'a']+=p;
}
void calc2(ll m,int p){
	int i;
	if (m<=(n<<1)){
		for (i=1; i<=m; i++) ans[s[i]-'a']+=p;
		return;
	}
	ll x=n,y=f[n],A=1,B=1,a=1,b=0;
	for (; (x<<1)<=m; y=x-y,x+=y){
		a=A-a; b=B-b;
		A+=a; B+=b;
	}
	for (i=1; i<=f[n]; i++) ans[s[i]-'a']+=A*p;
	for (i=f[n]+1; i<=n; i++) ans[s[i]-'a']+=B*p;
	calc2(m-x,p);
}
int main(){
	scanf("%s",s+1); n=strlen(s+1)>>1;
	int i;
	for (i=2; i<=n; i++){
		f[i]=f[i-1];
		for (; f[i] && s[i]!=s[f[i]+1]; f[i]=f[f[i]]);
		if (s[i]==s[f[i]+1]) f[i]++;
	}
	scanf("%lld%lld",&l,&r);
	if (!(n%(n-f[n]))){
		n-=f[n];
		calc1(r,1); calc1(l-1,-1);
	} else{
		calc2(r,1); calc2(l-1,-1);
	}
	for (i=0; i<26; i++) printf("%lld%c",ans[i],(i<25)?' ':'\n');
	return 0;
}


Measured memory_bytes: 896
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
using ll = long long;
using namespace std;

const long long MOD = 1000000007;
const ll LINF = 1LL << 50;

int main() {
  int N;
  cin >> N;
  vector<int> nums(100000,0);
  ll ans = 0;
  
  REP(n,N){
    int a;
    cin >> a;
    nums[a-1] += 1;
    ans += a;
  }


  int Q;
  cin >> Q;

  REP(q,Q){
    int b, c;
    cin >> b >> c;
    int tmp;
    tmp = nums[b-1];
    nums[b-1] = 0;
    nums[c-1] += tmp;
    ans = ans + (c-b)*tmp;
    cout << ans << endl;
  }

}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int64 h, w;
  cin >> h >> w;
  if (h == 1 || w == 1) {
    cout << 1 << endl; return 0;
  }
  cout << (h * w + 1) / 2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;
#define pi 3.141592653589793283462
int main(){
    int n;
    int tc=0,hc=0;
    string t,h;
    cin>>n;
    for(int i=0;i<n;++i){
        cin>>t>>h;
        if(t<h)
            hc+=3;
        else if(t>h)
            tc+=3;
        else{
            tc++;
            hc++;
        }
    }
    cout<<tc<<" "<<hc<<endl;
    return 0;
}

Measured memory_bytes: 1208
#include<unistd.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<stdint.h>
#include<time.h>
#include<tgmath.h>
inline int max(int a, int b){return a>b?a:b;}
inline int min(int a, int b){return a>b?b:a;}
long gcd(long a, long b){return b?gcd(b, a%b):a;}

//fast(?) Input
#define buf_sz 1<<24
char buf[buf_sz];
unsigned int nextint(){
	static int idx = 0;
	if(idx == 0)read(0, buf, buf_sz);
	unsigned int res = 0;
	while(idx<buf_sz && buf[idx]<'0' || '9'<buf[idx])idx++;
	while(idx<buf_sz && '0'<=buf[idx] && buf[idx]<='9'){
		res *= 10;
		res += buf[idx++] - '0';
	}if(idx>=buf_sz)exit(1);
	return res;
}

main(){putchar((nextint()^1) + 48);}

Measured memory_bytes: 1480
#include <iostream>
#include <string>//
#include <vector>//
#include <map>
#include <cstdlib>
#include <numeric>
#include <algorithm>//ソート等に使用
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <thread>///////////////////
#include <queue>//幅優先等のキュー
#include <stack>
#include <bitset>

#define rep(i,m,n) for(int i=(m);i<=(n);i++)
#define mer(i,m,n) for(int i=(m);i>=(n);--i)

#define MOD 1000000007
//#define MOD 998244353
//#define MAX 

using namespace std;

using ll = long long int;
using ld = long double;
using std::swap;

vector<int> v;
vector<long long int> vll;
//vector<vector<int>> vec(50, vector<int>(4, 0));
vector<vector<int>> vv;
vector<char> vc;
vector<string> vs;




int main() {
	
	ll a, b, c, d,ans;
	vll.resize(4);
	cin >> a >> b >> c >> d;
	vll[0] = a * c;
	vll[1] = a * d;
	vll[2] = b * c;
	vll[3] = b * d;
	ans = *max_element(vll.begin(), vll.end());
	cout << ans << '\n';
	return 0;
}

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }

int a,b,c;

int main()
{
  cin >> a >> b >> c;

  cout << max(0,c - (a-b)) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int money,coin=0;
  while(1){
    coin=0;
    cin >> money;
    if(money==0){
      break;
    }
    money=1000-money;
    while(money>0){
      if(money>=500){
	money-=500;
	coin++;
      }
      else if(money>=100){
	money-=100;
	coin++;
      }
      else if(money>=50){
	money-=50;
	coin++;
      }
      else if(money>=10){
	money-=10;
	coin++;
      }
      else if(money>=5){
	money-=5;
	coin++;
      }
      else if(money>=1){
	money-=1;
	coin++;
      }
    }
    cout << coin << endl;
  }
  return (0);
}

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

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

    vector<int> x(n);

    for(int i=0;i<n;i++){
        cin >> x[i];
    }

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

    int max = x[n-1];
    int min = x[0];

    cout << (max-min+1)/2 << endl;

}


Measured memory_bytes: 3132
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    
    public static void main(String[] args) {
        int s = scn.nextInt();
        System.out.println(
          s / 3600 + ":" + s % 3600 / 60 + ":" + s % 60
        );
    }
}

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

int main(){
  int i,ge,shi,bai,qian;
  cin>>i;
  ge=i%10;
  shi=i%100/10;
  bai=i/100%10;
  qian=i/1000;
  if(ge==shi||shi==bai||bai==qian) cout<<"Bad";
  else cout<<"Good"; 
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pf printf
#define sc(x) scanf("%d",&x);
#define scs(x) scanf("%s",x);
#define scl(x) scanf("%lld",&x);
#define rep(i,s,e) for(int i=s; i<=e; ++i)
#define dep(i,s,e) for(int i=s; i>=e; --i)
typedef long long ll;
using namespace std;
__int128 bj=1e18;
int main()
{
	int biaoji=0,biaoji1=0;
	int n;__int128 num;ll v;
	sc(n);scl(v);num=v;
	for(int i=2;i<=n;i++){
		scl(v);
		if(v==0)biaoji1=1;
		num*=v;if(num>bj)biaoji=1;
	}if(biaoji1==1)pf("0");
	else {
		if(biaoji==1)pf("-1");
		else {v=num;pf("%lld\n",v);}
	}
}


Measured memory_bytes: 3760
#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 equals(a,b) (fabs((a)-(b)) < EPS)
#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();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    int a,b,c,d; cin >> a >>b>>c>>d;
    if(a != c){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }

}


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

#define SIZE 9

using namespace std;

int main(){
	int N,M;
	int total;
	int d,p;
	pair<int,int>pd[10000+1];
	while(cin>>N>>M,N){
		total = 0;
		for(int i=0; i<N; i++){
			cin>>d>>p;
			pd[i] = make_pair(p,d);
			total += p*d;
		}
		sort(pd,pd+N);
		reverse(pd,pd+N);
		for(int i=0; i<N; i++){
			if(pd[i].second > M){
				total -= M*pd[i].first;
				break;
			}else{
				M -= pd[i].second;
				total -= pd[i].first*pd[i].second;
			}
		}
		cout<<total<<endl;
	}
	return 0;
}

Measured memory_bytes: 1240
import java.io.*;;
 
class Main{
    public static void main(String[] args)throws IOException{
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();

		char [] ch = str.toCharArray();
		for(int i=0;i<ch.length;++i){
			if (Character.isUpperCase(ch[i])){
				ch[i]=Character.toLowerCase(ch[i]);
			}else{
				ch[i]=Character.toUpperCase(ch[i]);
			}
		}
		System.out.println(new String(ch));
    }
}

Measured memory_bytes: 24264
local n = io.read("*n")
local tmin, tmax = {}, {}
local t, a = {}, {}
local amin, amax = {}, {}

for i = 1, n do t[i] = io.read("*n") end
for i = 1, n do a[i] = io.read("*n") end
for i = 1, n do
  if i == 1 then
    tmin[i], tmax[i] = t[1], t[1]
  else
    if t[i - 1] < t[i] then
      tmin[i], tmax[i] = t[i], t[i]
    else
      tmin[i], tmax[i] = 1, tmax[i - 1]
    end
  end
end
for i = 1, n do amin[i], amax[i] = 0, 0 end
for i = n, 1, -1 do
  if i == n then
    amin[i], amax[i] = a[i], a[i]
  else
    if a[i + 1] < a[i] then
      amin[i], amax[i] = a[i], a[i]
    else
      amin[i], amax[i] = 1, amax[i + 1]
    end
  end
end
local ret = 1
local mmi, mma = math.min, math.max
for i = 1, n do
  local l = mma(tmin[i], amin[i])
  local r = mmi(tmax[i], amax[i])
  ret = (ret * mma(0, r - l + 1)) % 1000000007
end
print(ret)


Measured memory_bytes: 12736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
ll res = 0, l;
char s[15];

void Dfs(int x, ll last, ll sum) 
{
	if(x >= l + 1) {
		res += sum + last; 
		return ;
	}
	Dfs(x + 1, last * 10 + s[x] - '0', sum); 
	Dfs(x + 1, 0, sum + last); 
}

int main() {
	scanf("%s", s + 1);
	l = strlen(s + 1);
	Dfs(1, 0, 0);
	printf("%lld\n", res);
}

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

using namespace std;

struct vw_pair {
    int v, w;
    vw_pair(int v,int w) : v(v), w(w) {};
};

typedef pair<int, int> ii;
typedef vector <ii> vii;
typedef vector<int> vi;
typedef vector <string> vs;
typedef vector <vi> vvi;
typedef vector <vector<vw_pair>> adj_list;
typedef vector <bool> vb;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef priority_queue<int> max_heap_int;
typedef priority_queue<int, vi, greater<>> min_heap_int;

#define isOn(S, j) (S & (1<<j))
#define setBit(S, j) (S |= (1<<j))
#define clearBit(S, j) (S &= ~(1<<j))
#define toggleBit(S, j) (S ^= (1<<j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1<<n)-1)
#define modulo(S, N) ((S) & (N-1))   // returns S % N, where N is a power of 2
#define isPowerOfTwo(S) (!(S & (S-1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S-1))
#define turnOnLastZero(S) ((S) | (S+1))
#define turnOffLastConsecutiveBits(S) ((S) & (S+1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S-1))
#define in_range(lo, hi, x) ((x >= lo && x <= hi))

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    vi a(n), b(n), c(n-1);
    for (int i=0;i<n;++i) cin >> a[i];
    for (int i=0;i<n;++i) cin >> b[i];
    for (int i=0;i<(n-1);++i) cin >> c[i];

    int s = 0;
    for (int i=0;i<n;++i) {
        if (i == 0) s += b[a[i]-1];
        else {
            s += b[a[i]-1];
            if (a[i-1] == a[i]-1) {
                s += c[a[i-1]-1];
            }
        }
    }

    cout << s << "\n";
    
    return 0;
}

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

namespace AOJ1043
{
    internal class Program
    {
        private static void Main()
        {
            foreach (var sortedTeams in from teams in ReadInputs()
                                        select from team in teams
                                               orderby team.Id ascending
                                               orderby team.Penalty ascending
                                               orderby team.Correct descending
                                               select team)
            {
                var picked = new List<Team>();
                foreach (var team in sortedTeams)
                {
                    var sameAffiliation = picked.Count(t => t.Affiliation == team.Affiliation);

                    if (picked.Count < 10)
                    {
                        if (sameAffiliation < 3)
                        {
                            picked.Add(team);
                        }
                    }
                    else if (picked.Count < 20)
                    {
                        if (sameAffiliation < 2)
                        {
                            picked.Add(team);
                        }
                    }
                    else if (picked.Count < 26)
                    {
                        if (sameAffiliation == 0)
                        {
                            picked.Add(team);
                        }
                    }
                }

                foreach (var team in picked)
                {
                    Console.WriteLine(team.Id);
                }
            }
        }

        public static IEnumerable<Team[]> ReadInputs()
        {
            while (true)
            {
                var count = int.Parse(Console.ReadLine() ?? "");
                if (count == 0) yield break;

                var teams = new Team[count];

                for (var i = 0; i < count; i++)
                {
                    var values = (Console.ReadLine() ?? "").Split(' ').Select(int.Parse).ToArray();
                    teams[i] = new Team(values[0], values[1], values[2], values[3]);
                }

                yield return teams;
            }
        }
    }

    public class Team
    {
        public int Id { get; private set; }
        public int Affiliation { get; private set; }
        public int Correct { get; private set; }
        public int Penalty { get; private set; }

        public Team(int id, int affiliation, int correct, int penalty)
        {
            Id = id;
            Affiliation = affiliation;
            Correct = correct;
            Penalty = penalty;
        }
    }
}

Measured memory_bytes: 6660
import sys
def SI(): return sys.stdin.readline().strip()
MOD = 10 ** 9 + 7


def main(): 
    S = SI()

    # 桁DP。この init で dp_table[len(S)][13] となる。前後逆になるので注意。
    dp_table = [[0 for _ in range(13)] for _ in range(len(S))]

    # 最初の桁を見る。
    if S[0] == '?':
        region = range(10)
    else:
        region = [int(S[0]),]

    for i in region:
        dp_table[0][i] = 1

    # 以降の桁を見ていく。
    for digit in range(1, len(S)):
        if S[digit] == '?':
            region = range(10)
        else:
            region = [int(S[digit]),]

        for prev_res, comb in enumerate(dp_table[digit-1]):
            for x in region:
                res = (prev_res*10+x)%13
                dp_table[digit][res] = (dp_table[digit][res] + comb)%MOD

    print(dp_table[len(S)-1][5])

main()

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

using namespace std;

int main(void) {
    int r, g, b;
    cin >> r >> g >> b;
    int a = r * 100 + g * 10 + b;
    if (!(a % 4)) cout << "YES\n";
    else cout << "NO\n";
    
    return 0;
}

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

int main(){
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    bool judge=false;

    if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){
        judge=true;
    }

    if(judge){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}



Measured memory_bytes: 3100
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

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

    int b = a.size();
    int c[15];
    for(int i=0;i<b;++i){
        c[i] = a[i] -'0';
    }
    int d[10];
    for(int i=0;i<b-2;++i){
        d[i] = c[i]*100 + c[i+1]*10 + c[i+2];
    }
    //cout<<d[5];

    int Min=10000;
    for(int i=0;i<b-2;++i){
        if(fabs(d[i] - 753) < Min){
            Min = fabs(d[i] - 753);
        }
        else if(fabs(d[i] - 753 == 0)){
            Min = 0;
            break;
        }
    }
    cout<<Min;
}



Measured memory_bytes: 256
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,p = readInts()
A = readInts()
odd = 0
for i in range(n):
    # count odd numbers
    # you can use Binomial coefficient
    # if P = 0, you should calculate this in using an odd number of odd numbers
    # else even numbers
    if A[i]%2:
        odd += 1
if odd == 0:
    if p == 0:
        print(2**n)
    else:
        print(0)
else:
    print(2**(n-1)) # 2**(n-1) = 2**(m-1) choosing odd * 2**(n-m) choosing even


Measured memory_bytes: 10452
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;
 
    int main(){
      int n,z,w;
      cin >> n >> z >> w;
      int a[n];
      rep(i,n)cin >> a[i];
      if(n==1){
        cout << abs(w-a[0]) << endl;
        return 0;
      }
      cout << max(abs(a[n-2]-a[n-1]),abs(w-a[n-1])) << endl;;
      return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int N;
	long long sum=0;
	string s;
	cin>>N>>s;
	vector<vector<int> >dp1(N,vector<int>(3)),dp2(N,vector<int>(3));
	vector<int>dp3(N);
	for(int i=0;i<N;i++)
		if(s[i]=='R')
			if(i>0) {
				dp1[i][0]=dp1[i-1][0]+1;
				dp1[i][1]=dp1[i-1][1];
				dp1[i][2]=dp1[i-1][2];
				dp2[i][0]=dp1[i-1][1];
				dp2[i][2]=dp1[i-1][2];
				for(int j=i-1;j>0;j--) dp3[i]+=dp2[j][1]-(2*j-i>=0&&(s[j]=='B'&&s[2*j-i]=='G'||s[j]=='G'&&s[2*j-i]=='B'));
			}
			else dp1[0][0]=1;
		else if(s[i]=='G')
			if(i>0) {
				dp1[i][0]=dp1[i-1][0];
				dp1[i][1]=dp1[i-1][1]+1;
				dp1[i][2]=dp1[i-1][2];
				dp2[i][0]=dp1[i-1][0];
				dp2[i][1]=dp1[i-1][2];
				for(int j=i-1;j>0;j--) dp3[i]+=dp2[j][2]-(2*j-i>=0&&(s[j]=='B'&&s[2*j-i]=='R'||s[j]=='R'&&s[2*j-i]=='B'));
			}
			else dp1[0][1]=1;
		else
			if(i>0) {
				dp1[i][0]=dp1[i-1][0];
				dp1[i][1]=dp1[i-1][1];
				dp1[i][2]=dp1[i-1][2]+1;
				dp2[i][1]=dp1[i-1][1];
				dp2[i][2]=dp1[i-1][0];
				for(int j=i-1;j>0;j--) dp3[i]+=dp2[j][0]-(2*j-i>=0&&(s[j]=='G'&&s[2*j-i]=='R'||s[j]=='R'&&s[2*j-i]=='G'));
			}
			else dp1[0][2]=1;
	for(int i=0;i<N;i++) sum+=dp3[i];
	cout<<sum<<"\n";
	return 0;
}


Measured memory_bytes: 4056
<?php
// B
fscanf(STDIN, '%d %d %d %d', $x1, $y1, $x2, $y2);
$xx = $x2 - $x1;
$yy = $y2 - $y1;
echo implode(' ', [$x2 - $yy, $y2 + $xx, $x1 - $yy, $y1 + $xx]);

Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int odd = 0;
    rep(i, 1, n + 1) if (i % 2) odd++;
    cout << fixed;
    cout << setprecision(10);
    cout << (double) odd / n << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String s = sc.next();

        char[] c = s.toCharArray();

        int[] a = new int[c.length+1];

        long ans = 0;

        if (s.length()==1){
            System.out.println(1);
            return;
        }

//        List<Integer> list = new ArrayList<>();

        if (c[0]=='<') {
            a[1] = 1;
            for (int i=1; i<c.length; i++){
                if (c[i]=='<'){
                    a[i+1] = a[i]+1;
                }else {
                    break;
                }
            }
        }

        if (c[c.length-1]=='>'){
            a[a.length-2] = 1;
            for (int i=c.length-2; i>=0; i--){
                if (c[i]=='>'){
                    a[i] = a[i+1]+1;
                }else {
                    break;
                }
            }
        }

        for (int i=0; i<c.length; i++){
            if (c[i]=='<'){
                a[i+1] = a[i]+1;
            }
        }
        for (int i=c.length-1; i>=0; i--){
            if (c[i]=='>'){
                if (a[i]<a[i+1]+1){
                    a[i] = a[i+1]+1;
                }
            }
        }

        for (int i=0; i<a.length; i++){
            ans += a[i];
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 34116
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var num = Input.num;
        var ar = Input.ar;
        var ct = new int[3];
        for (var i = 0; i < num; i++)
            if (ar[i] % 4 == 0) ct[2]++;
            else if (ar[i] % 2 == 0) ct[1]++;
            else ct[0]++;
        if (ct[2] >= ct[0]) WriteLine("Yes");
        else if (ct[2] == ct[0] - 1 && ct[1] == 0) WriteLine("Yes");
        else WriteLine("No");
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const double eps = 1e-11;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 20576
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

 
int main(){
  string s;
  cin >> s;
  int n = s.size();
  set<char> st;
  rep(i,n) st.insert(s[i]);

  if(n<=25){
    string ans = s;
    for(char i='a'; i<='z'; i++)if(st.find(i)==st.end()){
      ans += i;
      cout << ans << endl;
      return 0;
    }
  }

  if(s=="zyxwvutsrqponmlkjihgfedcba"){
    cout << -1 << endl; return 0;
  }

  string ans = s;
  next_permutation(ans.begin(),ans.end());
  rep(i,n){
    if(ans[i]!=s[i]){
        ans.erase(i+1,n-1);
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			int m = scan.nextInt();
			if(n == 0 && m == 0){
				break;
			}
			int[] d = new int[n+m];
			for(int i = 0;i < n+m;i++){
				d[i] = scan.nextInt();
			}
			Arrays.sort(d);
			int max = d[0];
			int t;
			for(int i = 0;i < n+m-1;i++){
				t = d[i+1] - d[i];
				if(max < t){
					max = t;
				}
			}
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 63472
c = [list(map(int,input().split())) for _ in range(3)]

L1 = [(i[1]-i[0],i[2]-i[0]) for i in c]
L2 = [(c[1][i] - c[0][i],c[2][i] - c[0][i]) for i in range(3)]
if (L1[0] == L1[1] == L1[2]) and (L2[0] == L2[1] == L2[2]):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#if 0
30?????????????????£???

??????????????????????????§??????????????????????????§??????????????¨???????????????????????§
?????????????????????????????????????????????????????????????????????????????§?????????????????????????????????set????????????????????£??????
set????????????????????????????????????????????????????´???°????¢???????????????¨????????¨??????
#endif


#include <set>
#include <string>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int N;
  cin >> N;
  string word;
  string word1,word1r; //??????
  string word2,word2r; //??????
  typedef set<string> train;
  while (cin >> word && N) {
    train A;
    for(int i=0;i<word.length();i++){
          word1 ="";
          word2 ="";
      for(int j=0;j<=i;j++){
	word1+=word[j]; //??????
      }
      for(int j=0;j<word.length()-1-i;j++){
	word2+=word[word.length()-1-j]; //??????
      }
      word1r=word1;
      reverse(word1.begin(),word1.end());//??????????????????
      word2r=word2;
      reverse(word2.begin(),word2.end());//??????????????????
      //cout <<" word1="<<word1<<endl;
      //cout <<" word1r="<<word1r<<endl;
      //cout <<" word2="<<word2<<endl;
      //cout <<" word2r="<<word2r<<endl;
      //cout<<" "<<word1+word2<<endl;
      //cout<<" "<<word1r+word2<<endl;
      //cout<<" "<<word1+word2r<<endl;
      //cout<<" "<<word1r+word2r<<endl;
      //cout<<" "<<word2+word1<<endl;
      //cout<<" "<<word2r+word1<<endl;
      //cout<<" "<<word2+word1r<<endl;
      //cout<<" "<<word2r+word1r<<endl; check!!
      A.insert(word1+word2);
      A.insert(word1r+word2);
      A.insert(word1+word2r);
      A.insert(word1r+word2r);
      A.insert(word2+word1);
      A.insert(word2r+word1);
      A.insert(word2+word1r);
      A.insert(word2r+word1r);//???????????????????????¨??¨??????
    }
    cout << A.size() <<endl;
    //cout <<"--"<<endl;check
    N -= 1;
  }
}

Measured memory_bytes: 3108
"use strict";

const main = arg => {
    const input = arg.trim().split("\n");

    const N = Number(input[0].split(" ")[0]);
    const M = Number(input[0].split(" ")[1]);
    const A = input[1].split(" ").map(n => Number(n));
    const total = A.reduce((acc, curr) => acc+curr)
    const thresh = 1*total / (4*M)
    A.sort((a,b) => b-a)
    if(A[M-1] < thresh) console.log("No")
    else console.log("Yes")
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));  


Measured memory_bytes: 29476
tate_yoko = list(map(int, input().split()))
tate = tate_yoko[0]
yoko = tate_yoko[1]
matrix = []
operation = []
count = 0
hoge = 0
x = 1
y = 1
coin_flag = False
printing1 = 0
printing2 = 0
printing3 = 0
printing4 = 0


for i in range(tate):
    list1 = list(map(int, input().split()))
    matrix.append(list1)

for j in range(tate * yoko):
    if matrix[y - 1][x - 1] % 2 == 1:
        if not coin_flag:
            matrix[y - 1][x - 1] = matrix[y - 1][x - 1] - 1
            coin_flag = True
            printing1 = y
            printing2 = x
        elif coin_flag:
            matrix[y - 1][x - 1] = matrix[y - 1][x - 1] + 1
            coin_flag = False
            printing3 = y
            printing4 = x
            operation.append([printing1, printing2, printing3, printing4])
            count = count + 1
            hoge = 0
    elif matrix[y - 1][x - 1] % 2 == 0:
        if coin_flag:
            printing3 = y
            printing4 = x
            operation.append([printing1, printing2, printing3, printing4])
            count = count + 1
            hoge = hoge + 1
            printing1 = y
            printing2 = x
    if y % 2 == 1:
        if x == yoko:
            y = y + 1
        else:
            x = x + 1
    elif y % 2 == 0:
        if x == 1:
            y = y + 1
        else:
            x = x - 1

if not coin_flag:
    hoge = 0
print(count - hoge)
length = len(operation)
for l in range(hoge):
    operation.pop(length - hoge)
for k in range(len(operation)):
    syuturyoku = " ".join(list(map(str, operation[k])))
    print(syuturyoku)

Measured memory_bytes: 25840
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 3010

ll power(ll k, ll n, int M){
  ll res = 1;
  while(n > 0) {
    if (n & 1) res = res * k % M;
    k = k * k % M;
    n /= 2;
  }
  return res;
}

// a + bx
vector<int> mul(const vector<int> &v, int a, int b, int P) {
  vector<int> res(v.size()+1);

  a = (a % P + P) % P;
  b = (b % P + P) % P;

  for (int i=0; i<v.size(); i++) {
    res[i+1] += v[i] * b % P;
    res[i] += v[i] * a % P;
    res[i] %= P;
  }

  return res;
}

// a + bx
vector<int> div(const vector<int> &v, int a, int b, int P) {
  vector<int> res(v.size()-1), vc = v;

  a = (a % P + P) % P;
  b = (b % P + P) % P;
  int binv = power(b, P-2, P);

  for (int i=(int)vc.size()-1; i>0; i--) {
    res[i-1] = vc[i] * binv % P;
    vc[i-1] = (vc[i-1] - res[i-1] * a % P + P) % P;
  }

  assert(vc[0] == 0);

  return res;
}


int solve(int P, vector<int> &A) {
  int r[SIZE];
  vector<int> ans(P);

  vector<int> Q(1, 1);

  for (int i=0; i<P; i++) {
    Q = mul(Q, i, -1, P);
  }

  for (int i=0; i<P; i++) {
    vector<int> C = div(Q, i, -1, P);

    ll sum = 0, p = 1;
    for (int j=0; j<P; j++) {
      sum += C[j] * p;
      p = p * i % P;
    }

    r[i] = A[i] * power(sum % P, P-2, P) % P;

    for (int j=0; j<P; j++) {
      ans[j] += r[i] * C[j];
      ans[j] %= P;
    }
  }

  for (int i=0; i<P; i++) {
    int p = 1, res = 0;
    for (int j=0; j<P; j++) {
      res += ans[j] * p;
      res %= P;
      p = p * i % P;
    }
    if (res % P != A[i]) {
      debug(A);
      debug(ans);
      exit(1);
    }
  }

  for (int i=0; i<P; i++) {
    printf("%d%c", ans[i] % P, " \n"[i==P-1]);
  }

  return 0;
}


int main() {
  int P;

  cin >> P;

  vector<int> A(P);

  for(int i=0; i<P; i++)
    cin >> A[i];

  solve(P, A);

  /*
  while(1) {
    for (int i=0; i<P; i++)
      A[i] = rand() % P;

    solve(P, A);
  }
  */
}


Measured memory_bytes: 384
package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}
func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

// ax+by=gcd(a,b)
func extgcd(a, b int) (x, y int) {
	y = 1
	x = 0
	for u, v := 1, 0; a != 0; {
		q := b / a
		u, x = x - q * u, u
		v, y = y - q * v, v
		a, b = b - q * a, a
	}

	return
}

func modinv(a, m int) int {
	x, _ := extgcd(a, m)
	return (m + x % m) % m
}

func fact(n, mod int) int {
	ret := 1
	for n > 1 {
		ret = ret * n % mod
		n--
	}
	return ret
}

type P struct {
	c,s,f int
}

func maxInt(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

func main() {
	io := NewIo()
	defer io.writer.Flush()

	n := io.NextInt()

	vp := make([]P, n - 1, n - 1)
	for i := 0; i < n - 1; i++ {
		vp[i].c = io.NextInt()
		vp[i].s = io.NextInt()
		vp[i].f = io.NextInt()
	}

	for i := 0; i < n; i++ {
		cur := 0
		for j := i; j < n - 1; j++ {
			r1 := (cur + vp[j].f - 1) / vp[j].f * vp[j].f
			cur = maxInt(vp[j].s, r1) + vp[j].c
		}
		io.Printf("%d\n", cur)
	}

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  cout << n*n << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////


int main() {
	ll N, E, T;
	cin >> N >> E >> T;

	vector<ll> x(N + 1,0);
	repn(i, N) cin >> x[i];

	vector<ll> dp(N + 1, 0), mn(N + 1, INF);

	repn(i, N) {
		auto itr = lower_bound(++x.begin(), x.end(), x[i] - T / 2);
		ll j = distance(x.begin(), itr);
		dp[i] = dp[j - 1] + T;

		dp[i] = min(dp[i], mn[j - 1] + 2 * x[i]);

		mn[i] = min(mn[i - 1], dp[i - 1] - 2 * x[i]);
	}

	cout << E + dp[N] << endl;
}


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

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<vector<int>> A(H, vector<int>(W));
  for (int i = 0, cnt = 1; i < H; i++) {
    for (int j = 0; j < W; j++) {
      char c;
      cin >> c;
      if (c == '#') A.at(i).at(j) = cnt++;
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0, tmp = 0; j < W; j++) {
      if (A.at(i).at(j) != 0) tmp = A.at(i).at(j);
      else A.at(i).at(j) = tmp;
    }
    for (int j = W - 1, tmp = 0; j >= 0; j--) {
      if (A.at(i).at(j) != 0) tmp = A.at(i).at(j);
      else A.at(i).at(j) = tmp;
    }
  }
  vector<int> tmp;
  for (int i = 0; i < H; i++) {
    if (*max_element(A.at(i).begin(), A.at(i).end()) == 0) A.at(i) = tmp;
    else tmp = A.at(i);
  }
  vector<int> tmp2;
  for (int i = H - 1; i >= 0; i--) {
    if (*max_element(A.at(i).begin(), A.at(i).end()) == 0) A.at(i) = tmp2;
    else tmp2 = A.at(i);
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (j) cout << " ";
      cout << A.at(i).at(j);
    }
    cout << "\n";
  }
}

Measured memory_bytes: 1152
#pragma GCC optimize("O2")
// #include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
using namespace std;
#define MOD 1000000007


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	long long a , b , n;
	cin >> a >> b >> n ;
	// long long mx = -1  , c;
	long long m ;
	if (n <= b - 1) {
		cout << floor(a * n / b) << "\n";

	}
	else {
		m = b - 1 ;
		cout << floor(a * m / b) << "\n";
	}
	// else {
	// 	for (int i = b - 1 ; i <= n ; i += b) {
	// 		c = floor(a * i / b) - a * floor(i / b);
	// 		mx = max(mx, c);
	// 	}
	// 	cout << mx << "\n";
	// }






	return 0 ;
}



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

using namespace std;
using ll = long long;

int n, m;
vector<int> graph[100005];
int dp[100005];

int solve(int node) {
  int& res = dp[node];
  if (res != -1) {
    return res;
  }
  res = 0;
  for (int child : graph[node]) {
    res = max(res, 1 + solve(child));
  }
  return res;
}

int main() {
  fill(dp, dp + 100005, -1);
  cin >> n >> m; 
  for (int i = 0; i < m; i++) {
    int a, b; cin >> a >> b;
    a--, b--;
    graph[a].push_back(b);
  }
  int res = 0;
  for (int i = 0; i < n; i++) {
    res = max(res, solve(i));
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 7424
#include<cstdio>
int main(){
	char a[101],b[101],c[101];
	char turn = 'a';
	int pa = 0,pb = 0,pc = 0;
	scanf("%s %s %s",a,b,c);
	while(true){
		if(turn=='a'){
			if(a[pa]=='\0'){
				printf("A\n");
				return 0;
			}
			turn = a[pa];
			pa++;
		}else if(turn=='b'){
			if(b[pb]=='\0'){
				printf("B\n");
				return 0;
			}
			turn = b[pb];
			pb++;
		}else if(turn=='c'){
			if(c[pc]=='\0'){
				printf("C\n");
				return 0;
			}
			turn = c[pc];
			pc++;
		}
	}
}


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

using namespace std;
using pint = pair<int,int>;

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

int H, W;
string fi[110];
int dist[110][110]; // BFS 用

int main() {
    // 入力
    cin >> H >> W;
    int wnum = 0;
    for (int i = 0; i < H; ++i) {
        cin >> fi[i];
        for (int j = 0; j < W; ++j) {
            if (fi[i][j] == '.') ++wnum;
        }
    }

    // BFS
    memset(dist, -1, sizeof(dist));
    dist[0][0] = 1;
    queue<pint> que;
    que.push(pint(0, 0));
    while (!que.empty()) {
        pint cur = que.front();
        que.pop();
        int x = cur.first;
        int y = cur.second;
        for (int dir = 0; dir < 4; ++dir) {
            int nx = x + dx[dir];
            int ny = y + dy[dir];
            if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
            if (fi[nx][ny] == '#') continue;
            if (dist[nx][ny] == -1) {
                dist[nx][ny] = dist[x][y] + 1;
                que.push(pint(nx, ny));
            }
        }
    }
    if (dist[H-1][W-1] == -1) cout << -1 << endl;
    else  cout << wnum - dist[H-1][W-1] << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n, k;
	char s[51];

	scanf("%d", &n);
	scanf("%d", &k);
	scanf("%s", s);
	switch (s[k - 1]) {
	case 'A':
		s[k - 1] = 'a';
		break;
	case 'B':
		s[k - 1] = 'b';
		break;
	case 'C':
		s[k - 1] = 'c';
		break;
	}
	printf("%s\n", s);
	return 0;
}

Measured memory_bytes: 128
class Integer
  def modinv(m)
    a, b, i, j = self, m, 1, 0
    while b > 0
      t = a / b
      a, b = b, a - t * b
      i, j = j, i - t * j
    end
    i % m
  end
end

gets.chomp.to_i
an = gets.chomp.split.map(&:to_i)
m = (1e9 + 7).to_i
lcm = an.inject(:lcm) % m
sum = 0
an.each do |ai|
  sum += ai.modinv(m)
end
puts lcm * sum % m

Measured memory_bytes: 58840
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
 
int main() {
    ld n; 
    ll flag = 0;
    cin >> n;
    for(ll x = 1; x <= n; x++) {
        ld cur = floor(x * 1.08) * 1.0;
        if(cur == n) {
            cout << x;
            return 0;
        }
    }
    cout << ":(";
	
	return 0;
}

Measured memory_bytes: 256
def even(s):
    return s[0:len(s)//2] == s[(len(s)//2):]

def longest_even(s):
    for i in range(1, len(s)+1):
        if even(s[0:len(s)-i]):
            return(len(s)-i)


if __name__ == '__main__':
    s = input()
    print(longest_even(s))


Measured memory_bytes: 2940
import sys
input = sys.stdin.readline
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in range(n)]
ab = [(x,y) for x,y in zip(a,b)]
from operator import itemgetter
ab = tuple(sorted(ab,key=itemgetter(0),reverse=True))
dp = [[-10**14]*(n+1) for i in range(n+1)]
dp[0][0] = 0
for i in range(n):
  for j in range(i+2):
    dp[i+1][j] = max(dp[i][j]+ab[i][0]*abs(ab[i][1]-(n-1-(i-j))),dp[i][j-1]+ab[i][0]*abs(ab[i][1]+1-j))
print(max(dp[n]))

Measured memory_bytes: 106268
a,b,k=map(int,input().split())
s=set()
if k>(b-a):
  for i in range(a,b+1):
    print(i)
else:
  for i in range(min(k,b-a)):
    s.add(a+i)
    s.add(b-i)
  arr=list(s)
  arr=sorted(arr)
  for i in arr:
    print(i)

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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, m; cin >> n >> m;
    if (m >= n % 500) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int dif(int a, int b) {
    int tmp = abs(a - b);
    return min(tmp, 24-tmp);
}

int main() {
    int n = 0;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i);
    }
    vector<int> cnt_even(100001), cnt_odd(100001);
    for (int i=0; i<n; i+=2) {
        cnt_even.at(a.at(i))++;
    }
    for (int i=1; i<n; i+=2) {
        cnt_odd.at(a.at(i))++;
    }
    vector<pair<int, int>> even(2), odd(2);
    for (int i=1; i<100001; i++) {
        int buf = cnt_even.at(i);
        if (buf > even.at(0).first) {
            even.at(1).first = even.at(0).first;
            even.at(1).second = even.at(0).second;
            even.at(0).first = buf;
            even.at(0).second = i;
        }
        else if (buf > even.at(1).first) {
            even.at(1).first = buf;
            even.at(1).second = i;
        }
    }
    for (int i=1; i<100001; i++) {
        int buf = cnt_odd.at(i);
        if (buf > odd.at(0).first) {
            odd.at(1).first = odd.at(0).first;
            odd.at(1).second = odd.at(0).second;
            odd.at(0).first = buf;
            odd.at(0).second = i;
        }
        else if (buf > odd.at(1).first) {
            odd.at(1).first = buf;
            odd.at(1).second = i;
        }
    }
    if (even.at(0).second != odd.at(0).second) {
        cout << n - even.at(0).first - odd.at(0).first << endl;
    }
    else {
        if (even.at(0).first > odd.at(0).first) {
            cout << n - even.at(0).first - odd.at(1).first << endl;
        }
        else if (even.at(0).first == odd.at(0).first) {
            cout << n - even.at(0).first - max(even.at(1).first, odd.at(1).first) << endl;
        }
        else {
            cout << n - even.at(1).first - odd.at(0).first << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>

int main()
{

    int a,b,c;

    scanf("%d %d %d",&a,&b,&c);
    if(a+b==c || b+c==a || c+a==b){
    printf("Yes\n");

    }

    else{

    printf("No\n");
    }

return 0;
}


Measured memory_bytes: 128
import java.math.BigDecimal;
import java.sql.Array;
import java.util.*;
public class Main {
	public static void main(String[] args){
      	
		Scanner sc = new Scanner(System.in);
		
		BigDecimal bd1 = new BigDecimal(sc.next());
		BigDecimal bd  = new BigDecimal("100");
		BigDecimal bd2 = new BigDecimal("1.01");
		for (int i = 1; i < 10000; i++) {
			bd = bd.multiply(bd2).setScale(0, BigDecimal.ROUND_DOWN);
			if (bd.compareTo(bd1)==1||bd.compareTo(bd1)==0) {
				System.out.println(i);
				break;
			}	
		}
		sc.close();
    }	
		
}

Measured memory_bytes: 27904