akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(llint i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<int>>
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！


//2のn乗を求めるよ！！！
int ni(int n) {
	if (n == 0)return 1;
	int x = ni(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;
}

//フィボナッチ数列のx番目を求めるよ！
llint f(int x, vector<llint> &s) {
	if (x == 0)return 0;
	if (x == 1)return 1;
	if (s[x] != 0)return s[x];
	return  s[x] = f(x - 1, s) + f(x - 2, s);
	
}

//aとｂの最大公約数を求めるよ！
llint gcd(llint a, llint b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}



// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}

//m進数のn桁を全列挙やで
void dfs(int m, int n,hei(int) a) {
	stack<string> st;
	st.push("");
	while (!st.empty()) {
		string now = st.top();
		st.pop();
		if (now.size() == n) cout << now << endl;
		else {
			for (int i = m - 1; i >= 0; i--) {
				string next = now + to_string(i);
				st.push(next);
			}
		}
	}

}
void press(vector<int>& v) { v.erase(unique((v).begin(), (v).end()), v.end()); }

llint min(llint a, llint b) {
	if (a < b)return a;
	return b;
}
llint max(llint a, llint b) {
	if (a < b)swap(a, b);
	return a;
}
llint p(int n) {
	if(n==1)return 1;
	return n * p(n - 1);
}

int main() {
	int n;
	llint y;
	cin >> n >> y;
	rep(i, 0, n+1) {
		rep(j, 0,n-i+1) {
			if(10000*i+5000*j+1000*(n-i-j)==y){
				cout << i << " " << j << " " << n - j - i << endl;
				return 0;
			}
			
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
	return 0;
}

Measured memory_bytes: 384
from collections import namedtuple


Card = namedtuple('Card', 'suit value')
Card.__str__ = lambda self: self.suit + str(self.value)


def printcards(cards):
    print(' '.join([str(c) for c in cards]))


def bubblesort(it, key):
    it = list(it)
    for start_ind in range(len(it)):
        for target_ind in range(len(it)-1, start_ind, -1):
            target_val = key(it[target_ind])
            compare_val = key(it[target_ind-1])
            if target_val < compare_val:
                it[target_ind], it[target_ind-1] = it[target_ind-1], it[target_ind],
    return it


def selectsort(it, key):
    it = list(it)
    for start_ind in range(len(it)):
        min_ind = start_ind
        for target_ind in range(start_ind, len(it)):
            target_val = key(it[target_ind])
            min_val = key(it[min_ind])
            if target_val < min_val:
                min_ind = target_ind
        it[start_ind], it[min_ind] = it[min_ind], it[start_ind]
    return it


if __name__ == '__main__':
    n = int(input())
    cards = [Card(*suit_val) for suit_val in input().split()]
    cards_bub = bubblesort(cards, key=lambda x: x.value)
    cards_slc = selectsort(cards, key=lambda x: x.value)
    printcards(cards_bub)
    print('Stable')
    printcards(cards_slc)
    print('Stable') if cards_bub == cards_slc else print('Not stable')



Measured memory_bytes: 6084
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
int gcd(int a, int b) // assuming a,b >= 1
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    if (a % b == 0)
        return b;
    return gcd(b, a % b);
}
int lcm(int a, int b) // assuming a,b >= 1
{
    return  a * b / gcd(a, b);
}
using namespace std;
#pragma endregion
signed main() {
    int A,B;
    cin >> A >> B;
    if (A == B)
        cout << A * 2;
    else
        cout << max({ A,B }) * 2 - 1;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>

using namespace std;

//Nayeem Shahriar Joy,Applied Physics And Electronic Engineering,University of Rajshahi.




int main(void)

{
    int a,b;

    cin>>a>>b;

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

Measured memory_bytes: 3088
N,M = map(int,input().split())
L = []
for i in range(M):
  L.append(list(map(int,input().split())))
ball = [1]*N
aka = [False]*N
aka[0] = True
for i in range(M):
  if aka[L[i][0]-1] == True:
    aka[L[i][1]-1] = True
  ball[L[i][0]-1] -= 1
  if ball[L[i][0]-1] == 0:
    aka[L[i][0]-1] = False
  ball[L[i][1]-1] += 1
ans = 0
for i in range(N):
  if aka[i] == True:
    ans += 1
print(ans)

Measured memory_bytes: 28964
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  vector<long long> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  if(n == 1) cout << a[0] << endl;
  else {
    long long g = a[0];
    for(int i = 1; i < n; i++) g = g / __gcd(g, a[i]) * a[i];
    cout << g << endl;
    return 0;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll      long long int
#define INF2    ((ll)1e18)
#define pii     pair<ll,ll>
#define x       first
#define y       second
#define vi      vector<ll>
#define pb      push_back
#define sz(a)   (ll)((a).size())
#define all(x)  (x).begin(), (x).end()
#define FIO     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define W(x)    cout<<#x<<": "<<x<<"\n";
#define SzOf(x) sizeof((x))/1048576;
using namespace std;
template<typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& p){os<<"("<<p.x<<","<<p.y<<") "; return os;}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v){for(auto i: v) os<<i<<" "; return os;}

const ll mxN = 1e5;
const ll mod = 1e9+7;

int main(){
    FIO;
	//freopen("input.txt", "r", stdin);
    ll a, b;
    cin>>a>>b;
    if(b>=a) cout<<"unsafe";
    else cout<<"safe";
}




Measured memory_bytes: 3612
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
--import Data.Array
--import Data.Array.Unboxed
import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe

-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
-- templete

calc n es = g (n,0,0,0,0,0) es
g (0,_,_,_,_,_) _ = []
g (n,f,s,t,3,p) es = p : g (n-1,0,0,0,0,0) es
g (n,f,s,t,o,p) ("HIT":es) = g (n,1,f,s,o,p+t) es
g (n,f,s,t,o,p) ("HOMERUN":es) = g (n,0,0,0,o,p+f+s+t+1) es
g (n,f,s,t,o,p) ("OUT":es) = g (n,f,s,t,o+1,p) es

main = do
    (n:es) <- lines <$> getContents
    mapM_ print $ calc (readInt n) es


Measured memory_bytes: 3708
import sys
from math import sqrt

def solve(N):
    def f(a, b):
        return max([ len(str(x)) for x in [a, b] ])

    m = float('inf')
    i = 1
    imax = sqrt(N)
    while i <= imax:
        if N % i == 0:
            m = min(m, f(i, N // i))
        i += 1

    print(m)

def main():
    N = int(input())
    solve(N)

if __name__ == "__main__":
    main()

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

const ll MAXN = 200000;
const ll INF = 1001001001;

ll A, V, B, W, T, ans=0, tmp=0;

signed main(){
    cin >> A >> V >> B >> W >> T;
    if(abs(A-B)<=T*(V-W)) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3592
import java.util.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int count1 = 0;//1010...
		int count2 = 0;//0101...
		for (int i = 0; i < s.length(); i++) {
			if (i % 2 == 0) {
				if (s.charAt(i) == '0') {
					count1++;
				} else {
					count2++;
				}
			} else {
				if (s.charAt(i) == '1') {
					count1++;
				} else {
					count2++;
				}
			}
		}
		System.out.println(Math.min(count1, count2));
	}
}

Measured memory_bytes: 23904
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
using namespace std;
ll n;

vector<ll>get_divs(ll x) {
	vector<ll>divs;
	for(ll i=1LL;i*i<=x;i++) {
		if(x % i == 0) {
			divs.pb(i);

			ll d = x / i;
			if(x % d == 0 && d != i) {
				divs.pb(d);
			}
		}
	}
	return divs;
}

int main() {
	cin>>n;

	vector<ll>v1 = get_divs(n-1);
	vector<ll>v2 = get_divs(n);

//	cout<<"A1\n";

	set<ll> st;
	for(ll i:v1) 
		st.insert(i);

//	cout<<"A2\n";

	for(ll i:v2) {
		ll x = n;
		if(i != 1)
			while(x % i == 0) x /= i;

		if(x % i == 1) st.insert(i);
	}

	cout<<sz(st)-1<<"\n";
}

Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
const ll MAX_N=50;
ll N;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N;
	ll sm=0,sm2=0;
	REP(i,N){
		ll d;
		cin>>d;
		sm+=d;
		sm2+=d*d;
	}
	cout<<(sm*sm-sm2)/2<<endl;
	//cout<<ans*ans<<endl;
}


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

using namespace std;

int main(){
    int n, k;
    double p[200009];
    cin >> n >> k;
    for(int i=0;i<n;i++){
        cin >> p[i];
    }
    double sm=0;
    double mx=0;
    for(int i=0;i<k;i++){
        sm += (p[i]+1.0)/2;
    }
    mx = sm;
    for(int i=k;i<n;i++){
        sm += (p[i]+1.0)/2;
        sm -= (p[i-k]+1.0)/2;
        mx = max(mx, sm);
    }
    
    printf("%.08lf\n", mx);
}

Measured memory_bytes: 1792
#include <stdio.h>

int
main()
{
	for (;;)
	{
		int w, h;
		scanf("%d %d", &h, &w);

		if (w == 0 && h == 0)
			break;

		int x, y;
		for (y = 0; y < h; y++)
		{
			for (x = 0; x < w; x++)
			{
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class Dice{
public:
	array<int,6> F;
	array<map<int,int>,6> R;
	map<int,int> L,C;
	Dice(){
		R[0][1]=2;
		R[0][2]=4;
		R[0][4]=3;
		R[0][3]=1;

		R[1][0]=3;
		R[1][3]=5;
		R[1][5]=2;
		R[1][2]=0;

		R[2][0]=1;
		R[2][1]=5;
		R[2][5]=4;
		R[2][4]=0;

		R[3][0]=4;
		R[3][4]=5;
		R[3][5]=1;
		R[3][1]=0;

		R[4][0]=2;
		R[4][2]=5;
		R[4][5]=3;
		R[4][3]=0;

		R[5][1]=3;
		R[5][3]=4;
		R[5][4]=2;
		R[5][2]=1;
	}
	void Roll(char ch){
		int temp;
		switch(ch){
		case 'W':
			temp = F[0];
			F[0] = F[2];
			F[2] = F[5];
			F[5] = F[3];
			F[3] = temp;
			break;
		case 'E':
			temp = F[0];
			F[0] = F[3];
			F[3] = F[5];
			F[5] = F[2];
			F[2] = temp;
			break;
		case 'N':
			temp = F[0];
			F[0] = F[1];
			F[1] = F[5];
			F[5] = F[4];
			F[4] = temp;
			break;
		default:
			temp = F[0];
			F[0] = F[4];
			F[4] = F[5];
			F[5] = F[1];
			F[1] = temp;
		}
	}
};

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

	auto X=vecin(6);
	Dice D1,D2;
	REP(i,6){
		D1.F[i] = X[i];
		D1.L[X[i]] = i;
		D1.C[X[i]]++;
	}
	X=vecin(6);
	REP(i,6){
		D2.F[i] = X[i];
		D2.L[X[i]] = i;
		D2.C[X[i]]++;
	}
	
	int minDF1 = min_element(ALL(D2.C))->first;
	if(D2.L.find(minDF1)==D2.L.end()){
		out("No");
		return 0;
	}

	switch(minDF1){
	case 1:
		D1.Roll('N');
		break;
	case 2:
		D1.Roll('W');
		break;
	case 3:
		D1.Roll('E');
		break;
	case 4:
		D1.Roll('S');
		break;
	case 5:
		D1.Roll('W');
		D1.Roll('W');
		break;
	}

	int DF1=D1.F[0];
	int DFR1=D1.F[5];

	bool fit = false;
	int DL2;
	for(int i=0;i<6;i++){
		if(D2.F[i]==DF1 && D2.F[5-i]==DFR1){
			fit = true;
			DL2 = i;
			break;
		}
	}
	if(!fit){
		out("No");
		return 0;
	}

	switch(DL2){
	case 1:
		D2.Roll('N');
		break;
	case 2:
		D2.Roll('W');
		break;
	case 3:
		D2.Roll('E');
		break;
	case 4:
		D2.Roll('S');
		break;
	case 5:
		D2.Roll('W');
		D2.Roll('W');
		break;
	}

	array<int,4> DFS1={D1.F[1],D1.F[2],D1.F[4],D1.F[3]};
	array<int,4> DFS2={D2.F[1],D2.F[2],D2.F[4],D2.F[3]};

	bool exist=false;
	int start = 0;
	for(int i=0;i<4;i++){
		if(DFS2[i]==DFS1[0]){
			exist = true;
			start = i;
			break;
		}
	}
	if(!exist){
		out("No");
		return 0;
	}
	for(int i=1;i<4;i++){
		if(DFS1[i]!=DFS2[(start+i)%4]){
			out("No");
			return 0;
		}
	}

	out("Yes");
	return 0;
}



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

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s = r.readLine();
    String[] sl = s.split("[\\s]+");
    int a = Integer.parseInt(sl[0]);
    int b = Integer.parseInt(sl[1]);

    char[][] m = new char[100][100];

    for(int i = 0; i < 50; i++)
    {
      for(int j = 0; j < 100; j++)
      {
        m[i][j] = '.';
      }
    }
    a--;

    for(int i = 50; i < 100; i++)
    {
      for(int j = 0; j < 100; j++)
      {
        m[i][j] = '#';
      }
    }
    b--;

    int x = 0;
    int y = 0;
    while(b > 0)
    {
      m[x][y] = '#';
      y += 2;
      if(y >= 100)
      {
        y -= 100;
        x += 2;
      }
      b--;
    }

    x = 51;
    y = 0;
    while(a > 0)
    {
      m[x][y] = '.';
      y += 2;
      if(y >= 100)
      {
        y -= 100;
        x += 2;
      }
      a--;
    }

    System.out.println("100 100");
    for(int i = 0; i < 100; i++)
    {
      for(int j = 0; j < 100; j++)
      {
        System.out.print(m[i][j]);
      }
      System.out.print('\n');
    }
  }
}

Measured memory_bytes: 23124
#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}};

struct UF{
	int par[100010];
	int r[100010];
	void init(){
		rep(i,100010){
			par[i] = i;
			r[i] = 0;
		}
	}
	int find(int x){
		if(par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	bool same(int x,int y){
		return find(x) == find(y);
	}
	void unit(int x,int y){
		if(same(x,y))return;
		x = find(x);
		y = find(y);
		if(r[x] < r[y]){
			par[x] = y;
		}
		else {
			par[y] = x;
			if(r[x] == r[y]){
				r[x] ++;
			}
		}
	}
}uf;

int color[100010];
vector<int> G[100010];
bool f(int v,int c){
	if(color[v] == c)return true;
	if(color[v] == -c)return false;
	color[v] = c;
	rep(i,G[v].size()){
		if(!f(G[v][i],-c))return false;
	}
	return true;
}

int main(){
	rep(i,100010)color[i] = 0;
	
	int n,m;
	int a[100010],b[100010];
	scanf("%d%d",&n,&m);
	rep(i,m)scanf("%d%d",&a[i],&b[i]);
	
	uf.init();
	rep(i,m){
		uf.unit(a[i],b[i]);
		G[a[i]].pb(b[i]);
		G[b[i]].pb(a[i]);
	}
	
	static ll c[100010] = {},d[100010] = {};
	static bool t[100010];
	rep1(i,n){
		if(uf.find(i) == i){
			t[i] = f(i,1);
		}
	}
	rep1(i,n){
		if(color[i] == 1)c[uf.find(i)] ++;
		else d[uf.find(i)] ++;
	}
	
	ll ret = 0;
	rep1(i,n){
		if(uf.find(i) == i){
			if(!t[i])ret += (c[i]+d[i])*(c[i]+d[i]-1)/2;
			else ret += c[i]*d[i];
		}
	}
	cout << ret-m << endl;
}
	


Measured memory_bytes: 8704
s = input()
p = []

ans = 0
ansp = []

for i in s:
    if i == "A" or i == "C" or i == "G" or i == "T":
        p.append(1)
    else:
        p.append(0)
lenp = len(p)

for ii in range(20):
    for j in range(len(p)):
        if p[j] == 1:
            ans = ans + 1
        else:
            break
    ansp.append(ans)
    ans = 0

    if len(ansp) == lenp:
        break

    del p[0]

print(max(ansp))


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

#define ll   long long

int main() {

    int A,B,C;
    int remain;

    cin >> A >> B >> C;

    if((A-B) >= C){
        remain = 0;
    }else{
        remain = C-(A-B);
    }

    cout << remain << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int x,i;

  for( i = 1 ; 1 ; i ++ )
    {
      scanf("%d" , &x );
      if( x == 0) break;
      printf("Case %d: %d\n" , i , x );
    }
  
  return 0;
}


Measured memory_bytes: 2032
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
from collections import deque, defaultdict
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    S = input()
    T = input()

    nt = len(T)
    ans = INF
    for i in range(0, len(S)-nt+1):
        # print(i, S[i: i+nt])
        ss = S[i: i+nt]
        cnt = 0
        for j, s in enumerate(ss):
            if s == T[j]:
                pass
            else:
                cnt += 1
        ans = min(ans, cnt)
    print(ans)


if __name__ == '__main__':
    solve()



Measured memory_bytes: 9296
N, Q = map(int, input().split())
S = input()
Prob = [[int(_) for _ in input().split()] for _ in range(Q)]
numlist = [0, ]
cnt = 0

for i in range(1, N):
    if S[i-1: i+1] == "AC":
        cnt += 1
    numlist.append(cnt)

for j, k in Prob:
    print(numlist[k-1]-numlist[j-1])

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

int n;
long long ans;
long long l[100];

long long func(int n){
	if(l[n] != 0) return l[n];
	if(n == 0) return l[n] = 2;
	if(n == 1) return l[n] = 1;
	return l[n] = func(n-1) + func(n-2);
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n;
	cout << func(n) << "\n";
}

Measured memory_bytes: 256
<?php

    $n = trim(fgets(STDIN));
    $a = explode(" ", trim(fgets(STDIN)));
    sort($a);
    
    $c = $n * 3 - 2;
    $ans = 0;
    for($i=0;$i<$n;$i++){
        $ans += $a[$c];
        $c -= 2;
    }
    echo $ans;
 
?>

Measured memory_bytes: 36544
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) for (ll i = 0; i < n; ++i)
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = 1e14;
const ll MOD = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // input
    ll N, K;
    cin >> N >> K;
    vector<ll> V(N);
    rep(i, N) { cin >> V[i]; }

    // 実装
    ll ans = 0;
    for (ll l = 0; l <= min(N, K); ++l) { // 右側から取り出す-
        for (ll r = 0; r + l <= min(N, K); ++r) { // 左側から取り出す
            vector<ll> temochi = V;
            temochi.erase(temochi.begin() + l, temochi.end() - r); // 取っていない要素を削る
            sort(ALL(temochi));
            if (K - (l + r) < 0) { // 宝石の操作の限界を超えたらスキップ
                continue;
            }
            ll temp_ans = accumulate(ALL(temochi), 0);
            ll suteru = min(K - (l + r), (ll)temochi.size()); // 捨てる回数
            rep(s, suteru)
            {
                if (temochi[s] < 0) {
                    temp_ans -= temochi[s];
                }
            }
            ans = max(ans, temp_ans);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC diagnostic error "-Wconversion"
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define mp(a, b) make_pair(a, b)
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = (1e9 + 7);
using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
ll dp[100010];
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}
ll digits(ll x){
  ll length = 0;
  while (x > 0){
    x /= 10;
    length++;
  }
  return length;
  if (x == 0) return 0;
}
map<ll, ll> factor(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while (n >= a * a){
    if (n % a == 0){
      ans[a]++;
      n /= a;
    }
    else a++;
  }
  ans[n]++;
  return ans;
}
template<class T> inline bool chmin(T& a, T b){
  if (a > b){
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b){
  if (a < b){
    a = b;
    return true;
  }
  return false;
}

int main(){
  cout << fixed << setprecision(15);
  int ans = 0;
  //string ans = "No";

  int h, w; cin >> h >> w;
  vector<string> table(h);
  rep(i, h) cin >> table[i];

  vector<int> dx = {-1, -1, -1, 0, 0, 1, 1, 1};
  vector<int> dy = {-1, 0, 1, -1, 1, -1, 0, 1};

  rep(i, h){
    rep(j, w){
      if (table[i][j] == '#') continue;
      table[i][j] += 2;
      rep(k, 8){
        if (i + dx[k] < 0 || i + dx[k] >= h || j + dy[k] < 0 || j + dy[k] >= w) continue;
        if (table[i + dx[k]][j + dy[k]] == '#') table[i][j]++;
      }
    }
  }
  rep(i, h) cout << table[i] << endl;

  //cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cassert>
#include <bitset>

//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

//std::cout << std::fixed << std::setprecision(10)
//std::ios::sync_with_stdio(false);
constexpr long long MOD = 1000000007;

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

int main()
{
  long long N, K;
  std::cin >> N >> K;
  long long ans = 0;
  for(long long k = K; k <= N + 1; ++k)
  {
    ans += (N - k + 1) * k + 1;
    ans %= MOD;
  }
  std::cout << ans << std::endl;
  return 0;
}



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

int main(){
    string str;
    int c=0;
    while(cin>>str){
        int t=0;
        for(int i=0;i<str.length();i++){
            if(str[i]>='0'&&str[i]<='9')
                t=t*10+str[i]-'0';
            else{
                c+=t;
                t=0;
            }
        }
        c+=t;
    }
    cout<<c<<endl;
}

Measured memory_bytes: 1184
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
int main() {
	int a, b;
	cin >> a >> b;
	if (a % 2 == 1 && b % 2 == 1) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	return 0;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = l[0], A = l[1], B = l[2];

            Console.WriteLine(N*A < B ? N*A : B);
        }
    }
}


Measured memory_bytes: 13268
#include <stdio.h>
int main(void) {
    int n, i, smallest, ans;
    int p[200001];
    scanf("%d", &n);
    smallest=200002;
    ans=0;
    for (i=0; i<n; i++) {
        scanf("%d", &p[i]);
        if (p[i] < smallest) {
            smallest = p[i];
            ans++;
        }
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;

public class Main {
	private static Scanner s = new Scanner(System.in);

	public static void main(String[] args) {

		StringBuffer sb = new StringBuffer(s.next());
		int q = s.nextInt();

		for(int i=1; i<=q; i++) {
			String action = s.next();
			int a = s.nextInt();
			int b = s.nextInt();

			if(action.equals("print")) {
				System.out.println(sb.toString().substring(a, b+1));

			} else if(action.equals("reverse")) {
				StringBuffer temp = new StringBuffer(sb.toString().substring(a, b+1));
				temp = temp.reverse();
				sb = sb.replace(a, b+1, temp.toString());

			} else {
				StringBuffer p = new StringBuffer(s.next());
				sb = sb.replace(a, b+1, p.toString());

			}
		}
	}

}

Measured memory_bytes: 29260
#include <bits/stdc++.h>
using namespace std;
#define int long long

struct edge {
  int to, cost;
};

signed main() {
  int K;
  cin >> K;
  vector<bool> vis(K, false);
  deque<pair<int, int>> dq;
  dq.push_back({1, 1});

  while (!dq.empty()) {
    pair<int, int> p = dq.front();
    dq.pop_front();
    int x = p.first, d = p.second;

    if (vis[x]) continue;
    vis[x] = true;

    if (x == 0) {
      cout << d << endl;
      return 0;
    }

    dq.push_back({(x + 1) % K, d + 1});
    dq.push_front({(x * 10) % K, d});
  }

  return 0;
}


Measured memory_bytes: 1920
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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




int main() {
    ll n, m;
    cin >> n >> m;
    
    vector<vector<ll>> v(8, vector<ll>(n));
    REP(i, n){
        ll x, y, z;
        cin >> x >> y >> z;
        
        v[0][i] = x + y + z;
        v[1][i] = -x + y + z;
        v[2][i] = x + -y + z;
        v[3][i] = x + y + -z;
        v[4][i] = -x + -y + z;
        v[5][i] = x + -y + -z;
        v[6][i] = -x + y + -z;
        v[7][i] = -x + -y + -z;
    }
    
    REP(i, 8){
        sort(v[i].begin(), v[i].end(), greater<ll>());
    }
    
    ll ans = -INF;
    REP(i, 8){
        ll sum = 0;
        REP(j, m){
            sum += v[i][j];
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
}

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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> S[M];
  int p[M];
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int s;
      cin >> s;
      S[i].push_back(s-1);
    }
  }
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  int ans = 0;
  int Q[M] = {0};
  for (int i = 0; i < (1 << N); i++) {
    for (int i = 0; i < M; i++) {
      Q[i] = 0;
    }
    bool OK = true;
    for (int j = 0; j < M; j++) {
        for (int k = 0; k < S[j].size(); k++) {
          if (i & (1 << S[j][k])) {
              Q[j]++;
          }
        }
        if (Q[j] % 2 != p[j]) {
          OK = false;
        }
      }
    if (OK) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt, gcd
from copy import deepcopy

def main():
    a,b,c,k = map(int, input().split())

    if k <= a:
        print(k)
        sys.exit()
    elif k <= a+b:
        print(a)
        sys.exit()
    else:
        print(a+(k - a - b)*(-1))

if __name__ == "__main__":
    main()

Measured memory_bytes: 9524
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

template<typename T> void push_val(T& pq, long long& sum, long long val)
{
  if (pq.empty()) {
    pq.push(val);
    return;
  }
  long long old_top = pq.top();
  pq.push(val);
  if (old_top == pq.top()) {
    sum += abs(old_top - val);
  } else {
    sum += abs(old_top - val) * (pq.size() - 1);
  }
}

template <typename T> long long pop_val(T& pq, long long& sum)
{
  long long old_top = pq.top();
  pq.pop();
  sum -= abs(old_top - pq.top()) * pq.size();
  return old_top;
}

int main()
{
  long long nqueries;
  std::cin >> nqueries;
  long long bsum = 0;
  priority_queue<long long, std::vector<long long>, std::greater<long long>> larger_half;
  priority_queue<long long, std::vector<long long>, std::less<long long>> smaller_half;
  long long larger_sum = 0;
  long long smaller_sum = 0;
  for (long long i = 0; i < nqueries; i++) {
    long long query;
    std::cin >> query;
    if (query == 1) {
      long long a, b;
      std::cin >> a >> b;
      bsum += b;
      if ((smaller_half.size() + larger_half.size()) % 2 == 0) {
        if (smaller_half.empty()) {
          push_val(smaller_half, smaller_sum, a);
        } else if (larger_half.top() < a) {
          long long old_top = pop_val(larger_half, larger_sum);
          push_val(larger_half, larger_sum, a);
          push_val(smaller_half, smaller_sum, old_top);
        } else {
          push_val(smaller_half, smaller_sum, a);
        }
      } else {
        if (smaller_half.top() <= a) {
          push_val(larger_half, larger_sum, a);
        } else {
          long long old_top = pop_val(smaller_half, smaller_sum);
          push_val(smaller_half, smaller_sum, a);
          push_val(larger_half, larger_sum, old_top);
        }
      }
    } else {
      long long x = smaller_half.top();
      long long fx;
      if (larger_half.empty()) {
        fx = 0;
      } else {
        fx = smaller_sum + larger_sum + abs(x-larger_half.top()) * larger_half.size();
      }
      std::cout << x << ' ' << fx+bsum << '\n';
    }
  }
  return 0;
}


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

int main(){
    long long int n, l, t;
    cin >> n >> l >> t;

    vector<long long int> x(n), y(n), w(n);
    long long int times = 0;
    for(int i=0; i<n; i++){
        cin >> x[i] >> w[i];

        if(w[i] == 1){
            y[i] = (x[i] + t) % l;
            if(w[0] == 2){
                if((l - x[i]) + x[0] <= 2 * t){
                    times += 1;
                    times += (2 * t - ((l - x[i]) + x[0])) / l;
                }
            }
        }
        if(w[i] == 2){
            y[i] = ((x[i] - t) % l + l) % l;
            if(w[0] == 1){
                if(x[i] - x[0] <= 2 * t){
                    times += 1;
                    times += (2 * t - (x[i] - x[0]) -1) / l;
                    // need -1 (!!!)
                    // since when two ants are at the same place at the end,
                    // smaller-number-ant should be in front (in the sense of y[i]),
                    // and therefore one should NOT exchange the number in this case, opposed to the previous case...
                }
            }
        }
    }
    vector<long long int> ys = y;
    sort(ys.begin(),ys.end());
    
    vector<long long int> ans(2*n);
    for(int i=0; i<n; i++){
        ans[i] = ys[i];
        ans[i+n] = ys[i];
    }

    if(w[0] == 1) times %= n;
    if(w[0] == 2) times = ((-times) % n + n) % n;

    int s = 0;
    while(ys[s] != y[0]) s += 1;
    
    //cout << "times : " << times << ", s = " << s << endl;
    if(s - times < 0) s += n;
    for(int i=0; i<n; i++){
        cout << ans[i+s-times] << endl;
    }
    return 0;
}

Measured memory_bytes: 7992
#include <iostream>

using namespace std;

int main(){

    int N, L;
    cin >> N >> L;

    int sum = 0, min = (1 << 30);
    for(int i = 0; i < N; i++){
        sum += L + i;
        if(min > abs(L + i)) min = abs(L + i);
    }

    if(sum < 0) sum += min;
    else sum -= min;

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
int main(){
  int n,k;
  int ans = 0;
  cin >> n >> k;
  for(int left = 0;left < k;left++){
    int sum = 0;
	int right = left;
    int size = 0;
	while(right <= n){
	  if(size != k){
	    right++;
        size++;
      }else{
		sum++;
		size=0;   
      }
    }
    ans+=sum;
  }
  cout << ans << "\n";
}


Measured memory_bytes: 256
s = list(input())
N = len(s)
a = [0] * (10+N)
if(s[0] == '<'): p = 0
else: p = 1
count = 0
count2 = 0
A = 0
start = 0
end = 0

for i in range(N):
    if ((s[i] == '>')& (p == 0)):
        #print('a')
        count2 += 1
        p = 1
        max_ = i
    elif(p == 0):
        #print('b')
        count += 1
    elif(s[i] == '<'):
        #print('c')
        end = i
        if(count > count2):
            count2 -=1
            A += count*(count+1)/2
            A += count2*(count2+1)/2
        else:
            count -=1
            A += count*(count+1)/2
            A += count2*(count2+1)/2
        p = 0
        start = i
        count = 1
        count2 = 0
        max_ = 0
    else:
        #print('d')
        count2 += 1
if(count > count2):
    count2 -=1
    A += count*(count+1)/2
    A += count2*(count2+1)/2
else:
    count -=1
    A += count*(count+1)/2
    A += count2*(count2+1)/2
print(int(A))

Measured memory_bytes: 11312
#include<iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int i=1;
    while(++i<=n){
        int x=i;
        if(x%3==0){
            cout << " " << i;
            continue;
        }
        while(x){
            if(x%10==3){
        cout << " " << i;
        break;
            }
            x/=10;
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3092
n = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))

base = sum(b_list)

bouns = 0
pre = -10
for index, a in enumerate(a_list):
    if index > 0:
        if a - pre == 1:
            bouns += c_list[pre - 1]
    pre = a

print(base + bouns)

Measured memory_bytes: 3064
{-# LANGUAGE BangPatterns #-}
import Data.List
import Data.Maybe
import Data.Function (fix)
import Data.Array (Array, array, (!))
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as BS8
 
getInts :: IO [Int]
getInts = (map parseInt . BS8.words) <$> BS.getLine 
    where parseInt = fst . fromJust . BS8.readInt

data Tree a = Tree (Tree a) a (Tree a)

instance Functor Tree where
    fmap f (Tree l m r) = Tree (fmap f l) (f m) (fmap f r)

index :: Tree a -> Int -> a
index (Tree _ m _) 0 = m
index (Tree l _ r) n = case (n - 1) `divMod` 2 of
    (q,0) -> index l q
    (q,1) -> index r q

nats :: Tree Int
nats = go 0 1
    where go !n !s = Tree (go l s') n (go r s')
            where l = n + s
                  r = l + s
                  s' = s * 2

memo :: (Int -> a) -> (Int -> a)
memo f = index cached
    where cached = fmap f nats

memo2 :: (Int -> Int -> a) -> (Int -> Int -> a)
memo2 f = memo (\x -> memo (f x))

memo3 :: (Int -> Int -> Int -> a) -> (Int -> Int -> Int -> a)
memo3 f = memo (\x -> memo2 (f x))

{- dp example
fibo 0 = 0
fibo 1 = 1
fibo n = mfibo (n-1) + mfibo (n-2)

mfibo = memo f
-}


solve :: (Array Int Int) -> Int -> Integer
solve arr a = f 0 10000 - 1
    where n = length arr
          f idx s
            | idx == n && s == 10000 = 1
            | idx == n = 0
            | otherwise = f' (idx+1) s + f' (idx+1) (s+(arr ! idx))
          f' = memo2 f

main :: IO ()
main = do
    [n, a] <- getInts
    arr <- getInts
    print (solve (array (0,n-1) (zip [0..] $ map (a-) arr)) a)

Measured memory_bytes: 15612
import java.util.Scanner;

public class Main {

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

    Scanner scanner = new Scanner(System.in);
    int a = scanner.nextInt();
    int b = scanner.nextInt();
    int c = scanner.nextInt();
    int x = scanner.nextInt();

    int count = 0;
    int sum1 = 0;
    int sum2 = 0;
    int sum3 = 0;

    // 500円利用する
    for (int i = 0; i <= a; i++) {
      sum1 = i * 500;
      for (int j = 0; j <= b; j++) {
        sum2 = j * 100;
        for (int k = 0; k <= c; k++) {
          sum3 = k * 50;
          if ((sum1 + sum2+ sum3) == x) {
            count++;
          }
        }
      }
    }

    System.out.println(count);

  }

}

Measured memory_bytes: 21972
if __name__ == '__main__':
    s = input()
    ans = 0
    for i in range(len(s)):
        a = s[i]
        h = len(s)//2
        if i <= h-1:
            if a != s[len(s)-i-1]:
                ans = ans+1
        else:
            break
    print(ans)



Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  while (true) {
    int x, y, s;
    cin >> x >> y >> s;
    if (x == 0 && y == 0 && s == 0)
      break;
    int res = 0;
    for (int i = 1; i <= s-1; ++i) {
      int j = 1;
      for (; j <= s-1; ++j) {
        if (j * (100 + x) / 100 + i * (100 + x) / 100 == s)
          break;
      }
      if (j * (100 + x) / 100 + i * (100 + x) / 100 != s)
        continue;
      res = max(res, i * (100 + y) / 100 + j * (100 + y) / 100);
    }
    cout << res << endl;
  }
}



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

struct SCC{
    int V; // # of node
    vector<vector<int>> G,rG;
    vector<int> vs,cmp; // vs:行きかけ順序の並び cmp:どの集合に属するか?
    vector<bool> used;

    SCC(){}
    SCC(int v){ init(v); }

    void init(int v){
        V = v;
        G.assign(V,vector<int>());
        rG.assign(V,vector<int>());
        vs.clear();
        cmp.resize(V);
    }

    void add_edge(int from,int to){
        G[from].emplace_back(to);
        rG[to].emplace_back(from);
    }

    void dfs(int v){
        used[v] = true;
        for(const int& u : G[v]) if(!used[u]) dfs(u);
        vs.push_back(v);
    }

    // @args k 何番目の成分か?
    void rdfs(int v,int k){
        used[v] = true;
        cmp[v] = k;
        for(const int& u : rG[v]) if(!used[u]) rdfs(u,k);
    }

    // @return 強連結成分分解した後の成分の数
    int scc(){
        used.assign(V,false);
        for(int v=0;v<V;v++) if(!used[v]) dfs(v);
        used.assign(V,false);
        int k=0;
        for(int i=vs.size()-1;i>=0;i--){
            if(!used[vs[i]]) rdfs(vs[i],k++);
        }
        return k;
    }

    bool is_same(int i,int j){ return cmp[i] == cmp[j]; }
};

int main(){
    int v,e; cin >> v >> e;
    SCC graph(v);
    for(int i=0;i<e;i++){
        int s,t; cin >> s >> t;
        graph.add_edge(s,t);
    }
    graph.scc();
    int Q; cin >> Q;
    for(int i=0;i<Q;i++){
        int u,v; cin >> u >> v;
        if(graph.is_same(u,v)){
            cout << 1 << endl;
        }else{
            cout << 0 << endl;
        }
    }
}



Measured memory_bytes: 4472
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end());
using namespace std;
#define INF 2000000000
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;

int main(){
		int n; cin>>n;
		string B[n];
		rep(i,n){
			cin>>B[i];
		}
		int m ; cin >> m;
		string R[m];
		rep(i,m){
			cin>>R[i];
		}
		int a = 1 ;
		int ans = 0;
		rep(i,n){
			int a = 1;
				for(int k = i+1; k<n; k++){
					if(B[i]==B[k]){
						a++;
					}
				}
			rep(j,m){
				if(B[i]==R[j]){
					a --;
				}
			}
			ans = max( ans, a );	
				}
		cout<<ans<<endl;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

using ll = long long;
template <ll MOD = 1000000007>
struct Mint{
    ll x;

    Mint() : x(0) {}
    Mint(ll t){
        x = t % MOD;
        if(x < 0) x += MOD;
    }
    
    Mint pow(ll n){
        Mint res(1), t(x);
        while(n > 0){
            if(n & 1) res *= t;
            t *= t;
            n >>= 1;
        }
        return res;
    }

    Mint inv() const {
        ll a = x, b = MOD, u = 1, v = 0, t;
        while(b > 0){
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return Mint(u);
    }

    Mint & operator += (Mint a){
        x += a.x;
        if(x >= MOD) x -= MOD;
        return *this;
    }
    
    Mint & operator -= (Mint a){
        x += MOD - a.x;
        if(x >= MOD) x -= MOD;
        return *this;
    }

    Mint & operator *= (Mint a){
        x = 1LL * x * a.x % MOD;
        return *this;
    }

    Mint & operator /= (Mint a){
        return (*this) *= a.inv();
    }

    Mint operator + (Mint a) const { return Mint(x) += a; }
    Mint operator - (Mint a) const { return Mint(x) -= a; }
    Mint operator * (Mint a) const { return Mint(x) *= a; }
    Mint operator / (Mint a) const { return Mint(x) /= a; }

    Mint operator - () const{ return Mint(-x); }

    bool operator == (const Mint a){ return x == a.x; }
    bool operator != (const Mint a){ return x != a.x; }
    bool operator < (const Mint a){ return x < a.x; }

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

    friend istream & operator >> (istream & is, Mint &a){
        ll t;
        is >> t;
        a = Mint<MOD>(t);
        return (is);
    }
};

map<long long, int> PrimeFactor(long long n){
    map<long long, int> mp;
    for(int i = 2; (long long)i * i <= n; i++){
        while(n % i == 0){
            mp[i]++;
            n /= i;
        }
    }
    if(n != 1) mp[n]++;
    return mp;
}

signed main(){
    int n;
    cin >> n;
    ll a[n];
    REP(i,n){
        cin >> a[i];
    }
    map<ll, int> all;
    REP(i,n){
        map<ll, int> mp = PrimeFactor(a[i]);
        for(auto j : mp){
            all[j.first] = max(all[j.first], j.second);
        }
    }
    Mint<> t = 1;
    for(auto j : all){
        t *= Mint<>(j.first).pow(j.second);
    }
    Mint<> ans = 0;
    REP(i,n){
        ans += t / Mint<>(a[i]);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {

    int n;
    string s;

    char ntoc[9][6] = {".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};

    cin >> n;

    while(n-- && cin >> s) {

        int len = s.size();
        int p = -1;

        for(int i = 0; i < len; ++i) {
            if(p == -1) {
                if(s[i] != '0') {
                    p = (s[i] - '1') * 10;
                }
            } else {
                if(s[i] == '0') {
                    cout << ntoc[p / 10][p % 10];
                    p = -1;
                } else {
                    p = (p / 10 * 10) + (p % 10 + 1) % strlen(ntoc[p / 10]);
                }
            }
        }

        cout << endl;

    }

}

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

int main() {
    int n; cin >> n;
    int taro = 0, hanako = 0;

    for (int i = 0; i < n; i++) {
        string T, H;
        cin >> T >> H;

        if (T > H) {
            taro += 3;
        } else if (T < H) {
            hanako += 3;
        } else {
            taro += 1;
            hanako += 1;
        }
    }

    cout << taro << " " << hanako << endl;

    return 0;
}


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

const int MAXN = 1e5 + 10;
int a[MAXN], b[MAXN], n, mn = 1e9, V;
long long ans;
vector<pair<int, int> > Mat[MAXN];
int dfs(int v, int p, long long w) {
	int cnt = 1;
	bool C = 1;
	for (int i = 0; i < Mat[v].size(); i++) {
		int u = Mat[v][i].first, o = Mat[v][i].second;
		if (u != p) {
			int tmp = dfs(u, v, o);
			if (tmp > n / 2)
				C = 0;
			cnt += tmp;
		}
	}
	if (n - cnt > n / 2)
		C = 0;
	ans += (long long) min(cnt, n - cnt) * 2LL * w;
	if (cnt - (n - cnt) == 0)
		mn = w;
	else if (C)
		V = v;
	return cnt;
}

int main() {
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int a, b, w;
		cin >> a >> b >> w;
		Mat[a].push_back({ b, w });
		Mat[b].push_back({ a, w });
	}
	dfs(1, 1, 0);
	if (mn != 1e9)
		cout << ans - mn;
	else {
		for (int i = 0; i < Mat[V].size(); i++)
			mn = min(Mat[V][i].second, mn);
		cout << ans - mn;
	}
}


Measured memory_bytes: 12416