akhauriyash/Code-Regression huggingface dataset:
/*
*Author : Omkar Deshmukh
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define all(v) v.begin(), v.end()
#define intvect vector<int>
#define ull unsigned long long
#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
const int mod = 1e9 + 7;
void solve()
{
    int k, a, b;
    cin >> k >> a >> b;
    for (int i = a; i <= b; i++)
    {
        if (i % k == 0)
        {
            cout << "OK" << endl;
            exit(0);
        }
    }
    cout << "NG" << endl;
}
int main()
{
    fast;
    solve();
    return 0;
}

Measured memory_bytes: 3668
import std.functional,
       std.algorithm,
       std.container,
       std.typetuple,
       std.typecons,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv,
       std.format;

void main()
{
foreach(i; 0..10000){
	auto ip = readln.split.to!(int[]);
	if(ip[0] == 0 && ip[1] == 0) break;
	else{
		ip.sort().array;
		writefln("%s %s", ip[0], ip[1]);
	} 
}
}


Measured memory_bytes: 2628
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N; cin >> N;
  vector<vector<int>> M(N, vector<int>(N,1));
  int edge = N*(N-1)/2;
  if (N%2==0) {
    for (int i=0; i<N; i++) {
      for (int j=i+1; j<N; j++) {
        if(i+j+2==N+1) {M[i][j]=0;edge--;}
      }
    }
  }
  else {
    for (int i=0; i<N; i++) {
      for (int j=i+1; j<N; j++) {
        if (i+j+2==N) {M[i][j]=0; edge--;}
      }
    }
  }
  cout << edge << "\n";
  for (int i=0; i<N; i++) {
    for (int j=i+1; j<N; j++) {
      if(M[i][j]==1) cout << i+1 << ' ' << j+1 << "\n";
    }
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{


    int H,W;

    while(1)
    {

 scanf("%d%d",&H,&W);
 if(H==0&&W==0)
    break;
    for(int i=0;i<H;i++)
    {
        for(int j=0;j<W;j++)
        {
            if((j+i)%2==0)
                printf("#");
            else
                printf(".");
        }
        printf("\n");
    }
     printf("\n");
    }
}



Measured memory_bytes: 2704
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int n;
  cin>>n;
  int a[n];
  REP(i, n)cin>>a[i];
  if(n==1){
    cout<<a[0]<<endl;
    return 0;
  }

  deque<int> b;
  b.push_back(a[0]);
  FOR(i, 1, n){
    if((i+n)%2) b.push_front(a[i]);
    else b.push_back(a[i]);
  }

  REP(i, n-1)cout<<b[i]<<" ";
  cout<<b[n-1]<<endl;


  return 0;
}


Measured memory_bytes: 3840
#include<iostream>
#include<string>
#include<cctype>

using namespace std;

string toUpper(string s) {
	string t = s;
	for (int i = 0; i < s.size(); i++) {
		t[i] = toupper(s[i]);
	}
	return t;
}

int main() {
	string target, source;

	cin >> target;
	target = toUpper(target);

	int cnt = 0;

	while (1) {
		cin >> source;
		if (source == "END_OF_TEXT")break;
		source = toUpper(source);
		if (target == source)cnt++;
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 3176
import java.util.*;

public class Main{
    public static void main(String[] args){
        new Main().A();
    }

    void A(){
        int a,b;

        Scanner sc=new Scanner(System.in);

        a=sc.nextInt();
        b=sc.nextInt();

        int n=0;

        if(a>b){
            n=a;
            a=b;
            b=n;
        }

        StringBuilder sb=new StringBuilder();

        for(int i=0;i<b;i++){
            sb.append(a);
        }

        System.out.println(sb.toString());
    }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N;
    cin>>N;
    int ans=0;
    for(int i=1;i<=N;i++){
        int x=N/i;
        int y=(x+1)*x/2;
        y*=i;
        ans+=y;
    }
    cout << ans << endl;



    



}


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


def main():
    s = list(map(int, input()))
    n = len(s)

    case1 = [0] * n
    case2 = [0] * n

    for i in range(n):
        if i % 2 == 0:
            case1[i] = 1
        else:
            case2[i] = 1

    count1 = 0
    count2 = 0

    for one, si in zip(case1, s):
        if one != si:
            count1 += 1

    for two, si in zip(case2, s):
        if two != si:
            count2 += 1

    print(min(count1, count2))


if __name__ == '__main__':
    main()


Measured memory_bytes: 5536
#include <iostream>
#include <vector>
#include <string>

int main() {
  size_t H, W;
  std::cin >> H >> W;

  std::vector<std::string> a;
  for (size_t i = 0; i < H; ++i) {
    std::string tmp;
    std::cin >> tmp;
    if (tmp != std::string(W, '.')) a.push_back(tmp);
  }

  std::vector<std::string> b(a.size());
  for (size_t j = 0; j < W; ++j) {
    bool black = false;
    for (size_t i = 0; i < a.size(); ++i) {
      if (a[i][j] == '#') {
        black = true;
        break;
      }
    }
    if (black)
      for (size_t i = 0; i < a.size(); ++i)
        b[i] += a[i][j];
  }

  for (const auto& bi: b)
    std::cout << bi << std::endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=510000;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
    ll N;
    cin>>N;
    vector<ll> X(N),L(N);
    vector<pair<ll,ll>> p(N);
    for(ll i=0;i<N;i++) cin>>X[i]>>L[i];
    for(ll i=0;i<N;i++){
        p[i].second=X[i]-L[i];
        p[i].first=X[i]+L[i];
    }
    sort(p.begin(),p.end());
    ll cur=p[0].first,cnt=0;
    for(ll i=1;i<N;i++){
        if(cur<=p[i].second){
            cur=p[i].first;
        }else cnt++;
    }
    cout<<N-cnt<<endl;
}

Measured memory_bytes: 3328
/*

    author : s@if

*/

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

#define 		NIL 			-1
#define		 	fi	 		    first
#define 		sec 			second
#define 		MAX 			INT_MAX
#define			INF 			99999999
#define 		ll 			    long long
#define 		PI 			    acos(-1.0)
#define			MOD 			1000000007
#define 		PLL 			pair<ll,ll>
#define 		PII			    pair<int,int>
#define 		ull 			unsigned long long
#define 		For(i,a,b) 		for(int i=a;i<=(int)b;i++)


bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hr[]={-2,-2,-1,+1,+2,+2,-1,+1};
int hc[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)1e5+9;

int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */

    int i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

    cin>>n>>m>>p;

    cout<<min(n*m,p)<<endl;

    return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)


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

#素数列挙
M=55555
m=int(M**0.5)+1

S=[ 0 for _ in range(M+1) ]

#エラトステネスの篩
for i in range(2,m+1):
    for j in range(i*2,M+1,i):
        S[j]=1

N=input()
cnt=0
for i in range(2,M+1):
    if S[i]==0 and i%5==1:
        print i,
        cnt+=1
        if cnt==N:
            quit()


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

int main() {
  int N;
  cin >> N;
  
  int occupancy = 0;
  
  for (int i=0; i<N; i++){
    int l,r;
    
    cin >> l >> r;
    
    occupancy += (r-l)+1;
  }
  
    cout << occupancy << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	if (a < b)
	{
		cout << "a < b" << endl;
	}
	else if (a > b)
	{
		cout << "a > b" << endl;
	}
	else
	{
		cout << "a == b" << endl;
	}
	return 0;
}


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

bool palindrome(string s)
{
int n=s.size();
int i=0;
while(s[i]!='\0')
{
    if(s[i]!=s[n-i-1])
    return false;
    i++;
}
return true;
}



int main(){
int i,j;
string s;
cin>>s;

int n=s.size();
if(palindrome(s))
{
j=0;
string t="";
int l=(n+1)/2;
--l;
while(j<l)
{
t=t+s[j];
j++;
}


if(palindrome(t))
{
i=(n+3)/2,j=0;
--i;
string p="";
while(i<n)
{
p=p+s[i];
j++;i++;
}


if(palindrome(p))
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}

else
cout<<"No"<<endl;


}

else
cout<<"No"<<endl;

}

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

#ifdef _DEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif

using namespace std;

int main() {
    int S, W; cin >> S >> W;
    if (S <= W) {cout << "unsafe" << endl;}
    else {cout << "safe" << endl;}
}

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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)

#define BR "\n"

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

  queue<int> Q[n];

  rep0(i, q) {
    int query; cin >> query;
    if (query == 0) {
      int t, x; cin >> t >> x;
      Q[t].push(x);
    } else if (query == 1) {
      int t; cin >> t;
      if (Q[t].size() > 0) cout << Q[t].front() << BR;
    } else {
      int t; cin >> t;
      if (Q[t].size() > 0) Q[t].pop();
    }
  }

  return 0;
}


Measured memory_bytes: 4196
N, x = gets.split.map(&:to_i)
as = gets.split.map(&:to_i).sort

if as.inject(:+) == x
    puts N
else
    ans = 0
    as.each do |a|
        if x >= a
            ans += 1
            x -= a
        else
            break
        end
    end
    puts [ans, N-1].min
end

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

int m, nMin, nMax;
int p[200];

int main() {
	while (cin >> m >> nMin >> nMax) {
		if (!m) break;
		for (int i = 0; i < m; i++) {
			cin >> p[i];
		}
		
		int gap = -1, ans = -1;
		for (int i = nMax; i >= nMin; i--) {
			if (gap < p[i-1] - p[i]) {
				gap = p[i-1] - p[i];
				ans = i;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int compare(const void *a, const void *b){
  return strcmp(a,b);
}

int main(void){
  int n;
  int i;
  char s[200000][11];
  int count = 0;
  
  scanf("%d",&n);
  
  for(i =0; i < n; i++)
    scanf("%s",s[i]);
  
  qsort(s,n,11,compare);
  
  for(i = 0;i < n; i++){
    if(strcmp(s[i],s[i+1])!=0){
      count++;
    }
  }
  
  printf("%d",count);
}


Measured memory_bytes: 5704
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main(){
    int n, a=0;
    cin >> n;
    int h[n];
    for(int i=0; i<n; ++i) cin >> h[i];
    int ans = 0;

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

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    ll v[3][2];
    rep(i, 2) rep(j, 3) cin >> v[j][i];
    ll ans = 0;
    //Aで換金、Bで購入
    ll dp1[N+1];
    rep(i, N+1){
        dp1[i] = i;
        rep(j, 3){
            if(v[j][0] >= v[j][1]) continue;
            if(i >= v[j][0]) dp1[i] = max(dp1[i], dp1[i-v[j][0]]+v[j][1]);
        }
    }
    //Bで換金、Aで購入
    N = dp1[N];
    ll dp2[N+1];
    rep(i, N+1){
        dp2[i] = i;
        rep(j, 3){
            if(v[j][1] >= v[j][0]) continue;
            if(i >= v[j][1]) dp2[i] = max(dp2[i], dp2[i-v[j][1]]+v[j][0]);
        }
    }
    cout << dp2[N] << endl;
}

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

int h,w,k,ans;
bool a[6][6];
char c;

int main() {
    cin >> h >> w >> k;
    for (int i = 0 ; i < h ; ++i) {
        for (int j = 0 ; j < w ; ++j) {
            cin >> c;
            a[i][j] = (c == '#');
        }
    }

    int sum;
    for (int rmask = 0 ; rmask < (1 << h) ; ++rmask) {
        for (int cmask = 0 ; cmask < (1 << w) ; ++cmask) {
            sum = 0;
            for (int i = 0 ; i < h ; ++i) {
                for (int j = 0 ; j < w ; ++j) {
                    sum += (((rmask >> i) & 1) && ((cmask >> j) & 1) && a[i][j]);
                }
            }

            if (sum == k) ans++;
        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 300009
#define mx 10000000000008
#define mod 1000000007
ll n,tt,arr[sz],t[4*sz];
ll query(ll node,ll l,ll r,ll le,ll ri)
{
    if(le>ri || l>ri || r<le)
        return 0;
    if(le<=l && r<=ri)
        return t[node];
    ll mid=(l+r)/2;
    return max(query(2*node,l,mid,le,ri),query(2*node+1,mid+1,r,le,ri));
}
void update(ll node,ll l,ll r,ll ind,ll val)
{
    if(ind>r || ind<l)
        return;
    if(l==r)
    {
        t[node]=val;
        return;
    }
    ll mid=(l+r)/2;
    update(node*2,l,mid,ind,val);
    update(node*2+1,mid+1,r,ind,val);
    t[node]=max(t[2*node],t[2*node+1]);
    return;
}
int main()
{
    //scanf("%lld",&t);
    tt=1;
    while(tt--)
    {
        ll k;
        scanf("%lld %lld",&n,&k);
        ll ans=0;
        for(int i=1;i<=n;i++)
        {
            scanf("%lld",&arr[i]);
            ll a=query(1,0,300000,arr[i]-k,arr[i]+k);
            update(1,0,300000,arr[i],a+1);
            ans=max(ans,a+1);
        }
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 14296
from functools import lru_cache
import sys

sys.setrecursionlimit(10 ** 7)


@lru_cache(maxsize=None)
def check(l, r, n, k=1):
    t = l + '0' * k + r
    e = l + '9' * k + r

    if int(e) <= n:
        return pow(10, k) + check(l, r, n, k + 1)

    if int(t) <= n < int(e):
        x = int(str(n)[1:-1])
        if int(str(n)[-1]) < int(r):
            x -= 1
        return x + 1

    if n < int(t):
        return 0


def main():
    n = int(input())

    ret = 0
    for x in range(1, n + 1):
        if x % 10 == 0:
            continue
        s = str(x)
        t = s[-1] + s[0]
        if s[0] == s[-1]:
            ret += 1
        if int(t) <= n:
            ret += 1
        ret += check(s[-1], s[0], n, k=1)

    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include <iostream>
        #include <algorithm>
        using namespace std;
        
        long long int comb[100][100];
        
        int main() {
        	long long int N, A, B, v[100];
        	cin >> N >> A >> B;
        	for(int i = 0; i < N; i++){
        		cin >> v[i];
        	}
        	sort(v, v + N);
        	double sum = 0;
        	for(int i = N - A; i <= N - 1; i++){
        		sum += v[i];
        	}
        	sum /= A;
        	for(long long int i = 0; i < 60; i++){
        		for(long long int j = 0; j <= i; j++){
        			if(j == 0 || j == i){
        				comb[i][j] = 1;
        			}else{
        				comb[i][j] = comb[i - 1][j] + comb[i - 1][j - 1];
        			}
        		}
        	}
        	long long int ans = 0;
        	int count2 = 0;
        	long long int num = v[N - A];
        	for(int i = 0; i < N; i++){
        		count2 += num == v[i];
        	}
        	bool flag = true;
    	for(int i = N - A + 1; i <= N - 1; i++){
    		if(v[i] != v[i - 1]){
    			flag = false;
    		}
    	}
        	ans = 0;
        	int count = 0;
        	if(flag){
        		for(int i = N - 1; i >= 0; i--){
        			if(v[i] == num){
        				count++;
        				if(N - B <= i && i <= N - A){
        					ans += comb[count2][count];
        				}
        			}
        		}
        	}else{
        		for(int i = N - 1; i >= 0; i--){
        			if(v[i] == num){
        				count++;
        				if(N - A == i){
        					ans += comb[count2][count];
        				}
        			}
        		}
        	}
        	printf("%.6f\n", sum);
        	cout << ans << endl;
        	return 0;
        }

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



int main(){

	int W,H,i,j;

	for (;;){
		cin >> H >> W;
		if (W == 0 && H == 0)
			break;

		for (i = 0; i < H; i++){
			for (j = 0; j < W; j++){

				if (i % 2 == 0){//??¶??°???
					if (j % 2 == 0){//??¶??°?????¶??°???
						cout << "#";
					}
					else{//??¶??°????\???°???
						cout << ".";
					}
				}
				else{//?\???°???
					if (j % 2 == 0){//?\???°?????¶??°???
						cout << ".";
					}
					else{//?\???°????\???°???
						cout << "#";
					}
				}
			}
			cout << endl;
		}cout << endl;
	
	}

	return 0;
}

Measured memory_bytes: 1152
import math
N,D = map(int,input().split())
X = [list(map(int,input().split())) for _ in range(N)]
cnt = 0
for i in range(N-1):
    for j in range(i+1,N):
        distance = 0
        for d in range(D):
            distance += (X[i][d]-X[j][d])**2
        distance = math.sqrt(distance)
        if(distance == int(distance)):
            cnt += 1
print(cnt)

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

using namespace std;

int main()
{
   ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int k,x;
    cin>>k>>x;
    for(int i=x-k+1;i<=x+k-1;i++)
    {
        cout<<i<<" ";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {

  int H, W; std::cin >> H >> W;
  std::vector< std::vector<char> > a(H, std::vector<char>(W));
  for(int i=0; i<H; i++) for(int j=0; j<W; j++) std::cin >> a[i][j];

  std::vector<int> h(H), w(W);
  for(int i=0; i<H; i++) {
    bool ok = true;
    for(int j=0; j<W; j++) {
      if ( a[i][j] == '#' ) ok = false;
    }
    if ( ok ) h[i] = 1;
    else      h[i] = 0;
  }

  for(int j=0; j<W; j++) {
    bool ok = true;
    for(int i=0; i<H; i++) {
      if ( a[i][j] == '#' ) ok = false;
    }
    if ( ok ) w[j] = 1;
    else      w[j] = 0;
  }

  for(int i=0; i<H; i++) {
    bool fill = false;
    for(int j=0; j<W; j++) {
      if ( h[i] == 0 && w[j] == 0 ) {
        std::cout << a[i][j];
        fill = true;
      }
    }
    if( fill ) std::cout << std::endl;
    fill = false;
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main() {
	char S[11];
	char x[11];
	int loop1, loop2;
	loop2 = 0;
	scanf("%s",&S);
	for (loop1 = 0; loop1 <= 10; loop1++) {
		if (S[loop1] == '\0') {
			x[loop2] = '\0';
			break;

		}
		switch (S[loop1]) {
		case 48:
		case 49: {
			x[loop2] = S[loop1];
			loop2++;
			break;
		}
		case 66: {
			if (loop2 != 0) loop2--;
			break;
		}

		}

	}

	printf("%s\n", x);

	return 0;

}


Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<queue>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	if(n<1200){
		printf("ABC\n");
	}
	else if(n<2800){
		printf("ARC\n");
	}
	else{
		printf("AGC\n");
	}
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
typedef long long int64;
typedef pair<int64, int64> pll;

const int MAX_N = 200000;

map<int,int> cnt;

int A[MAX_N];

int main(){
	int N;	scanf("%d",&N);
	for (int i = 0; i < N; ++i)
		scanf("%d", A+i);

	int64 ans = 0;
	for (int i = 0; i < N; ++i){
		ans += cnt[i-A[i]];
		++cnt[i+A[i]];
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 20980
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}
#define int ll

map<pair<int,int>, int> cnter;
void starter() {
	int cnt[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
	int day = 1;
	int month = 1;
	int now = 60 * 24;
	while (month != 13) {
		cnter[mp(month, day)] = now;
		now += 60 * 24;
		day++;
		if (cnt[month] == day - 1) {
			day = 1;
			month++;
		}
	}
	return;
}

pair<int, int> goi(string s) {
	int a = (s[0] - '0') * 10 + s[1] - '0';
	int b = (s[3] - '0') * 10 + s[4] - '0';
	return mp(a, b);
}

void solve(){
	starter();
	while (true) {
		int n;
		cin >> n;
		if (n == 0) return;
		vector<tuple<int, string, int>> gogo;
		REP(i, n) {
			string a, b, c, d;
			cin >> a >> b >> c >> d;
			pair<int, int> e = goi(a);
			pair<int, int> f = goi(b);
			gogo.push_back(make_tuple(cnter[e] + f.first * 60 + f.second, c, stoll(d)));
		}
		sort(ALL(gogo));
		set<int> now_here;
		map<int, int> winning;
		REP(i, gogo.size()) {
			if (now_here.find(0) != now_here.end()) {
				for (auto x : now_here) {
					if (x == 0) continue;
					winning[x] += get<0>(gogo[i]) - get<0>(gogo[i - 1]);
				}
			}
			if (get<1>(gogo[i]) == "I") {
				now_here.insert(get<2>(gogo[i]));
			}
			else {
				now_here.erase(get<2>(gogo[i]));
			}
		}
		int now_max = 0;
		for (auto x : winning) {
			now_max = max(now_max, x.second);
		}
		cout << now_max << endl;
	}
}

#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pairs;

#define MOD 998244353


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

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}


const double PI = acos(-1);

int main(){
    ll a,b,h,m;
    cin>>a>>b>>h>>m;
    
    double thetah = double(h*60+m)/720 * 2*PI;
    double thetam = double(m)/60 * 2*PI;
    double xh = a*cos(thetah), yh = a*sin(thetah);
    double xm = b*cos(thetam), ym = b*sin(thetam);
    double dx = xh-xm, dy = yh-ym;
    double ans = sqrt(dx*dx + dy*dy);
    printf("%.10f\n",ans);
    
    return 0;
}


Measured memory_bytes: 4032
# -*- coding: utf-8 -*-
# 整数の入力
import math

short, long, H, M = map(int, input().split())

x_pos_short = short * math.sin(math.radians(H*30 + (30*(M/60))))
y_pos_short = short * math.cos(math.radians(H*30 + (30*(M/60))))

x_pos_long = long * math.sin(math.radians(M*6))
y_pos_long = long * math.cos(math.radians(M*6))

dist = math.sqrt(math.pow((x_pos_short - x_pos_long),2) + math.pow((y_pos_short - y_pos_long),2))

print(dist)

Measured memory_bytes: 9528
#include<bits/stdc++.h>
#define ll long long
#define fastio  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD=1000000007;
#define PI acos(-1)
using namespace std;
int main(){
	 string s;
	 cin >> s ;
	 ll sum =0;
	 for(int i =0 ; i < s.size() ; i++){
	 	 sum += (s[i]-'0');
	 }
	 if(sum%9 ==0) cout << "Yes" << endl;
	 else cout << "No" <<endl;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch OrdinaryNumber | diff OrdinaryNumber.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address OrdinaryNumber.cpp && ./a.out

/*
 
 6/29/2019
 
 5:03-
 
 */

const int MAX_N=1e6+1;
LL A[MAX_N];
int N;

void solve() {
  int res=0;
  REP(i,N-2) {
    int a=A[i],b=A[i+1],c=A[i+2];
    res+=(a>b&&b>c)||(c>b&&b>a);
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N;
  REP(i,N) cin>>A[i];
  solve();
  
  return 0;
}


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

using namespace std;

int main() {
    int N, M, sum, count;
    cin >> N >> M;
    vector<double> vec(N);
    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
        sum += vec.at(i);
    }
    double jd = (double) sum / (4.0 * M);
    for (int i = 0; i < N; i++) {
        if (vec.at(i) >= jd) {
            count++;
        }
    }
    if (M <= count) {
        cout << "Yes" << endl;
    } else {
        cout << "No"<< endl;
    }
}

Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


def cumsum(a):
    """l[i] = sum(a[:i]) なるlを返す
    sum(a[i:j]) == l[j+1] - l[i]
    """
    c = 0
    l = [None] * (len(a)+1)
    for i,num in enumerate(a):
        l[i] = c
        c += num
    l[-1] = c
    return l

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

r = m-1
s = sum(b)
num = m
best = 0
while s>k and r>=0:
    s -= b[r]
    r -= 1
    num -= 1
if s<=k:
    best = max(best, num)
for l in range(n):
    num += 1
    s += a[l]
    while s>k and r>=0:
        s -= b[r]
        r -= 1
        num -= 1
    if s<=k:
        best = max(best, num)
print(best)

Measured memory_bytes: 118068
#include <stdio.h>

int main(void)
{
	int a,b,c,d,e[10000],f[10000],h,g,i,j;
	a = b = 1;
	h = g = 0;
	
	while(a != 0 && b != 0){
		scanf("%d %d",&a,&b);
		
		e[h] = a;
		f[g] = b;
		
		++g;
		++h;
		j = h;
	}
	g = h = 0;
	
	for(i = 1;i < j;++i){
		for(c = 1;c <= e[g];++c){
			if(c % 2 == 1){
				for(d = 1;d <= f[h];++d){
					if(d % 2 == 1){
						printf("#");
					}
					else if(d % 2 == 0){
						printf(".");
					}
				}
			}
			else if(c % 2 == 0){
				for(d = 1;d <= f[h];++d){
					if(d % 2 == 1){
						printf(".");
					}
					else if(d % 2 == 0){
						printf("#");
					}
				}
			}
				
			printf("\n");
		}
		printf("\n");
		++h;
		++g;
	}
	
	return(0);
}

Measured memory_bytes: 2564
n = int(input())
h_L = list(map(int,input().split()))


s = h_L[0]
tmp = 0
result_L = []
for i in range(0,n-1):

    if s >= h_L[i+1]:
        tmp += 1
    else:
        result_L.append(tmp)
        tmp = 0

    s = h_L[i+1]

result_L.append(tmp)
print(max(result_L))

Measured memory_bytes: 63856
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
vector<int> g[100000];
int dp[100000][15] = {};
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, m, q;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  cin >> q;
  vector<int> c(q + 1);
  for (int i = 1; i <= q; i++) {
    int v, d;
    cin >> v >> d >> c[i];
    v--;
    dp[v][d] = max(dp[v][d], i);
  }
  for (int i = 10; i >= 1; i--) {
    for (int j = 0; j < n; j++) {
      for (int nbr : g[j]) {
        dp[nbr][i - 1] = max(dp[nbr][i - 1], dp[j][i]);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    int t = 0;
    for (int j = 0; j <= 10; j++) {
      t = max(t, dp[i][j]);
    }
    cout << c[t] << endl;
  }
  return 0;	
}

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

int main(){
    int N;
    int d[101];
    int count = 0;

    cin >> N;
    for (int i = 0; i < N; i++) cin >> d[i];

    for (int i = 0; i < N; i++){
        for(int j = i + 1; j < N; j++){
            if (d[i] == d[j]) d[j] = 0;
        }
    }
    for (int i = 0; i < N; i++){
        if (d[i] != 0) count ++;
    }

    cout << count << endl;
}

// model code with backet
// int main() {
//     int N;
//     int d[110];
//     cin >> N;
//     for (int i = 0; i < N; ++i) cin >> d[i];

//     int num[110] = {0};  // バケット
//     for (int i = 0; i < N; ++i) {
//         num[d[i]]++;  // d[i] が 1 個増える
//     }

//     int res = 0;  // 答えを格納
//     for (int i = 1; i <= 100; ++i) {  // 1 <= d[i] <= 100 なので 1 から 100 まで探索
//         if (num[i]) {  // 0 より大きかったら
//             ++res;
//         }
//     }
//     cout << res << endl;
// }

// model code with std::set
// #include <iostream>
// #include <set>
// using namespace std;

// int main() {
//     int N;
//     int d[110];
//     cin >> N;
//     for (int i = 0; i < N; ++i) cin >> d[i];

//     set<int> values; // insert するときに重複を取り除いてくれます
//     for (int i = 0; i < N; ++i) {
//         values.insert(d[i]); // 挿入します
//     }

//     // set のサイズを出力します
//     cout << values.size() << endl;
// }

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
score = 0
for a, b in zip(A, B):
    diff = b - a
    if diff > 0:
        score += diff // 2
    else:
        score += diff
print("Yes") if score >= 0 else print("No")


Measured memory_bytes: 68588
#include <bits/stdc++.h>
#include <string.h>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15

 int main(){

 long long n,a,b,ans=0;
 cin>>n>>a>>b;

  for(int i=1;i<=n;i++)
 {
    int sum =0;

    if(i<10) sum = i;
    else{
    int num = i;
    while(num){
        int rem = num%10;
        sum += rem;
        num = num/10;
    }
  }

    if(sum >= a && sum <= b)
        ans += i;
  }

  cout<<ans<<endl;

 return 0;
 }


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

int main() {
  const unsigned long long mod = 1000000007;
  unsigned long long h, w, a, b;
  std::cin >> h >> w >> a >> b;
  std::vector<unsigned long long> inv(h + w + 1);
  inv[1] = 1;
  for (unsigned i = 2; i <= h + w; ++i) {
    inv[i] = mod - (mod / i) * inv[mod % i] % mod;
  }
  std::vector<unsigned long long> fact(h + w + 1);
  fact[0] = 1;
  for (unsigned i = 1; i <= h + w; ++i) {
    fact[i] = fact[i - 1] * i % mod;
  }
  std::vector<unsigned long long> inv_fact(h + w + 1);
  inv_fact[0] = 1;
  for (unsigned i = 1; i <= h + w; ++i) {
    inv_fact[i] = inv_fact[i - 1] * inv[i] % mod;
  }
  unsigned long long ans = 0ull;
  for (unsigned i = 1; i <= h - a; ++i) {
    auto x = fact[i - 1 + b - 1];
    x *= inv_fact[i - 1];
    x %= mod;
    x *= inv_fact[b - 1];
    x %= mod;
    auto y = fact[h - i + w - b - 1];
    y *= inv_fact[h - i];
    y %= mod;
    y *= inv_fact[w - b - 1];
    y %= mod;
    ans += x * y % mod;
    ans %= mod;
  }
  std::cout << ans;
  return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define debug(x) cerr<<#x<<" = "<<(x)<<endl
#define eps 1e-8
#define pi acos(-1.0)
using namespace std;
void test(){cerr<<"\n";}
template<typename T,typename... Args>void test(T x,Args... args){cerr<<x<<" ";test(args...);}
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int MAXN=(int)1e5+5;
const int MOD=(int)1e9+7;
pii a[MAXN];
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>a[i].fi>>a[i].se;
    }
    sort(a+1,a+1+n);
    ll ans=0;
    for(int i=1;i<=n;i++){
        int de=min(a[i].se,m);
        m-=de;
        ans+=1ll*de*a[i].fi;
    }
    cout<<ans<<"\n";
    return 0;
}


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

int main() {
    int n, m;
    vector<string> S, T;
    cin >> n;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        S.push_back(s);
    }
    cin >> m;
    for (int i = 0; i < m; i++) {
        string s;
        cin >> s;
        T.push_back(s);
    }

    int ans_max = 0;
    for (int i = 0; i < n; i++) {
        int ans = 0;
        for (int j = 0; j < n; j++) {
            if (S[i] == S[j]) {
                ans++;
            }
        }
        for (int j = 0; j < m; j++) {
            if (S[i] == T[j]) {
                ans--;
            }
        }
        ans_max = max(ans, ans_max);
    }

    cout << ans_max << endl;

    return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a = [2**(ord(c)-97) for c in S()]
    b = [0]
    d2 = {}
    d2[0] = 0
    c = 0
    ii = [2**i for i in range(26)]
    for t,i in zip(a, range(1,len(a)+1)):
        c ^= t
        tr = inf
        if c in d2:
            tr = d2[c] + 1

        for j in ii:
            e = c ^ j
            if e in d2 and d2[e] + 1 < tr:
                tr = d2[e] + 1
        if c not in d2 or d2[c] > tr:
            d2[c] = tr
    return d2[c] if d2[c] else 1



print(main())




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

int main(){
    string S;
    cin >> S;
    string res;
    reverse(S.begin(),S.end());
    for(int i=0;i<S.size();){
        if(S[i]=='r'&&S[i+2]=='s'){
            res=S.substr(i,6);
            if(res!="resare"){
                cout << "NO" << endl;
                return 0;
            }
            i+=res.size();
        }else if(S[i]=='e'){
            res=S.substr(i,5);
            if(res!="esare"){
                cout << "NO" << endl;
                return 0;
            }
            i+=res.size();
        }else if(S[i]=='r'&&S[i+2]=='m'){
            res=S.substr(i,7);
            if(res!="remaerd"){
                cout << "NO " << endl;
                return 0;
            }
            i+=res.size();
        }else if(S[i]=='m'){
            res=S.substr(i,5);
            if(res!="maerd"){
                cout << "NO" << endl;
                return 0;
            }
            i+=res.size();
        }else{
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

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

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

    if(S[5] == '0' && S[6] <= '4'){
        cout << "Heisei" << endl;
    }else{
        cout << "TBD" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
//#typedef int ll
// include
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <tuple>
// namespace
using namespace std;
// typedef
typedef long long ll;
typedef long double ld;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pint;
// const
const int inf = 1e9;
const ll mod = ((ll)1e9 + 7);
// loop
#define rep(i, n) for(ll i = 0, i##_mx = n; i < i##_mx; i++)
#define brep(i, b, e) for(ll i = b; i < e; i++)
#define erep(i, b, e) for(ll i = b; i <= e; i++)
#define rrep(i, b, e) for(ll i = b; i >= e; i--)
// STL
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(), (v).end()
// sort
#define vsort(v, b) sort(all(v), [](auto l, auto r){return (b);})
// access
#define gt(i, n) get<n>(i)
// function
ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
void prime(vll& v, ll n){brep(i, 2, n){bool fg = false; for(auto e : v){if(i % e == 0){fg = true;}} if(fg){continue;} v.pb(i);}}
void in(vint& v){for(auto& i : v){cin >> i;}}
void in(vll& v){for(auto& i : v){cin >> i;}}
ll egcd(ll a, ll b, ll& x, ll& y){if(b == 0){x = 1; y = 0; return a;} ll d = egcd(b, a % b, y, x); y -= a / b * x; return d;}

signed main(){
    ll a, b;
    cin >> a >> b;
    
    ll g = gcd(a, b);
    
    ll ans = 1;
    if(g % 2 == 0){
        ans++;
        while(g % 2 == 0){
            g /= 2;
        }
    }
    
    for(auto i = 3; i <= 1e6; i += 2){
        if(g % i == 0){
            ans++;
            while(g % i == 0){
                g /= i;
            }
        }
    }
    
    if(g != 1){
        ans++;
    }
    
    cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left
import sys
def main():
  input=sys.stdin.readline
  a,b,q=map(int,input().split())
  s=[int(input()) for i in range(a)]
  t=[int(input()) for i in range(b)]
  x=[int(input()) for i in range(q)]
  inf=10**11
  minf=-10**11
  s=[minf]+s+[inf]
  t=[minf]+t+[inf]
  for i in range(q):
    ns=bisect_left(s,x[i])
    nt=bisect_left(t,x[i])
    ans=float('inf')
    for j in [s[ns],s[ns-1]]:
      for k in [t[nt],t[nt-1]]:
        ans=min(ans,min(abs(x[i]-j),abs(x[i]-k))+abs(max(j,k)-min(j,k)))
    print(ans)
if __name__=='__main__':
  main()

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    int N, Q; 
    string S;
    cin >> N >> Q;
    cin >> S;
    vector<int> l(N, 0), r(N, 0);
    REP(i, Q)
    {
        cin >> l[i] >> r[i];
    }

    vector<int> sum(N + 1, 0);
    for(int i = 1; i < N; ++i)
    {
        if (S[i - 1] == 'A' && S[i] == 'C') sum[i + 1] = sum[i] + 1;
        else sum[i + 1] = sum[i];
    }

    REP(i, Q) cout << sum[r[i]] - sum[l[i]] << endl;
}

Measured memory_bytes: 2176
N = int(input())
d = [int(input()) for j in range(N)]

# d = [1,2]

d.sort(reverse=True)

current_mochi = 0
next_mochi = 0
counter = 0

for i,num in enumerate(d):
    next_mochi = num
    if i == 0:
        counter+=1
        current_mochi = num
    elif i + 1 == len(d):
        if current_mochi > next_mochi:
            counter+=1
            break
        else:
            break
    elif current_mochi > next_mochi:
        counter+=1
        current_mochi = num

print(counter)

Measured memory_bytes: 3064
import math
import fractions
#import sys
#input = sys.stdin.readline

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans
'''
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 2
N = 10 ** 6 + 2
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

'''

#a = list(map(int, input().split()))

#################################################
#################################################
#################################################
#################################################


n = int(input())

AB = [[-1 for i in range(n)]for j in range(n)]

for ii in range(n):
    i = ii+1
    for jj in range(n):
        j = jj+1
        AB[ii][jj] = fractions.gcd(i,j)

ans=0
for i in range(n):
    for j in range(n):
        for k in range(n):
            ans += AB[AB[i][j]-1][k]
            
print(ans)







Measured memory_bytes: 75688
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
#define int long long

signed main() {
    int n, t, a;
    cin >> n >> t >> a;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    int dis = 10000 * INF;
    int ans;
    rep(i, n) {
        if (chmin(dis, abs(1000 * t - h[i] * 6 - 1000 * a)))
            ans = i;
    }
    cout << ans + 1 << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007
#define pi atan(1) * 4

int main()
{
	int n, m, r;
	cin >> n >> m >> r;
	int rr[8];
	for(int i = 0; i < r; i++){
		cin >> rr[i];
		rr[i]--;
	}
	long long int graph[201][201];
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			graph[i][j] = (long long int)10000 * mod;
		}
		graph[i][i] = 0;
	}
	for(int i = 0; i < m; i++){
		int a, b;
		long long int c;
		cin >> a >> b >> c;
		a--;
		b--;
		graph[a][b] = c;
		graph[b][a] = c;
	}
	for(int k = 0; k < n; k++){
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
			}
		}
	}
	long long int result[(1 << 8)][8];
	for(int i = 0; i < (1 << r); i++){
		for(int j = 0; j < r; j++){
			result[i][j] = (long long int)1000000 * mod;
		}
	}
	for(int i = 0; i < r; i++){
		result[(1 << i)][i] = 0;
	}
	for(int i = 1; i < (1 << r); i++){
		for(int j = 0; j < r; j++){
			if((i & (1 << j)) != 0) continue;
			for(int k = 0; k < r; k++){
				if((i & (1 << k)) == 0) continue;
				result[i | (1 << j)][j] = min(result[i | (1 << j)][j], result[i][k] + graph[rr[j]][rr[k]]);
			}
		}
	}
	long long int ans = (long long int)100000 * mod;
	for(int i = 0; i < r; i++){
		ans = min(ans, result[(1 << r) - 1][i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <stdlib.h>
#include <vector> //vector
#include <algorithm> //sort()

using namespace std;
//long a, b, c, d, i, j, k, n;


int main(){
//////////////////////////////////////////////////////

    long n, h;
    cin >> n >> h ;

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

    //debug
    //cout << "n:" << n << endl;
    //cout << "h:" << h << endl;

    // for ( int i = 0 ; i < n ; ++i)
    // {
    //     cout << i << ":" << a[i] <<"," << b[i] << endl;
    // }


    long sumh = 0;
    long turn = 0;

    //解説
    //最後から順番に考えていく
    //最後，強い剣を全て投げた状態で終わるのが理想なので，強い剣から順番に投げていく
    //ただし,斬撃力の高い剣より打撃力の弱い剣は使わない．
    //（使わないものを除く）全ての剣を投げても相手が死なない場合は，最も斬撃力が強い剣を振ってダメージを与える

    //斬撃力の高い剣より打撃力の弱い剣は最初から使わないので
    //long max_a = *max_element(a.begin(), b.begin());
    long max_a = *max_element(a.begin(), a.end());

    //cout << "debug : max_a :" << max_a << endl;

    //投げる剣から
    vector<long> bs(b); //コピーコンストラクタを利用してbのコピーbsを作成
    sort(bs.begin(), bs.end());
    reverse(bs.begin(), bs.end());//降順に整理

    for(long x : bs)
    {
        if( x < max_a )//斬撃力の高い剣より打撃力の弱い剣の場合は何もしない
        {
            continue;
        }
        sumh += x;
        turn ++;
        if ( h <= sumh)
        {
            //戦闘終了
            cout << turn << endl;
            return 0;
        }
    }

    //cout << "debug: " << sumh << endl;
    // << "debug: " << turn << endl;

    //振ってダメージを与える
    while ( sumh < h )
    {
        sumh += max_a;
        turn ++;
    }
    //先頭終了
    cout << turn << endl;

    




    //long as[n], bs[n];
    //long_quicksort(as , a , n);
    //long_quicksort(bs , b , n);


    



    // long sum = 0;
    // for ( i = 0 ; i < n ; i ++ )
    // {
    //     sum += i;
    // }






    // cout <<      << endl;

//////////////////////////////////////////////////////
// Ctrl + Opt + N to make
    return 0;
}



Measured memory_bytes: 2560