akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <climits>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#define _USE_MATH_DEFINES
#include <math.h>
#include <complex>

using namespace std;

#define INF (int)1e8
#define _INF (int)-1e8
#define INFLL (long long)1e15
#define _INFLL (long long)-1e15
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef complex<double> cdouble;
typedef vector<complex<double>> vcd;
typedef vector<vector<complex<double>>> vvcd;

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

int main() {
  int n; cin >> n;
  vi a(n);
  ll sum = 0;
  Loop(i, n) {
    cin >> a[i];
    sum += a[i];
  }
  bitset<2000 * 2000 + 1> dp = 0;
  bitset<2000 * 2000 + 1> dp_buf = 0;
  dp[0] = 1;
  Loop(i, n) {
    dp_buf = dp;
    dp_buf <<= a[i];
    dp |= dp_buf;
  }
  ll mid = (sum % 2 == 1 ? sum / 2 + 1 : sum / 2);
  for (ll j = mid; j < dp.size(); j++) {
    if (dp[j]) {
      cout << j << endl;
      break;
    }
  }
  return 0;
}

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

int main (){
	int n;cin>>n;
	if(n<=9)cout<<n<<endl;
	else if(n<=99)cout<<"9"<<endl;
	else if(n<=999)cout<<n-99+9<<endl;
	else if(n<=9999)cout<<"909"<<endl;
	else if(n<=99999)cout<<n-9999+909<<endl;
	else cout<<"90909"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    string a,b;
    cin>>a;
    cin>>b;
    b.erase(b.length()-1);
    if(a==b){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    
}


Measured memory_bytes: 3596
import java.io.*;

class Main {
	public static void main(String[] args){
		int a, b, d, r;
		double f;
		String buf;
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			buf = br.readLine();
			
			String[] line = buf.split(" ");
			
			a = Integer.parseInt(line[0]);
			b = Integer.parseInt(line[1]);
			
			d = a/b;
			r = a % b;
			f = (double)a/b;
			
			System.out.printf("%d %d %f", d, r, f);
		} catch(Exception e){
		}
		System.out.print("\n");
	}
}
			

Measured memory_bytes: 24604
n = int(input())
if n % 10 == 2 or n % 10 == 4 or n % 10 == 5 or n % 10 == 7 or n % 10 == 9:
  print("hon")
elif n % 10 == 0 or n % 10 == 1 or n % 10 == 6 or n % 10 == 8:
  print("pon")
else:
  print("bon")

Measured memory_bytes: 9180
#include <bits/stdc++.h>
#define rep( i, n ) for( int ( i ) = 0; ( i ) < ( n ); ( i )++ )
#define repr( i, n ) for( int ( i ) = ( n ); ( i ) >= 0; ( i )-- )
#define FOR( i, m, n ) for( int ( i ) = ( m ); ( i ) < ( n ); ( i )++ )
#define all( x ) ( x ).begin(), ( x ).end()
typedef long long lint;
using namespace std;

int main( void ){
	
	int a,b;
	
	cin >> a >> b;
	
	if( b % a == 0){
		cout << a + b;
	}else{
		cout << b - a;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    vector<int> v(3, 0);
    cin >> v[0] >> v[1] >> v[2];
    sort(v.begin(), v.end());
    cout << v[0] + v[1] << endl;    
}


Measured memory_bytes: 3632
#include<iostream>
#include<string.h>
using namespace std;

struct Disc{
	int x,y,r,c;
	Disc(int p_x,int p_y,int p_r,int p_c){
		x=p_x;y=p_y;r=p_r;c=p_c;
	}
	Disc(){};
};

int n;
char memo[1<<24];
bool exist[24];
Disc D[24];
int ans;

bool touch(Disc a,Disc b){
	return (a.r+b.r)*(a.r+b.r)>(a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
}

bool top(int k){
	for(int i=k-1;i>=0;i--){
		if(exist[i]){
			if(touch(D[k],D[i])){return false;}
		}
	}
	return true;
}

int dfs(int bit,int num){
	if(memo[bit]>=0) return memo[bit];
	int res=num;

	for(int i=0;i<n;i++){
		if(exist[i] && top(i)){
			for(int j=i+1;j<n;j++){
				if(exist[j] && top(j) && i!=j && D[i].c==D[j].c){
					exist[i]=false;
					exist[j]=false;
					res=dfs((bit&(~(1<<i)))&(~(1<<j)),num+2);
					exist[i]=true;
					exist[j]=true;
				}
			}
		}
	}
	memo[bit]=res;
	ans=max(ans,res);
	return res;
}

int main()
{
	while(cin>>n && n!=0){
		ans=0;
		memset(memo,-1,sizeof(memo));
		memset(exist,true,sizeof(exist));
		for(int i=0;i<n;i++){
			int x,y,r,c;
			cin>>x>>y>>r>>c;
		D[i]=Disc(x,y,r,c);
		}
		ans=0;
		dfs((1<<24)-1,0);
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
using System;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            var abn = Console.ReadLine().Split(' ');
            var a = long.Parse(abn[0]);
            var b = long.Parse(abn[1]);
            var n = long.Parse(abn[2]);
            long tmp = Math.Clamp(b - 1, 0, n);
            Console.WriteLine(a * tmp / b);
        }
    }
}

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

int main(){
  int n,k,s;
  s = 1;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    if(k>s) s *= 2;
    else s += k;
  }
  cout<<s<<endl;
  return 0;
}
    

Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>
using namespace std;

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

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

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
default_random_engine generator;

void solve();

int main() {
#ifdef LOCAL
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);  
#endif 
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << setprecision(12) << fixed;
    cerr << setprecision(12) << fixed;  

    int tests = 1;
    // cin >> tests;

    while (tests--) {
        solve();
    }

#ifdef LOCAL
    cerr << "Time: " << double(clock()) / CLOCKS_PER_SEC << endl;
#endif
}

// -----------------------------------------------------------------------

void solve() {  
    int n;
    cin >> n;

    if (n <= 2) {
        cout << -1 << endl;
        return;
    }

    vector<vector<string>> res(8);

    res[3] = {
        "aa.",
        "..a",
        "..a"
    };

    res[4] = {
        "aacd", 
        "bbcd",
        "cdaa",
        "cdbb"
    };
    
    res[5] = {
        "aabba", 
        "bxx.a",
        "b..yb",
        "a..yb",
        "abbaa"
    };

    res[7] = {
        ".aabba.",
        "bb...ab",
        "a.xx..b",
        "a...y.a",
        "b...y.a",
        "ba...bb",
        ".abbaa."
    };

    vector<string> ans(n, string(n, '.'));

    if (n % 3 == 0) {
        for (int k = 0; k < n; k += 3) {
            for (int i = 0; i < 3; ++i) {
                for (int j = 0; j < 3; ++j) {
                    ans[k + i][k + j] = res[3][i][j];
                }
            }
        }
    } else {
        int m = n;

        while (m > 7) {
            if ((m - 4) % 3) {
                m -= 4;
                for (int i = 0; i < 4; ++i) {
                    for (int j = 0; j < 4; ++j) {
                        ans[m + i][m + j] = res[4][i][j];
                    }
                }
            } else {
                m -= 5;
                for (int i = 0; i < 5; ++i) {
                    for (int j = 0; j < 5; ++j) {
                        ans[m + i][m + j] = res[5][i][j];
                    }
                }
            }
        }


        for (int i = 0; i < m; ++i) {
            for (int j = 0; j < m; ++j) {
                ans[i][j] = res[m][i][j];
            }
        }
    }

    for (int i = 0; i < n; ++i) {
        cout << ans[i] << endl;
    }





}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n, k;
  	cin>>n>>k;
  	int* h = new int[n];
  	for(int i=0; i<n; i++)
      	cin>>h[i];
  	int* dp = new int[n];
  	dp[0] = 0;
  	for(int i=1; i<n; i++)
    {
      int ans = INT_MAX;
      for(int j=i-1; j>= max(0, i - k); j--) 
      {
        ans = min(dp[j] + abs(h[i] - h[j]), ans);
      }
      dp[i] = ans;
    }
    cout<<dp[n-1]<<endl;
}

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

#define ll long long

int main(){
	int t;
	string s;
	cin >> t;
	int ac = 0, wa = 0, tle = 0, re = 0;
	map <string, int> v;
	while(t--){
		cin >> s;
		if (s == "AC"){
			ac++;
		} else if (s == "WA"){
			wa++;
		} else if (s == "TLE"){
			tle++;
		} else {
			re++;
		}
	}
	cout << "AC x " << ac << "\n";
	cout << "WA x " << wa << "\n";
	cout << "TLE x " << tle << "\n";
	cout << "RE x " << re << "\n";
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

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

	int sum=0;

	rep(i,n){
		int in;
		cin >> in;
		sum+=in%2;
	}

	if(sum%2==0)
		puts("YES");
	else
		puts("NO");


	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int mmath(long long a,long long b,long long c,long long d){
    return llabs(a - c) + llabs(b - d);
}
int ssearch(long long s[],int m)
{
    long long min = s[0];
    int ss = 0;
    int i = 0;
    while(i < m){
        if(min > s[i]){
            min = s[i];
            ss = i;
        }
        i++;
    }
    return ss + 1;
}
/*long long lsearch(long long s[],int m)
{
    long long min = s[0];
    int ss = 0;
    int i = 0;
    while(i < m){
        if(min > s[i]){
            min = s[i];
            ss = i;
        }
        i++;
    }
    return min;
}*/
int main(void)
{
    int i,j;
    int n,m;
    long long a[60] = {0},
                b[60] = {0},
                c[60] = {0},
                d[60] = {0};
    long long man[60][60] = {0};

    
    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++){
        scanf("%lld %lld",&a[i],&b[i]);
    }
    for(i=0;i<m;i++){
        scanf("%lld %lld",&c[i],&d[i]);
    }
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            man[i][j] = mmath(a[i],b[i],c[j],d[j]);
        }
    }

    for(i=0;i<n;i++){
        printf("%d\n",ssearch(man[i],m));
    }
    return 0;


}

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

int main() {
	int n, x;
	int count;
	for (;;) {
		count = 0;
		cin >> n >> x;
		if (n == 0 && x == 0) break;
		for (int i = 1; i <= x / 3 && i <= n - 2; i++) {
			for (int j = n; j >= i + 2; j--) {
				if (x - i - j > i && x - i - j < j) count += 1;
			}
		}
		cout << count << endl;
	}
}


Measured memory_bytes: 3092
# -*- coding: utf-8 -*-

import sys
from collections import defaultdict


def check(graph, edge):
    checked = set()
    checking = set([edge[0]])
    while True:
        for p in checking - checked:
            if p == edge[0] and edge[1] in graph[p]:
                checked.add(p)
                checking.update(graph[p] - set([edge[1]]))
                continue

            if edge[1] in graph[p]:
                return True

            checked.add(p)
            checking.update(graph[p])

        if checking - checked == set():
            break

    return False


def main():
    m, n = [int(x) for x in sys.stdin.readline().rstrip().split(" ")]
    graph = defaultdict(set)
    edges = []
    for line in sys.stdin:
        x, y = line.rstrip().split(" ")
        graph[x].add(y)
        graph[y].add(x)
        edges.append((x, y))

    count = 0
    for edge in edges:
        if not check(graph, edge):
            count += 1

    print(count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
#include <stdio.h>
long long n, k, s, x, y, z;
long long a[200000];
long long c[200000];
int main() {
	scanf("%lld%lld", &n, &k);
	for (long long i = 0; i < n; i++) {
		scanf("%lld", a + i);
		a[i]--;
	}
	y = -1; z = -1;
	while (z < 0) {
		s++;
		c[x]++;
		if (c[x] == 2 && y < 0)y = s;
		if (c[x] == 3 && z < 0)z = s;
		x = a[x];
	}
	if (k > n) {
		k %= (z - y);
		while (k < n)k += (z - y);
	}
	x = 0;
	for (int i = 0; i < k; i++) {
		x = a[x];
	}
	printf("%lld\n", x + 1);
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll d, t, s;
	cin >> d >> t >> s;

	cout << (s*t >= d ? "Yes" : "No") << endl;

}



Measured memory_bytes: 3604
N = int(input())
A, B = [], []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

A = A[::-1]
B = B[::-1]
ans = 0

for a, b in zip(A, B):
    target = ((a+ans)//b + 1) * b
    ans += (target - (ans + a)) % b

print(ans)

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

using namespace std;

int main() {
  string s;
  cin >> s;
  vector<char> v(26);
  for (int i = 0; i < s.size(); i++) {
    if (count(v.begin(), v.end(), s[i])) {
      cout << "no" << '\n';
      return 0;
    }
    v.push_back(s[i]);
  }
  cout << "yes" << '\n';
  return 0;
}


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

using namespace std;

int solve(vector<int> list) {
  int diff_max;
  int tmp_max = 0;
  int tmp_max_num;
  for (int i = 0; i < list.size() - 1; ++i) {
    if (i == 0) {
      for (int j = 1; j < list.size(); ++j) {
        if (list[j] > tmp_max) {
          tmp_max = list[j];
          tmp_max_num = j;
        }
      }
      diff_max = tmp_max - list[i];
    } else if (i < tmp_max_num) {
      int diff = tmp_max - list[i];
      if (diff > diff_max) {
        diff_max = diff;
      }
    } else {
      tmp_max = 0;
      for (int j = i + 1; j < list.size(); ++j) {
        if (list[j] > tmp_max) {
          tmp_max = list[j];
          tmp_max_num = j;
        }
      }
      int diff = tmp_max - list[i];
      if (diff > diff_max) {
        diff_max = diff;
      }
    }
  }
  return diff_max;
}

int main() {
  int N;
  cin >> N;
  vector<int> v;
  for (int i = 0; i < N; ++i) {
    string n;
    cin >> n;
    v.push_back(stoi(n));
  }
  cout << solve(v) << endl;
}

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

#include <iostream>
using namespace std;
int main() {
  int64_t x, y;
  cin >> x >> y;
  bool ans = false;
  for (int64_t i = 0; i <= x; ++i) {
    int64_t j = x - i;
    if (i * 2 + j * 4 == y) {
      ans = true;
      break;
    }
  }
  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using edge = pair<ll, P>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
using Graph = vector<vector<ll>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

ll dp[100005][3];

void Main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N);
    rep(i, N) cin >> A[i] >> B[i] >> C[i];
    rep(i, N) {
        dp[i+1][0] += max(dp[i][1], dp[i][2]) + A[i];
        dp[i+1][1] += max(dp[i][0], dp[i][2]) + B[i];
        dp[i+1][2] += max(dp[i][1], dp[i][0]) + C[i];
    }
    cout << max({dp[N][0], dp[N][1], dp[N][2]}) << endl;

}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


Measured memory_bytes: 3840
#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 = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

class UnionFind {
    public:
        vector<int> rank, p, size;

        UnionFind() {}
        UnionFind(int s) {
            rank.resize(s, 0);
            p.resize(s, 0);
            size.resize(s, 0);
            rep (i, s) init(i);
        }

        void init(int x) {
            p[x] = x;
            rank[x] = 0;
            size[x] = 1;
        }

        bool isSame(int x, int y) {
            return root(x) == root(y);
        }

        void unite(int x, int y) {
            if (isSame(x, y)) return;
            link(root(x), root(y));
        }

        void link(int x, int y) {
            if (rank[x] > rank[y]) {
                p[y] = x;
                size[x] += size[y];
            } else {
                p[x] = y;
                size[y] += size[x];
                if (rank[x] == rank[y]) {
                    rank[y]++;
                }
            }
        }

        int root(int x) {
            if (x != p[x]) {
                p[x] = root(p[x]);
            }
            return p[x];
        }

        int getSize(int x) {
            return size[root(x)];
        }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n, m, q;
    cin >> n >> m;
    UnionFind uf = UnionFind(n);
    rep (i, m) {
        int s, t;
        cin >> s >> t;
        uf.unite(s, t);
    }
    cin >> q;
    rep (i, q) {
        int s, t;
        cin >> s >> t;
        if (uf.isSame(s, t)) cout << "yes" << endl;
        else cout << "no" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 4160
import math
"""
方針
nは１<= n <= 200なので、
あらかじめ200まで全探索 O(n*2*√n)
"""
def countyakusu(n):
    cnt = 0
    for i in range(1,int(math.sqrt(n))+1):
        if n%i == 0:
            cnt += 1
            if i != n//i:
                cnt += 1
    return cnt
result = [0]*200
for i in range(1,201):
    if i%2 != 0:
        result[i-1] = countyakusu(i)

n = int(input())
cnt = 0
for i in range(n):
    if result[i] == 8:cnt += 1
print(cnt)

Measured memory_bytes: 3064
c1=0
c2=0
c3=0
c4=0
a = [list(map(int, input().split())) for _ in range(3)]
for i in range(3):
    for j in range(2):
        if a[i][j] == 1 :
            c1 += 1
        elif a[i][j] == 2 :
            c2 += 1
        elif a[i][j] == 3 :
            c3 += 1
        else:
            c4 += 1
if max(c1,c2,c3,c4) > 2:
    print('NO')
else:
    print('YES')

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
int main(void){
	char str[1001],tmp[1001],p[1001],command[10];
	int q,a,b,i,j;

	scanf("%s %d",str,&q);
	for(j=0;j<q;j++){
		scanf("%s %d %d",command,&a,&b);
		if(!strcmp(command,"print")){
			for(i=a;i<=b;i++) printf("%c",str[i]);
			printf("\n");
		}
		if(!strcmp(command,"reverse")){
			strcpy(tmp,str);
			for(i=a;i<=b;i++) str[i]=tmp[b-(i-a)];
		}
		if(!strcmp(command,"replace")){
			scanf("%s",p);
			for(i=a;i<=b;i++) str[i]=p[i-a];
		}
	}
	return 0;
}

Measured memory_bytes: 588
/// Kazuki Hoshino


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple

int n, sum[1010], sumr[1010], a[3][1010], ans ;


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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);


cin >> n;
rep(j, 1, 2)
rep(i, 1, n){
cin >> a[j][i];

}

rep(i, 1, n){
sum[i]+=sum[i-1]+a[1][i];
}

rep1(i, n, 1){
sumr[i]+=sumr[i+1]+a[2][i];
}

rep(i, 1, n){

ans = max(ans, sum[i]+sumr[i]);

}
cout << ans << endl;

return 0;}
///.... Maria Otonashi


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001


int main(){
  cin.sync_with_stdio(false);
  while(true) {
    int n;
    cin >> n;
    if (n == 0) break;
    int c[27] = {};
    int f = 0, s = 26, flag = 0;
    char tmp, ans;
    cin >> ans;
    c[ans - 'A']++;
    f = ans - 'A';
    if (n > 1) {
      repl(i, 1, n) {
        cin >> tmp;
        c[tmp - 'A']++;
        if (c[tmp - 'A'] > c[f]) {
          s = f;
          f = tmp - 'A';
        } else if (tmp- 'A' != f && c[tmp - 'A'] > c[s]) {
          s = tmp - 'A';
        }

        if (flag == 0 && c[s] + n - 1 - i < c[f]) {
          ans = f + 'A';
          flag = i + 1;
        }
      }

      if (flag == 0) {
        print("TIE");
      } else {
        cout << ans << " " << flag << endl;
      }
    } else {
      cout << ans << " " << 1 << endl;
    }
  }

  return 0;
}

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

int main()
{
  int n,k;
  cin>>n>>k;
  long long int sum=0;
  multiset<int> s;
  while(n--)
  {
    int t;
    cin>>t;
    sum+=t;
    s.insert(t);
    if(s.size()>k)
    {
      s.erase(s.begin());
    }
  }
  for(auto i:s)
    sum-=i;
  cout<<sum;
  return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <map>
typedef long long ll;
using namespace std;

int main() {
    int n, k, x;
    cin >> n >> k;
    int mid = k/2;
    int ans=0;
    for(int i=0; i<n; i++) {
        cin >> x;
        if(x<=mid) ans += x*2; // use A
        else ans += (k-x)*2; // use B
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n";
#define ll long long
ll MOD = 10e9 + 7;

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if ( max(a,b) >= c && min(a,b) <= c) {
      OUT("Yes");
    }
    else OUT("No");
    return 0;
}

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

int main() {
  int N,T; cin >> N >> T;
  int c[1000],t[1000];
  int mincost = 100000000;
  bool f = false;
  for ( int i = 0; i < N; i++ ) {
    cin >> c[i] >> t[i];
    if ( T >= t[i] ){
      mincost = min(mincost,c[i]);
      f = true;
    }
  }

  if ( f ) cout << mincost << endl;
  else cout << "TLE" << endl;
  return 0;
}


Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const S = arg[1].split("");
    
    let leftCnt  = 0;
    let rightCnt = 0;
    
    for(let i in S) {
        if(S[i] === ")" && leftCnt) {
            leftCnt--;
        } else if (S[i] === ")") {
            rightCnt++;
        }
        
        if(S[i] === "(") {
            leftCnt++;
        }
    }
    
    for(let i=0; i<rightCnt; i++) {
        S.unshift("(");
    }
    
    for(let i=0; i<leftCnt; i++) {
        S.push(")");
    }
    
    console.log(S.join(""));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 9420
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int N;
ll r[MAX_N];

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

  r[0] = 2, r[1] = 1;
  for (int i = 2; i < 90; i++) {
    r[i] = r[i - 1] + r[i - 2];
  }

  cout << r[N] << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = [list(str(input())) for i in range(N)]

AC = 0
WA = 0
TLE = 0
RE = 0
for i in range(N):
    if S[i][0] == 'A':
        AC += 1
    elif S[i][0] == 'W':
        WA += 1
    elif S[i][0] == 'T':
        TLE += 1
    else:
        RE += 1

print('AC x ' + str(AC))
print('WA x ' + str(WA))
print('TLE x ' + str(TLE))
print('RE x ' + str(RE))

Measured memory_bytes: 97280
N = int(input())
a = list(map(int, input().split()))

b = [0] * (N + 1)
ans = 0
for ai in a:
    if ai <= N:
        b[ai] += 1
    else:
        ans += 1
for i in range(N + 1):
    if b[i] > i:
        ans += b[i] - i
    elif b[i] < i:
        ans += b[i]

print(ans)

Measured memory_bytes: 14232
#include <bits/stdc++.h>
#define nl ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()

using namespace std;

int main() {
    nl // youtu.be/QosiU0JR_h8  
    ll x, t;
    cin >> x >> t;
    cout << (x >= t ? x-t : 0);
    return 0;
}

Measured memory_bytes: 3632
import sys
n, m = map(int, input().split())
s = []
c = []
for _ in range(m):
    s_, c_ = map(int, input().split())
    s.append(s_)
    c.append(c_)
res = [-1]*n
for i in range(m):
    for j in range(n):
        if s[i] == (j+1):
            if res[j] == -1 or res[j] == c[i]:
                res[j] = c[i]
            else:
                print(-1)
                sys.exit()
if res[0] == 0 and n > 1:
    print(-1)
    sys.exit()
ans = 0
if n == 1 and m == 0:
    print(0)
    sys.exit()
if res[0] == -1:
    ans += 10**(n-1)
for i in range(n):
    if res[i] != -1:
        ans += res[i]*((10)**(n-i-1))
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

int main() {
    int N;
    cin >> N;
    vector<int> p, m;
    for(int i = 0; i < N; i++) {
        int a;
        cin >> a;
        if (a >= 0) p.push_back(a);
        else m.push_back(a);
    }
    sort(p.begin(), p.end(), greater<int>());
    sort(m.begin(), m.end());

    vector<pii> ans;
    int M = 0;

    if (m.size() > 0 && p.size() > 0) {
        int mi = m[0];
        for(int i = 1; i < p.size(); i++) {
            ans.push_back({mi, p[i]});
            mi -= p[i];
        }

        int ma = p[0];
        for(int i = 1; i < m.size(); i++) {
            ans.push_back({ma, m[i]});
            ma -= m[i];
        }

        ans.push_back({ma, mi});
        M = ma - mi;
    } else if (m.size() <= 0) {
        int mi = p.back();
        for(int i = 1; i < p.size()-1; i++) {
            ans.push_back({mi, p[i]});
            mi -= p[i];
        }

        ans.push_back({p[0], mi});
        M = p[0] - mi;
    } else {
        int ma = m.back();
        for(int i = 1; i < m.size()-1; i++) {
            ans.push_back({ma, m[i]});
            ma -= m[i];
        }

        ans.push_back({ma, m[0]});
        M = ma - m[0];
    }

    cout << M << endl;
    for(auto e : ans) {
        cout << e.first << " " << e.second << endl;
    }

    return 0;
}

Measured memory_bytes: 3444
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

int main() {

	long long X, K, D;
	cin >> X >> K >> D;

	long long b = abs(X) / D;

	long long v1 = abs(X) - D * b;
	long long v2 = D * (b + 1) - abs(X);
	
	long long dans = 0;
	long long val;
	if (v1 <= v2) {
		dans = v1;
		val = b;
	}
	else {
		dans = v2;
		val = b + 1;
	}

	long long ans;
	if (K < val) {
		ans = abs(X) - K * D;
	}
	else {
		K -= val;
		if (K % 2 == 0) {
			ans = dans;
		}
		else {
			if (dans == v1) {
				ans = v2;
			}
			else {
				ans = v1;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3576
using System;

class Program
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine();
        foreach (var e in s)
        {
            Console.Write((char)('A' + (e - 'A' + n) % 26));
        }
        Console.WriteLine();
    }
}

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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    ll N;
    cin >> N;

    vi digs;
    for (ll T = N; T; T /= 10)
        digs.push_back(T % 10);
    reverse(all(digs));

    int ans = 0, sum = 0;

    for (int i = 0; i < digs.size(); i++) {
        if (digs[i]) {
            ans = max(ans, sum + digs[i] - 1 + 9 * (int(digs.size()) - i - 1));
        }
        sum += digs[i];
    }

    cout << max(ans, sum) << endl;
    return 0;
}



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

int a, b, C = ~(1<<31), M = (1<<16)-1;
int r() {
  a = 36969 * (a & M) + (a >> 16);
  b = 18000 * (b & M) + (b >> 16);
  return (C & ((a << 16) + b)) % 1000000;
}

class HappySequence{
public:
	map<int,int> seq;
	HappySequence(){ int inf = 1e9; seq[-inf] = -inf; }
	bool insert(int key,int val){
		if( (--seq.lower_bound(key))->second >= val ) return false;
		seq[key] = val;
		auto it = ++seq.find(key);
		while( it != seq.end() && (*it).second <= val ) seq.erase(it++);
		return true;
	}
};

HappySequence seg[1000100];

void ins(int y,int z,int v){
	for(int i = y ; i < 1000100 ; i += i & -i ) seg[i].insert(z,v);
}
int get(int y,int z){
	int v = 0;
	for(int i = y ; i > 0 ; i -= i & -i ){
		v = max(v,(--seg[i].seq.lower_bound(z))->second);
	}
	return v;
}

int main(){
	int n,m,A,B;
	while( cin >> m >> n >> A >> B && n+m ){	
		a = A;
		b = B;
		vector< array<int,3> > ps;
		vector<int> uy;
		for(int i = 0 ; i < m ; i++){	
			int x,y,z;
			cin >> x >> y >> z;
			ps.push_back(array<int,3>{x,y,z});
			uy.push_back(y);
		}
		for(int i = 0 ; i < n ; i++){
			int x = r();
			int y = r();
			int z = r();
			ps.push_back(array<int,3>{x,y,z});
			uy.push_back(y);
		}
		sort(uy.begin(),uy.end());
		uy.erase(unique(uy.begin(),uy.end()),uy.end());
		for(int i = 0 ; i <= uy.size() ; i++) seg[i] = HappySequence();
		sort(ps.begin(),ps.end(),[&](array<int,3> a,array<int,3> b){
			if( a[0] != b[0] ) return a[0] < b[0];
			return make_pair(a[1],a[2]) > make_pair(b[1],b[2]);
		});
		int ans = 0;
		for( auto p : ps ){
			p[1] = lower_bound(uy.begin(),uy.end(),p[1]) - uy.begin() + 1;
			int mx = get(p[1]-1,p[2]) + 1;
			ans = max(ans,mx);
			ins(p[1],p[2],mx);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 159324
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define fi first
#define se  second
ll dp[100005][102];
/*ll solve(int i)
{
    if(i>n)
        return 0;
    if(dp[i]!=-1)
        return dp[i];
    int x,y;
    if(i+1>n)
        x=0;
    else
        x=abs(a[i]-a[i+1]);
    if(i+2>n)
        y=0;
    else
        y=abs(a[i]-a[i+2]);
    dp[i]=min(solve(i+1)+x,solve(i+2)+y);
    return dp[i];
}*/
int main()
{
    int n,k;
    cin>>n>>k;
    int a[n+1];
    vector<ll>dp(n+1,1e18);
    for(int i=1;i<=n;++i)
        cin>>a[i];
    dp[1]=0;
    for(int i=1;i<=n;++i)
    {
        for(int j=1;j<=k;++j)
        {
            if(i+j<=n)
            dp[i+j]=min(dp[i+j],dp[i]+abs(a[i]-a[i+j]));
        }
    }
    cout<<dp[n]<<endl;
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

vector<int> a, b, c;

int main()
{
    int n;
    cin>>n;
    a.resize(n);
    b.resize(n);
    c.resize(n-1);
    REP(i,n) cin>>a[i];
    REP(i,n) cin>>b[i];
    REP(i,n-1) cin>>c[i];

    int ans = b[a[0]-1];
    REP(i,n-1) {
        ans += b[a[i+1]-1];
        if (a[i] + 1 == a[i+1])
            ans += c[a[i]-1];
    }
    cout<<ans<<endl;

    return 0;
}


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

struct Card {char suit, value; };

void bubbleSort(Card A[], int n)
{
    for (int i = 0; i != n; ++i)
    {
        for (int j = n-1; j > i; --j)
        {
            if (A[j-1].value > A[j].value)
            {
                swap(A[j-1], A[j]);
            }
        }
    }
}

void selectionSort(Card A[], int n)
{
    for (int i = 0; i != n-1; ++i)
    {
        int minj = i;

        for (int j = i; j != n; ++j)
        {
            if (A[j].value < A[minj].value)
            {
                minj = j;
            }
        }

        if (minj != i)
        {
            swap(A[minj], A[i]);
        }
    }
}

bool isStable(Card A[], Card B[], int n)
{
    for (int i = 0; i != n; ++i)
    {
        if (A[i].suit != B[i].suit)
        {
            return false;
        }
    }

    return true;
}

void print(Card A[], int n)
{
    for (int i = 0; i != n; ++i)
    {
        if (i > 0)
        {
            cout << " ";
        }

        cout << A[i].suit << A[i].value;
    }

    cout << endl;
}

int main()
{
    Card A[36], B[36];
    int n;
    
    cin >> n;

    for (int i = 0; i != n; ++i)
    {
        cin >> A[i].suit >> A[i].value;
    }

    for (int i = 0; i != n; ++i)
    {
        B[i].suit = A[i].suit;
        B[i].value = A[i].value;
    }

    bubbleSort(A, n);
    selectionSort(B, n);

    print(A, n);
    cout << "Stable" << endl;
    print (B, n);
    
    if (isStable(A, B, n) == true)
    {
        cout << "Stable" << endl;
    }
    else
    {
        cout << "Not stable" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3112
use std::cmp::max;

#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let _ = scan!(usize);
    let vs = scan!(i64;;);
    let cs = scan!(i64;;);
    let mut ans = 0;
    for i in 0..vs.len() {
        ans += max(vs[i] - cs[i], 0);
    }
    println!("{}", ans)
}


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

struct P{
	int a, b;
	P(int a_, int b_){ a = a_; b = b_; }
	P(){}
};

const int INF = 1e+8;
vector<P> h[10001];

int main(){
	for(int a=1 ; a <= 10000 ; a++ ){
		for(int b=1 ; b <= 10000 && a * b <= 10000 ; b++ ){
			h[a*b].push_back( P(a,b) );
		}
	}
	int x, y;
	while( cin >> x >> y , x || y ){
		int ans = INF;
		for(int i=0 ; i < h[x].size() ; i++ ){
			for(int j=0 ; j < h[y].size() ; j++ ){
				vector<int> v;
				v.push_back( h[x][i].a );
				v.push_back( h[x][i].b );
				v.push_back( h[y][j].a );
				v.push_back( h[y][j].b );
				sort( v.begin() , v.end() );
				int n=0;
				for(int i=1 ; i < v.size() ; i++ ){
					n += (v[i-1] - v[i]) * (v[i-1] - v[i]);
				}
				ans = min( ans , n );
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 2624
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
 double a,b,x; cin>>a>>b>>x;
  double pi=M_PI;
  //cout<<a*b/2.0*a<<endl;
  //cout<<b*b/2.0/tan(45.0*pi/180.0)*a<<endl;
  if(x<=a*b/2.0*a){
  for(  double i=0.000000; i<=90.000000;i+=0.000002){
    if(b*b/2.0/tan(i*pi/180.0)*a-x<0.000000001){
  cout << fixed << setprecision(10);
      cout<<i<<endl; return 0;
    }
  }
  }
  else{
   for(  double i=0.000000; i<=90.000000;i+=0.000002){
    if((a*b-a*a/2.0*tan(i*pi/180.0))*a-x<0.000000001){
  cout << fixed << setprecision(10);
      cout<<i<<endl; return 0;
    }
  }
  }
  
  
  }
  
  



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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n,w,d;cin>>n>>w>>d;
  while(n!=0||w!=0||d!=0)
  {
    vector<int> p(n);
    vector<int> s(n);
    int i;
    rep(i,n)cin>>p[i]>>s[i];
    rep(i,n)p[i]--;
    vector<tuple<int,int,int,int>> ps(1);
    ps[0]=make_tuple(0,0,d,w);
    rep(i,n)
    {
      int d1=get<0>(ps[p[i]]);
      int d2=get<2>(ps[p[i]]);
      int w1=get<1>(ps[p[i]]);
      int w2=get<3>(ps[p[i]]);
      int kd=d2-d1;
      int kw=w2-w1;
      int sd,sw;
      s[i]%=(kw*2+kd*2);
      if(s[i]<=kw)
      {
        sd=d1;
        sw=w1+s[i];
      }
      else if(s[i]<=kw+kd)
      {
        sd=d1+s[i]-kw;
        sw=w2;
      }
      else if(s[i]<=kw*2+kd)
      {
        sd=d2;
        sw=w1+kw*2+kd-s[i];
      }
      else
      {
        sd=d1+kw*2+kd*2-s[i];
        sw=w1;
      }
      if(sd==d1||sd==d2)
      {
        int nw=sw;
        tuple<int,int,int,int> a;
        tuple<int,int,int,int> b;
        a=make_tuple(d1,w1,d2,nw);
        b=make_tuple(d1,nw,d2,w2);
        int area_a=(nw-w1);
        int area_b=(w2-nw);
        ps.erase(ps.begin()+p[i]);
        if(area_a<=area_b)
        {
          ps.emplace_back(a);
          ps.emplace_back(b);
        }
        else
        {
          ps.emplace_back(b);
          ps.emplace_back(a);
        }
      }
      else
      {
        int nd=sd;
        tuple<int,int,int,int> a;
        tuple<int,int,int,int> b;
        a=make_tuple(d1,w1,nd,w2);
        b=make_tuple(nd,w1,d2,w2);
        int area_a=(nd-d1);
        int area_b=(d2-nd);
        ps.erase(ps.begin()+p[i]);
        if(area_a<=area_b)
        {
          ps.emplace_back(a);
          ps.emplace_back(b);
        }
        else
        {
          ps.emplace_back(b);
          ps.emplace_back(a);
        }
      }
    }
    vector<int> anss(0);
    rep(i,ps.size())
    {
      int d1=get<0>(ps[i]);
      int d2=get<2>(ps[i]);
      int w1=get<1>(ps[i]);
      int w2=get<3>(ps[i]);
      anss.emplace_back((d2-d1)*(w2-w1));
    }
    sort(all(anss));
    rep(i,anss.size())
    {
      if(i!=0)cout<<' ';
      cout<<anss[i];
    }
    cout<<endl;
    cin>>n>>w>>d;
  }
}



Measured memory_bytes: 3108
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int n, m, k;
	while (cin >> n >> m >> k) {
		if (!n && !m && !k)return 0;
		vector<int>v;
		for (int i = 0; i < n; i++)v.push_back(i + 1);
		int num = k - 1;
		while (v.size() != 1) {
			v.erase(v.begin() + num);
			num--;
			for (int i = 0; i < m; i++){
				num++;
				if (num == v.size())num = 0;
			}
		}
		cout << v[0] << endl;
	}
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  ll mn = 3 * 1e15;
  int n;
  cin >> n;
  int arr[n];
  ll sum = 0;
  ll cur = 0;
  for(int i = 0;i < n;i++){
    cin >> arr[i];
    sum += arr[i];
  }
  for(int i = 0;i < n - 1;i++){
    cur += arr[i];
    mn = min(mn, abs(cur - (sum - cur)));
//    cout << cur << endl;
  }
  //
  cout << mn;
}


Measured memory_bytes: 1024
#include <stdio.h>
void insertionSort(int *A,int N){
    int i,j,v;
    for(i=1;i<N;i++){
    	for(j=0;j<N-1;j++) printf("%d ",A[j]);
    	printf("%d\n",A[N-1]);
        v=A[i];
        j=i-1;
        while(j>=0&&A[j]>v){
            A[j+1]=A[j];
            j--;
        }
        A[j+1]=v;
    }
    for(i=0;i<N-1;i++) printf("%d ",A[i]);
    printf("%d\n",A[N-1]);
}
int main(void){
	int N,a,i;
	int A[100];
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d",&a);
		A[i]=a;
	}
	insertionSort(A,N);
	return 0;
}



Measured memory_bytes: 1964
#include <iostream>
#include <string>
#include <map>
#include <stdio.h>
#include <cmath>
#include <vector>  

using namespace std;

int main() {
    string N;
    int len = 2200000;
    cin >> N;
    int a = len;
    int z = len;
    int res;
    for(int i = 0; i < N.size(); ++i){
        if(N[i] == 'A'){
            if(a > i)a = i;
        }
        if(N[i] == 'Z'){
            if(i > a || z > i)z = i;
        }
    }
    res = (z - a) + 1;
    cout << res << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
int main(){
 int ans=0;
 char s[4]={},t[4]={};
 scanf("%s%s",s,t);
 for(int i=0;i<3;i++)if(s[i]==t[i])ans++;
 printf("%d\n",ans);
 return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>

#define swap(x, y) { \
    int v = x; \
    x = y; \
    y = v; \
}

/*
gcd(x, y)
    if x < y
        swap(x, y)
    while y > 0
        r = x % y
        x = y
        y = r

    return x
*/

int main(void) {
    int a;
    int b;

    fscanf(stdin, "%d %d", &a, &b);

    if (a < b) {
        swap(a, b);
    }

    while (b > 0) {
        int r = a % b;
        a = b;
        b = r;
    }

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

    return 0;
}



Measured memory_bytes: 2080
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var ab = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
			Console.WriteLine(ab[0] * ab[1] / 3.305785);
		}
	}
}

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL<<60;
const ll mod = 1000000007;		


int main() {

	
	int k;
	cin >> k;
	
	VLL a(k);
	REP(i, k)cin >> a[i];
	reverse(ALL(a));

	if (a[0] != 2) {
		cout << -1 << endl;
		return 0;
	}

	ll maxn = 3, minn = 2;
	
	FOR(i, 1, k) {
		minn = (minn + a[i] - 1) / a[i] * a[i];
		maxn = maxn / a[i] * a[i] + a[i] - 1;
	}


	ll tmp = maxn;
	for (int i = k - 1; i >= 0; i--)tmp = tmp / a[i] * a[i];
	if (tmp != 2) {
		cout << -1 << endl;
		return 0;
	}
	tmp = minn;
	for (int i = k - 1; i >= 0; i--)tmp = tmp / a[i] * a[i];
	if (tmp != 2) {
		cout << -1 << endl;
		return 0;
	}

	cout << minn << ' ' << maxn << endl;



	return 0;

}


Measured memory_bytes: 1024