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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : (x))
#define all(x) x.begin(), x.end() // sort(all(x))
#define sz(x) (int)(x).size()
#define mp(x, y) make_pair((x), (y))

typedef long long ll;

typedef double T;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tiii;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<T> vt;
typedef vector<vt> vvt;
typedef vector<pii> vpi;
typedef vector<pii> vpl;
typedef vector<vpi> graph;
typedef complex<T> Pt;
typedef pair<Pt, Pt> Line;

const ll MOD = 1e9 + 7; // 998244353;
const T EPS = 1e-10;
const int INF = 1e9 + 1;

/* Mod Library */

struct Mod {
    ll x;
    Mod (ll x = 0) : x(x) {}
    Mod operator+(Mod b) { return Mod((x + b.x)%MOD); }
    Mod operator-(Mod b) { return Mod((x - b.x + MOD)%MOD); }
    Mod operator*(Mod b) { return Mod((x * b.x)%MOD); }
    Mod operator/(Mod b) { return *this * inverse(b); }
    Mod operator%(Mod b) { return Mod(x % b.x); }

    static ll euclid(ll a, ll b, ll &x, ll &y) {
        if (b) {
            ll d = euclid(b, a%b, y, x);
            y -= a/b*x;
            return d;
        }
        x = 1; 
        y = 0;
        return a;
    }
    
    Mod inverse(Mod a) {
        ll x, y, g = euclid(a.x, MOD, x, y);
        assert(g == 1);
        return Mod((x + MOD)%MOD);
    }

    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this^(e/2);
        r = r*r;
        return e&1 ? *this*r : r;
    }
};

/* Input Library */
template <typename A, typename B>
istream& operator>>(istream &in, pair<A, B> &p) {
    in >> p.first >> p.second;
    return in;
}

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

template <typename I>
istream& operator>>(istream &in, vector<I> &a) {
    trav(i, a) in >> i;
    return in;
}

template <typename I>
ostream& operator<<(ostream &out, vector<I> &a) {
    rep(i, 0, sz(a)) {
        if (i) out << " ";
        out << a[i];
    }
    return out;
}

void fast_io() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    //cout.tie(0);
    cin.exceptions(cin.failbit);
} 

void solve_test() {
  ll n;
  cin >> n;
  /*
  vector<ll> b(1, 1);
  while (b.back() < 1e17) {
    b.push_back(b.back() * 26 + 1);
  }
  for (int i = b.size() - 1; i >= 0; --i) {
    if (b[i] <= n && i > 0) {
      n -= b[i-1];
      break;
    } 
  }
  */
  string s = "";
  while (n > 0) {
    char c = ((n + 25) % 26) + 'a';
    s = c + s; 
    n = (n - 1) / 26;
  }
  cout << s << endl;
}

void setup() {
}

int main() {
    setup();
    srand(time(0));
    fast_io();
    int t = 1;
    //cin >> t;
    while (t--) {
        solve_test();
    }
}


Measured memory_bytes: 3648
S=list(input())

odd = [S[i] for i in range(len(S)) if i%2==0]

even = [S[i] for i in range(len(S)) if i%2!=0]

flg=0
for s in odd:
    if s=='R' or s=='U' or s=='D':
        flg+=0
    else:
        flg+=1

for s in even:
    if s=='L' or s=='U' or s=='D':
        flg+=0
    else:
        flg+=1

if flg !=0:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

int main(){
    int a,b,x;
    cin>>a>>b>>x;
    double pi=acos(-1);
    double ans;
    if(a*b*0.5<x/a){
        ans = 2.0*(1.0*b/a-1.0*x/a/a/a);
        ans = atan(ans);
        cout<<setprecision(15)<<ans/pi*180.0<<endl;
    }
    else if(a*b*0.5==x/a){
        ans = 45.0;
        cout<<ans<<endl;
    }
    else if(x==a*a*b){
        ans = 90.0;
        cout<<ans<<endl;
    }
    else{
        ans = 2.0*x/a/b/b;
        ans = atan(ans);
        cout<<setprecision(15)<<90-ans/pi*180.0<<endl;
    }
    
}

Measured memory_bytes: 256
as = gets.chomp!.split("/")
as = as.map{|item| item = item.to_i}

if as[0]>2019 then
	puts "TBD"
elsif as[1]>4 then
	puts "TBD"
elsif as[2]>30 then
	puts "TBD"
else
	puts "Heisei"
end

Measured memory_bytes: 1788
import sys
input = sys.stdin.readline

def main():
    S = input().rstrip()
    c = [0] * 2
    ans = [0] * len(S)
    i = j = 0
    while i < len(S):
        c[i&1] += 1
        if i == len(S)-1 or S[i] == 'L' and S[i+1] == 'R':
            ans[j] += c[j&1]
            ans[j+1] += c[(j&1)^1]
            c[0]=c[1]=0
        elif S[i] == 'R' and S[i+1] == 'L':
            ans[i] += c[i&1]
            ans[i+1] += c[(i&1)^1]
            c[0]=c[1]=0
            j = i
        i += 1
    print(*ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 47932
def main():
    N=int(input())
    dp=[[0]*(3) for _ in range(N)]
    dp[0][0],dp[0][1],dp[0][2]=map(int,input().split())
    for i in range(1,N):
        a,b,c=map(int,input().split())
        dp[i][0]=a+max(dp[i-1][1],dp[i-1][2])
        dp[i][1]=b+max(dp[i-1][0],dp[i-1][2])
        dp[i][2]=c+max(dp[i-1][1],dp[i-1][0])
    print(max(dp[-1][0],dp[-1][1],dp[-1][2]))
main()

Measured memory_bytes: 22772
process.stdin.resume();
process.stdin.setEncoding('utf8');

let inputData = '';
let a, b;

process.stdin.on('data', inputStdin => {
  inputData += inputStdin;
});

process.stdin.on('end', _ => {
  inputData = inputData.replace(/\s*$/g, '')
    .split(' ');
  main();
});

function solve() {
  return a * b / 100n;
}

function main() {
  a = BigInt(inputData[0]);
  b = BigInt(inputData[1].replace('.', ''));

  process.stdout.write(solve().toString());
}


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

using namespace std;
#define rep(i,n) for (int i =0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
//int choose2(ll x){
	//	return x*(x-1)/2;}
const int INF = 1001001001;

int main() {
	int N,M;
	int ans = 0;
	cin >> N >> M;
	vector<ll> H(N);
	rep(i, N)cin >> H[i];
	vector<int> A(M);
	vector<int> B(M);
	vector<int> tmp(N);
	rep(i,N)tmp[i] = 0;
	rep(i, M) {
		cin >> A[i] >> B[i];
		if (H[A[i] - 1] == H[B[i] - 1]) {
			tmp[B[i] - 1]++;
			tmp[A[i] - 1]++;
		}
		else if (H[A[i]-1] > H[B[i]-1]) {
			tmp[B[i]-1]++;
		}
		else tmp[A[i]-1]++;
	}
		rep(i,N) {
			if (tmp[i] == 0)ans++;
		}
	
	cout << ans;

	
}

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

int main(){
  int i,j,n,k,m[51],R,data[51][51];
  int rabbit[51][51];
  int p,q;

  for( i = 0; i < 51; i++ ){
    for( j = 0; j < 51; j++ ){
      data[i][j] = 0;
    }
  }
  
  cin >> n >> k;
  for( i = 0; i < k; i++ ){
    cin >> m[i];
    for( j = 0; j < m[i]; j++ ) cin >> rabbit[i][j];
  }

  cin >> R;
  
  while( R > 0 ){
    R--;
    cin >> p >> q;

    for( i = 0; i < k; i++ ){
      int flag = 0;
      int tmp;
      for( j = 0; j < m[i]; j++ ){
	if( flag == 1 && p == rabbit[i][j] ) flag = 2;
	if( flag == 1 && q == rabbit[i][j] ) flag = 2;

	if( flag == 2 ){
	  data[i][j] = 1;
	  data[i][tmp] = 1;
	}
	
	if( p == rabbit[i][j] || q == rabbit[i][j] ){
	  flag = 1;
	  tmp = j;
	}
	
      }
    }
    
  }
  
int cnt = 0;
for( i = 0; i < 51; i++ ){
  for( j = 0; j < 51; j++ ){
    if( data[i][j] == 1 ){
      // cout << "i" << " " << i << " " << "j" << " " << j << endl;
      cnt++;
    }
  }
 }

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

Measured memory_bytes: 1180
a, b, c = map(int, input().split())

#約数
def F(n):
    lis = []
    for i in range(1, n+1):
        if n%i==0: lis.append(i)
    return lis
    
lis = F(c)
lis = [i for i in lis if a<=i<=b]
print(len(lis))


Measured memory_bytes: 5604
n = int(input())
data = []
for i in range(n):data.append(sorted(input()))
data, backup, ans, temp = sorted(data), [], 0, 1
for i in data:
    if backup==i:temp+=1
    else:ans, temp = ans + int(temp*(temp-1)/2), 1
    backup = i
ans+= int(temp*(temp-1)/2)
print(ans)

Measured memory_bytes: 98264
#include <iostream>
#include <cstdlib>
#define MAX 1299710

using namespace std;
int era[ MAX ]; // 0-initialized.
int prime[ MAX ];

int main(){
  for( int i = 2; i < MAX; i++ ){
    if( era[ i ] ){ continue; }
    for( int j = i * 2; j < MAX; j = j + i ){
      era[ j ] = 1;
    }
  }
  int k = 0;
  for( int i = 2; i < MAX; i++ ){
    if( !era[ i ] ){
      prime[ k++ ] = i;
    }
  }
  while( 1 ){
    int n;
    cin >> n;
    if( n == 0 ){ return EXIT_SUCCESS; }
    if( n == 2 ){
      cout << 0 << endl; 
      continue;
    }
    for( int i = 1; i < k; i++ ){
      if( prime[ i ] > n ){
        cout << prime[ i ] - prime[ i - 1 ] << endl;
        break;
      }else if( prime[ i ] == n ){
        cout << 0 << endl;
        break;
      }
    }
  }
}

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

int main(){
    long long N, C;
    std::cin >> N >> C;
    std::vector< long long > X(N);
    std::vector< long long > V(N);
    for(int i=0; i<N; i++){
        std::cin >> X[i] >> V[i];
    }
    
    std::vector< long long > left_best(N+1);
    std::vector< long long > left_b_best(N+1);
    std::vector< long long > right_best(N+1);
    std::vector< long long > right_b_best(N+1);
    long long tmpl = 0, tmpr = 0;
    
    left_best[0] = 0;
    left_b_best[0] = 0;
    right_best[0] = 0;
    right_b_best[0] = 0;
    
    for(int i=0; i<N; i++){
        tmpl = tmpl + V[i];
        if(left_best[i] < tmpl - X[i]){
            left_best[i+1] = tmpl - X[i];
        }else{
            left_best[i+1] = left_best[i];
        }
        
        if(left_b_best[i] < tmpl - 2 * X[i]){
            left_b_best[i+1] = tmpl - 2 * X[i];
        }else{
            left_b_best[i+1] = left_b_best[i];
        }
        
        tmpr = tmpr + V[N - i - 1];
        if(right_best[i] < tmpr - (C - X[N - i - 1])){
            right_best[i+1] = tmpr - (C - X[N - i - 1]);
        }else{
            right_best[i+1] = right_best[i];
        }
        if(right_b_best[i] < tmpr - 2 * (C - X[N - i - 1])){
            right_b_best[i+1] = tmpr - 2 * (C - X[N - i - 1]);
        }else{
            right_b_best[i+1] = right_b_best[i];
        }
        
    }
    
    long long max = 0;
    for(int i=0; i<=N; i++){
        if(max < left_best[i] + right_b_best[N - i]){
            max = left_best[i] + right_b_best[N - i];
        }
        
        if(max < left_b_best[i] + right_best[N - i]){
            max = left_b_best[i] + right_best[N - i];
        }
    }
    
    std::cout << max << std::endl;
    
    return 0;
    
}


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

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

    string s;

    cin >> s;

    int sunny = 0;
    int  rain = 0;

    for(int i=0; i<3; i++)
    {
        if(s[i] == 'R')
        {
            rain++;
        }

    }

    if(rain == 0)
    {
        cout << "0";
    }

    else if(rain == 3)
    {
        cout << "3";
    }

    else if(rain == 2)
    {
        if(s[0] == 'R' && s[2] == 'R')
        {
            cout << "1";
        }

        else
        {
            cout << "2";
        }
    }

    else if(rain == 1)
    {
        cout << "1";
    }

    return 0;

}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;

const LL inf = 0x3f3f3f3f3f3f3f3f;
const int N = 55, M = 110;
struct Edge {
	int to, next;
	LL a, b;
}e[M * 2];
int head[N], idx;
LL c[N], d[N];
LL dis[N][2510];
int n, m, s;

void add(int u, int v, LL a, LL b) {
	e[++idx].to = v;
	e[idx].next = head[u];
	e[idx].a = a;
	e[idx].b = b;
	head[u] = idx;
}

void spfa() {
	queue<PII> q;
	for(int i = 1; i <= n; i++) {
		for(int j = 0; j <= 2500; j++) {
			dis[i][j] = inf;
		}
	}
	dis[1][s] = 0;
	q.push({1, s});
	while(!q.empty()) {
		int u = q.front().first, w = q.front().second; q.pop();
		for(int i = head[u]; i; i = e[i].next) {
			int v = e[i].to;
			LL a = e[i].a, b = e[i].b;
			if(w >= a && dis[v][w - a] > dis[u][w] + b) {
				dis[v][w - a] = dis[u][w] + b;
				q.push({v, w - a});
			}
		}
		if(dis[u][min(w + c[u], (LL)2500)] > dis[u][w] + d[u]) {
			dis[u][min(w + c[u], (LL)2500)] = dis[u][w] + d[u];
			q.push({u, min(w + c[u], (LL)2500)});
		}
	}
}

int main() {
	scanf("%d%d%d", &n, &m, &s);
	s = min(s, 2500);
	while(m--) {
		int u, v;
		LL a, b;
		scanf("%d%d%lld%lld", &u, &v, &a, &b);
		add(u, v, a, b);
		add(v, u, a, b);
	}
	for(int i = 1; i <= n; i++) {
		scanf("%lld %lld", &c[i], &d[i]);
	}
	spfa();
	for(int i = 2; i <= n; i++) {
		LL res = inf;
		for(int j = 0; j <= 2500; j++) res = min(res, dis[i][j]);
		printf("%lld\n", res);
	}
	return 0;
}

Measured memory_bytes: 5060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

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 = 0; i < n-1; i++){
    if(a[i] < a[i+1]){
      ans += a[i+1] - a[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import math
N, H = (int(x) for x in input().split())
list = []
for i in range(N):
    list.append([int(x) for x in input().split()])

joint_list = []
for i in range(N):
    joint_list.append([list[i][0],0])
    joint_list.append([list[i][1],1])

joint_list.sort(key = lambda x: x[0])
total_damage, ans, index = 0, 0, 2*N-1
while total_damage < H:
    if joint_list[index][1] == 1:
        total_damage += joint_list[index][0]
        index -= 1
        ans += 1
    else:
        ans += math.ceil((H - total_damage) / joint_list[index][0])
        break

print(ans)


Measured memory_bytes: 45300
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#define	MOD  1000000007;
#define PI = 3.14159265358979323846;
using namespace std;

string append(string s, char c, int max)
{
	for (int i = 0; i < max; i++)
	{
		s.push_back(c);
	}

	return s;
}
int main()
{
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;

	int A = tx - sx;
	int B = ty - sy;

	string S;

	S = append(S, 'U', B);
	S = append(S, 'R', A);
	S = append(S, 'D', B);
	S = append(S, 'L', A);

	S.push_back('L');
	S = append(S, 'U', B + 1);
	S = append(S, 'R', A + 1);
	S.push_back('D');
	S.push_back('R');
	S = append(S, 'D', B + 1);
	S = append(S, 'L', A + 1);
	S.push_back('U');

	cout << S << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>

using namespace std;

int main(){
    long X;
    cin >> X;

    long happiness = 0;

    happiness = happiness + (X / 500) * 1000;
    X = X % 500;
    
    happiness = happiness + (X / 5) * 5;
    
    cout << happiness << endl;
    return 0;
}


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

#define ll             long long
#define LL             long long
#define gcd(a,b)       __gcd(a, b)
#define lcm(a,b)       a * (b / gcd(a, b))
#define pii            pair<int, int>
#define pll            pair<ll, ll>
#define pil            pair<int, ll>
#define pli            pair<ll, int>
#define vi             vector<int>
#define vl             vector<ll>
#define vii            vector<pii>
#define vll            vector<pll>
#define vil            vector<pil>
#define vli            vector<pli>
#define pb             push_back
#define ppb            pop_back
#define mp             make_pair
#define ff             first
#define ss             second
#define all(v)         v.begin(), v.end()
#define fill(a, b)     memset(a, b, sizeof a)
#define smax(a, b)     a = max(a, b)
#define smin(a, b)     a = min(a, b)
#define sqr(x)         x * x
#define cube(x)        x * x * x
#define endl           '\n'

int in() {
	int n;
	scanf("%d", &n);
	return n;
}

ll Lin() {
	ll n;
	scanf("%lld", &n);
	return n;
}

double Din() {
	double n;
	scanf("%lf", &n);
	return n;
}

const ll inf = (ll)1e17;
const ll mod = (ll)1e9 + 7;
const int N = 1e5 + 5;

int n, k;
int a[N], dp[N];

void bfs() {
    for (int i = 1; i <= k; i++) {
        for (int j = 1; j <= n; j++) {
        	if(i - a[j] >= 0 && !dp[i - a[j]]) dp[i] = 1;
        }
    }
}

int solve() {
	n = in(), k = in();
	for (int i = 1; i <= n; i++) {
		a[i] = in();
	}
	bfs();
	if(dp[k]) printf("First\n");
	else printf("Second\n");
	return 0;
}

int main() {
	int test = 1, tc = 0;
	while (test--) {
		//printf("Case %d: ", ++tc);
		solve();
	}
	return 0;
}


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

void solve(int64_t a, int64_t b, int64_t c, int64_t d)
{
    cout << max(a * c, max(a * d, max(b * c, b * d))) << endl;
}

int main()
{
    int64_t a;
    cin >> a;
    int64_t b;
    cin >> b;
    int64_t c;
    cin >> c;
    int64_t d;
    cin >> d;
    solve(a, b, c, d);
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;
const int MAX_N = 2e5;

int main(){
  int a, b, c, d, e;
  string s, t;
  cin >> s >> t;
  int ans = 0;
  rep(i, s.size()){
    if(s[i] != t[i]) ans++;
  }
  cout << ans <<endl;
}

Measured memory_bytes: 3920
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
map<long long ,long long>dp;
long long solve(long long x)
{
if(dp[x])
{
return dp[x];
}
else
{
return dp[x]=((solve(x/2)+solve((x-1)/2)+solve((x-2)/2)))%mod;
}
}
int main()
{
dp[0]=1;
dp[1]=2;
long long n;
cin>>n;
cout<<solve(n)<<endl;
return 0;
}

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

using namespace std;

int main(void){
  int N,Q,l,r;
  string s;
  int  ans;
  cin >> N >> Q >> s;
  vector<int> a(N,0);

  int b = 0;
  for (int i = 1; i < N; i++){
    if(s[i-1] == 'A' && s[i] =='C')b++;
    a[i] = b;
  }
  for ( int i = 0; i < Q; i++ ){
    cin >> l >> r;
    cout << ( a[r-1] - a[l-1] ) << endl;
  }

}



Measured memory_bytes: 1408
#include<stdio.h>
int main(void){
	
	int k,n,s,t,u,fin1,fin2;
	int n1,n2,n3,n4,n5,n6,n7,n8,n9;
	char c,d,word[76];
	char c1[5],c2[3],c3[3],c4[3],c5[3];
	char c6[3],c7[4],c8[3],c9[4];
	
	fin2=0;
	
	c1[1]='.';
	c1[2]=',';
	c1[3]='!';
	c1[4]='?';
	c1[0]=' ';
	
	c2[1]='a';
	c2[2]='b';
	c2[0]='c';
	
	c3[1]='d';
	c3[2]='e';
	c3[0]='f';
	
	c4[1]='g';
	c4[2]='h';
	c4[0]='i';
	
	c5[1]='j';
	c5[2]='k';
	c5[0]='l';
	
	c6[1]='m';
	c6[2]='n';
	c6[0]='o';
	
	c7[1]='p';
	c7[2]='q';
	c7[3]='r';
	c7[0]='s';
	
	c8[1]='t';
	c8[2]='u';
	c8[0]='v';
	
	c9[1]='w';
	c9[2]='x';
	c9[3]='y';
	c9[0]='z';
	
	scanf("%d\n",&n);
	
	//すべての列
	for(k=1;k<=n;k++){
		
		u=0;
		
		//各列の表示
		for(s=1;s<=76;s++){
			
			n1=0;
			n2=0;
			n3=0;
			n4=0;
			n5=0;
			n6=0;
			n7=0;
			n8=0;
			n9=0;
			
			fin1=0;
			d='*';
			
			//各文字の決定
			for(t=1;t<=1025;t++){
				
				scanf("%c",&c);
				
				if(c=='1'){
					n1++;
					d=c1[(n1)%5];
				}else if(c=='2'){
					n2++;
					d=c2[(n2)%3];
				}else if(c=='3'){
					n3++;
					d=c3[(n3)%3];
				}else if(c=='4'){
					n4++;
					d=c4[(n4)%3];
				}else if(c=='5'){
					n5++;
					d=c5[(n5)%3];
				}else if(c=='6'){
					n6++;
					d=c6[(n6)%3];
				}else if(c=='7'){
					n7++;
					d=c7[(n7)%4];
				}else if(c=='8'){
					n8++;
					d=c8[(n8)%3];
				}else if(c=='9'){
					n9++;
					d=c9[(n9)%4];
				}else if(c=='0'){
					break;
				}else if(c==10){
					fin1=1;
					break;
				}else if(c==0){
					fin2=1;
					break;
				}
				
			}
			
			if(fin1==1){
				
				for(s=1;s<76;s++){
					printf("%c",word[s]);
					if(s==u)break;
				}
				printf("\n");
				break;
			}
			
			if(d=='*'){
				s--;
			}else{
				word[s]=d;
				u++;
			}
		}
		
		if(fin2==1)break;
	}
	return 0;
}


Measured memory_bytes: 2072
#include <stdio.h>
#include <float.h>

int main()
{
    int i;
    long int n, m;
    long int sum = 0;
    long int a[10000];
    scanf("%ld %ld", &n, &m);

    for(i=0; i<m; i++)
    {
        scanf("%ld", &a[i]);
        sum += a[i];
    };
    if(n >= sum) printf("%ld\n", n-sum);
    else printf("-1\n");

    return 0;
}



Measured memory_bytes: 1764
N=int(input())
Llist=list(map(int,input().split()))
cnt=0
for i in range(N):
  for j in range(i,N):
    for k in range(j,N):
      if (Llist[i]!=Llist[j]) and (Llist[j]!=Llist[k]) and (Llist[k]!=Llist[i]) and (Llist[i]+Llist[j]>Llist[k]) and (Llist[j]+Llist[k]>Llist[i]) and (Llist[k]+Llist[i]>Llist[j]) :
        cnt=cnt+1
print(cnt)

Measured memory_bytes: 73768
#![allow(unused_imports)]
use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    s: Chars,
    t: Chars
    }
    let mut ans = 0;
    for i in 0..s.len(){
        if s[i] != t[i] {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4000
n=gets.to_i
q=0
c=0
n.times do
  a=gets.to_i
  if q==1
    c+=(a+1)/2
    if a%2==1||a==0
      q=0
    end
  else
    c+=a/2
    if a%2==1
      q=1
    end
  end
end
puts c


Measured memory_bytes: 2044
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <random>
#include <cassert>
#include <numeric>
#define ll long long int
#define LL unsigned long long
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;

ll y[10000005];

int main() {
    int n, m; cin >> n >> m;
    vector<int> ko(n,1);
    vector<bool> ball(n,false);
    ball[0] = true;

    rep(i,m){
        int x,y;
        cin >> x >> y;
        x--; y--;
        if(ball[x] && ko[x] > 1){
            ball[y] = true;
            ko[y]++;
            ko[x]--;
        }else if(ball[x] && ko[x] == 1){
            ball[y] = true;
            ball[x] = false;
            ko[y]++;
            ko[x]--;
        }else{
            ko[y]++;
            ko[x]--;
        }
    }
    int ans = 0;
    rep(i,n) {
        if(ball[i]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3732
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
//大きな数を扱うときは素因数分解した形で持っておく
// (l/a[i]) = l*powmod(a[i],MOD-2)%MOD;
//auto itr=lower_bound(ALL(a),key) a[itr-a.begin()]
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

const ll MOD = 1000000007;
signed main(){
    int n,m;
    cin >> n >> m;
    int s[n],t[m];
    rep(i,n) cin >> s[i];
    rep(i,m) cin >> t[i];
    //dp[i][j]:=sをi,tをj見たときの部分列の組
    ll dp[n+1][m+1];
    memset(dp,0,sizeof(dp));
    rep(i,n+1){
        rep(j,m+1){
            if(i==0||j==0) dp[i][j]=1;
            else{
                if(s[i-1]==t[j-1]) dp[i][j]+=dp[i-1][j-1];
                dp[i][j]+=(dp[i][j-1]+dp[i-1][j]-dp[i-1][j-1])%MOD;
                if(dp[i][j]<0) dp[i][j]+=MOD;
                dp[i][j]%=MOD;
            }
        }
    }
    cout << dp[n][m] << endl;
}


Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
#define lp(i, x, n) for (int i = x; i < (int)n; ++i)
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()
#define ll unsigned long long
#define N 1000011

int main() {
        int n, t;
        cin >> n>> t;
        pair<int, int> p[101];
        lp (i, 0, n) {
                int a, b;
                cin >> a>> b;
                p[i] = {a, b};
        }
        sort(p, p + n);
        for (int i = 0; i < n; i++) {
                if (p[i].second <= t) {
                        cout << p[i].first;
                        return 0;
                }
        }
        cout << "TLE";
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int main() {
	
	int n;
	cin >> n;
	map<string, int> mp;
	while (n--) {
		string s;
		cin >> s;
		mp[s]++;
	}

	cout << "AC" << " x " << mp["AC"] << endl;
	cout << "WA" << " x " << mp["WA"] << endl;
	cout << "TLE" << " x " << mp["TLE"] << endl;
	cout << "RE" << " x " << mp["RE"] << endl;

}

Measured memory_bytes: 3632
#include <stdio.h>

int main(void){
  int n, d, i, j, ans = 0;
  scanf("%d%d", &n, &d);
  int p[n];
  for(i = 0; i < n; ++i) {
    scanf("%d", &p[i]);
    p[i] -= d;
  }
  for(i = 0; i < n; ++i) if(p[i] > 0) ans += p[i];
  if(ans > 0) printf("%d\n", ans);
  else printf("kusoge\n");
  return 0;
}


Measured memory_bytes: 2756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define TIMES(n) for(int _i_=0; _i_<(n);_i_++)
#define ALL(v) (v).begin(),(v).end()

int main() {

	int N, Q, a, b, p, x;
	cin >> N >> Q;
	VV<> adj(N);
	REP(i, N-1) {
		cin >> a >> b;
		adj[a-1].push_back(b-1);
		adj[b-1].push_back(a-1);
	}
	V<> cnt(N, 0);
	REP(i, Q) {
		cin >> p >> x;
		cnt[p-1] += x;
	}

	V<> oya(N+1);
	V<bool> visited(N,false);
	oya[0] = N;
	cnt.push_back(0);
	stack<int> s;
	visited[0] = true;
	s.push(0);
	while(!s.empty()) {
		int v = s.top(); s.pop();
		cnt[v] += cnt[oya[v]];
		for(int u : adj[v]) if(!visited[u]) {
			visited[u] = true;
			oya[u] = v;
			s.push(u);
		}
	}

	REP(i, N) cout << cnt[i] << " \n"[i==N-1];
	return 0;
}

Measured memory_bytes: 16356
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
const ll dx[4] = {1, 0, -1, 0};
const ll dy[4] = {0, 1, 0, -1};
 
int main() {
    ll h, w;
    cin >> h >> w;
    
    vvl board(h, vl(w));
    rep(i, h) {
        string s;
        cin >> s;
        rep(j, w) {
            if(s[j] == '#') {
                board[i][j] = 1;
            }
        }
    }

    rep(x, h) {
        rep(y, w) {
            if(board[x][y]) {
                ll dame = 1;
                rep(k, 4) {
                    ll nx = x + dx[k];
                    ll ny = y + dy[k];
                    if(nx < 0 || h <= nx || ny < 0 || w <= ny) {   
                        continue;
                    }
                    if(board[nx][ny]) {
                        dame = 0;
                    }
                }
                if(dame) {
                    out("No");
                    re0;
                }
            }
        }
    }
    
    out("Yes");
    re0;
}

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

int main(){
    ll n,m;
    cin >> n >> m;
    if(n>=2 && m>=2){
        cout << (n-2)*(m-2) << endl;
    }
    else if(n==1 && m!= 1){
        cout << (m-2) << endl;
    }
    else if(n!=1 && m ==1){
        cout << (n-2) << endl;
    }
    else{
        cout << 1 << endl;
    }
}

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

typedef long long LL;
#define lowbit(x) ((x)&(-x))
#define INF 0x3f3f3f3f
#define memset(a,b) memset(a,b,sizeof(a))
#define	GE() printf(">----------\n")
#define	IN() freopen("in.txt","r",stdin)
#define	OUT() freopen("out.txt","w",stdout)
const int mod=1000000007;
const int inf=0x3f3f3f3f;
const double pi=acos(-1.0);
const double eps=1e-8;
const int maxn=100005;

int n, data[maxn];

int main()
{
    while(~scanf("%d", &n)){
        for(int i=1;i<=n;i++)scanf("%d", &data[i]);
        sort(data+1, data+n+1);
        data[0]=data[1];
        int ans=0;
        for(int i=1;i<n;i++){
            ans=max(max(ans, abs(data[i]-data[0])), abs(data[i]-data[n]));
        }
        printf("%d\n", ans);
    }
    return 0;
}



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

vector<vector<ll>>dp;
vector<ll>v, w;
ll N, W, amt;

void F(ll idx)
{
	if (idx == N + 1)
	{
		ll ans = 0;
		for (ll i = 0; i <= amt; i++)
		{
			if (dp[N][i] <= W)
				ans = i;
		}
		cout << ans;
		return;
	}
	dp[idx] = dp[idx - 1];
	for (ll i = v[idx - 1]; i <= amt; i++)
		dp[idx][i] = min(dp[idx][i], dp[idx - 1][i - v[idx - 1]] + w[idx - 1]);
	F(idx + 1);
}

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

	cin >> N >> W;
	v = w = vector<ll>(N);
	for (ll i = 0; i < N; i++)
	{
		cin >> w[i] >> v[i];
		amt += v[i];
	}
	dp = vector<vector<ll>>(N + 1, vector<ll>(amt + 1, 1e12));
	dp[0][0] = 0;
	F(1);

	return 0;
}

Measured memory_bytes: 83056
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int A = scan.nextInt();
        int B = scan.nextInt();
        int C = scan.nextInt();
        int answer = Math.min(B/A, C);
        System.out.println(answer);
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int const maxn=2e5+5;
ll const INF=1e18;
ll tmp,b[maxn],res;
int n;
inline ll read(){
   ll s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
ll get(int l,int pos,int r){
    res=min(res,max(max(b[l],b[pos]-b[l]),max(b[r]-b[pos],b[n]-b[r]))-min(min(b[l],b[pos]-b[l]),min(b[r]-b[pos],b[n]-b[r])));
}
void dfs(int pos){
    int l=lower_bound(b+1,b+n+1,b[pos]>>1)-(b+1);
    int r=lower_bound(b+1,b+n+1,b[pos]+((b[n]-b[pos])>>1))-(b+1);
    get(l,pos,r);
    if(l+1<pos) get(l+1,pos,r);
    if(r+1<n) get(l,pos,r+1);
    if(l+1<pos&&r+1<n) get(l+1,pos,r+1);
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        tmp=read();
        b[i]=b[i-1]+tmp;
    }
    res=INF;
    for(int i=2;i<=n-2;i++) dfs(i);
    printf("%lld\n",res);
}


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

int n;
char appear[10000];
int diff_count[10000];

int main(void) {
	int i,j;
	int max;
	int temp;
	while(1) {
		scanf("%d",&n);
		if(n==0)break;
		memset(appear,0,sizeof(appear));
		memset(diff_count,0,sizeof(diff_count));
		for(i=1;i<n;i++) {
			appear[(i*i)%n]++;
		}
		max=(n-1)/2;
		for(i=0;i<n;i++) {
			if(appear[i]) {
				for(j=i+1;j<n;j++) {
					if(appear[j]) {
						temp=j-i;
						if(temp>max)temp=n-temp;
						diff_count[temp]++;
					}
				}
			}
		}
		for(i=1;i<=max;i++)printf("%d\n",diff_count[i]*2);
	}
	return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.IO;

public class Festival{
       public string getFest(string inLn){
           int festInd = inLn.LastIndexOf("FESTIVAL");
	   string retStr = inLn.Substring(0,festInd);
           return retStr;
       }
       
       public static void Main(string[]args){
          Festival f = new Festival();
	  string inStr = Console.ReadLine();
	  string outLn = f.getFest(inStr);
	  Console.WriteLine(outLn);
       }
}

Measured memory_bytes: 13280
n, m = map(int, input().split())
L = []
for i in range(m):
  L.append([i for i in input().split()])
Lcorr = [0 for i in range(n)]
Lflag = [0 for i in range(n)]
Lpena = [0 for i in range(n)]

for i in range(m):
  if Lflag[int(L[i][0])-1] == 0 and L[i][1] == "AC":
    Lcorr[int(L[i][0])-1] += 1
    Lflag[int(L[i][0])-1] = 1
  if int(Lflag[int(L[i][0])-1]) == 0 and L[i][1] == "WA":
    Lpena[int(L[i][0])-1] += 1
    
for j in range(n):
  if Lflag[j] == 0:
    Lpena[j] = 0

corr = sum(Lcorr)
pena = sum(Lpena)
print("{0} {1}".format(corr, pena))

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

namespace CsTest
{
    public class Program
    {
        public static long Lcm(long a, long b)
        {
            return a * b / Gcd(a, b);
        }

        public static long Gcd(long a, long b)
        {
            if (a < b)
                return Gcd(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }

        static void Main(string[] args)
        {
                string[] line = Console.ReadLine().Split(' ');
                long A = long.Parse(line[0])-1, B = long.Parse(line[1]);
                long C = long.Parse(line[2]), D = long.Parse(line[3]);
                long lcm = Lcm(C, D);
                Console.WriteLine((B-A)-((B / C) + (B / D) - (A / C) - (A / D) - (B / lcm) + (A / lcm)));
        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define bg begin()
#define en end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll gcd(ll a,ll b){
    if(a==0)
    return b;
    else
    return gcd(b%a,a);
}
ll sod(ll x){
    ll r,sum=0;
    while(x>0){
        r=x%10;
        x/=10;
        sum+=r;
    }
    return sum;
}
using namespace std;
int main()
{
    ll n;
    cin>>n;
    if(n>=30)
    cout<<"Yes";
    else
    cout<<"No";
    
}

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

int main(){
//    int a;
//    cin >> a;
    stack<int> length;
    vector<int> lanes;
    vector<int> pos;
    vector<int> ponds;
    char grad;
    int total=0;
    int meter=0;
    while(cin >> grad){
        meter++;
        switch(grad){
            case 95:
                if(!length.empty()){
                    length.top()+=1;
                }
                break;
            case 47:
                if(!length.empty()){
                    length.top()+=1;
                    int a=length.top();
//                    mass+=a;
                    total+=a;
                    lanes.push_back(a);
                    pos.push_back(meter);
                    length.pop();
                    if(!length.empty()){
                        length.top()+=a;
                    }else{
//                        mass=0;
                    }
                }
                break;
            case 92:
                if(!length.empty()){
                    length.top()+=1;
                }
                length.push(0);
                break;
        }
    }
//    int mass=0;
//    int cnt=0;
    bool checked=false;
    vector<int> lanes2=lanes;
    for(int i=0;i<lanes.size();i++){
        checked=false;
        for(int j=i+1; j<lanes.size();j++){
            if(pos[i]-(lanes2[i])>pos[j]-(lanes2[j])&& pos[i]<pos[j]){
                lanes[j]+=lanes[i];
                checked=true;
                break;
            }
        }
        if (!checked){
            ponds.push_back(lanes[i]);
        }
    }    
    cout << total << endl;
    cout << ponds.size();
    if(ponds.size()>0){
        cout << " ";
    }
    for (int i=0;i!=ponds.size();i++){
        cout << ponds[i];
        if (i!=ponds.size()-1){
            cout << " ";
        }
    }
    cout << endl;
    return 0;
}


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

int main() {
 int x,y,z;
 cin >>x >>y>>z;
  int total=z;
  int ans = 0;
for (int i=0;i>=0;i++){
  total+=y+z;
  if (total<=x)
   ans ++;
  else 
    break;
}
  cout <<ans ;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
        int a,b,c,res=0;
        cin>>a>>b>>c;
        while(1){
                if(a==b&&b==c)break;
                if(a>b&&a>c){
                        b++;c++;res++;
                }
                else if(b>c&&b>a){a++;c++;res++;}
                else if(c>a&&c>b){a++;b++;res++;}
                else if(a==b){if(a-1==c){a++;b++;res++;}c+=2;res++;}
                else if(a==c){if(a-1==b){a++;c++;res++;}b+=2;res++;}
                else if(b==c){if(b-1==a){b++;c++;res++;}a+=2;res++;}
        }
        cout<<res<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e9
#define endl '\n'
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define FORE(i, a, b) for (int i = (a), e = (b); i < e; ++i)
#define RFORE(i, a, b) for (int i = (b)-1, e = (a); i >= e; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTR(c) sort((c).begin(), (c).end(), greater<int>())
using namespace std;
typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    vector<int> ABC(3);
    for (int i = 0; i < 3; i++) {
        cin >> ABC.at(i);
    }
    SORT(ABC);
    int p11 = ABC.at(2) - ABC.at(1);
    int p2  = 0;
    p2 += (ABC.at(2) - (ABC.at(0) + p11)) / 2;
    if ((ABC.at(1) - ABC.at(0)) % 2 == 1) {
        ++p11;
        ++p2;
    }
    cout << p11 + p2 << endl;
}


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

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


int main(){

    ll n,a,b;
    cin >> n >> a >> b;

    ll p = n/(a+b);
    ll q = n%(a+b);
    ll ans;

    if(q > a) q = a;
    ans = p*a + q;
    cout << ans << endl;



    return 0;
}  

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

using namespace std;

const int MAXN = 110;

int n;

int v[MAXN];

int cost(int k)
{
	int ans = 0;

	for(int i = 1 ; i <= n ; i++)
		ans += (v[i] - k)*(v[i] - k);

	return ans;
}

int main()
{
	scanf("%d",&n);

	int sum = 0;

	for(int i = 1 ; i <= n ; i++)
	{
		scanf("%d",&v[i]);
		sum += v[i];
	}

	float aux = sum;
	aux /= n;

	printf("%d\n",min( cost( floor(aux) ) , cost( ceil(aux) ) ));
}

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

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define pb push_back
#define ll long long
int dp[1000006][2];
int main(int argc, char** argv) {
string s;
cin>>s;
int ans=0;
dp[0][0]=0;
dp[0][1]=1e9;
for(int i=1;i<=s.length();i++)dp[i][0]=dp[i][1]=1e9;
for(int i=0;i<s.length();i++)
{
	int x=s[i]-'0';
	dp[i+1][0]=min(dp[i][0]+x,dp[i][1]+x);
	dp[i+1][1]=min(dp[i][1]+10-x-1,dp[i][0]+10-x+1);
}

cout<<min(dp[s.length()][0],dp[s.length()][1]);
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  
  string arare;
  vector<int> colorCheck(N);
  int color=0;
  
  for(int i=0;i<N;i++){
    cin >> arare;
    if(arare=="P"){
      colorCheck.at(0)=1;
    }
    else if(arare=="W"){
      colorCheck.at(1)=1;
    }
    else if(arare=="G"){
      colorCheck.at(2)=1;
    }
    else if(arare=="Y"){
      colorCheck.at(3)=1;
    }
  }
  
  for(int i=0;i<4;i++){
    color+=colorCheck.at(i);
  }
  
  if (color==3){
    cout << "Three" << endl;
  }
  else if(color==4){
    cout << "Four" << endl;
  }
}
    
    
    
    


Measured memory_bytes: 256
// A.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <string>
#include <stdlib.h>
#include <string.h>
using namespace std;

int main()
{
	int n;
	cin >> n;
	char s[50][60];
	int alpha[50][26];
	for (int i = 0; i < 50; i++) {
		for (int j = 0; j < 60; j++) {
			s[i][j] = 0;
	}
	}
	for (int i = 0; i < 50; i++) {
		for (int j = 0; j < 26; j++) {
			alpha[i][j] = 0;
		}
	}
	for (int i = 0; i < n; i++) { cin >> s[i]; }
	

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < strlen(s[i]); j++) {
			alpha[i][s[i][j] - 97] += 1;
		}
	}
	int smallest[26];
	for (int i = 0; i < 26; i++) {
		smallest[i] = alpha[0][i];
	}
	for (int i = 1; i < n; i++) {
		for (int j = 0; j < 26; j++) {
			if (smallest[j] > alpha[i][j]) smallest[j] = alpha[i][j];
		}
	}
	char c;
	for (int i = 0; i < 26; i++) {
		for (int j = 0; j < smallest[i]; j++) {
			c = i + 97;
			cout << c;
		}
	}
	cout << endl;
	//cin >> n;
    return 0;
}



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

int main(){
  int N;cin>>N;
  vector<bool> A(N);
  for(int i=0;i<N;i++){
    int S,T;cin>>S>>T;
    if(S==T) A.at(i)=true;
    else A.at(i)=false;
  }
  bool can=false;
  for(int i=2;i<N;i++){
    if(A.at(i) && A.at(i-1) && A.at(i-2)){
      can=true;
      break;
    }
  }
  cout<<(can?"Yes":"No")<<endl;
}


Measured memory_bytes: 3620
n = int(input())
alst = []
blst = []
clst = []
for _ in range(n):
  a, b, c = map(int, input().split())
  alst.append(a)
  blst.append(b)
  clst.append(c)

dp = [[0, 0, 0] for _ in range(n)]
dp[0][0] = alst[0]
dp[0][1] = blst[0]
dp[0][2] = clst[0]
for i in range(1, n):
  dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + alst[i]
  dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + blst[i]
  dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + clst[i]
print(max(dp[n - 1]))

Measured memory_bytes: 82520
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;

bool G[51][51];
int N, M;
bool visit[51];

void dfs(int v) {
    visit[v] = true;
    rep(i, N) {
        if (!G[v][i]) continue;
        if (visit[i]) continue;
        dfs(i);
    }
}

int main()
{
    cin >> N >> M;
    vector<int> a(M), b(M);

    rep(i, M) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        G[a[i]][b[i]] = true;
        G[b[i]][a[i]] = true;
    }

    int ans = 0;
    rep(i, M) {
        G[a[i]][b[i]] = false;
        G[b[i]][a[i]] = false;

        rep(i, N) visit[i] = false;

        dfs(0);

        int cnt = 0;
        rep(i, N) {
            if (visit[i]) cnt++;
        }
        if (cnt == N) ans++;

        G[a[i]][b[i]] = true;
        G[b[i]][a[i]] = true;
    }

    cout << M - ans << endl;
    return 0;
}

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

int main(){
  ll n,a,b;cin>>n>>a>>b;
  ll ans=0;
  ans+=(n/(a+b))*a;
  if(n-n/(a+b)*(a+b)>=a){
    ans+=a;
  }
  else
    ans+=n-n/(a+b)*(a+b);
  cout <<ans<<endl;
  return 0;
}

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

#define REP(i, n) for(int i=0;i<int(n);++i)
#define FOR(i, a, b) for(int i=int(a);i<int(b);++i)

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

    int N;
    while (cin >> N, N) {
        vector<vector<int>> costs(N, vector<int>(N+1));
        REP(i, N) REP(j, N+1) cin >> costs[i][j];

        vector<int> dp(1<<N);
        dp[0] = 0;
        FOR(S, 1, 1<<N) {
            int v = INT_MAX;
            REP(i, N) if (S & (1<<i)) {
                int c = costs[i][0];
                REP(j, N) if (~S & (1<<j)) {
                    c = min(c, costs[i][j+1]);
                }
                v = min(v, dp[S^(1<<i)] + c);
            }
            dp[S] = v;
        }
        cout << dp[(1<<N)-1] << '\n';
    }
}

Measured memory_bytes: 3372
#include "iostream"

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	if (a > b) {
		cout << "a > b" << endl;
	}
	else if(a < b){
		cout << "a < b" << endl;
	}
	else if(a == b){
		cout << "a == b" << endl;
	}

    return 0;
}

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

#define ll long long
#define ii pair<int,int>
#define INF 1e18L + 7
#define vi vector<ll>
#define add emplace_back


int main(){ios_base::sync_with_stdio(false);
    // cannot use same element multiple times 
    // O(N*V)
    // d[i] = minimum total weight with total value exactly i
    int n, w;
    cin >> n >> w;
    vi weight(n), value(n);
    
    for(int i=0; i<n; ++i)
        cin >> weight[i] >> value[i];
    
    int sum_value = 0;
    for(int i: value)
        sum_value += i;

    vi dp(sum_value+1, INF);
    dp[0] = 0;

    for(int item=0; item<n; ++item)
        for(int i=sum_value; i>=value[item]; --i)
            dp[i] = min(dp[i], dp[i-value[item]]+weight[item]);
    
    int ans=0;
    for(int i=0; i<sum_value+1; ++i)
        if(dp[i] <= w)
            ans = max(ans, i);
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024