akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
    #define rep(i,a,b) for(int i=(a);i<(b);i++)
    #define per(i,a,b) for(int i=(a);i>(b);i--)
    typedef long long ll;
    using namespace std;

    typedef double dd;

    int main(){
         ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;cin>>s;
    ll x=0;
    for(int i=0;i<s.size();i++){
        x+=(s[i]-'0');
    }
    if(x%9==0){cout<<"Yes"; return 0;}
    else{cout<<"No"; return 0;}
    cout<<x;


        return 0;
    }


Measured memory_bytes: 3776
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        a: usize,
        b: usize,
        k: usize,
    }

    if b<a+k || b-a<2*k {
        for i in a..b+1 {
            println!("{}", i);
        }
    } else {
        for i in a..a+k {
            println!("{}", i);
        }
        for i in b-k+1..b+1 {
            println!("{}", i);
        }
    }

}


Measured memory_bytes: 2180
#include <iostream>

 

using namespace std;

 

int main() 
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if(x-r >= 0 && y-r>=0 && x+r<=w && y+r<=h)
        cout<< "Yes" << endl;
    else
        cout<< "No" << endl;
}


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

typedef long long ll;

int N, W;
int v[100], w[100];
int dp[100][10001];

ll solve(int idx, int value) {
  if (idx >= N)
    return value != 0 ? 1e9 : 0;

  if (dp[idx][value] != -1)
    return dp[idx][value];

  ll ret = solve(idx + 1, value);

  if (v[idx] <= value)
    ret = min(solve(idx + 1, value - v[idx]) + w[idx], ret);

  return dp[idx][value] = ret;
}

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

  int vsum = 0;
  for (int i = 0; i < N; i++) {
    cin >> v[i] >> w[i];
    vsum += v[i];
  }

  memset(dp, -1, sizeof(dp));

  for (int i = vsum; i >= 0; i--) {
    ll ret = solve(0, i);
    if (ret <= W) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 7036
def gcd(a, b) :
    if a < b :
        a,b = b,a
    if b == 0 :
        return a
    else :
        return gcd(b, a%b)


n,k = map(int, input().split())
a = list(map(int, input().split()))

g = a[0]
for i in range(n-1) :
    g = gcd(g,a[i+1])

if (k < max(a) and k%g == 0) or (k in a) :
    print('POSSIBLE')
else :
    print('IMPOSSIBLE')

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

#define y1 aklsdja
#define ii pair < int , int >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define pb push_back
#define t top()
#define fr front()

#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define REP(i , x) for(int i = 0 ; i < x ; ++i)
#define FORD(i , x , n) for(int i = x ; i >= n ; --i)

#define oo 1e17 + 5
#define ll long long
#define int long long
#define pow poww

const int N = 3e3 + 5;
int n , m;
int dp[N][N];
char f1[N] , f2[N];

void tr(int i , int j)
{
    if(i != 0 && j != 0)
    {
        if(dp[i][j] == dp[i - 1][j])
            tr(i - 1 , j);
        else if(dp[i][j] == dp[i][j - 1])
            tr(i , j - 1);
        else
        {
            tr(i - 1 , j - 1);
            cout << f1[i];
        }
    }
}

main()
{
    //freopen("F.inp","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> f1;
    cin >> f2;
    n = strlen(f1);
    m = strlen(f2);
    FORD(i , n , 1)
        f1[i] = f1[i - 1];
    FORD(i , m , 1)
        f2[i] = f2[i - 1];

    FOR(i , 1 , n)
        FOR(j , 1 , m)
        {
            if(f1[i] == f2[j])
                dp[i][j] = dp[i - 1][j - 1] + 1;
            else
                dp[i][j] = max(dp[i - 1][j] , dp[i][j - 1]);
        }
    tr(n , m);
}


Measured memory_bytes: 70784
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string a, b; cin >> a >> b;
	string ans;
	for (int i = 0; i < (a.size() + b.size()); i++) {
		if (i % 2 == 0) {
			ans += a.at(i / 2);
		}
		else {
			ans += b.at(i / 2);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
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() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    ll sum = 0;
    rep(i,n){
        cin >> a[i];
        sum += a[i];
    }
    set<ll> cand;
    for(ll i = 1; i*i <= sum; i++){
        if(sum%i == 0){
            cand.insert(i);
            cand.insert(sum/i);
        }
    }
    ll ans = 1;
    for(ll x : cand){
        ll need = 0;
        vector<ll> r(n);
        rep(i,n) r[i] = a[i] % x;
        sort(r.begin(), r.end());
        ll tot = 0;
        rep(i,n) tot += r[i];
        ll l = n - tot/x;
        rep(i,l) need += r[i];
        if(need <= k) chmax(ans, x);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    a%=b;
    if(a==0) a=b;
    cout<<a<<endl;
  }
  return 0;
}



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

int main(){
  int N;
  cin >> N;
  int ans=0;
  int A=0,B=0,BA=0;
  rep(i,N) {
    string s;
    cin >> s;
    rep(j,s.size()-1) if(s[j]=='A' and s[j+1]=='B') ans++;
    if (s[0]=='B') B++;
    if (s.back()=='A') A++;
    if (s[0]=='B' and s.back()=='A') BA++;
  }
  if(B==BA and A==BA) A--;
  cout << ans+max(0,min(A,B)) << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
str = [''.join(sorted(input())) for i in range(N)]
dict = {}
sum = 0

for i in range(N):
  try:
    dict[str[i]] += 1
  except KeyError:
    dict[str[i]] = 1

for i in dict.values():
  sum += (i*(i-1))//2

print(sum)

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

int main() {
  int h,n,a,b,mx=-1;
  cin >> h >> n;
  vector<int> c(h+1,1e9);
  c[0] = 0;
  for(int i=0;i<n;i++){
    cin >> a >> b;
    for(int j=0;j<h+1;j++) c[j] = min(c[j],(j<a ? 0 : c[j-a])+b);
  }
  cout << c[h] << endl;
}


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

using namespace std;

typedef long long LL;
typedef unsigned int UI;

#define rSort(a) 		sort(a.rbegin(),a.rend())
#define Sort(a) 		sort(a.begin(),a.end())
#define Reverse(a) 		reverse(a.begin(),a.end())
#define Sum(a)  		accumulate(a.begin(), a.end(), 0)
#define REP(i, n) 		for(UI i = 0;i < n;i++)
#define REPR(i, n) 		for(UI i = n;i >= 0;i--)
#define FOR(i, m, n) 	for(UI i = m;i < n;i++)
#define pb(i) 			push_back(i)

#define MOD  			(LL)1e9 + 7;
#define INF  			(LL)1 << 62;

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

	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;

	cin >> n;

	cout << 180 * (n - 2) << endl;

	return 0;

}

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

int n;
int ans = -1;
int a[200005];
bool book[200005];

void init() {
	scanf("%d", &n);
	for(register int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	return ;
}

void solve() {
	book[0] = true;
	for(register int i = 1; i <= n; i++) {
		if(book[a[i]] == true) continue;
		if(book[a[i]-1] == false) continue;
		book[a[i]] = true;
	}
	for(register int i = 1; i <= n; i++) {
		if(book[a[i]] == true) {
			ans = max(ans, a[i]);
		}
	}
	if(ans == -1) printf("-1");
	else printf("%d", n-ans);
	return ;
}

int main() {
	init();
	solve();
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(a) cout << (a) << endl;
#define all(x) (x).begin(),(x).end()

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

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

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    for (ll d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}

int main()
{
    string s,now;
    ll ans = 0;
    cin >> s;
    now = s[0];
    rep1(i, s.size()){
        if(now.size() == 1 && now[0] == s[i]){
            now = s[i];
            now += s[i + 1];
            ++i;
            ++ans;
        }else{
            now = s[i];
            ++ans;
        }
    }
    pf(ans)
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    int i=0, l, j, k, u, n, m;
    string o,s,c,q;

    cin >> s;
    cin >> n;

    l = s.length();
    for(i =0; i < n; i++) {
        cin >> o >> u >> k;
        c = s;
        if (o == "replace") {
            cin >> q;
            for(j = 0;j <= (k - u);j++) {
                c[u+j] = q[j];
            }
            s = c;
        }
        if (o == "reverse") {
            for(j = 0;j <= (k - u);j++) {
                c[u+j] = s[k-j];
            }
            s = c;
        }
        if (o == "print") {
            for(j = 0;j <= (k - u);j++) {
                putchar(c[u+j]);
            }
            cout << endl;
        }
    }
}




Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 9;
vector<int>V[N];
int n;

int Dfs (int u, int fa) {
	int sg = 0; for (auto v : V[u]) if (v != fa) sg ^= Dfs(v, u) + 1; return sg;
}

int main () {
	scanf("%d", &n);
	for (int i = 1, u, v; i < n; ++i) {
		scanf("%d%d", &u, &v);
		V[u].emplace_back(v);
		V[v].emplace_back(u);
	}
	puts(Dfs(1, 0) ? "Alice" : "Bob");
	return 0;
}

Measured memory_bytes: 10368
#include<iostream>
using namespace std;
void check(int b);
void makeCombination();
int rec(int i);
int a[20];
int s[20];
int n;
int b;
int tekitou[1048576];
int c = 0;
int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int n2;
    cin >> n2;
    makeCombination();
    for (int i = 0; i < n2; i++) {
        cin >> b;
        check(b);
    }
    return 0;
}
void check(int b) {
    for (int i = 0; i < c; i++) {
        if (tekitou[i] == b) {
            cout << "yes" << endl;
            return;
        }
    }
    cout << "no" << endl;
    return;
}
void makeCombination() {
    for (int i = 0; i < n; i++) {
        s[i] = 0; //initialize   20 bits row
    }
    rec(0);
}
int rec(int i) {
    if (i == n) { //because 0 indexed
        for (int j = 0; j < n; j++) {
            tekitou[c] += s[j] * a[j];
            //cout << s[j] << " ";
        }
        //cout << endl;
        c++;
        return *s;
    }
    rec(i+1);
    s[i] = 1;
    rec(i+1);
    s[i] = 0;
    return *s;
}


Measured memory_bytes: 7164
import java.io.IOException;
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) throws IOException {
             
       Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      
      if(a<=b && b<=c){
    	 System.out.print(a);
    	 System.out.print(" ");
    	 System.out.print(b);
    	 System.out.print(" ");
    	 System.out.println(c);
      }
      else if(b<=c && c<=a){
    	 System.out.print(b);
     	 System.out.print(" ");
     	 System.out.print(c);
     	 System.out.print(" ");
     	 System.out.println(a);
     	
      }
      else if(c<=a && a<=b){
     	 System.out.print(c);
      	 System.out.print(" ");
      	 System.out.print(a);
      	 System.out.print(" ");
      	 System.out.println(b);
      	
       }
      else if(a<=c && c<=b){
     	 System.out.print(a);
      	 System.out.print(" ");
      	 System.out.print(c);
      	 System.out.print(" ");
      	 System.out.println(b);
      	
       }
      else if(b<=a && a<=c){
     	 System.out.print(b);
      	 System.out.print(" ");
      	 System.out.print(a);
      	 System.out.print(" ");
      	 System.out.println(c);
      	
       }
      else if(c<=b && b<=a){
     	 System.out.print(c);
      	 System.out.print(" ");
      	 System.out.print(b);
      	 System.out.print(" ");
      	 System.out.println(a);
      	
       }
     	 
      } 
   
    }

Measured memory_bytes: 17160
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define eps 1e-9
#define maxp 220000
#define mod 1000000007
#define pi 3.141592653589793238
#define sin(s) scanf("%lld",&s);
#define sout(s) printf("%lld\n",s);
#define in(s) cin>>s
#define in2(a,b) cin>>a>>b
#define in3(a,b,c) cin>>a>>b>>c
#define vll vector<ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl '\n'
#define sp ' '
#define gear_change ios_base::sync_with_stdio(false),cin.tie(0)
#define nfl(i,n) for(i=0;i<n;i++)
#define sfl(i,s,e) for(i=s;i<e;i++)
#define ufl(i,n) for(i=n-1;i>=0;i--)
ll power(ll x,ll y){
    ll ret=1;
    while(y>0){
        if(y&1)
            ret=(ret*x);
        y/=2;
        x=(x*x);
    }
    return ret;
}
vector<ll> divs(ll n){
	vector<ll>ret;
	for(int i=1;i*i<=n;i++){
		if(n%i==0){
			if(i*i==n){
				ret.push_back(i);
			}
			else{
				ret.push_back(i);
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}
void solve(){
	ll n,i;
	cin>>n;
	string ans="";
	while(n>0){
		n--;
		ans+='a'+n%26;
		n/=26;
	}
	reverse(ans.begin(), ans.end());
	cout<<ans<<endl;
}	
int main(){
	gear_change;
	ll test=1;
	// in(test);
	while(test--){
		solve();
	}
}	

Measured memory_bytes: 3652
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
#include<vector>
#include<unordered_map>
#include<cmath>
#include<algorithm>

using namespace std;


int main(void)
{
	int A, B, C;

	cin >> A >> B >> C;

	int ret = 0;

	if (C>A+B+1)
	{
		ret = A+B+1+B;
	}
	else {
		ret = B + C;
	}

	cout << ret;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N; cin >> N;
    vecl A(N); 
    REP(i,N) {
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    int cnt = 0;
    ll total = 0;
    REP(i,N-1) {
        total += A[i];
        if(2*total >= A[i+1]) cnt++;
        else cnt = 0;
    }
    cout << cnt+1 << endl;
}

Measured memory_bytes: 4020
let rec grading g =
  let s = Scanf.scanf "%d %d %d\n" (fun x y z->(x,y,z)) in
  let grade = function
    (-1,-1,-1) -> g
  | (-1,_,_) | (_,-1,_) -> grading (g^"F\n")
  | (m,f,r) when m+f >= 80 -> grading (g^"A\n")
  | (m,f,r) when m+f >= 65 -> grading (g^"B\n")
  | (m,f,r) when m+f >= 50 -> grading (g^"C\n")
  | (m,f,r) when m+f >= 30 && r >= 50 -> grading (g^"C\n")
  | (m,f,r) when m+f >= 30 -> grading (g^"D\n")
  | (m,f,r) when m+f < 30 -> grading (g^"F\n")
  | _ -> ""
  in grade s;;

let () = grading "" |> print_string;;

Measured memory_bytes: 2180
def f(X):
    x = (X + 1) // 2
    y = x % 2

    if X % 2 == 1:
        ans = 1 - y % 2
    else:
        ans = (1 - y % 2) ^ X
    return ans


A, B = map(int, input().split())

print(f(A - 1) ^ f(B))


Measured memory_bytes: 2940
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)

	writer := bufio.NewWriter(os.Stdout)

	r := getNextInt(scanner)
	c := getNextInt(scanner)
	maze := make([][]byte, r)
	steps := make([][]int, r)
	queue := make([][]int, 0)
	for y := 0; y < r; y++ {
		maze[y] = make([]byte, c)
		steps[y] = make([]int, c)
		s := getNextString(scanner)
		for x := 0; x < c; x++ {
			maze[y][x] = s[x]
			if s[x] == '.' {
				continue
			}
			steps[y][x] = 1
			queue = append(queue, []int{
				y, x,
			})
		}
	}

	dy := [4]int{-1, 0, 0, 1}
	dx := [4]int{0, -1, 1, 0}
	ans := -1
	for len(queue) > 0 {
		l := len(queue)
		for q := 0; q < l; q++ {
			p := queue[q]
			for i := 0; i < 4; i++ {
				if p[0]+dy[i] < 0 || p[0]+dy[i] >= r {
					continue
				}
				if p[1]+dx[i] < 0 || p[1]+dx[i] >= c {
					continue
				}
				if maze[p[0]+dy[i]][p[1]+dx[i]] == '#' {
					continue
				}
				if steps[p[0]+dy[i]][p[1]+dx[i]] > 0 {
					continue
				}
				steps[p[0]+dy[i]][p[1]+dx[i]] = 1
				queue = append(queue, []int{
					p[0] + dy[i],
					p[1] + dx[i],
				})
			}
		}
		ans++
		queue = queue[l:]
	}

	fmt.Fprintln(writer, ans)

	writer.Flush()
}


Measured memory_bytes: 119040
import math

def main():
    #n, k = map(int,input().split())
    k = int(input())
    lists = []
    sum = 0
    for i in range(1,k+1):
        for j in range(1,k+1):
            for l in range(1,k+1):
                #print(i,j,l)
                sum = sum + math.gcd(math.gcd(i,j),l)
    print(sum)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9180
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 1e3 + 5;
int main() {
    abdelrahman010
    int n;
    cin >> n;
    map<string , int> mp;
    while(n--) {
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << '\n';
    cout << "WA x " << mp["WA"] << '\n';
    cout << "TLE x " << mp["TLE"] << '\n';
    cout << "RE x " << mp["RE"] << '\n';
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int x[4],y[4];
REP(i,2) cin >> x[i] >> y[i];
int X = x[1]-x[0];
int Y = y[1]-y[0];
x[2] = x[1]-Y;
y[2] = y[1]+X;
x[3] = x[2]-X;
y[3] = y[2]-Y;
REP(i,2) cout << x[i+2] << " " << y[i+2] << " ";
return 0;
}


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

int main() {
  int a,b,k;
  cin>>a>>b>>k;
  int ans,cnt=0;
  for(int i=min(a,b);i>=1;i--){
    if(a%i==0 && b%i==0)
      cnt++;
    if(cnt==k){
      ans=i;
      break;
    }
  }
  
  cout<<ans;
  
  
}

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

struct node {
    int to;
    node *next;
};

node *adj[100000], fm[200000];
int g[100000];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, i;
    cin>>n>>m;
    m+=m;
    int s, t;
    i=0;
    while(i<m) {
        cin>>s>>t;
        fm[i].to=t;
        fm[i].next=adj[s];
        adj[s]=&fm[i];
        i++;
        fm[i].to=s;
        fm[i].next=adj[t];
        adj[t]=&fm[i];
        i++;
    }
    int group=1;
    vector<int> st;
    st.reserve(n);
    for(i=0; i<n; i++) {
        if(g[i]) continue;
        g[i]=group;
        st.push_back(i);
        while(!st.empty()) {
            node *p=adj[st.back()];
            g[st.back()]=group;
            st.pop_back();
            while(p) {
                if(g[p->to]==0) st.push_back(p->to);
                p=p->next;
            }
        }
        group++;
    }
    cin>>n;
    for(int i=0; i<n; i++) {
        cin>>s>>t;
        if(g[s]==g[t]) cout<<"yes\n";
        else cout<<"no\n";
    }
    return 0;
}

Measured memory_bytes: 5488
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
void dfs(ll x,ll count,vector<vector<ll> > &a,std::vector<ll> &c,vector<ll> &ans,std::vector<ll> &vis)
{
	vis[x]=1;
	count+=c[x];
	ans[x]=count;
	for (int i = 0; i < a[x].size(); ++i)
	{
		if(vis[a[x][i]]==0)
			dfs(a[x][i],count,a,c,ans,vis);

	}
}
int main()
{
	ll n,q;
	cin>>n>>q;
	std::vector<ll> c(n,0);
	std::vector<ll> ans(n,0);
	std::vector<ll> vis(n,0);
	std::vector<std::vector<ll> > a(n);
	for (int i = 0; i < n-1; ++i)
	{
		ll x,y;
		cin>>x>>y;
		a[x-1].push_back(y-1);
		a[y-1].push_back(x-1);
	}
	for (int i = 0; i < q; ++i)
	{
		ll p,vl;
		cin>>p>>vl;
		c[p-1]+=vl;
	}
	dfs(0,0,a,c,ans,vis);
	for (int i = 0; i < n; ++i)
	{
		cout<<ans[i]<<" ";
	}
}



Measured memory_bytes: 33664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define ALL(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define COUT(x) cout << (x) << endl
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl

int main() {
    IN(int, k);
    IN(int, x);
    for (int i = (x+1-k); i < x+k; i++) {
        cout << i;
        if (i == x+k-1) {
            cout << endl;
        }else{
            cout << " ";
        }
    }
   
}




Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<sstream>

using namespace std;

int main()
{
	string s;
	cin >> s;
	string x = "";
	x += s.at(0);
	x += s.at(1);
	string y = "";
	y += s.at(2);
	y += s.at(3);
	int xx = stoi(x);
	int yy = stoi(y);
	int a = 0, b = 0, c = 0, d = 0;
	if (1 <= xx && xx <= 12)
	{
		a++;
	}
	else
	{
		b++;
	}
	if (1 <= yy && yy <= 12)
	{
		c++;
	}
	else
	{
		d++;
	}
	if (b == 1 && c == 1)
	{
		cout << "YYMM" << endl;
	}
	else if (a == 1 && d == 1)
	{
		cout << "MMYY" << endl;
	}
	else if (a == 1 && c == 1)
	{
		cout << "AMBIGUOUS" << endl;
	}
	else
	{
		cout << "NA" << endl;
	}

}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        for(;;){
            int a = Integer.parseInt(sc.next());
            String op = sc.next();
            int b = Integer.parseInt(sc.next());
            sc.nextLine();
            if (op.equals("?")) break;
            if (op.equals("+")) System.out.println(a+b);
            if (op.equals("-")) System.out.println(a-b);
            if (op.equals("*")) System.out.println(a*b);
            if (op.equals("/")) System.out.println(a/b);
        }
    }
}


Measured memory_bytes: 26120
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;

ll ketasu(ll a){
   ll num=1;
   while(a/10){
       num++;
       a/=10;
   }
   return num;
}

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

ll kosuu(ll a){
    ll sum=0;
    for(ll i=1;i*i<=a;i++){
        if(a%i==0){
            if(a!=1&&i*i!=a){
            sum+=2;
            }else{
             sum++;   
            }
        }
    }
    return sum;
}




    vector<pair<ll,ll>>p;

ll n,m,q;
vector<ll>a,b,c,d;
ll ans=0;
void dfs(vector<ll> v){
    if(v.size()==n){
      ll sum=0;
      rep(i,q)if(v[b[i]]-v[a[i]]==c[i])sum+=d[i];
      ans=max(ans,sum);
      return;
    }
    if(v.size()==0)v.push_back(1);
    v.push_back(v.back());
    dfs(v);
    while(v.back()<m){
        v.back()++;
        dfs(v);
    }
    return;
}


int main()
{
 cin>>n>>m>>q;
 a=b=c=d=vector<ll>(q);
 rep(i,q){
     cin>>a[i]>>b[i]>>c[i]>>d[i];
     a[i]--;b[i]--;
 }
 dfs(vector<ll>());
 cout<<ans<<endl;
}



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

typedef long long ll;
typedef struct {
	int a,aa,aaa,aaaa;
} an;
int main () {
	int h,w;cin >> h >> w;
	int a[h][w];
	for (int i = 0;i < h;i++) {
		for (int j = 0;j < w;j++) {
			cin >> a[i][j];
		}
	}
	vector<an> anan;
	for (int i = 0;i < h-1;i++) {
		for (int j = 0;j < w;j++) {
			if (a[i][j]%2) {
				a[i][j]--;
				a[i+1][j]++;
				anan.push_back({i+1,j+1,i+2,j+1});
			}
		}
	}
	for (int i = 0;i < w-1;i++) {
		if (a[h-1][i]%2) {
			a[h-1][i]--;
			a[h-1][i+1]++;
			anan.push_back({h,i+1,h,i+2});
		}
	}
	cout << anan.size() << endl;
	for (int i = 0;i < anan.size();i++) {
		cout << anan[i].a << " " << anan[i].aa << " " << anan[i].aaa << " " << anan[i].aaaa << endl;
	}
}

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

int main() {
  int n;
  cin >> n;
  int max = 0, min = 1000;
  for(int i=0; i<n; i++) {
    int a = 0;
    cin >> a;
    if(max < a) max = a;
    if(min > a) min = a;
  }

  cout << max - min << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    int n;
    cin>>n;
    string s;
    cin>>s;
    map<char, int> mp;
    rep(i, n) mp[s[i]]++;
    ll ans = 1;
    int t=0;
    for(auto p : mp){
        ans*=p.second;
        t++;
    }
    if(t!=3) {
        cout<<0<<endl;
        return 0;
    }
    for(int i=1;i<=n;i++){
        rep(j, n){
            int a, b, c;
            a=j;
            b=j+i;
            c=j+2*i;
            if(c>=n) continue;
            if(s[a]!=s[b] && s[b]!=s[c] && s[a]!=s[c]) ans--;
        } 
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3636
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define eb emplace_back
#define pb push_back
#define mp make_pair

template <typename T>
bool uax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template <typename T>
bool uin(T& a, T b) { if (b < a) { a = b; return true; } return false; }

using namespace std;

typedef pair<int, int> pii;
typedef vector<pii> vpi;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef list<int> li;
typedef vector<li> vli;
typedef vector<vpi> vvpi;
typedef long long i64;

const int inf = 1e9;

void solve_a() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  pii a(0, 0);
  for (char c: s) if (c == 'W') a.se += 1; else a.fi += 1;
  pii b(0, 0);
  int ans = n;
  for (char c: s) {
    if (c == 'W') a.se -= 1; else a.fi -= 1;
    uin(ans, a.fi + b.se);
    if (c == 'W') b.se += 1; else b.fi += 1;
  }
  cout << ans << endl;
}

int main() {
  solve_a();
  return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;

int main(){
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    int res = INF;
    for (int i = 0; i <= max(x, y); ++i) {
        int tmp = 0;
        tmp += 2 * i * c;
        if (x >= i){
            tmp += (x-i) * a;
        }
        if (y >= i){
            tmp += (y-i) * b;
        }
        res = min(res, tmp);
    }
    cout << res << endl;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> b(n-1);
    rep(i,n-1) cin >> b[i];

    vector<int> ans(n);
    ans[0] = b[0];
    ans[n-1] = b[n-2];
    rep(i,n-2) {
        ans[i+1] = min(b[i],b[i+1]);
    }
    int sum = 0;
    rep(i,n) sum += ans[i];
    cout << sum << endl;
    return 0;

}

Measured memory_bytes: 256
//  Created by liszt on 2019/07/22.
#include<bits/stdc++.h>
using namespace std;

int gcd(int a,int b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    return gcd(b,a%b);
}
int main(){
    int n; cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    int ans=a[0];
    for(int i=1;i<n;i++)ans=gcd(ans,a[i]);
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

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

using namespace std;

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

    string S;
    cin >> S;
    ll n = S.size();

    set<ll> RL, LR;
    ll now = 0;
    ll gather;
    vector<ll> ans(n, 0);
    Rep (i, n-1) {
        now++;
        if (S[i] == 'R' && S[i+1] == 'L') {
            gather = i;
        } else if (S[i] == 'L' && S[i+1] == 'R') {
            if (now % 2 == 0) {
                ans[gather] = ans[gather+1] = now/2;
            } else {
                if ((i - gather) % 2 == 0) {
                    ans[gather] = now / 2 + 1;
                    ans[gather+1] = now / 2;
                } else {
                    ans[gather] = now / 2;
                    ans[gather+1] = now / 2 + 1;
                }
            }
            now = 0;
        }
    }

    now++;

    if (now % 2 == 0) {
        ans[gather] = ans[gather+1] = now/2;
    } else {
        if ((n - 1 - gather) % 2 == 0) {
            ans[gather] = now / 2 + 1;
            ans[gather+1] = now / 2;
        } else {
            ans[gather] = now / 2;
            ans[gather+1] = now / 2 + 1;
        }
    }

    Rep (i, n) {
        if (i != 0) cout << " ";
        cout << ans[i];
    }

    cout << "\n";


}

Measured memory_bytes: 1488
program main
  implicit none
  character(len=10) :: S
  integer :: n
  integer,allocatable :: A(:)
  integer :: om
  integer :: out
  integer :: i,j
  read(*,*) S
  n=len(trim(S))
  allocate(A(N))
  A=0
  do i = 1,N
     if (S(i:i)=='A') then
        A(i) = 1
     elseif (S(i:i)=='T') then
        A(i) = 1
     elseif (S(i:i)=='C') then
       A(i) = 1 
     elseif (S(i:i)=='G') then
       A(i) = 1 
     end if
  end do

  out=0
  om=0
  do i = 1,N
     do j = N,j,-1
        if ( sum(A(i:j)) == j-i+1 ) then
           out=j-i+1
           if (out > om ) om = out
        end if
     end do
  end do
  write(*,'(i0)') om
  stop
end program main


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7

ll max(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
//aとbの大きい方

ll min(ll a, ll b) {

	if (a < b)return a;
	else return b;

}
//aとbの小さい方

ll avd_i(ll a, ll b) {

	if (a > b)return a - b;
	else return b - a;

}
double avd_d(double a, double b) {

	double re;
	if (a > b)re = a - b;
	else re = b - a;
	return re;

}
//aとbの差の絶対値

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

	}
	ll r;
	r = b%a;
	if (r == 0)return a;
	else return gcd(r, a);

}
//最大公約数

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//最小公倍数

int main() {
	
	int N, A[100005], B[100005], m = 0, ans;

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

		cin >> A[i] >> B[i];
		if (m < A[i]) {

			m = A[i];
			ans = m + B[i];

		}

	}

	cout << ans << endl;

	return 0;
}

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

enum{OFF,ON};
int n,m,v[90][90];
int dy[4]={0,1,0,-1};
int dx[4]={1,0,-1,0};

int rec(int y,int x,int broken)
{
  int M;
  v[y][x]=OFF;
  broken++;
  M=broken;
  for(int i=0;i<4;i++){
    int ny=y+dy[i];
    int nx=x+dx[i];
    if(nx<0 || m<=nx || ny<0 || n<=ny)continue;
    if(v[ny][nx]==OFF)continue;
    M=max(M,rec(ny,nx,broken));
  }
  v[y][x]=ON;
  return M;
}

int main()
{
  int ans;
  while(cin>>m>>n,m|n){
    for(int i=0;i<n;i++)for(int j=0;j<m;j++)cin>>v[i][j];
    ans=0;
    for(int i=0;i<n;i++)for(int j=0;j<m;j++)if(v[i][j])ans=max(ans,rec(i,j,0));
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 0
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn alleven(v: &Vec<i32>) -> bool {
    for i in v.iter() {
        if i % 2 != 0 {
            return false;
        }
    }
    true
}

fn main() {
    let N = read::<i32>();
    let mut v = read_vec::<i32>();

    let mut c = 0;
    while alleven(&v) {
        v = v.into_iter().map(|i| i / 2).collect();
        c += 1;
    }
    println!("{}", c);
}


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

using namespace std;

int dp[3], m[3];

int main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    int n;
    cin >> n;
    cin >> dp[0] >> dp[1] >> dp[2];
    for (int i = 1; i < n; i++) {
        cin >> m[0] >> m[1] >> m[2];
        m[0] += max(dp[1], dp[2]);
        m[1] += max(dp[0], dp[2]);
        m[2] += max(dp[1], dp[0]);
        dp[0] = m[0];
        dp[1] = m[1];
        dp[2] = m[2];
    }
    printf("%d", max(dp[0], max(dp[1], dp[2])));


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

#define max(a,b) ((a>b)?(a):(b))
#define min(a,b) ((a<b)?(a):(b))

int main(){
  int n;
  cin >> n;
  long long a;
  long long ans=0;
  long long renzoku=0;
  for(int i=0;i<n;i++){
    cin >> a;
    ans+=a/2;
    if(a%2){
      renzoku++;
    }
    if(a==0){
      ans+=renzoku/2;
      renzoku=0;
    }
  }
  ans+=renzoku/2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
ans = 0
now = 1
for _ in range(N):
    A = int(input())
    ans+=(A-1)//now
    r = (A-1)%now+1
    if r+1>now:
        if now == 1 or (A-1)//now == 0:
            now = r+1
        
print(ans)

Measured memory_bytes: 43628
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
BC = [list(map(int, input().split())) for _ in range(Q)]

counter = Counter(A)
counter_sum = sum(k*v for k, v in counter.items())

for b, c in BC:
    counter[c] += counter[b]
    counter_sum -= b * counter[b]
    counter_sum += c * counter[b]
    counter[b] = 0
    print(counter_sum)


Measured memory_bytes: 40200
N = gets.to_i
h = gets.split.map(&:to_i)

count = 0
while true do
  ok = false
  h.each_with_index do |h_d, idx|
    if h_d > 0
      break
    end
    if idx == h.size - 1
      ok = true
    end
  end
  if ok
    break
  end

  if h.min > 0
    h.each_index do |idx|
      h[idx] += -1
    end
  else
    start_idx = 0
    end_idx = N - 1

    h.each_index do |idx|
      if h[idx] != 0
        start_idx = idx
        break
      end
    end
    for idx in start_idx + 1 .. N - 1
      if h[idx] == 0
        end_idx = idx - 1
        break
      end
    end
    for idx in start_idx .. end_idx
      h[idx] += -1
    end
  end

  count += 1
end

puts count

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  bool flag = true;
  int cnt = 0;
  REP (i, s.size()) {
    if (i == 0 && s[i] != 'A') flag = false;
    else if (2 <= i && i <= s.size() - 2 && s[i] == 'C') cnt++;
    else if (i != 0 && s[i] - 'A' < 26) flag = false;
  }
  string ans = flag && cnt == 1 ? "AC" : "WA";
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector> 
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>

using namespace std;

int main(){
  long long X;
  cin>>X;
  long long yokin=100;
  int year=0;
  while(yokin<X){
    yokin=yokin*1.01;
    year++;
  }
  cout<<year;


}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define Rep(i,N) for(int i = 0;i < N;i++)
int main(){
  int n,ans=0;
  cin >> n;
  int a,b,c;
  int x,y,z;
  int bit[101][3];
  fill_n(*bit,101*3,0);
  cin >> a;
  Rep(i,a){
    cin >> x;
    bit[x][0]++;
  }
  cin >> b;
  Rep(i,b){
    cin >> y;
    bit[y][1]++;
  }
  cin >> c;
  Rep(i,c){
    cin >> z;
    bit[z][2]++;
  }
  for(int i = 1;i <= n;i++){
    if( bit[i][0] == 0 && bit[i][2] == 1 ) ans++;
    else if( bit[i][1] == 1 && bit[i][2] == 1) ans++;
  }
  cout << ans << endl;
 return (0);
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}



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

    if(A>B)cout << A+(A-1) << endl;
    else if (A==B)cout << A+B << endl;
    else cout << B+B-1 << endl;
}


Measured memory_bytes: 3612
l = (1260-540)+1
while True:
	N,M = map(int,input().split(" "))
	if N == 0 and M == 0:
		break
	T = [[0]*l for _ in range(M)]
	r = int(input())
	for i in range(r):
		t,n,m,s = map(int,input().split(" "))
		if s == 1:
			T[m-1][t-540] += 1
		else:
			T[m-1][t-540] -= 1

	q = int(input())
	used = {}
	for i in range(q):
		t1,t2,m = map(int,input().split(" "))
		if not (m-1) in used:
			T_range = []
			flg = True if T[m-1][0] >= 1 else False
			lb = 0
			for j in range(l-1):
				T[m-1][j+1] += T[m-1][j]
				if flg and T[m-1][j+1] == 0:
					T_range.append((lb+540,j+1+540))
					flg = False
				elif (not flg) and T[m-1][j+1] >= 1:
					flg = True
					lb = (j+1)
			if flg:
				T_range.append((lb+540,1261))
			used[m-1] = T_range

		ans = 0
		for a,b in used[m-1]:
			if not (b < t1 or t2 < a):
				ans += (min(t2,b) - max(t1,a))

		print(ans)



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

int main() {
  int N,M; scanf("%d %d", &N,&M);
  vector<int> cost(M);
  for (int i=0; i<M; i++) scanf("%d", &cost[i]);

  vector<vector<int>> dp(M+1, vector<int>(N+1, 100000001));
  dp[0][0]=0;
  for (int i=1; i<=M; i++) {
    for (int j=0; j<=N; j++) {
      dp[i][j]=dp[i-1][j];
      if(j-cost[i-1]<0) continue;
      dp[i][j]=min(dp[i][j], dp[i][j-cost[i-1]]+1);
    }
  }
  printf("%d\n", dp[M][N]);
  return 0;
}



Measured memory_bytes: 7132
#include<cstdio>
#include<algorithm>
using namespace std;
inline char gc(){
	static char now[1<<16],*S,*T;
	if (T==S){T=(S=now)+fread(now,1,1<<16,stdin);if (T==S) return EOF;}
	return *S++;
}
inline int read(){
	int x=0;char ch=gc();
	while(ch<'0'||ch>'9') ch=gc();
	while(ch<='9'&&ch>='0') x=x*10+ch-'0',ch=gc();
	return x;
}
int n,cnt[110000];
int main(){
	//freopen("arc.in","r",stdin);
	n=read();int max1=0,x=0;for (int i=1;i<=n;++i) x=read(),max1=max(max1,x),cnt[x]++;int kind=0,sum=0;
	for (int i=1;i<=max1;++i) if (cnt[i]) sum+=cnt[i]-1,kind++;
	if (sum%2) kind--; printf("%d",kind);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
using namespace std;
#define ll long long



int main() {
	int n, a[110];
	double ans, hoge = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		hoge += 1.0 / a[i];
	}
	ans = 1.0 / hoge;
	printf("%.8f", ans);
	return 0;
}

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

using namespace std;


int main() {
    int n;
    cin>>n;
    int a[n],b[n],c[n];
    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; ++i) {
        cin>>c[i];
    }
    sort(a,a+n);
    sort(b,b+n);
    sort(c,c+n);
    int count[n];
    long re=0;
    for (int j = 0; j < n; ++j) {
        re+=(lower_bound(a,a+n,b[j])-a)*(c+n-upper_bound(c,c+n,b[j]));
    }
    cout<<re<<endl;
    return 0;
}

Measured memory_bytes: 1408
import sys
import numpy as np
input = sys.stdin.readline
n = int(input())
abn = []
for i in range(n):
  a,b = map(int,input().split())
  abn.append([a+b,a,b])
abn.sort()
cn = np.array(abn)
print(sum(cn[-1::-2,1])-sum(cn[-2::-2,2]))

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

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

    int memo[10][10] = {};
    for (int i = 1; i <= n; ++i) {
        int e = i;
        while (e >= 10)e /= 10;
        ++memo[e][i % 10];
    }

    long long ret = 0;
    for (int i = 0; i <= n; ++i) {
        int e = i;
        while (e >= 10)e /= 10;
        ret += memo[i % 10][e];
    }

    cout << ret << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
import copy
import sys
s = input()
n_s = len(s)
t = input()
n_t = len(t)

chr_firstind = defaultdict(lambda:-1)
chr_nextind = defaultdict(lambda:-1)
i_to_chr_nextind = [0] * n_s
for i in range(n_s-1,-1,-1):
    chr_firstind[s[i]] = i
    i_to_chr_nextind[i] = copy.copy(chr_nextind)
    chr_nextind[s[i]] = i 

first_target = t[0]
previous_ind = chr_firstind[first_target]
if previous_ind == -1:
    print(-1)
    sys.exit()
if n_t == 1:
    print(previous_ind+1)
    sys.exit()
s_used = 0
for i in range(1,n_t):
    # 一つ前のtarget_indを使って、次のtargetのs内でのindexを求める
    d = i_to_chr_nextind[previous_ind]
    next_ind = d[t[i]]
    if next_ind == -1:
        s_used += 1
        next_ind = chr_firstind[t[i]]
        if next_ind == -1:
            print(-1)
            sys.exit()
    previous_ind = next_ind
print(n_s*s_used+previous_ind+1)




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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n, i##_len=(n); i>=0; i--)
#define FOR(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)

//最大公約数 
 ll gcd(ll a,ll b){
 if(b == 0) return a;
 return gcd(b,a%b);
 }

//最小公倍数
 ll lcm(ll a,ll b){
 ll g = gcd(a,b);
 return a / g * b; // Be careful not to overflow  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 







int main(){
int N;
cin >> N;
vector<int>B(N - 1);
REP(i, N - 1) cin >> B.at(i);
vector<int>ans(N);
ans.at(0) = B.at(0);
ans.at(N -1) = B.at(N - 2);

for(int i = 1; i < N - 1; i++){
ans.at(i) = min(B.at(i - 1), B.at(i));
}

int sum = 0;
REP(i, N) sum += ans.at(i);
print(sum);


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
#define int long long
typedef pair<int,int>pii;
const int mxN=1e5+5,M=1e9+7;
//did u check when n=1?
//is mxN correct?
int n,m;
int v[mxN];
int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>m;
    priority_queue<int>fila;
    for(int i=0;i<n;i++){
        int x;cin>>x;
        fila.push(x);
    }
    int ans=0LL;
    while(m>0 && !fila.empty()){
        int x=fila.top();
        fila.pop();
        x/=2;
        if(x>0)fila.push(x);
        m--;
    }
    while(!fila.empty()){
        int x=fila.top();
        ans+=x;
        fila.pop();
    }
    cout<<ans;
    
}


Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <iomanip>
#define ll long long int
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int a, b, c, d, e[102] = {}, f = 0;
    cin >> a >> b >> c >> d;
    for (int i = a; i < b; i++) e[i] = 1;
    for (int i = c; i < d; i++) e[i] += 2;
    fr(102) if (e[i] == 3) f++;
    cout << f;
}


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

using namespace std;


int solve(int n) {
	int div, rest, a, sum;

	sum = 0;
	a = 1;
	while (true) {
		if (n == 0) {
			break;
		}
		div = n / (-10);
		rest = n - div * (-10);
		if (rest < 0) {
			rest = 10 + rest;
			++div;
		}
		sum += rest*a;
		a *= 10;
		n = div;
	}
	return sum;
}

int main() {
	int n;

	while (cin >> n, n) {
		cout << solve(n) << endl;
	}

	return 0;
}



Measured memory_bytes: 3076