akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int mod = 1'000'000'007;
int mul(long long a, long long b){
	return a * b % mod;
}
int a[2345];
int main(){
	int n; long long  k; cin >> n >> k;
	for(int i = 0; i < n; i++) cin >> a[i];
	int ans = 0;
	int nr = (k * (k - 1) / 2) % mod;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(a[i] > a[j]){
				ans += nr;
				if(ans >= mod) ans -= mod;
				if(i < j){
					ans += k;
					if(ans >= mod) ans -= mod;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
  int k,n; cin>>k>>n;
  vector<int> a(n+1);
  for (int i=0; i<n; i++) cin>>a[i];
  a[n]=a[0]+k;
  
  int sum=0;
  int max_d=0;
  for (int j=1; j<n+1; j++){
    sum+=a[j]-a[j-1];
    max_d=max(max_d,a[j]-a[j-1]);
  }
  cout<<sum-max_d<<endl;  
}

Measured memory_bytes: 1024
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var X = sc.nextInt();
        var A = sc.nextInt();
        var B = sc.nextInt();
        if (A - B >= 0) {
            WriteLine("delicious");
        } else if (Abs(A - B) <= X) {
            WriteLine("safe");
        } else {
            WriteLine("dangerous");
        }
    }
    
}

class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 11220
dp=[1]*(10**5+1)
dp[0],dp[1]=0,0
for i in range(2,10**5+1):
  if dp[i]==0:
    continue
  j=i
  while j+i<=10**5:
    j+=i
    if dp[j]==1:
      dp[j]-=1
      
ni=[0]*(10**5+1)
for i in range(2,10**5+1):
  if dp[i]==1 and dp[(i+1)//2]==1:
    ni[i]=1

ru=[0]*(10**5+1)
for i in range(1,10**5+1):
  ru[i]=ru[i-1]+ni[i]

q=int(input())
for i in range(q):
  l,r=map(int,input().split())
  print(ru[r]-ru[l-1])

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

int main()
{
    /*A
    double n;
    cin>>n;
    if(int(n)%2==0)
    {
        cout<<(n/2)/n<<endl;
    }
    else
    {
        cout<<((n+1)/2)/n<<endl;
    }
    */

    int n,k;
    cin>>n>>k;
    int a[n];
    int count=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]>=k)
        {
            count++;
        }
    }

    cout<<count<<endl;
    
    return 0;
}

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

int main(){
    int n,m,l,cnt = 0;
    cin >> n;
    int a[n] = {0};
    
    rep(i,0,n){
        a[i] = 1;
    }
    
    rep(i,0,3){
        cin >> m;
        rep(j,0,m){
            cin >> l;
            a[l-1] *= 2*i+3;
        }
    }
    
    rep(i,0,n){
        if(((a[i] % 3 != 0) && (a[i] % 7 == 0)) || (a[i] % 35 == 0)){
            cnt++;
        }
    }
    
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 3112
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
	
	private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
	public static String[] readStandartInput() throws IOException{
		String str = br.readLine();
		String[] list = str.split(" ");
		
		return list;
	}
	
	public static void main(String[] args) throws NumberFormatException, IOException {
		int n = Integer.valueOf(readStandartInput()[0]);
		List<Integer> list = new ArrayList<>();
		
		for(int i = 0; i < n; i++){
			int a = Integer.valueOf(readStandartInput()[0]);
			list.add(a);
		}
		
		
		int old = list.get(0);
		int max = old;
		int min = old;
		int maxBenefit = 0;
		int maxDelta = Integer.MIN_VALUE;
		
		for(int i = 1; i < list.size(); i++){
			int r = list.get(i);
			int delta = r - old;
			if(maxDelta < delta){
				maxDelta = delta;
			}
			if(r < min){
				min = r;
				max = r;
			}else if(max < r){
				max = r;
				int benefit = max - min;
				if(maxBenefit < benefit){
					maxBenefit = benefit;
				}
			}
			old = r;
		}
		if(maxBenefit == 0){
			maxBenefit = maxDelta;
		}
		
		System.out.println(maxBenefit);
		
		
	}
	
}



Measured memory_bytes: 56516
N,A = map(int,input().split())
X = list(map(int,input().split()))

# dp[n][k][s] : n枚目までからk枚選んで合計をsにする場合の数
dp = [[[0 for _ in range(2501)] for _ in range(N+1)] for _ in range(N+1)]
dp[0][0][0] = 1

for n in range(N+1):
    for k in range(n+1):
        for s in range(50*k+1):
            if n>=1 and s<X[n-1]:
                dp[n][k][s] = dp[n-1][k][s]
            elif n>=1 and k>=1 and s>=X[n-1]:
                dp[n][k][s] = dp[n-1][k][s] + dp[n-1][k-1][s-X[n-1]]

Ans = 0
for i in range(1,N+1):
    Ans += dp[N][i][i*A]

print(Ans)

Measured memory_bytes: 65520
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Integer[] a = new Integer[n];

		int i = 0;
		while(sc.hasNext()) {
			a[i] = sc.nextInt();
			i++;
		}

		Arrays.sort(a, Collections.reverseOrder());

		int Alice = 0;
		int Bob = 0;
		int diff = 0;
		for(int j=0; j<a.length; j++) {
			if (j % 2 == 0) {
				Alice += a[j];
			} else {
				Bob += a[j];
			}
		}
		diff = Alice - Bob;
		System.out.println(diff);
	}
}


Measured memory_bytes: 22740
x,y=list(map(int, input().split()))
a=list(map(int, input().split()))
ans=0
for i in range(y-1):
	if ans<abs(a[i]-a[i+1]):
		ans=abs(a[i]-a[i+1])

if (x+a[0])-a[y-1]>ans:
	ans=(x+a[0])-a[y-1]

print(x-ans)

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

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'

using namespace std;

typedef long long   ll;
typedef long double ld;

typedef pair<ll, ll>    pll;
typedef pair<ll, int>   pli;
typedef pair<int, int>  pii;

typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll>  vll;

const int Inf = (int) 1e9;
const ll  InfL = (ll)  1e18;

const int MaxN = (int) 2e5 + 5;

int n, a[MaxN], b[MaxN];

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

#ifdef LOCAL
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif

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

	sort(b, b + n);

	for (int i = 0; i < n; i++)
		if (a[i] >= b[n/2]) cout << b[n/2 - 1] << endl;
		else cout << b[n/2] << endl;

	return 0;
}


Measured memory_bytes: 3840
#include <iostream>
using namespace std;
int main() {
    string s; cin >> s;
    int ans = 1000;
    for (char c = 'a'; c <= 'z'; c++) {
        int temp = 0;
        for (int i = 0; i < s.size(); i++) {
            int j =  i;
            while (j < s.size() && s[j] != c) j++;
            temp = max(temp, j-i);
        }
        ans = min(ans, temp);
    }
    cout << ans << endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;

#define INF INT_MAX
#define MOD 1000000007
#define all(x) x.begin(), x.end()

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

    int N, P; cin >> N >> P;
    string S; cin >> S;


    if(P == 2 or P == 5){
        ll ans = 0;
        for(int x = 0; x < N; x++){
            int v = S[x] - '0';
            if(v % P == 0) ans += x+1;
        }
        cout << ans << endl;
        exit(0);
    }
    reverse(all(S));


    map<ll, ll> K; K[0]++;
    ll ans = 0;

    ll val = 0, pow = 1;
    for(int x = 0; x < N; x++){
        ll v = S[x] - '0';
        val += (v*pow)%P;
        val %= P;

        ans += K[val]++;

        pow *= 10;
        pow %= P;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1044
from math import factorial
import sys

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip()
    count = 0
    for s in (input_raw):
        if s == 'o':
            count += 1
    print 700 + count * 100

if __name__ == '__main__':
    main()

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

int main(){
  int N ; cin >> N ;
  string S ; cin >> S ;
  int s = S.size();
  string t = S.substr(0,s/2) ;
  string p = S.substr(s/2,s/2);
  if(s%2!=0) cout << "No" << endl;
  else if(t==p) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}



Measured memory_bytes: 256
def solve():
  x_max, y_max, N_max = map(int, input().split())
  x_min, y_min = 0, 0
  area = x_max * y_max
  W, H, N = [], [], []
  for i in range(N_max):
    x, y, a = map(int, input().split())
    if a == 1 and x_min < x:
      x_min = x
    elif a == 2 and x_max > x:
      x_max = x
    elif a == 3 and y_min < y:
      y_min = y
    elif a == 4 and y_max > y:
      y_max = y

  if x_max <= x_min or y_max <= y_min:
    print(0)
  else:
    print((x_max - x_min) * (y_max - y_min))

solve()

Measured memory_bytes: 3064
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

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();}

#define dump(x)  cout << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class ESecondSum {
public:
    void solve(std::istream& in, std::ostream& out) {
        int N;
        in >> N;
        vector<int> P(N);
        REP(i,0,N) in >> P[i];

        vector<pair<int,int>> pIndex(N);
        REP(i,0,N) pIndex[i] = {P[i], i};
        sort(all(pIndex), greater<pair<int,int>>());


        ll answer = 0;
        set<int> processed;
        REP(i,0,N) {
            const int target = pIndex[i].first;
            const int targetIndex = pIndex[i].second;
            const auto itrRight = processed.upper_bound(targetIndex);
            const auto itrLeft = itrRight != processed.begin() && processed.size() != 0 ? prev(itrRight) : processed.end();
            if (itrRight != processed.end()) {
                const auto itrRight2 = next(itrRight);
                ll left = itrLeft != processed.end() ? targetIndex - *itrLeft : targetIndex+1;
                ll right = itrRight2 != processed.end() ? *itrRight2 - *itrRight : N - *itrRight;
                answer += left * right * target;
            }
            if (itrLeft != processed.end()) {
                const auto itrLeft2 = itrLeft != processed.begin() && processed.size() != 0 ? prev(itrLeft) : processed.end();
                ll left = itrLeft2 != processed.end() ? *itrLeft - *itrLeft2 : (*itrLeft)+1;
                ll right = itrRight != processed.end() ? *itrRight - targetIndex : N - targetIndex;
                answer += left * right * target;
            }
            processed.insert(targetIndex);
        }
        out << answer << "\n";
    }
};


int main() {
    ESecondSum solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 6144
#include <stdio.h>

int main () {
	int H, W, A;
	int c[10][10];
	scanf ("%d %d", &H, &W);
	int sum = 0;
	for (int col=0; col<10; col++)
		for (int row=0; row<10; row++)
			scanf ("%d", &(c[col][row]));

	for (int k=0; k<10; k++)
		for (int i=0; i<10; i++)
			for (int j=0; j<10; j++)
				if (c[i][j]>c[i][k]+c[k][j]) c[i][j] = c[i][k]+c[k][j];

	for (int w=0; w<W; w++) {
		for (int h=0; h<H; h++) {
			scanf ("%d", &A);
			if (A!=-1)
				sum += c[A][1];
		}
	}
	printf ("%d\n", sum);
	return 0;
}




Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define degreeToRadian(deg) (((deg)/360)*2*M_PI)
#define radianTodegree(rad) (((rad)/2/M_PI)*360)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const int MOD = 1e9 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//cin.tie(0);ios::sync_with_stdio(false);
//cout << fixed << setprecision(15) << y << endl;
int main() {
  string s;
  cin >> s;
  int q;
  cin >> q;

  bool rev = false;
  vector<char> head, tail;
  rep (i, q) {
    int t;
    cin >> t;
    
    if (t == 1) {
      if (!rev) rev = true;
      else rev = false;
      vector<char> tmp = head;
      head = tail;
      tail = tmp;
      //reverse
    } else if (t == 2) {
      int f;
      char c;
      cin >> f >> c;

      if (f == 1) {
	// insert to front.
	head.push_back(c);
      } else {
	// insert to back.
	tail.push_back(c);
      }
    }
  }


  string s1 = "";
  string s2 = "";
  reverse(head.begin(), head.end());
  for (auto v : head) s1 += v;
  for (auto v : tail) s2 += v;

  if (rev) reverse(s.begin(), s.end());
  

  cout << s1 + s + s2 << endl;

  return 0;
}


Measured memory_bytes: 4600
/*
ei1333さんのライブラリ
verify
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_A

*/
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
#include<map>
#include<set>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/

typedef pair<ll,ll> P;
vector<P> prime_factor(ll N){
    vector<P> ret;
    int count=0;
    while(!(N&1)) N>>=1,count++;
    if(count) ret.emplace_back(2,count);

    for(ll i=3;i*i<=N;i++){
        if(N%i==0 ){
            int count=0;
            while(N%i==0){
                N/=i;
                count++;
            }
            ret.emplace_back(i,count);
        }
    }
    if(N!=1) ret.emplace_back(N,1);
    return ret;
}

signed main(void){
    int N;
    cin>>N;
    cout<<N<<":";
    vector<P> V=prime_factor(N);
    for(auto x: V){
        for(int i=0;i<x.second;i++) cout<<" "<<x.first;
    }
    cout<<endl;    
}


Measured memory_bytes: 3112
n,m=map(int,input().split())
arr=[[]for i in range(8)]
ans=0
sign=[(1,1,1),(1,1,-1),(1,-1,1),(1,-1,-1)
    ,(-1,1,1),(-1,1,-1),(-1,-1,1),(-1,-1,-1)]

for i in range(n):
    x,y,z=map(int,input().split())
    for j in range(8):
        p,q,r=sign[j]
        arr[j].append(p*x+q*y+r*z)
for i in range(8):
    arr[i].sort()
    arr[i].reverse()
for i in range(8):
    ans=max(ans,sum(arr[i][:m]))
print(ans)

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

int main(){
	int k, even, odd;
	cin >> k;
	even = k/2;
	if(k % 2 == 1){
		odd = (k+1)/2;
	}
	else{
		odd = k/2;
	}
	
	cout << even*odd << endl;
	
	return 0;
}
	


Measured memory_bytes: 256
// TOPSIC001_0

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int _loop_int;
#define REP(i, n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i, a, b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i, a, b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a, b) a=min((a),(b))
#define CHMAX(a, b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a, b) (abs(a-b)<EPS)
typedef complex<Real> P;


int main() {
    int N,D;cin >> N >> D;
    D*=2;
    D++;

    int ans;
    ans=N/D;

    if(N%D)ans++;

    cout << ans;
}


Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=400;
const int MAXM=100000;
typedef struct E { int to,t; } E;

int n,m;
vector<E> e[MAXN];

bool survive[MAXN];
int eat[MAXN][MAXN];
int q[MAXN],qhead,qtail;

void run() {
	scanf("%d%d",&n,&m);
	REP(i,m) {
		int a,b; scanf("%d%d",&a,&b); --a,--b;
		E ea; ea.to=b; ea.t=i; e[a].PB(ea);
		E eb; eb.to=a; eb.t=i; e[b].PB(eb);
	}

	REP(i,n) {
		//printf("processing %d\n",i);
		REP(j,n) eat[i][j]=-1; survive[i]=true;
		qhead=qtail=0; q[qhead++]=i;
		while(qtail<qhead&&survive[i]) {
			int at=q[qtail++];
			//printf("\tat=%d\n",at);
			REPSZ(k,e[at]) {
				int to=e[at][k].to,t=e[at][k].t;
				if(eat[i][at]!=-1&&t>=eat[i][at]) continue;
				if(eat[i][to]!=-1) { survive[i]=false; break; }
				eat[i][to]=t; q[qhead++]=to;
			}
		}
	}
	int ret=0;
	REP(i,n) if(survive[i]) FOR(j,i+1,n) if(survive[j]&&eat[i][j]==-1&&eat[j][i]==-1) {
		bool ok=true;
		REP(k,n) if(k!=i&&k!=j&&eat[i][k]!=-1&&eat[j][k]!=-1) ok=false;
		if(ok) ++ret;
	}
	printf("%d\n",ret);
}

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


Measured memory_bytes: 3328
n, m, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

x = sorted(x)
y = sorted(y)

#X < x[-1]では境界値が抜けている。
if x[-1] < y[0] and X <= x[-1] and y[0] <= Y:
    print("No War")
else:
    print("War")


Measured memory_bytes: 9104
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
  ll N; cin>>N;
  char c;
  while(cin>>c && c != '='){
    ll M; cin>>M;
    if(c == '+'){
      N = N + M;
    }else if(c == '-'){
      N = N - M;
    }else if(c == '*'){
      N = N * M;
    }else if(c == '/'){
      N = N / M;
    }
  }
  cout<<N<<endl;
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
#include <random>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector <int> a(n);
  int sum = 0;
  for (int i = 0; i < n; i++) {
	  cin >> a[i];
	  sum += a[i];
	}
  int m  = 1e9;
  int mn = -1;
  for (int i = 0; i < n; i++) {
	  if (abs(sum - n * a[i]) < m) {
		  m  = abs(sum - n * a[i]);
		  mn = i;
		}
	}
  cout << mn << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstdlib>

int main(void){
	double d,a;
	scanf("%lf",&d);
	if(d<1.0){
		printf("%.10f\n",d*sqrt(2.0));
	}else if(d<sqrt(2)){
		printf("%.10f\n",2.0);
	}else if(d<2.0){
		printf("%.10f\n",d*sqrt(2.0));
	}else{
		printf("%.10f\n",fmax(3.0,d*sqrt(2.0)));
	}
	return 0;
}

Measured memory_bytes: 1084
using System;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');
        var cat = Convert.ToInt32(input[0]);
        var other = Convert.ToInt32(input[1]);
        var will = Convert.ToInt32(input[2]);

        if (cat <= will&&will <= cat + other) Console.WriteLine("YES");
        else Console.WriteLine("NO");
    }
}


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

using namespace std;

typedef long long ll;

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

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

int solve(const int N, const int K, const string S) {
    char prev = S[0];
    int count = 0;
    int ok = 0;
    for (int i = 1; i < N; i++) {
        if (S[i] != prev) {
            count++;
            prev = S[i];
        } else {
            ok++;
        }
    }
    return min(N - 1, ok + 2 * K);
}

int main(void) {
    int N, K;
    cin >> N >> K;

    string S;
    cin >> S;

    cout << solve(N, K, S) << endl;

    return 0;
}


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

using lint = long long;
#define reps(i, a, n) for (lint i = (a); i < (lint)(n); ++i)
#define rep(i, n) reps(i, 0, n)
struct pre_{pre_(){cin.tie(0);ios::sync_with_stdio(0);}} pre__;
// }}}

int n;
int a[100000];
lint res = 1;
const int mod = 1e9 + 7;

signed main() {
  cin >> n;
  rep(i, n) cin >> a[i];
  map<int, int> chie;
  if (n % 2 != 0) {
    rep(i, n) {
      chie[a[i]]++;
    }
    for (auto c : chie) {
      if (c.first == 0) {
        if (c.second != 1) {
          cout << "0" << endl;
          return 0;
        }
      } else {
        if (c.second % 2 != 0) {
          cout << "0" << endl;
          return 0;
        }
      }
      (res *= c.second) %= mod;
    }
  } else {
    rep(i, n) {
      chie[a[i]]++;
    }
    for (auto c : chie) {
      if (c.second % 2 != 0) {
        cout << "0" << endl;
        return 0;
      }
      (res *= c.second) %= mod;
    }
  }
  cout << res % mod << endl;
}


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

int main () {
  int N, M, S;
  cin >> N >> M;
  vector<int> A(N);
  S = 0;
  
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    S += A.at(i);
  }
  
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  
  if (A.at(M-1) * 4 * M < S) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}

    
  

Measured memory_bytes: 256
n = int(input())
s = input()
t = input()


ans = []

for i in range(n):
    if (s[i] == t[0]):
        for j in range(0, n - i):
            if (s[i + j] != t[j]):
                break
        else:
            ans+=t
            #print(t)
            break

    #else:
    ans.append(s[i])
#        print(s[i],end="")
else:
    ans+=t
    #print(t)
#print(ans)
print(len(ans))


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
 
using namespace std;
 
const int INF = 999999;
int N, M_a, M_b;
int dp[41][401][401];
int a[41];
int b[41];
int c[41];
int ans = INF;
int s, t;
 
int gcd (int x, int y) {
  if(x < y) swap(x,y);
  while(y > 0) {
    int r = x % y;
    x = y;
    y = r;
  }
  return x;
}
 
int main() {
  cin >> N >> M_a >> M_b;
 
 
  for(int i = 0; i < N; i++) {
    
    cin >> a[i] >> b[i] >> c[i];
    s += a[i];
    t += b[i];
  }
 
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < s+1; j++) {
      for(int k = 0; k < t+1; k++) {
	dp[i][j][k] = INF;
      }
    }
  }
 
 
  dp[0][0][0] = 0;
  dp[0][a[0]][b[0]] = c[0];
  
  for(int i = 1; i < N; i++) {
    for(int j = 0; j < s+1; j++) {
      for(int k = 0; k < t+1; k++) {
	if(j >= a[i] && k >= b[i]){
	  dp[i][j][k] = min(dp[i-1][j][k],dp[i-1][j-a[i]][k-b[i]] + c[i]);
	}
	else {dp[i][j][k] = dp[i-1][j][k];}
      }
    }
  }
  
  for(int i = 1; i < s+1; i++) {
    for(int j = 1; j < t+1; j++) {
      // cout <<"dp["<<i<<"]["<<j<<"] = "<<dp[N-1][i][j]<<endl;
      if((i * M_b) == (j * M_a)) {
	ans = min(ans,dp[N-1][i][j]);
      }
    }
  }
  if(ans == INF) cout <<"-1"<<endl;
  else cout << ans <<endl;
}

Measured memory_bytes: 24448
#include <stdio.h>
int main(void){
int n;
int a[100];
int i;
int x=0;
int max=0;
int min=101;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&a[i]);
if(((a[i]%10)!=0)&&(min >a[i])){
min =a[i];
x=1;
}
max=a[i]+max;
}
if((max%10)!=0)
printf("%d",max);
else{
if(x==1){
max = max -min;
}
else{
max=0;
}
printf("%d",max);

}
return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

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

		Scanner sc = new Scanner(System.in);

		int n,y;

		n = sc.nextInt();
		y = sc.nextInt();

		int i,j,k;



		for(i = 0; i <= n; i++) {
			for(j = 0; j <= n; j++) {
				for(k = 0 ; k <= n; k++) {

					int total = 10000*i+5000*j+1000*k;
					if(i+j+k > n || total > y) {
						break;
					}

					if(total == y && i+j+k == n) {
						System.out.println(i+" "+j+" "+k);
						return;
					}
				}
			}
		}
		System.out.println("-1 -1 -1");

	}

}


Measured memory_bytes: 23252
#include<cstdio>

static const int MAX_N = 100;
int N;
int A[MAX_N];

void InsertionSort(){
	for(int i = 1; i < N; i++){
		int key = A[i];
		int j = i - 1;
		while(j >= 0 && A[j] > key){
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = key;
		for(int k = 0; k < N; k++){
			printf("%d", A[k]);
			if(k == N - 1) printf("\n");
			else printf(" ");
		}
	}
}

int main(void){
	scanf("%d", &N);
	for(int i = 0; i < N; i++){
		scanf("%d", &A[i]);
	}
	for(int i = 0; i < N; i++){
		printf("%d", A[i]);
		if(i == N - 1) printf("\n");
		else printf(" ");
	}
	InsertionSort();
	return 0;
}

Measured memory_bytes: 2688
#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int x,k,d;
   cin >> x >> k >> d;
   if(x < 0){
      x = -x;      
   }
   int req = x/d;
   if(k < req){
      cout << x-k*d << '\n';
      return 0;
   }
   debug(req);
   int c = x-req*d;
   k -= req;
   if(k & 1){
      cout << abs(c-d) << '\n';
   }else{
      cout << c << '\n';
   }
   return 0;
} 

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef pair<ll,ll> pll;
typedef vector<string> vs;
typedef vector<pll> vpl;
typedef vector<int> vi;

int32_t main(){
	int n , k;
	cin >> n >> k;
	int ans = 0;
	while(n > 0){
		ans ++ ;
		n /= k;
	}	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
     
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
     
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll, ll>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

#define N 100001
#define K 100001
vi par(N); //親
vi ran(N); //木の深さ
vi num(N);

//n要素で初期化
void init(int n){
	int i;
	for (i = 0; i < n; i++) {
		par[i]=i;
		ran[i]=0;
		num[i] = 1;
	}
}

//木の根を求める
int find(int x){
	if(par[x]==x){
		return x;
	}else{
		return par[x]=find(par[x]);
	}
}

//xとyの属する集合を併合
void unite(int x,int y){
	x=find(x);
	y=find(y);
	int numsum = num[x] + num[y];
	if(x==y){
		return;
	}
	if(ran[x]<ran[y]){
		par[x]=y;
	}else{
		par[y]=x;
		if(ran[x]==ran[y]){
			ran[x]++;
		}
	}
	num[x] = num[y] = numsum;
}

//xとyが同じ集合に属するか否か
bool same(int x,int y){
	return find(x)==find(y);
}


int main() {
  int n, m, i, j;
  cin >> n >> m;
  vi k(n);
  vii p2l(n, vi());
  vii l2p(m, vi());
  for (i = 0; i < n; i++) {
    cin >> k[i];
    for (j = 0; j < k[i]; j++) {
      int a;
      cin >> a;
      a--;
      p2l[i].push_back(a);
      l2p[a].push_back(i);
    }
  }
  init(n);
  for (i = 0; i < m; i++) {
    for (j = 1; j < l2p[i].size(); j++) {
      unite(l2p[i][0], l2p[i][j]);
    }
  }
  if (num[find(0)] == n) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 9976
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/


int N, K, A[101];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> K;
    rep(i, 0, N) cin >> A[i];
    sort(A, A + N, greater<int>());

    int ans = 0;
    rep(i, 0, K) ans += A[i];
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int sum=0;
    while(m--)
    {
        int x;
        scanf("%d",&x);
        sum+=x;
    }
    if(n>=sum) printf("%d\n",n-sum);
    else printf("-1\n");
    return 0;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,H,W;cin >> N >> H >> W;
  int count = 0;
  rep(i,N){
    int h,w;cin >> h >> w;
    if(H<=h && W<=w)++count;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct node{
	int val;
	node *l,*r;
};
node* parse(string S){
	// cout << S << endl;
	int nest = 0;
	int val = 0;
	int st = -1;
	int end = -1;
	for(int i=0;i<S.size();i++){
		if(S[i]=='('){
			nest++;
		}else if(S[i]==')'){
			nest--;
		}
		if(nest==0&&S[i]=='['){
			st = i;
		}
		if(st!=-1&&'0'<=S[i]&&S[i]<='9'){
			val = val*10+(int)(S[i]-'0');
		}
		if(st!=-1&&S[i]==']'){
			end = i;
			break;
		}
	}
	if(st==-1){
		return NULL;
	}
	//cout << st << ' ' << end << endl;
	node* v = (node*)malloc(sizeof(node));
	v->val = val;
	v->l = parse(S.substr(1,st-2));
	v->r = parse(S.substr(end+2,S.size()-end-3));
	return v; 
}
node* conv(node* a,node* b){
	node* v = (node*)malloc(sizeof(node));
	v->val = (a->val)+(b->val);
	if((a->l)==NULL||(b->l)==NULL)v->l = NULL;
	else v->l = conv(a->l,b->l);
	if((a->r)==NULL||(b->r)==NULL)v->r = NULL;
	else v->r = conv(a->r,b->r);
	return v;
}
void print(node* v){
	if(v==NULL){
		cout << "";
		return;
	}
	cout << '(';
	print(v->l);
	cout << ')';
	cout << '[' <<  v->val << ']';
	cout << '(';
	print(v->r);
	cout << ')';
	return;
}
string s,t;
int main(){
	cin >> s >> t;
	node *a = parse(s);
	node *b = parse(t);
	node *c = conv(a,b);
	print(c);
	cout << endl;
	return 0;
}


Measured memory_bytes: 3312
#include <stdio.h>
int main (void){
    int n,a,b,c,d,ans;
    while(scanf("%d",&n)!=EOF){
        ans=0;
        for(a=0;a<10;a++){
            for(b=0;b<10;b++){
                for(c=0;c<10;c++){
                    for(d=0;d<10;d++){
                        if(a+b+c+d==n){
                            ans++;
                        }
                    }
                }
            }
        }
        printf("%d\n",ans);
    }
return 0;
}

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

int main() 
{
  int a,b,c,x,counter=0,sum=0;
  cin >> a >> b >> c >> x;

  for(int i=0; i<=a; i++)
  {
    for(int j=0; j<=b; j++)
    {   
      for(int k=0; k<=c; k++)
      {   
        sum = 500*i + 100*j + 50*k;
        if(sum == x) counter++;
      }   
    }   
  }

  cout << counter << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

typedef long long LL;

struct D{
	int i;
	LL k;
};

const int maxn=2e5+5;

int n,a[maxn],occur[maxn],d0;
LL k;
D p[maxn],d[maxn];
bool bz[maxn];

int ans0,ans[maxn];
void Last(int x)
{
	memset(bz,0,sizeof(bz));
	fo(i,x,n) if (!bz[a[i]])
	{
		ans[++ans0]=a[i];
		bz[a[i]]=1;
	} else
	{
		while (bz[a[i]]) bz[ans[ans0--]]=0;
	}
	fo(i,1,ans0) printf("%d ",ans[i]);
}

int main()
{
	scanf("%d %lld",&n,&k);
	fo(i,1,n) scanf("%d",&a[i]);
	
	fd(i,n,1)
	{
		if (occur[a[i]])
		{
			if (occur[a[i]]==n) p[i]=(D){1,1ll}; else p[i]=(D){occur[a[i]]+1,0ll};
		}
		occur[a[i]]=i;
	}
	memset(occur,0,sizeof(occur));
	fo(i,1,n)
	{
		if (!occur[a[i]]) occur[a[i]]=i;
		if (!p[i].i)
		{
			if (occur[a[i]]==n) p[i]=(D){1,2ll}; else p[i]=(D){occur[a[i]]+1,1ll};
		}
	}
	
	D i=(D){1,1};
	memset(occur,0,sizeof(occur));
	for(; i.k<k; i.k+=p[i.i].k, i.i=p[i.i].i)
	{
		d[++d0]=i;
		if (occur[i.i]) break; else occur[i.i]=d0;
	}
	
	if (i.k==k) {Last(i.i); return 0;}
	LL cir=d[d0].k-d[occur[d[d0].i]].k;
	i.k=d[occur[d[d0].i]].k+(k-d[occur[d[d0].i]].k)/cir*cir;
	
	for(; i.k<k; i.k+=p[i.i].k, i.i=p[i.i].i);
	Last(i.i);
}

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

int main(){
  int n, i;
  cin >> n;
  int a[n];

  for(i = 0; i <= n - 1; i++) cin >> a[i];
  for(i = n - 1; i > 0; i--) cout << a[i] << " ";
  cout << a[0] << endl;
  return 0;
}

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

int main() {
  int n; cin>>n;
  int allXOR=0;
  vector<int> a(n);
  for(int i=0; i<n; i++) {
    cin>>a[i];
    // 与えられた配列のXOR
    allXOR=allXOR^a[i];
  }
  // 与えられた数列のxorをもう一度求めたとする
  // それは、解となる数列のxorを奇数回求めたものと等しい
  // つまり、解となる数列のxorと同様（偶数倍のxorは相殺されるから）
  for(int i=0; i<n; i++) {
    int ans=allXOR^a[i];
    cout << ans << " ";
  }
  cout << endl;
}


Measured memory_bytes: 4048
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#define MODD 1000000007
#define ll long long
using namespace std;

int A[111111];

int main() {
    int N,T;
    cin>>N>>T;
    for(int i=1;i<=N;i++) {
        cin>>A[i];
    }
    
    int max_profit = 0;
    int mx = 0;
    for(int i=N;i>=1;i--) {
        if (mx > A[i]) {
            max_profit = max(max_profit, mx-A[i]);
        }
        mx = max(mx, A[i]);
    }
    
    int ans = 0;
    map<int,int> counts;
    for(int i=N;i>=1;i--) {
        int reqd = max_profit+A[i];
        if (counts.find(reqd) != counts.end())
            ans++;
        counts[A[i]]++;
    }
    
    cout << ans << endl;
    
}

Measured memory_bytes: 5376
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int[] a=new int[n];
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
    if(a[i]%2==0){
      if(a[i]%3==0||a[i]%5==0){
        
      }else{
        System.out.println("DENIED");
        return;
      }
    }
    }
    System.out.println("APPROVED");
  }
}

Measured memory_bytes: 22868
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
int main(){
ll a,b;
cin>>a;
  if(a<1200)
    cout<<"ABC";
  else if(a<2800)
    cout<<"ARC";
  else
    cout<<"AGC";
return 0;
}


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

int main(){
    ll N; cin >> N;
    vector<ll> A(N);
    rep(i, 0, N) cin >> A[i];
    sort(A.begin(), A.end());
    
    if(N%2 == 0){
        ll c = 1;
        for(ll i = 0; i < N-1; i += 2){
            if(A[i] != c || A[i+1] != c){
                cout << 0 << endl;
                return 0;
            }
            c += 2;
        }
    }else{
        ll c = 2;
        if(A[0] != 0){
            cout << 0 << endl;
            return 0;
        }
        for(ll i = 1; i < N-1; i += 2){
            if(A[i] != c || A[i+1] != c){
                cout << 0 << endl;
                return 0;
            }
            c += 2;
        }
    }

    ll ans = 1;
    ll mod = 1e9+7;
    rep(i, 0, N/2){
        ans *= 2;
        ans %= mod;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = a; i <= b; i++)

#include <iostream>

using namespace std;

int find(string str, char c)
{
    int ans = 0;
    rep(i, 0, str.size()) if (str[i] == c) ++ans;
    return ans;
}

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

    if (find(A+B+C, '5') == 2 && find(A+B+C, '7')) {
        cout << "YES" << endl;
        return 0;
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dump(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
/* テンプレートここまで */

struct UnionFind {
  vector<int> par;
  vector<int> sizes;

  UnionFind(int N) : par(N), sizes(N, 1) {
    for(int i = 0; i < N; i++) par.at(i) = i;
  }

  int find(int x) { 
    if (par.at(x) == x) return x;
    return par.at(x) = find(par.at(x));
  }

  void unite(int x, int y) {
    int rx = find(x); 
    int ry = find(y); 
    if (rx == ry) return; 
    if (sizes.at(rx) < sizes.at(ry)) swap(rx,ry);
    par.at(ry) = rx;
    sizes.at(rx) += sizes.at(ry);    
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }

  int size(int x){
    return sizes.at(find(x));
  }

  int num_of_connected_components(){
    int ret = 0;
    for(int i = 0; i < par.size(); i++){
      if(find(i) == i) ret++;
    }
    return ret;
  }
};

int main() {
  int N, M;
  cin >> N >> M;

  UnionFind uf(N);  

  REP(i,M){
    int x, y, z;
    cin >> x >> y >> z;
    x--; y--; z--;
    uf.unite(x,y);
  }

  cout << uf.num_of_connected_components() << endl;
}
 

Measured memory_bytes: 1024
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  string s; readV(s);
  writeln(min(s.count('0'), s.count('1'))*2);
}


Measured memory_bytes: 2556
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define MAX 100006
int a[MAX],dp[MAX];
signed main()
{
	int n,i,k,j;
	cin>>n>>k;
	for(i=1;i<=n;i++)
	{
	cin>>a[i];
	dp[i]=10000000000;
}
	dp[1]=0;
	for(i=2;i<=n;i++)
	for(j=1;j<=min(k,i-1);j++)
	dp[i]=min(dp[i-j]+abs(a[i]-a[i-j]),dp[i]);
	cout<<dp[n]<<"\n";
}

Measured memory_bytes: 1792
row , col = [int(x) for x in input().split()]
A = [0] * row

for i in range(row):
    A[i] = [int(x) for x in input().split()]
B = []
for i in range(col):
    B.append(int(input()))

for i in range(row):
    s = 0
    for j in range(col):
        s += A[i][j] * B[j]
    print(s)
    

Measured memory_bytes: 8108
public partial class IntroductionToProgramming{
	public static void Main(){
		string[] line = System.Console.ReadLine().Split(' ');

		int h = int.Parse(line[0]);
		int w = int.Parse(line[1]);

		while (!(h == 0 && w == 0))
		{
			string s = new string('#', w);
			for (int i = 0; i < h; i++ )
			{
				System.Console.WriteLine(s);
			}
			System.Console.WriteLine(string.Empty);

			string[] line2 = System.Console.ReadLine().Split(' ');

			h = int.Parse(line2[0]);
			w = int.Parse(line2[1]);
		}
	}
}

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

using namespace std;

string bu(int x){
    string rec = "";
    int cnt = 0;
    while(x) {
        rec += x % 10 + '0';
        x /= 10;
        cnt++;
    }
    reverse(rec.begin(), rec.end());
    cnt = 6 - cnt;
    rec = string(cnt, '0') + rec;
    return rec;
}

struct node{
    int x, i;
    string name;
    bool operator < (const node & rhs) const{
        return x < rhs.x;
    }
};

vector<node> a[100005];

string ans[100005];

int main(){
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= m; i++){
        int x, y;
        cin >> x >> y;
        a[x].push_back({y, i, ""});
    }
    for(int i = 1; i <= n; i++){
        sort(a[i].begin(), a[i].end());
        for(int j = 0; j < a[i].size(); j++){
            ans[a[i][j].i] = bu(i) + bu(j + 1);
        }
    }
    for(int i = 1; i <= m; i++){
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 12416
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

// ll m_lcm(vector<int> &a, int lv, int n){
// 	if(lv == 2){
// 		ll g = __gcd(a.at(lv-2), a.at(lv-1));
// 		ll l = a.at(lv-2) * a.at(lv-1);
// 		l /= g;
// 		return l;
// 	}else{
// 		ll lm = m_lcm(a, lv-1, n);
// 		ll g = __gcd(lm, (ll)a.at(lv-1));
// 		ll l = lm * a.at(lv-1);
// 		l /= g;
// 		return l;
// 	}
// }

int main(){
	int n, m;
	cin >> n >> m;
	vector<ll> a(n);
	rep(snip_i, n) cin >> a.at(snip_i);
	int c;
	rep(i, n){
		if(i == 0){
			c = 0;
			ll temp = a.at(0);
			while(1){
				if(temp % 2 == 0){
					temp /= 2;
					c++;
				}else{
					break;
				}
			}
		}else{
			int ct = 0;
			ll temp = a.at(i);
			while(1){
				if(temp % 2 == 0){
					temp /= 2;
					ct++;
				}else{
					break;
				}
			}
			if(ct != c){
				cout << 0 << endl;
				return 0;
			}
		}
	}
	rep(i, n) a.at(i) /= 2;
	ll l = a.at(0);
	rep2(i, 1, n){
		ll g = __gcd(l, a.at(i));
		l /= g;
		l *= a.at(i);
	}
	// cerr << l << endl;
	int ans = (ll)m / l - (ll)m / (2*l);
	cout << ans << endl;

	return 0;
}

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

using namespace std;
typedef long long int ll;

int bs(int x){
	int l=0, h=1000000;
	while(l<h){
		int m=(l+h)/2;
		ll v=m;
		v*=(m+1);
		v/=2;
		if(v==x) return m;
		if(v<x) l=m+1;
		else h=m;
	}
	ll v=l;
	v=v*(l+1)/2;
	if(v>x) l--;
	return l;
}
 
int main(){
	//~ int t;
	//~ cin>>t;
	//~ while(t--){
		int n;
		cin>>n;
		int k=bs(n);
		if(k*(k+1)/2==n) cout<<k<<endl;
		else cout<<k+1<<endl;
	//~ }
}

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

#define mod 1000000007

using namespace std;
typedef long long ll; 
 
int main(void){
	
	int A, B;
	string S;
	
	cin >> A >> B >> S;
	
	if(S.length() == A + B + 1 && S[A] == '-'){
		int count = 0;
		for(int i=0; i<A+B+1; i++){
			if(i == A)
				continue;
			else if(S[i] != '-')
				count++;
		}
		if(count == A + B)
			cout << "Yes";
		else
			cout << "No";
	}
	else
		cout << "No";
	
	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a:usize = read();
    let b:usize = read();
    let c:usize = read();
    let x:usize = read();
    let mut ans = 0;
    for i in 0..=a {
        for j in 0..=b {
            for k in 0..=c {
                if i*500 + j*100 + k*50 == x {
                    ans += 1;
                }
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int a, b;
    cin >> a >> b;
    if (a >= 13) cout << b << endl;
    else if (a >= 6) cout << b / 2 << endl;
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
q,h,s,d = map(int,input().split())
n = int(input())
a = [q,h,s,d]
b = [4*q,2*h,s]
c = b.index(min(b))

if b[c]*2 > d:
    ans = n//2 * d
    if n % 2 == 1:
        ans += b[c]
else:
    ans = n*b[c]
    
print(ans)

Measured memory_bytes: 3064