akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;


int Ctoi(const char c){
    if('A' <= c && c <= 'Z') return (c - 'A');
    else return -1;
}

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int N;cin >>N;
    string S;cin >> S;
    REP(i,S.size()){
        char C = S[i];
        int A = Ctoi(C) + N;
        A %= 26;
        cout << (char)(A + 'A');
    }
    cout << endl;
}

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

using namespace std;

int main()
{
    int r, D, x;
    cin >> r >> D >> x;
    for (int i = 0; i < 10; i++)
    {
        x = r * x - D;
        cout << x << endl;
    }
    return 0;
}

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

using VI = vector <int>;
using VVI = vector <VI>;

struct PQue {
    int cnt;
    int val;

    PQue(int pc, int pv) : cnt(pc), val(pv) {
    }

    bool operator<(const PQue& a) const {
        if (cnt != a.cnt) {
            return cnt < a.cnt;
        }
        return val < a.val;
    }
};

using PQ = priority_queue <PQue>;

void handle(PQ& outPq, PQ& inPq, VVI& cnt, int v) {
    if (cnt[1][v] > 0) {
        int sum = cnt[0][v]+cnt[1][v];
        if (cnt[0][v] == 0 || outPq.empty() || sum > outPq.top().cnt) {
            outPq.push(PQue(sum, v));
        } else if (cnt[0][v] > 0) {
            inPq.push(PQue(sum, v));
        }
    } else if (cnt[0][v] > 0) {
        inPq.push(PQue(cnt[0][v] + cnt[1][v], v));
    }
}

int main() {
    // No => if max(#Bi) >= Sigma#Aj where Aj != Bi
    int N;
    cin >> N;

    VI A[2];

    VVI cnt(2, VI(N+1));
    vector <set<int>> idxSet(N+1);
    PQ outPq;
    PQ inPq;

    for (int i = 0; i < 2; ++i) {
        A[i] = std::move(vector<int>(N));
        for (int j = 0; j < N; ++j) {
            cin >> A[i][j];
            ++cnt[i][A[i][j]];
            if (i == 0) {
                idxSet[A[i][j]].insert(j);
            }
        }
    }

    // for ch, #ch in A+B <= #total A (constant)
    int theMax = -1;
    int theMaxVal = -1;

    for (int v = 1; v <= N; ++v) {
        if (cnt[1][v] > 0) {
            int sum = cnt[0][v]+cnt[1][v];
            if (sum > theMax) {
                theMax = sum;
                theMaxVal = v;
            }
        }
    }

    handle(outPq, inPq, cnt, theMaxVal);

    for (int v = 1; v <= N; ++v) {
        if (v != theMaxVal) {
            handle(outPq, inPq, cnt, v);
        }
    }

    VI ans(N);
    bool ok = true;

    while (!outPq.empty()) {
        int outCho = outPq.top().val;
        outPq.pop();

        if (inPq.empty()) {
            ok = false;
            break;
        }

        int inCho = inPq.top().val;
        inPq.pop();

        auto iter = idxSet[inCho].begin();
        ans[*iter] = outCho;
        idxSet[inCho].erase(iter);

        --cnt[0][inCho];
        --cnt[1][outCho];

        handle(outPq, inPq, cnt, outCho);
        handle(outPq, inPq, cnt, inCho);
    }

    if (ok) {
        cout << "Yes" << endl;
        cout << ans[0] ;
        for (int i = 1; i < N; ++i) {
            cout << " " << ans[i] ;
        }
        cout << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 27960
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    string s;
    cin >> s;
    int a = 0;
    int b = 0;
    REPS(c, s) {
        if (c == '0') a++; else b++;
    }
    cout << min(a, b) * 2 << EOL;
}



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

int main(){
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    while(true){
        C -= B;
        if(C <= 0){
            cout << "Yes" << endl;
            return 0;
        }
        A -= D;
        if(A <= 0){
            cout << "No" << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3636
N,K = map(int,input().split())
V_list = list(map(int,input().split()))
min_ = min(N,K)
total = [0]
#get
for a in range(min_+1):
  for b in range(min_-a+1):
    score_get = V_list[:a]+V_list[N-b:]
    score_get.sort()
    score = sum(score_get)
    for i in range(min(K-(a+b),len(score_get))):
      if score_get[i]<0:
        score -= score_get[i]
      else:
        break
    total.append(score)
print(max(total))
      

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] T = new int[N];
		long sum = 0;
		for (int i = 0; i < N; i++) {
			T[i] = sc.nextInt();
			sum+=T[i];
		}

		int M = sc.nextInt();

		for (int i = 0; i < M; i++) {
			int P = sc.nextInt();
			int X = sc.nextInt();
			System.out.println(sum-T[P-1]+X);
		}

	}


}



Measured memory_bytes: 36276
#include <iostream>
#include <string>

using namespace std;
long long mod = 1000000007,a[30] = {},ans = 1;
int main(){
	int i,n;
	string s;
	cin >> n >> s;
	for(i=0;i<n;i++){
		a[s[i] - 'a']++;
	}
	for(i=0;i<26;i++){
		(ans *= (a[i] + 1)) %= mod;
	}
	cout << ans - 1 << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
#define N 210
#define db float
#define eps 1e-5
using namespace std;
struct node{
    db x,y;
    node(db X=0,db Y=0):x(X),y(Y){}
    node operator <(const node a)const{return x==a.x?y<a.y:x<a.x;}
    node operator +(const node a)const{return node(x+a.x,y+a.y);}
    node operator -(const node a)const{return node(x-a.x,y-a.y);}
    node operator *(const db a)const{return node(x*a,y*a);}
    node operator /(const db a)const{return node(x*1.0/a,y*1.0/a);}
}p[N];
int n,k;
db dis(node a){return sqrt(a.x*a.x+a.y*a.y);}
node stb(node a){if(abs(a.x)<=eps && abs(a.y)<=eps) return node(0,0);return a/dis(a);}
struct pnode{
    int id;
    db d;
    bool operator <(const pnode a)const{return d<a.d;}
}a[N];
node check(node o)
{
    for(int i=1;i<=n;i++)
    a[i]=(pnode){i,dis(p[i]-o)};
    sort(a+1,a+n+1);
    reverse(a+1,a+n+1);
    node res=node(0,0);
    for(int i=1;i<=k;i++) res=res+stb(p[a[i].id]-o);
    for(int i=k+1;i<=n;i++)
    if(abs(a[i].d-a[k].d)<=eps) res=res+stb(p[a[i].id]-o);
    return res;
}
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
    scanf("%f%f",&p[i].x,&p[i].y);
    node ans=p[1];
    db T=10;
    while(abs(T)>eps)
    {
        node o=check(ans);
        if(dis(o)<=1e-5) break;
        o=o*T;
        ans=ans+o;
        T=T*0.995;
    }
    for(int i=1;i<=n;i++)
    a[i]=(pnode){i,dis(p[i]-ans)};
    sort(a+1,a+n+1);
    reverse(a+1,a+n+1);
    db res=0;
    for(int i=1;i<=k;i++) res=res+a[i].d;
    printf("%.4f",res);
    return 0;
}


Measured memory_bytes: 3292
#include<stdio.h>

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

    if(n / 100 == 7)ans = 1;
    if((n % 100) / 10 == 7)ans = 1;
    if((n % 10) == 7)ans = 1;

    if(ans)printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 1664
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    string S;
    cin >> S;
    ll sz = S.size();
    rep(i,0,sz){
        ll val = S[i] - 'A';
        val = (val + N) % 26;
        char c = (char)('A' + val);
        cout << c;
        // ll v = S[i] - 'a';
        // char c;
        // if(S[i] + N > 'z'){
        //     ll diff = N - (25 - v);
        //     char c = (char)('a' + diff);
        // }else{
        //     char c = (char)(S[i] + N);
        //     print("hoge");
        // }
        // cout << c;
    }
    cout << endl;


    

}

Measured memory_bytes: 256
def saiki(s):
  if len(s) > 10:
    return
  
  if s[-1] == '0':
    tmp1 = s+'1'
    tmp2 = s+'0'
    ans.append(int(tmp1))
    ans.append(int(tmp2))
    saiki(tmp1)
    saiki(tmp2)
    
  elif s[-1] == '9':
    tmp1 = s+'8'
    tmp2 = s+'9'
    ans.append(int(tmp1))
    ans.append(int(tmp2))
    saiki(tmp1)
    saiki(tmp2)
    
  else:
    last = int(s[-1])
    tmp1 = s + str(last+1)
    tmp2 = s + str(last-1)
    tmp3 = s + str(last)
    ans.append(int(tmp1))
    ans.append(int(tmp2))
    ans.append(int(tmp3))
    saiki(tmp1)
    saiki(tmp2)
    saiki(tmp3)

k = int(input())

ans = [i for i in range(1,10)]

for i in range(1,10):
  saiki(str(i))
  
ans = sorted(ans)

print(ans[k-1])

Measured memory_bytes: 33280
#include <iostream>
using namespace std;
int main()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if (a>=b && c>=d){
    cout<<b+d;
  }else if (a<=b && c>=d){
    cout<<a+d;
  }else if (a>=b && c<=d){
    cout<<b+c;
  }else if (a<=b && c<=d){
    cout<<a+c;
  }
}

Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define _GLIBCXX_DEBUG

signed main() {
  int H, W; cin >> H >> W;
  vector<vector<int>> s(H, vector<int>(W)), dp(H, vector<int>(W));
  rep(i, H) rep(j, W) {
    char c; cin >> c;
    s[i][j] = (c == '#' ? 1 : 0);
  }
  
  rep(i, H) rep(j, W) {
    if(i==0 && j==0) {
      dp[i][j] = 0;
      continue;
    }
    dp[i][j] = 1000000;
    if(i > 0) {
      int l = dp[i-1][j];
      if(s[i-1][j] != s[i][j]) l++;
      dp[i][j] = min(dp[i][j], l);
    } 
    if(j > 0) {
      int u = dp[i][j-1];
      if(s[i][j-1] != s[i][j]) u++;
      dp[i][j] = min(dp[i][j], u);
    }
  }
  if(s[0][0]==1 && s[H-1][W-1]==1) dp[H-1][W-1]++;
  cout << (dp[H-1][W-1]+1)/2 << endl;

}

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

int main() {
	int x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	
	vector<int> A(a);
	vector<int> B(b);
	vector<int> C(c);
	
	rep(i,a)cin>>A[i];
	rep(i,b)cin>>B[i];
	rep(i,c)cin>>C[i];
	
	//A,Bを上からx,y個それぞえれX,Yに格納
	sort(A.begin(),A.end(),greater<int>());
	vector<int> X(x);
	rep(i,x)X[i]=A[i];
	sort(B.begin(),B.end(),greater<int>());
	vector<int> Y(y);
	rep(i,y)Y[i]=B[i];
	
	//XにYとC合体
	X.insert(X.end(),Y.begin(),Y.end());
	X.insert(X.end(),C.begin(),C.end());
	
	sort(X.begin(),X.end(),greater<int>());
	
	ll ans=0;
	rep(i,x+y)ans+=X[i];
	
	cout<<ans<<endl;
}


Measured memory_bytes: 3616
#include <iostream>

using namespace std;

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

    int A[n][m];

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

    int b[m];

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

    for(int i = 0; i < n; i++) {
        int c = 0;
        for(int j = 0; j < m; j++) {
            c += A[i][j] * b[j];
        }
        cout << c << endl;
    }

    return 0;
}


Measured memory_bytes: 3128
#include <cstdio>
#include <climits>
#include <algorithm>

using namespace std;

#define N 15
#define INF INT_MAX

int dp[N][N];

int n, ans_index, ans_length;

void solve(){
	for (int k = 0; k < n; k++){
		for (int i = 0; i < n; i++){
			for (int j = 0; j < n; j++){
				if (dp[i][k] != INF && dp[k][j] != INF){
					dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
				}
			}
		}
	}

	ans_index = 0;
	ans_length = INF;
	
	for (int i = 0; i < n; i++){
		int sum = 0;
		for (int j = 0; j < n; j++){
			if (i == j) continue;
			sum += dp[i][j];
		}
		if (sum < ans_length){
			ans_index = i;
			ans_length = sum;
		}
	}
}

int main(){
	int t;
	while(true){
		scanf("%d", &t);
		if (t == 0) break;
		n = 0;
		
		fill((int*)dp, (int*)dp + N * N, INF);
		for (int i = 0; i < t; i++){
			int a, b, c;
			scanf("%d %d %d", &a, &b, &c);
			if (a > n) n = a;
			if (b > n) n = b;
			dp[a][b] = c;
			dp[b][a] = c;
		}
		n++;
		solve();
		printf("%d %d\n", ans_index, ans_length);
	}
	return 0;
}

Measured memory_bytes: 2628
#include<stdio.h>
//const int maxn = 20000+ 10;
int a[200010];
int main() {
    int n; scanf ("%d", &n);
    
    for (int i = 0; i < n; i++)
    scanf ("%d", &a[i]);

    long long cnt = 0;

    for (int i = 1; i < n; i++)
    if (a[i-1] > a[i]) 
    {
        cnt += a[i-1] - a[i];
        
        //printf("a[%d] = %d\t cnt = %d\n", i, a[i],cnt);
        
        a[i] = a[i-1];
    }

    printf("%lld", cnt);

}


Measured memory_bytes: 2508
#include <vector> 
#include <list> 
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

const LL mod = 1e9 + 7;


bool F[101][5][2];
LL P[101][11];
int main() {
	
	int N;
	cin >> N;

	REP(i, N)REP(j, 5)REP(k, 2) {
		cin >> F[i][j][k];
	}
	REP(i, N)REP(j, 11) {
		cin >> P[i][j];
	}
	LL maxscore = -9223372036854775807;
	for (int p = 1; p < (1 << 10); p++) {
		VI kaburi(N);
		REP(i, N) { kaburi[i] = 0; }
		for(int i = 0; i < 5; i++) {
			if ((p&(1 << (2*i))) != 0) {
				REP(j, N) {
					kaburi[j] += F[j][i][0];
				}
			}
			if ((p&(1 << ((2*i)+1))) != 0) {
				REP(j, N) {
					kaburi[j] += F[j][i][1];
				}
			}
		}

		LL score = 0LL;
		REP(i, N) {
			score += P[i][kaburi[i]];
		}
		//debug(score);
		maxscore = max(score, maxscore);
	}
	cout << maxscore << endl;

}

Measured memory_bytes: 764
// Aizu Vol-3 0306: Symmetric Ternary Number
// 2017.8.27 bal4u@uu

#include <stdio.h>

char *balancedTernary(char *p, int plen, int n)
{
	int r;

	p += plen;
	*--p = 0;
	if (n == 0) *--p = '0';
	else {
		while (n != 0) {
			r = n % 3;
			p--;
			if (r == 0) *p = '0';
			else if (r == 1) *p = '+';
			else *p = '-', n++;
			n /= 3;
		}
	}
	return p;
}

int main(void)
{
	int w;
	char buf[50];

	scanf("%d", &w);
	puts(balancedTernary(buf, 50, w));
	return 0;
}

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

int solve(int arr[][3], int prevA, int prevB, int prevC, int n)
{
    int dp[n] = {0};
    for(int i=0;i<n;i++){
        int x = arr[i][0] + max(prevB, prevC);
        int y = arr[i][1] + max(prevA, prevC);
        int z = arr[i][2] + max(prevA, prevB);
        dp[i] = max(x,max(y,z));
        prevA = x;prevB = y;prevC = z;
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        if(ans < dp[i]){
            ans = dp[i];
        }
    }
    return ans;
}

int main()
{
    int n;
    cin>>n;
    int arr[n][3];
    int dp[n] = {0};
    for(int i=0;i<n;i++){
        cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    }
    int ans = solve(arr, 0, 0, 0, n);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2176
using System;
 class ProgramC
    {
        static void Main(string[] args)
        {
            //まずは数字を読む

            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int m = int.Parse(input[1]);

            int[] fallstair = new int[m + 1];
            long[] stair = new long[n + 1];

            //とりあえず全部読みこむ
            for (int i = 0; i <m;i++)
                fallstair[i] = int.Parse(Console.ReadLine());

            //ない階段を数える
            int count = 0;

            //結果出力
            long output = 0;

            //初期条件設定
            if (m >= 2)
            {
                if (fallstair[count] == 1 && fallstair[count + 1] == 2)
                {
                    output = 0;
                    goto end;
                }
                else if (fallstair[count] == 1 && fallstair[count + 1] != 2)
                {
                    stair[0] = 0;
                    stair[1] = 1;
                    count++;
                }
                else if (fallstair[count] != 1 && fallstair[count] == 2)
                {
                    stair[0] = 1;
                    stair[1] = 0;
                    count++;
                }
                else
                {
                    stair[0] = 1;
                    stair[1] = 2;

                }
            }
            else if(m <= 1)
            {
                if (fallstair[count] == 1)
                {
                    stair[0] = 0;
                    stair[1] = 1;
                    count++;
                }
                else if (fallstair[count] == 2)
                {
                    stair[0] = 1;
                    stair[1] = 0;
                    count++;
                }
                else
                {
                    stair[0] = 1;
                    stair[1] = 2;

                }
            }

            for (int i = 2; i < n; i++)
            {
                int fall = fallstair[count];

                if (fall == i + 1)
                {
                    stair[i] = 0;
                    count++;
                }
                else
                    stair[i] = stair[i - 1] + stair[i - 2];

                //ダメなときは出す
                if (stair[i] == 0 && stair[i - 1] == 0)
                {
                    output = 0;
                    goto end;
                }

                if (stair[i] > 1000000007)
                    stair[i] %= 1000000007;

            }

            output = stair[n - 1];

            //普通に終われば普通に出す


            
            //最初からダメなら求めない
            end:

            ;

            Console.WriteLine(output);


        }
    }

Measured memory_bytes: 14176
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long int

int main(){
  ll a,b,n;
  scanf("%lld%lld%lld",&a,&b,&n);

  ll max=0;
  ll k2=a/b;
  ll d1;
  ll d2=a%b;
  if(b<=n){
    d1=b-1;}
  else{
    d1=n;}
  max=k2*d1+d1*d2/b;

  printf("%lld\n",max);
  
  return 0;
}


Measured memory_bytes: 1736
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

    int A;
    int B;

    cin >> A >> B;

    if(B % A == 0){
        cout << A + B;
    }else{
        cout << B - A;
    }
}

Measured memory_bytes: 888
#include<stdio.h>

int main(){
   int n,h[100],max_h,cnt;
   scanf("%d",&n);
   for(int i = 0;i <n;i ++){
      scanf("%d",&h[i]);
   }
   cnt= 1;
   max_h =h[0];
   for(int i = 1;i<n;i++){
      if(max_h <= h[i]){
         max_h = h[i];
         cnt ++;
      }
   }
   printf("%d",cnt);
}


Measured memory_bytes: 128
#include <cstdio>
#include <vector>
using namespace std;

using i64 = long long;

#define REP(i, stop) for (int i = 0, i##_len = stop; i < i##_len; ++i)

signed main() {
	int n;
	scanf("%d", &n);
	vector<int> A(n + 1);
	REP(i, n + 1) {
		scanf("%d", &A[i]);
	}
	i64 s = 0;
	REP(i, n) {
		int b;
		scanf("%d", &b);
		int m = A[i] < b ? A[i] : b;
		s += m;
		b -= m;
		m = A[i + 1] < b ? A[i + 1] : b;
		s += m;
		A[i + 1] -= m;
	}
	printf("%lld", s);
}


Measured memory_bytes: 640
// Submitted by Subhash Yadav
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int n=sc.nextInt(),x=sc.nextInt(),t=sc.nextInt();
		
		int ans=(int) ((Math.ceil(1.0*n/x))*t);
		out.println(ans);
		
		out.close();

	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}

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

using Int = int;
using namespace std;

#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; };
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; };
template<class T> T th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

int main(){
	int n, q;
	std::string str;
	cin >> n >> str >> q;

	constexpr int N = 1 << 19;
	static int seg[N * 2 + 100] = {};

	RC(i, n) seg[i + N] = 1 << (str[i] - 'a');
	ARCH(i, N, 1) seg[i] = seg[i * 2] | seg[i * 2 + 1];

	for(int i = 0; i < q; ++i){
		int x;
		cin >> x;
		if(x == 1){
			int i;
			char c;
			cin >> i >> c;
			--i;
			seg[i + N] = 1 << (c - 'a');
			for(i = (i + N) / 2; i > 0; i /= 2){
				seg[i] = seg[i * 2] | seg[i * 2 + 1];
			}
		}else if(x == 2){
			int l, r;
			int ans = 0;
			cin >> l >> r;
			l += N - 1;
			r += N - 1;
			while(l <= r){
				if(l % 2 == 1){
					ans |= seg[l];
				}
				if(r % 2 == 0){
					ans |= seg[r];
				}
				l = (l + 1) / 2;
				r = (r - 1) / 2;
			}
			cout << __builtin_popcount(ans) << endl;
		}
	}

}


Measured memory_bytes: 4996
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main() {
    int a;
    string s;
    cin >> a >> s;
    if (a < 3200) {
        s = "red";
    }
    cout << s << endl;
}

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

int main() {
  int N;
  cin >> N;
  int a;
  bool b = true;

  for(int i = 1; i <= 9; i++){
    for(int j = 1; j <= 9; j++){
      if(i*j == N){
        cout << "Yes" << endl;
        return 0;
      }
      if(i == 9 && j == 9){
        cout << "No" << endl;
        return 0;
      }
    }
  }


}



Measured memory_bytes: 3592
x, y = map(int, input().split())
A = [1, 3, 5, 7, 8, 10, 12]
B = [4, 6, 9, 11]
C = [2]
if A.count(x) * A.count(y) + B.count(x) * B.count(y) + C.count(x) * C.count(y):
    print("Yes")
else: print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define mp(a, b) make_pair(a, b)
#define newline cout << endl;
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(v) v.begin(),v.end()
using namespace std;

template <typename S, typename T> ostream& operator<<(ostream& out, pair<S, T> const& p)
{
	out << '(' << p.ff << ", " << p.ss << ')';
	return out;
}

template <typename T> ostream& operator<<(ostream& out, vector<T> const& v)
{
	int l = v.size();
	for (int i = 0; i < l - 1; i++)
		out << v[i] << ' ';
	if (l > 0)
		out << v[l - 1];
	return out;
}

template <typename T> void trace(const char* name, T&& arg1) { cout << name << " : " << arg1 << endl; }

template <typename T, typename... Args> void trace(const char* names, T&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	cout.write(names, comma - names) << " : " << arg1 << " | ";
	trace(comma + 1, args...);
}

/*Input*/
/*Input*/

int main()
{
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	//cout.tie(0);
	clock_t tStart = clock();
	int test;
	test = 1;
	// cin >> test;
	while (test--) {
        ll n,k;
        cin >> n >> k;
        ll ans = 0;
        while(n){
            n = n/k;
            ans++;
        }
        cout << ans << endl;
	}
#ifdef LOCAL_DEFINE
	printf("Time taken: %.2fs\n", (double)(clock() - tStart) / CLOCKS_PER_SEC);
#endif
	return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
map<string,int> mymap;
int main(){
	boost ;
	int n;
	cin>>n;
	string ph;
	for (int i = 0; i < n; ++i)
	{
		cin>>ph;
		sort(all(ph));
		mymap[ph]++;
	}
	ll ans=0;
	for(auto it:mymap)
		ans+=(it.se*(it.se-1LL))/2LL;
	cout<<ans;
	return 0;
}

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

int main() {
  
  long long A, B, K;
  cin >> A >> B >> K; 
  
  if(A - K > 0){
    cout << A - K << " " << B << endl;
  }
  
  else if(A - K <= 0 && B - (K - A) > 0){
    cout << "0" << " " << B - (K - A) << endl;
  }
  
  else if(B - (K - A) <= 0){
    cout << "0" << " " << "0" << endl;
  }
  
}

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

using namespace std;

int main() {
    int c[3][3];
    for(int i=0; i<3; i++) for(int j=0; j<3; j++) {
        cin >> c[i][j];
    }
    int a[3], b[3];
    a[0] = c[0][0];
    b[0] = 0;
    for(int i=1; i<3; i++) {
        a[i] = a[i-1] + c[i][0] - c[i-1][0];
        b[i] = b[i-1] + c[0][i] - c[0][i-1];
    }
    for(int i=0; i<3; i++) for(int j=0; j<3; j++) {
        if(c[i][j] != a[i] + b[j]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

}

Measured memory_bytes: 256
main = interact $ unlines . map kings_inspection . read' . lines
 where
  read' ("0":_) = []
  read' (_:k:s:xs') = (map read (words k), s) : read' xs'

kings_inspection (ks,str) = zipWith (\c n -> head . drop n . dropWhile (/=c) $alpha) str (cycle ks)
 where alpha = cycle (['Z','Y'..'A'] ++ ['z','y'..'a'])

Measured memory_bytes: 4780
#include <iostream>

using namespace std;

int main() {
    long int N, K;
    long long int mins = 0, maxs = 0;
    long long int sum = 0;
    cin >> N >> K;

    for (int i = 0; i < K; i++) {
        mins += i;
        maxs += N - i;
    }
    sum += maxs - mins + 1;

    for (int i = K; i <= N; i++) {
        mins += i;
        maxs += N - i;

        sum += (maxs - mins + 1);
    }
    sum %= 1000000007;
    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 3624
from collections import deque
right = deque(input())
left = deque()
while right:
    left.append(right.popleft())
    if not right:
        break
    while left and right and left[-1] == 'S' and right[0] == 'T':
        left.pop()
        right.popleft()
print(len(left))

Measured memory_bytes: 89652
#include <iostream>
 using namespace std ;
 int main()
{
 int a,b, c, d,e;
 cin>>a;
cin>>b;
 c=(a*2-1);
 d=(b*2-1);
 e=(a+b);
 if (a > b)
 {
   cout<<c<<endl;
 }
 if  (a < b)
 {
   cout<<d<<endl;
 }
  if (a == b)
{
  cout<<e<<endl;
}
return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<stdio.h>
#include<vector>

using namespace std;

int main(int m, int f, int r) {
    while (true) {
        cin >> m >> f >> r;
        if (m == -1 && f == -1 && r == -1) break;
        else if (m == -1 || f == -1) cout << 'F' << endl;
        else if (m + f >= 80) cout << 'A' << endl;
        else if (m + f >= 65) cout << 'B' << endl;
        else if (m + f >= 50) cout << 'C' << endl;
        else if (m + f >= 30) {
            if (r >= 50) cout << 'C' << endl;
            else{
                cout << 'D' << endl;
            }
        }
        else {
            cout << 'F' << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3040
s = input()
k = int(input())

if "1" not in s[:k]:
	print (s[0])
	exit()
first = "1"
t = 0
for i in range(len(s)):
	if s[i] != "1":
		first = s[i]
		break
	else:
		t += 1
if k <= t:
	print ("1")
else:
	print (first)

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

int main(){
  int n,i,j,k;
  cin >> n >> k;
  long long x[n],ret=1e16;
  for(i=0;i<n;i++)cin >> x[i];
  for(i=0;i<n-k+1;i++){
    ret=min(ret, abs(x[i+k-1]-x[i]) + abs(x[i+k-1]));
    ret=min(ret, abs(x[i+k-1]-x[i]) + abs(x[i]));
  }
  if(ret==1e16)ret=x[0];
  cout << ret << endl;
}


Measured memory_bytes: 1024
using System;

class Program
{
    static void Main(string[] args)
    {
        var nm = Console.ReadLine().Split();
        var n = int.Parse(nm[0]);
        var m = int.Parse(nm[1]);

        var a = new int[n];
        var b = new int[n];
        for (int i = 0; i < n; i++)
        {
            var ab = Console.ReadLine().Split();
            a[i] = int.Parse(ab[0]);
            b[i] = int.Parse(ab[1]);
        }

        var c = new int[m];
        var d = new int[m];
        for (int i = 0; i < m; i++)
        {
            var cd = Console.ReadLine().Split();
            c[i] = int.Parse(cd[0]);
            d[i] = int.Parse(cd[1]);
        }

        for (int i = 0; i < n; i++)
        {
            var min = int.MaxValue;
            var min_j = 0;
            for (int j = 0; j < m; j++)
            {
                var distance = Math.Abs(a[i] - c[j]) + Math.Abs(b[i] - d[j]);
                if (distance < min)
                {
                    min_j = j;
                    min = distance;
                }
            }
            Console.WriteLine(min_j + 1);
        }
    }
}


Measured memory_bytes: 11220
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	int A,B;
	String S;

	private void solve(){
		A = nextInt();
		B = nextInt();
		S = next();

		if (S.matches("^[0-9]{"+A+"}-[0-9]{"+B+"}$")) {
			out.println("Yes");
		} else {
			out.println("No");
		}
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	private boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	private String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	private int nextInt() {
		return Integer.parseInt(next());
	}

	private long nextLong() {
		return Long.parseLong(next());
	}

	private double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 23252
using System;

class program
{
    public static int Main()
    {
        var In = Console.ReadLine();
        var a = int.Parse(In.Split(' ')[0]);
        var b = int.Parse(In.Split(' ')[1]);
        var c = int.Parse(In.Split(' ')[2]);

        if (a < b && b < c)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }

        return 0;
    }
}

Measured memory_bytes: 5280
#include <iostream>
#include <vector>
using namespace std;
long long MOD = 1e9 + 7;
int main(){
    int N;
    cin >> N;
    vector<long long> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    vector<long long> cnt(60, 0);
    for(int i = 0; i < N; i++){
        int cn = 0;
        long long t = A[i];
        while(t > 0){
            if(t % 2 == 1) cnt[cn]++;
            cn++;
            t >>= 1;
        }
    }
    long long ans = 0;
    for(int i = 0; i < N; i++){
        vector<int> c(60, 0);
        int cn = 0;
        while(A[i] > 0){
            if(A[i] % 2 == 1) c[cn]++;
            cn++;
            A[i] >>= 1;
        }
        for(int j = 0; j < 60; j++){
            if(c[j] == 1){
                cnt[j]--;
                ans += (1LL << j) % MOD * (N - i - 1 - cnt[j]) % MOD;
                ans %= MOD;
            }
            else{
                ans += (1LL << j) % MOD * cnt[j] % MOD;
                ans %= MOD;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5552
#include <iostream>
#include <math.h>

using namespace std;

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

    c = c / 180 * M_PI;
    double s = a * b * sin(c) / 2;
    double l = a + b + sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(c));
    double h = b * sin(c);
    
    cout << fixed << s << endl << l << endl << h << endl;
}


Measured memory_bytes: 3436
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

ll fact[200000], invFact[200000]; 

long long power(long long x, long long c) {
    if(c==0) return 1;
    if(c==1) return x;
    if (c%2==1) return (power( (x*x)%MOD, c/2)*x)%MOD;
    else return power( (x*x)%MOD, c/2)%MOD;
}

void make_combT(ll n){
    fact[0]=1;
    rep1(i,n) fact[i]= fact[i-1]*i%MOD;
    
    invFact[n] = power(fact[n],MOD-2);
    rrep(i,n-1) invFact[i] = invFact[i+1] * (i+1) %MOD;
}

ll comb(ll n, ll m){
    if(n<m||n<0||m<0) return 0;
    return (fact[n] * invFact[m] %MOD) * invFact[n-m] %MOD;
}

ll hcomb(ll n, ll m){
    if(n==0&&m==0) return 1;
    return comb(n+m-1,m);
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    make_combT(200000);
    int N,M;
    cin>>N>>M;
    
    map<int,int> dic;
    for(int i=2;i<=M;i++){
        while(M%i==0){
            dic[i]++;
            M/=i;
        }
    }
    
    ll ans=1;
    for(auto a:dic){
        ll n=a.second;
        ans=ans*hcomb(N,n)%MOD;
    }
    cout1(ans)
}

Measured memory_bytes: 3328
A=[]
for i in range(3):
  a,b,c=map(int,input().split())
  A+=[a,b,c]
  
n=int(input())
T=[0]*9
for i in range(n):
  p=int(input())
  if p in A:
    T[A.index(p)]=1
    
if [1,1,1] in [T[0:3],T[3:6],T[6:9],T[0:7:3],T[1:9:3],T[2:9:3],T[0:10:4],T[2:7:2]]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            //ここから
            int n = int.Parse(Console.ReadLine());

            string[] song = new string[n];
            int[] time = new int[n];
            for (int i = 0; i < n; i++)
            {
                string[] str = Console.ReadLine().Split(' ');
                song[i] = str[0];
                time[i]= int.Parse(str[1]);
            }

            string X = Console.ReadLine();

            int ans = 0;
            bool sleep = false;

            for(int i = 0; i < n; i++)
            {
                if (X == song[i])
                {
                    sleep = true;
                }else if (sleep)
                {
                    ans += time[i];
                }
            }

            Console.WriteLine(ans);


            //ここまで
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;

#define MAX_N 1000000
#define INF 1000000

int P[MAX_N];

int main() {

  // -----------------------------
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  // input
  int N;
  cin >> N;

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


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

  int minval = INF;
  int cnt = 0;
  
  for ( int i = 0; i < N; i++) {
    minval = min(P[i], minval);
    if (minval == P[i]) {
      cnt++;
    }
  }

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


Measured memory_bytes: 1024
#include<stdio.h>

int dfs(int p, int q, int a, int n, int pre) {
	if (p == 0) return 1;
	if (n == 0) return 0;
	int res = 0;
	for (int i = pre; i <= 6000; i++) {
		if ((a/i) == 0)break;
		res += dfs(i*p - q, i*q, a / i, n - 1, i);
	}
	return res;
}

int main() {
	int p, q, a, n;
	while (scanf("%d %d %d %d", &p, &q, &a, &n), p) {
		printf("%d\n", dfs(p, q, a, n, 1));
	}
}

Measured memory_bytes: 2584
#include <cmath>
#include <iostream>

using namespace std;

typedef long long ll;

int main() {
  ll n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  if (a > b) swap(a, b);
  ll diff = b-a;
  for (ll i = 0; i < n-1; ++i) {
    // ll diff2 = diff+i*d;
    ll diff2 = diff+i*c;
    if (diff2 >= c*(n-1-i) && diff2 <= d*(n-1-i)) {
      cout << "YES" << endl;
      return 0;
    }
    ll diff3 = diff+i*d;
    if (diff3 >= c*(n-1-i) && diff3 <= d*(n-1-i)) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}


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


int main(){

    int N;
    cin >> N;

    long prev=0,res=1,A;

    int flag=0,haszero=0;

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

        if(A==0){
            prev = 0;
            haszero=1;
        }else if(res<prev || res > 1000000000000000000){
            flag = 1;
            //cout << res << " " << prev << " " << A << endl;
            //cout << -1 << endl;
            //return 0;
        }
        prev = res;
    }

    if(flag){
        if(haszero){
            cout << 0 << endl;
        }else{
            cout << -1 << endl;
        }
        
    }else{
        cout << res << endl;
    }

    

    return 0;
}


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

int main() {
	int r;
	cin >> r;
	string out;
	if (r < 1200) { out = "ABC";} 
	else if(r < 2800) {out = "ARC";}
	else {out = "AGC";}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

ll h;
ll rec(ll x) {
	if (x == 1)
		return 1;
	return rec(x / 2) * 2 + 1;
}
int main() {
	scanf("%lld", &h);
	printf("%lld\n", rec(h));
}

Measured memory_bytes: 128
-- noch nicht fertig

import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (unfoldr)

main :: IO ()
main = do
  [n, m, q] <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    candidates = (:) <$> id <*> unfoldr next $ replicate n 1 :: [[Int]]
      where
        next :: [Int] -> Maybe ([Int], [Int])
        next = fmap ((,) <$> id <*> id) . next'
          where
            next' :: [Int] -> Maybe [Int]
            next' (d : ds) | d < m     = Just $ succ d : ds
                           | otherwise = ((:) <$> head <*> id) <$> next' ds
            next' _                    = Nothing
  abcds <- sequence . replicate q $ unsafeListToTuple . map unsafeTextToInt . T.words <$> T.getLine :: IO [((Int, Int, Int), Int)]
  let
    evaluate :: [Int] -> Int
    evaluate ds = sum . map snd . filter (p . fst) $ abcds
      where
        p :: (Int, Int, Int) -> Bool
        p (x, y, z) = dy - dx == z
          where
            dy : ds' = drop (n - y) ds :: [Int]
            dx : _   = drop (pred y - x) ds' :: [Int]
  print . maximum . map evaluate $ candidates

unsafeListToTuple :: [Int] -> ((Int, Int, Int), Int)
unsafeListToTuple [w, x, y, z] = ((w, x, y), z)

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 4800
n = int(input())
L, R = [], []
for i in range(n):
    a, b = 0, 0
    for c in input():
        if c == '(':
            b += 1
        if c == ')':
            if b > 0:
                b -= 1
            else:
                a += 1
    if -a + b > 0:
        L.append((a, b))
    else:
        R.append((a, b))
L.sort(key=lambda x: x[0])
R.sort(key=lambda x: x[1], reverse=True)
x = 0
for a, b in L + R:
    x -= a
    if x < 0:
        print('No')
        exit()
    x += b
if x == 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 91756
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
//const n = +input[0];
//const a = [];
//for(let i=0;i<n;i++){
//	a.push(input[i+1].split(" ").map((x:string):number=>+x));
//}

//const [n, m] = input[0].split(" ").map((x: string): number => +x);
//const a = input[1].split(" ").map((x: string): number => +x);

function compareFunc(a, b){
    return a-b;
}

const r: number = +input[0];

console.log(3*r*r);

Measured memory_bytes: 7500
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; double k; cin >> n >> k;
	double ans = 0;
	rep(i, n) {
		double now = i + 1;
		double cnt = 0;
		while (true) {
			if (now >= k) {
				break;
			}
			now *= 2;
			cnt++;
		}
		if (cnt == 0)ans += 1.0 / (double)(n);
		else {
			ans += (1.0 / (double)(n))*(double)(1.0 / pow(2, cnt));
		}
	}
	cout << fixed << setprecision(15) << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))
c = [0] * N
for i in range(1, N):
    if i == 1:
        c[i] = abs(h[i] - h[0])
    else:
        c[i] = min(c[i-1]+abs(h[i]-h[i-1]), c[i-2]+abs(h[i]-h[i-2]))
print(c[-1])

Measured memory_bytes: 13980
/*
ID: iCoder0020
PROG: Frog 1
LANG: C++                  
*/

#include <bits/stdc++.h>

using namespace std;

int main()
{
	int N;
	cin>>N;
	int H[N];
	for(int n = 0; n<N; n++)
	{
		cin>>H[n];
	}
	int dp[N+1];
	dp[0] = 0;
	dp[1] = 0;
	dp[2] = abs(H[1]-H[0]);
	for(int n = 3; n<=N; n++)
	{
		dp[n] = min(dp[n-1] + abs(H[n-1]-H[n-2]), dp[n-2] + abs(H[n-1]-H[n-3]));
	}
	cout<<dp[N]<<endl;
	return 0;	
}

Measured memory_bytes: 1024