akhauriyash/Code-Regression huggingface dataset:
//@author rohit_0801

 
#include <bits/stdc++.h>
#define ll long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define debug 0
 
using namespace std;
const ll MOD = 1000000007;
const ll MODD = MOD-1;
 
ll ar[900780],has[1234567];

string strng[505];

vector<ll> vec,pec;

map<ll,ll> mark;

 
 
int main() {
	//srand(time(0));
	ll a,b,n,m,flag=0,r,t,u,v,w,x,y,z,k,res=0,d,maxm=-999999999,i,j,ct,h,ans=0,s,l,e,f,p,minm=99999999999,c,type,q,len,siz,g;
 	
 	map<ll,ll>::iterator it,jt;
 	
 	string str="",ptr="";
 	char ch;
 	
 	cin>>n>>k;
 	
 	 l=0;
	 g=0;
 	
 	for(i=0;i<n;i++){
 		cin>>ar[i];
 		if(ar[i]<0){
 			vec.pb(-1*ar[i]);
		 }
		 else{
		 	pec.pb(ar[i]);
		 }
	 }
	 
	 d=vec.size();
	 e=pec.size();
	 x=min(k,d);
	 y=min(k,e);
	 
	 reverse(vec.begin(),vec.end());
	 
	 if(x==k){
	 	for(i=0;i<k;i++){
	 		l=vec[i];
		 }
	 }
	 
	 if(y==k){
	 	for(i=0;i<k;i++){
	 		g=pec[i];
		 }
	 }
	 
	 ll mini = min(l,g);
	 res=mini;
	 
	 if(mini==0 && l!=0){
	 	res=l;
	 }
	 
	 if(mini==0 && g!=0){
	 	res=g;
	 }
	 
	if(x!=k && y!=k){
		res=minm;
	}
	 
	 for(i=x+1;i<=k;i++){
	 	vec.pb(minm);
	 }
	 
	  for(i=y+1;i<=k;i++){
	 	pec.pb(minm);
	 }
	 c=0;
	 //cout<<"res="<<res<<"\n";
	
	 for(i=0;i<k-1;i++){
	 	c++;
	 	u=2LL*vec[i];
	 	x=pec[k-1-c];
	 	u+=x;
	 	v=2LL*pec[i];
	 	y=vec[k-1-c];
	 	v+=y;
	 	//cout<<u<<" "<<v<<"\n";
	 	res=min(res,min(u,v));
	 }
	 
	 cout<<res;
 	
		
	return 0;
}  

Measured memory_bytes: 6644
import java.util.*;
import static java.lang.Math.*;
public class Main {
	final Scanner sc=new Scanner(System.in);
	final int INF=1<<26;
	final int[] vx={0,1,0,-1}, vy={1,0,-1,0};
	public static void main(String[] args) {
		new Main().B();
	}
	void A(){
		final int[] xdis={-1,0,1,0}, ydis={0,-1,0,1};
		while(true){
			int n= sc.nextInt();
			if(n == 0) break;
			HashMap<Integer, Integer[] > map = new HashMap<Integer, Integer[]>();
			Integer [] first = {0,0};
			map.put(0, first);
			for(int i=1; i < n; i++){
				int ni = sc.nextInt();
				int di = sc.nextInt();
				Integer [] now = map.get(ni);
				int newx = now[0] + xdis[di];
				int newy = now[1] + ydis[di];
				Integer [] newarray = {newx, newy};
				map.put(i, newarray);
			}
			first = map.get(0);
			int minx =first[0];
			int maxx = minx;
			int miny = first[1];
			int maxy = first[1];
			for(Integer now: map.keySet()){
				Integer [] nowarray = map.get(now);
				int x = nowarray[0];
				int y = nowarray[1];
				minx = Math.min(minx, x);
				maxx = Math.max(maxx, x);
				miny = Math.min(miny, y);
				maxy = Math.max(maxy, y);
				
			}
			int resx = maxx - minx +1;
			int resy = maxy - miny + 1;
			System.out.println(resx + " " + resy );
		}
	}
	
	void B(){
		while(true){
			int W=sc.nextInt(),H=sc.nextInt();
			if((W|H)==0)	break;
			boolean[][] ww=new boolean[W*2+2][2*H+1],hh=new boolean[2*W+1][2*H+2];
			for(int i=1; i<=H; i++){
				for(int x=1; x<W; x++)	ww[2*x+1][i]=sc.nextInt()==1;
				if(i<H)	for(int y=1; y<=W; y++)	hh[y][2*i+1]=sc.nextInt()==1;
			}
			
			//disp(hh);
			
			PriorityQueue<CB> open=new PriorityQueue<CB>();
			open.add(new CB(1,1,1));
			int[][] close=new int[W+1][H+1];
			for(int i=0; i<=W; i++)	for(int j=0; j<=H; j++)	close[i][j]=INF;
			int ans=INF;
			while(!open.isEmpty()){
				CB now=open.poll();
				for(int i=0; i<4; i++){
					int xx=now.x+vx[i],yy=now.y+vy[i];
					if(!(0<xx && xx<=W && 0<yy && yy<=H))	continue;
					int x2=(2*now.x+2*xx)/2,y2=(2*now.y+2*yy)/2;
					if(ww[x2][now.y] || hh[now.x][y2]){
						//System.out.println(x2+" "+y2);
						continue;
					}
					if(now.s+1>=close[xx][yy])	continue;
					if(xx==W && yy==H){
						ans=min(ans,now.s+1);
						continue;
					}
					open.add(new CB(xx,yy,now.s+1));
					close[xx][yy]=now.s+1;
				}
			}
			System.out.println((ans>=INF?0:ans));
		}
	}
	class CB implements Comparable<CB>{
		int x,y,s;
		CB(int x,int y,int s){this.x=x; this.y=y;this.s=s;}
		@Override public int compareTo(CB o) {
			if(this.s<o.s)	return -1;
			if(this.s>o.s)	return 1;
			return 0;
		}
	}
	void disp(boolean[][] b){
		for(int y=0; y<b[0].length; y++){
			for(int x=0; x<b.length; x++)	System.out.print(b[x][y]?1:0);
			System.out.println();
		}
	}
	
}

Measured memory_bytes: 13000
n, m, q = map(int, input().split())
lr = []
for _ in range(m):
    lr.append(list(map(int, input().split())))

a = [[0] * n for i in range(n)]
for l, r in lr:
    a[l - 1][r - 1] += 1

cnt = [[0]*n for i in range(n)]
for y in range(n):
    v = 0
    for x in range(y, -1, -1):
        v += a[x][y]
        cnt[x][y] = cnt[x][y - 1] + v

for _ in range(q):
    p, q = map(int, input().split())
    print(cnt[p-1][q-1])

Measured memory_bytes: 46424
#include <iostream>
using namespace std;
int main(){
    int n;cin>>n;
    cout << n << ": ";
    for(int i = 2; n >= i*i; i++){
        if(n%i==0){
            cout << i << " ";
            n/=i;
            i--;
        }
    }
    cout << n << endl;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

/****************** グラフ ******************/
// 諸宣言
using Weight = lint;
using Flow = lint;
struct Edge {
    int src, dst;
    Weight weight;
    Flow cap;
    Edge() : src(0), dst(0), weight(0) {}
    Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
    Edge(int s, int d, Weight w, Flow c) : src(s), dst(d), weight(w), cap(c) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1, Flow c = 1) {
    g[a].emplace_back(a, b, w, c);
    g[b].emplace_back(b, a, w, c);
}
void add_arc(Graph &g, int a, int b, Weight w = 1, Flow c = 1) {
    g[a].emplace_back(a, b, w, c);
}

// ダイクストラ法（プライオリティーキュー）O((E+V)logV)
std::vector<Weight> dijkstra(const Graph &g, int s) {
    const Weight INF = std::numeric_limits<Weight>::max() / 8;
    using state = std::tuple<Weight, int>;
    std::priority_queue<state> q;
    std::vector<Weight> dist(g.size(), INF);
    dist[s] = 0;
    q.emplace(0, s);
    while (q.size()) {
        Weight d;
        int v;
        std::tie(d, v) = q.top();
        q.pop();
        d *= -1;
        /* if(v == t) return d; */
        if (dist[v] < d) continue;
        for (auto &e : g[v]) {
            if (dist[e.dst] > dist[v] + e.weight) {
                dist[e.dst] = dist[v] + e.weight;
                q.emplace(-dist[e.dst], e.dst);
            }
        }
    }
    return dist;
}


int main(void) {
    lint n; cin >> n;
    Graph g(n);
    rep(n - 1) {
        lint a, b, c;
        cin >> a >> b >> c;
        --a; --b;
        add_edge(g, a, b, c);
    }
    
    lint q, k; cin >> q >> k; --k;
    auto res = dijkstra(g, k);
    
    rep(q) {
        lint x, y;
        cin >> x >> y;
        --x; --y;
        cout << res[x] + res[y] << endl;
    }
}

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

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

   int d4 = N /1000;
   int d3 = (N-d4*1000)/100;
   int d2 = (N-d4*1000-d3*100)/10;
   int d1 = (N-d4*1000-d3*100-d2*10);


   if( (d4==d3 && d3==d2) || (d1==d2&&d2==d3)){
   cout << "Yes" << endl;
 }

 else{
   cout << "No" << endl;
 }
}


Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var n int
  fmt.Scanf("%v", &n)
  var p []int
  for i:=0;i<n;i++ {
    pp := 0
    fmt.Scanf("%v", &pp)
    p = append(p, pp)
  }
  sum := 0
  for i:=0;i<n-2;i++ {
    if (p[i]<p[i+1] && p[i+1]<p[i+2]) || (p[i]>p[i+1] && p[i+1]>p[i+2]) {
      sum ++
    }
  }
  fmt.Println(sum)
}


Measured memory_bytes: 1840
#include<iostream>
#include<cstring>
using namespace std;
char s[101010];
int main()
{
	cin>>s+1;
	int n=strlen(s+1);
	int ans=0;
	for(int i=2;i<=n;i++)
		if(s[i]!=s[i-1])
			ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
vector< long long > divisor(long long n) {
  vector< long long > ret;
  for(long long i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) {
          ret.push_back(n / i);
      }
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

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

    long long tmp = n-1;
    long long idx = 2;
    long long res = 0;

    vector<vector<long long>> a(1);

    a[0] = divisor(n);


    for(long long i = 1; i<a[0].size();i++){
        //cout << a[0][i] << " ";
        if(n%(a[0][i]-1) == n/(a[0][i]-1))res+=a[0][i]-1;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 384
import math
import itertools
n = int(input())
max = math.floor(n**(1/2))
L = [0 for i in range(n)]
l = []
for i in range(1, max+1):
    l.append(i)


for v in itertools.combinations_with_replacement(l, 3):
    x = v[0]
    y = v[1]
    z = v[2]
    t = x**2 + y**2 + z**2 + x*y + y*z + z*x
    if t <= n:
        if x == y and y == z:
            L[t-1] += 1
        elif x == y or y == z:
            L[t-1] += 3
        else:
            L[t-1] += 6
for j in L:
    print(j)


Measured memory_bytes: 9560
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/


int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> b(n, 0);
    int count = 0;
    vector<int> c;

    for(int i = n; i >= 1; i--){
        int sum = 0;
        for(int j = i; j <= n; j += i) sum += b[j - 1];
        if(sum % 2 != a[i - 1]){
            c.push_back(i);
            count++;
            b[i - 1]++;
        }
    }
    if(count != 0){
        cout << count << endl;
        for(auto it : c)cout << it << endl; 
    }else if(count == 0){
        if(*max_element(a.begin(), a.end()) == 0)cout << 0 << endl;
        else cout << -1 << endl;
    }
}

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI0(): return map(lambda s: int(s) - 1, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
def LMI0(): return list(map(lambda s: int(s) - 1, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


N = I()
C = input()

r_cnt = C.count('R')
ans = r_cnt - C[:r_cnt].count('R')
print(ans)

Measured memory_bytes: 62948
# ABC 110: B – 1 Dimensional World's Tale
n, m, x, y = [int(s) for s in input().split()]
x_cities_wants_A = [int(s) for s in input().split()]
y_cities_wants_B = [int(s) for s in input().split()]

is_break_out = 'War'

x_cities_wants_A.sort()
y_cities_wants_B.sort()

if y - x >= 1:
    for i in range(x + 1, y + 1):
        if i > max(x_cities_wants_A) and i <= min(y_cities_wants_B):
            is_break_out = 'No War'

print(is_break_out)

Measured memory_bytes: 3064
import java.util.*;

class Main {

	static Scanner sc = new Scanner(System.in);

	static int N,M,X,Y,a[],b[];
	String S;
	
	public static void main(String[] args) {
		N=sc.nextInt();
		System.out.println(N+N*N*N+N*N);
	}
}

Measured memory_bytes: 35848
import itertools
N,M,Q = map(int, input().split())
qs = []
for i in range(Q):
  qs.append(list(map(int, input().split())))
ans = 0
a = [i for i in range(1,M+1)]
cands = itertools.combinations_with_replacement(a,N)    
for cand in cands:
  _cand = [1]
  _cand.extend(cand)
  tmp = 0
  for q in qs:
    if _cand[q[1]-1]-_cand[q[0]-1] == q[2]:
      tmp += q[3]
  ans = max(ans, tmp)
print(ans)

Measured memory_bytes: 9216
n=gets.to_i
hash={}
max=0
n.times do
    s=gets.chomp
    if !hash.include?(s)
        hash[s]=1
    else
        hash[s]+=1
    end
    max=hash[s] if hash[s]>max
end
list = []
hash.each_key{|key| list.push(key) if hash[key]==max}
list.sort.each {|s| puts s}

Measured memory_bytes: 36768
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
int main(){
  int d,n,temp=1;
  cin>>d>>n;
  if(n==100)n++;
  for(int i=0;i<d;i++){
    temp*=100;
  }
  cout<<temp*n<<endl;
  return 0;
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

std::string S;
ll K;

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

    std::cin >> S >> K;

    if(std::all_of(S.begin(), S.begin() + std::min<ll>(K, S.size()), [](char c){return c == '1';})){
        std::cout << 1 << std::endl;
    }else{
        std::cout << *std::find_if(S.begin(), S.end(), [](char c){return c != '1';}) << std::endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < 3; i++) {
    if (s[i - 1] == 'R' && s[i] == 'R') ans++;
    else if(ans == 0 && s[i] == 'R') ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define pi  3.141592653589793238
#define int long long
signed main(){

  
   int n , m; cin >> n >> m;
   vector<int> v(m);
   for(int i = 0; i< m;i++) cin >> v[i];
    int sum = 0;
   for(int i = 0;i < m;i++) sum = sum  + v[i];
    if(sum > n) cout << -1 << endl;
  else cout << (n - sum) << endl;
 
  return 0;
}

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

int main() {
  int64_t n,k,i,j,ans,money=1000,kabu=0;
  cin >> n;
  vector<int> a(n);
  
  for(i=0;i<n;i++){
    cin >> a.at(i);
  }
  for(i=0;i<n-1;i++){
    if(a.at(i)<a.at(i+1)){
      kabu+=money/a.at(i);
      money%=a.at(i);
    }
    if(a.at(i)>a.at(i+1)){
      money+=kabu*a.at(i);
      kabu=0;
    }
  }
  money+=kabu*a.at(n-1);
  cout << money << endl;
  
  
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N,A,B,sum,cnt,cnt1;
    string S;
    cin >> N >> A >> B >> S;
    sum = A+B;
    cnt = 0;
    cnt1 = 0;
    for(int i = 0;i < N;i++){
        char ch = S[i];
        if(ch == 'a'){
            if(cnt < sum){
                cout << "Yes" << endl;
                cnt++;
            }else{
                cout << "No" << endl;
            }
        }
        if(ch == 'b'){
            if(cnt < sum && cnt1 < B){
                cout << "Yes" << endl;
                cnt++;
                cnt1++;
            }else{
                cout << "No" << endl;
            }
        }
        if(ch == 'c'){
            cout << "No" << endl;
        }
        
    }
}


Measured memory_bytes: 896
k,n = list(map(int,input().split()))
a = list(map(int,input().split()))

dp = [0 for i in range(n)]
dp[0] = abs(k-a[-1]) + a[0]

for i in range(1,n):
    dp[i] = abs(a[i]-a[i-1])

print(sum(dp) - max(dp))

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

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)

typedef long long ll;

const int N = 25;
const int M = 1e9 + 7;

int n;
int a[N][N];
ll dp[N][1<<22];

int calc(ll man, ll woman) {
    if(man == n) return 1;
    if(dp[man][woman] != -1) return dp[man][woman];
    ll ways = 0;
    fore(j, 0, n) if(a[man][j] && (woman & (1LL<<j))) {
        ways += calc(man + 1, woman ^ (1LL<<j));
        ways %= M;
    }
    return dp[man][woman] = ways % M;
}


int main() {
    cin >> n;
    fore(i, 0, n) fore(j, 0, n) cin >> a[i][j];
    memset(dp, -1, sizeof dp);
    ll mask = 0;
    fore(i, 0, n) mask |= (1LL<<i);
    cout << calc(0, mask) << endl;
}

Measured memory_bytes: 819456
from itertools import permutations

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
a = 0
b = 0
for i, perm in enumerate(permutations(range(1, n+1))):
    if perm == p:
        a = i
    if perm == q:
        b = i
print(abs(a-b))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <tuple>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

int N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
    cin>>N>>K;
    if(K == 1){
        cout<<0<<endl;
        return 0;
    }
    cout<<N-K<<endl;
}

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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll n, a[200] = {0}, count = 0;
  bool odd = true;
  cin >> n;
  rep(i, n) {
    cin >> a[i];
    if (a[i] % 2 == 1) odd = false;
    a[i] /= 2;
  }
  while(odd) {
    count++;
    rep(i, n) {
      if (a[i] % 2 == 1) odd = false;
      a[i] /= 2;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
N = int(input())

def prime_factorization(n):
    dct = {}
    tmp = n
    for i in range(2, int(n**0.5)+1):
        if tmp == 1:
            break
        if tmp % i == 0:
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            dct[i] = cnt
    if tmp != 1:
        dct[tmp] = 1
    if len(dct) == 0:
        dct[n] = 1

    return dct

if N == 1:
    print(0)
else:
    pf = prime_factorization(N)
    ans = 0
    for p in pf:
        num = pf[p]
        k = 1
        while num >= k:
            ans += 1
            num -= k
            k += 1
    print(ans)


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

int main(){
	vector<int> ansvec;

	for(;;){
		int n, p;
		cin >> n >> p;
		if (n == 0) break;
		
		int bowlp = p;
		int turn = 0;
		int mayors[50]{0};
		for(;;){
			if (bowlp == 1 && mayors[turn] == p - 1) break;
			else if (bowlp == 0){
				bowlp += mayors[turn];
				mayors[turn] = 0;
			}
			else{
				mayors[turn]++;
				bowlp--;
			}

			if (turn == n - 1) turn = 0;
			else turn++;
		}
		ansvec.push_back(turn);
	}

	for (int ans : ansvec){
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);std::cout<<std::fixed<<std::setprecision(10);
    string S,T;
    cin >> S >> T;
    int count = 0;
    if(S[0]==T[0])count++;
    if(S[1]==T[1])count++;
    if(S[2]==T[2])count++;
    cout <<count<< "\n";
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int h = x / 3600;
        int m = (x - h * 3600) / 60;
        int s = x - h * 3600 - m * 60;
        System.out.printf("%d:%d:%d\n", h, m, s);
    }
}


Measured memory_bytes: 26336
import sys
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(100000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if self.v is None:
            self.v = n
        else:
            self.v = self.f(self.v, n) 

def SS(L):
    S = [0] * (len(L))
    for i, l in enumerate(L):
        S[i + 1] = S[i] + l

    return S


def main():
    X, Y, A, B, C = read_values()
    P = sorted(read_list(), reverse=True) + [-1]
    Q = sorted(read_list(), reverse=True) + [-1]
    R = sorted(read_list(), reverse=True) + [-1]

    x = 0
    y = 0
    r = 0

    res = 0
    for _ in range(X + Y):
        a = P[x]
        b = Q[y]
        c = R[r]

        if c >= a and c >= b:
            res += c
            r += 1
            continue
        
        if x == X:
            if c >= b:
                res += c
                r += 1
            else:
                res += b
                y += 1
            continue

        if y == Y:
            if c >= a:
                res += c
                r += 1
            else:
                res += a
                x += 1
            continue

        if a >= b:
            res += a
            x += 1
        else:
            res += b
            y += 1

    print(res)
    
        
if __name__ == "__main__":
    main()


Measured memory_bytes: 23472
#!/usr/bin/env python3

def main():
    n,m = map(int, input().split())
    orders = [[int(s)-1 for s in input().split()] for i in range(m)]
    orders.sort(key=lambda x: x[1])
    
    fallen_bridge = -1
    ans = 0
    for order in orders:
        a = order[0]
        b = order[1]

        if fallen_bridge >= a:
            continue

        fallen_bridge = b - 1
        ans += 1
    
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 22828
#include <iostream>
#include<string>
using namespace std;
int main() {
    string num;
    while(cin>>num){
       
    if(num=="0")
        break;
    int sum=0;
    for(int i=0; i<num.size(); i++){
        sum+=num[i]-48;
    }
    cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 3132
import collections

n,m= map(int, input().split())


requests = []
for i in range(m):
    a,b = map(int, input().split())
    requests.append((b-1,-a+1))
requests.sort()
cnt = 0
lb = -1
for b,a in requests:
    if lb < -a or b<= lb:
        cnt += 1
        lb = b-1
print(cnt)

Measured memory_bytes: 17340
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<long> A(N+2,0),B(N,0);
  for (int i = 0; i < N;  i++) {
    cin >> A[i+1];
  }
  for (int i = 0; i < N; i++) {
    B[i] = abs(A[i+1] - A[i]) + abs(A[i+1] - A[i+2]) - abs(A[i+2] -A[i]);
  }
  int s;
  for (int i = 0; i < N+1; i++) {
    s += abs(A[i+1]-A[i]);
  }
  for (int i = 0; i < N ; i++) {
    cout << s - B[i] << endl;
  }
}

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

const std::string s[8] = { "*****     ",
						   "     *****",
						   "==========",
						   " **** ****",
						   "* **** ***",
						   "** **** **",
						   "*** **** *",
						   "**** **** " };

int main()
{
	int n;
	bool fst = true;
	
	while( std::cin >> n )
	{
		if( !fst )
			std::cout << std::endl;
		
		fst = false;

		std::vector<int> digit;
		for( int i = 0; i != 5; ++i )
		{
			digit.push_back( n % 10 );
			n /= 10;
		}

		for( int i = 0; i != 8; ++i )
		{
			for( int j = digit.size() - 1; j >= 0; --j )
				std::cout << s[i][digit[j]];

			std::cout << std::endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1216
package main

import (
  "fmt"
)

func main() {
  var a,b    int
  fmt.Scan(&a,&b)
  max := a*b
  if max < (a+b){
    max = a+b
  }
  if max < (a-b){
    max = a-b
  }
  fmt.Println(max)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  int k;
  string s;
  cin>>k>>s;
  if((int)s.size()<=k){
    cout<<s<<endl;
  }
  else{
    rep(i,k)cout<<s[i];
    cout<<"..."<<endl;
  }
  return(0);
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int dp[200005][2];
string ss;
int main(){
	cin>>ss;
	int ans;
	int Len=ss.length();
	ans=Len;
	for (int i=1;i<Len;i++)	
		if (ss[i]==ss[i-1]) ans--,i+=2;
	cout<<ans;
	return 0;
}

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

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

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	llong N;
	int ans = 0;
	cin >> N;
	int keta = 0;
	int last = 9, bb;
	bool kyu = true;
	while(N){
		bb = last;
		if(bb != 9)
			kyu = false;
		last = N%10;
		keta++;
		N /= 10;
	}

	ans = 9 * (keta-1);
	if(kyu)
		ans += last;
	else
		ans += last-1;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n,ans=0;
	cin>>n;
	ll ar[n];
	for (int i=0;i<n;i++)
		cin>>ar[i];
	sort(ar,ar+n);
	for (int i=1,j=n-1;i<n;i++)
	{
		if (!(i%2))j--;
		ans+=ar[j];
	}
	cout<<ans<<"\n";
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<char> vc;
typedef vector<string> vs;
const ll mod = 1e9+7;
const ll inf = 1e17;
const int INF = 1e9;
const double PI = acos(-1);
#define fo(i, a, b) for(int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  int h, w;
  cin >> h >> w;
  vector<vc> a(h, vc(w));
  re(i, h) {
    re(j, w) {
      cin >> a[i][j];
    }
  }

  vector<vc> c(h);
  int y = 0;
  re(i, h) {
    bool white = true;
    re(j, w) {
      if(a[i][j] == '#') white = false;
    }
    if(!white) {
      re(j, w) c[y].pb(a[i][j]);
      y++;
    }
  }
  int x = 0;
  re(j, w) {
    bool white = true;
    re(i, y) {
      if(c[i][j] == '#') white = false;
    }
    if(white) {
      re(i, y) c[i][j] = 'p';
    }
  }
  re(i, y) {
    re(j, w) {
      if(c[i][j] != 'p') cout << c[i][j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
A,B= map(int, input().split())

n=int(-(-A*25//2))
n0=int(-(-(A+1)*25//2))

d=[-1]

for i in range(n,n0):
    if i//10==B:
        d.append(i)

if d[-1]==-1:
    print(-1)
else:
    print(d[1])

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int N=5005;
int n,mod,ans,w[N],f[N];

signed main(){
	read(n,mod);w[2]=1;f[0]=1;
	for(int l=3,r=n;l<=r;l++,r--) w[l]=w[r]=w[l-1]+1;
	for(int i=2;i<=n;i++) for(int j=w[i];j<=n;j++) f[j]=(f[j]+f[j-w[i]])%mod;
	for(int i=0;i<=n;i++) ans=(ans+1ll*(n-i)*f[i]%mod)%mod;
	write(ans);
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<(int)N;i++)
#define p(S) cout<<(S)<<endl
#define ck(n,a,b) (a<=(n)&&(n)<b)
typedef long long ll;
using namespace std;
const int inf=1e9;

int effect[100010];
int edge[100010];
bool visited[100010];
int dfs(int x) {
	if (effect[x]==0) return edge[x] = x;
	if (edge[x]!=-1) return edge[x];
	if (visited[x]) return inf; //roop?
	visited[x]=true;
	return edge[x] = dfs(x + effect[x]);
}

int main(){
	int n;
	cin>>n;
	int d[100010];
	REP(i,0,n) {
		cin>>effect[i];
		visited[i]=false;
		edge[i]=-1;
		d[i]=inf;
	}

	REP(i,0,n)	if(edge[i] == -1) dfs(i);
	priority_queue<pair<int,int>> pq;//cost,node
	d[0]=0;
	pq.push({0,0});
	while(!pq.empty()){
		int cost = pq.top().first;
		int now = pq.top().second;
		pq.pop();
		if(-cost > d[now]) continue;
		REP(i,1,7){
			if(edge[now+i]==inf) continue;
			int next = edge[now+i];
			if(d[next] > d[now] + 1){
				d[next] = d[now] + 1;
				pq.push({-d[next],next});
			}
		}
		if(d[n-1] != inf) break;
	}
	p(d[n-1]);
	return 0;
}

Measured memory_bytes: 5648
package main

import "fmt"

func main(){
	var N int ;
	var gu, ki float64
	fmt.Scan(&N);

	for i := 1 ; i <= N ; i++ {
		if i % 2== 0{
			gu++;
		}else {
			ki++;
		}
	}
	fmt.Println(float64(ki / (ki+gu)));
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

void solve(){
	int a,b,c,k,s=0;
	cin>>a>>b>>c>>k;
	while(b<=a and k>0){
		b=b*2;
		k--;
	}
	while(c<=b and k>0){
		c=c*2;
		k--;
	}
	if(a<b and b<c){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	int i,t=1;
	//	cin>>t;
	for(i=1;i<=t;i++){
		solve();
	}
	return 0;
}

int mpow(int base, int exp) {
	base %= mod;
	int result = 1;
	while (exp > 0) {
		if (exp & 1) result = ((ll)result * base) % mod;
		base = ((ll)base * base) % mod;
		exp >>= 1;
	}
	return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}




Measured memory_bytes: 10684
#include <iostream>
#include <algorithm>
#include <numeric>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl


int main() {
    int buil[5][4][11] = {};
    int n,b,f,r,v;

    cin >> n;

    for(int i = 0; i < n; i++){
        cin >> b >> f >> r >> v;

        if(buil[b][f][r] + v > 9){
            buil[b][f][r] = 9;
        } else if(buil[b][f][r] + v < 0){
            buil[b][f][r] = 0;
        } else{
            buil[b][f][r] += v;
        }
    }

    for(int i = 1; i < 5; i++){
        for(int j = 1; j < 4; j++){
            for(int k = 1; k < 11; k++){
                cout << " " << buil[i][j][k];
            }
            cout << endl;
        }
        if(i != 4){
            cout << "####################" << endl;

        }
    }

    return 0;
}


Measured memory_bytes: 3132
from itertools import combinations
from collections import defaultdict
n = int(input())
d = defaultdict(int)
for i in range(n):
    tmp = input()
    if tmp.startswith("M"):
        d["m"] += 1
    elif tmp.startswith("A"):
        d["a"] += 1
    elif tmp.startswith("R"):
        d["r"] += 1
    elif tmp.startswith("C"):
        d["c"] += 1
    elif tmp.startswith("H"):
        d["h"] += 1

if len(d) < 3:
    print(0)
else:
    res = 0
    for a, b, c in combinations(d.keys(), 3):
        res += d[a] * d[b] * d[c]
    print(res)


Measured memory_bytes: 3564
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
#include <sstream>
#include <cctype>
using namespace std;


int main(){
  vector<char> list = {'a', 'i', 'u', 'e', 'o'};
  char c; cin >> c;
  if(find(list.begin(), list.end(), c) == list.end()) cout << "consonant" << endl;
  else cout << "vowel" << endl;
}


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

int main()
{
    int n, k, c = 0, i;
    cin >> n >> k;
    int arr[n+1];

    for(i = 1; i <= n; i++) cin >> arr[i];
    n--;
    k--;
    int res = (n + k - 1) / k;
    cout << res << endl;
}

Measured memory_bytes: 3980
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const ll MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<62;




int main(void){

    int bit=0;
    int ans=0;
    int n;
    cin>>n;
    vector<vpii> v(n,vpii());
    rep(i,n){
        int a;
        cin>>a;
        for(int j=0;j<a;j++){
            int x,y;
            cin>>x>>y;
            x--;
            v[i].pb(mp(x,y));
        }
    }
    while(bit<pow(2,n)){
        // fin(bit);
        string s="";
        int tmp=bit;
        while(tmp>0){
            s+=tmp%2+'0';
            tmp/=2;
        }
        while(s.size()<n)s+='0';
        reverse(all(s));
        // fin(s);
        
        int onestcount=0;
        bool allonest=true;
        for(int i=0;i<n;i++){
            bool isonest=true;
            if(s[i]=='1'){
                for(int j=0;j<v[i].size();j++){
                    if(bit==6){
                        // cout<<i<<j<<" "<<s[v[i][j].first]-'0'<<" "<<v[i][j].first<<" "<<v[i][j].second<<endl;
                    }
                    if(s[v[i][j].first]-'0' == v[i][j].second){;}
                    else isonest=false;
                }
            }
            if(isonest)onestcount++;
            else allonest=false;
        }
        if(allonest)ans=max(ans,(int)count(s.cbegin(), s.cend(), '1'));
        // cout<<onestcount<<endl<<endl;

        bit++;
    }
    fin(ans);

}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Azhan Khan
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CVacation solver = new CVacation();
        solver.solve(1, in, out);
        out.close();
    }

    static class CVacation {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            int[][] arr = new int[n][3];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < 3; j++) {
                    arr[i][j] = in.nextInt();
                }
            }

            int[][] dp = new int[n][3];
            dp[0][0] = arr[0][0];
            dp[0][1] = arr[0][1];
            dp[0][2] = arr[0][2];

            for (int i = 1; i < n; i++) {
                dp[i][0] = arr[i][0] + Math.max(dp[i - 1][1], dp[i - 1][2]);
                dp[i][1] = arr[i][1] + Math.max(dp[i - 1][0], dp[i - 1][2]);
                dp[i][2] = arr[i][2] + Math.max(dp[i - 1][0], dp[i - 1][1]);
            }
            out.println(Math.max(dp[n - 1][0], Math.max(dp[n - 1][1], dp[n - 1][2])));
        }

    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
        }

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

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

    }
}



Measured memory_bytes: 49832
#include <stdio.h>
int main()
{
    int a,b,c,d;
    scanf("%1d%1d%1d%1d",&a,&b,&c,&d);
    if(a+b+c+d==7)
        printf("%d+%d+%d+%d=7",a,b,c,d);
    else if(a+b+c-d==7)
        printf("%d+%d+%d-%d=7",a,b,c,d);
    else  if(a+b-c-d==7)
        printf("%d+%d-%d-%d=7",a,b,c,d);
    else if(a-b-c-d==7)
        printf("%d-%d-%d-%d=7",a,b,c,d);
    else if(a-b+c+d==7)
        printf("%d-%d+%d+%d=7",a,b,c,d);
    else if(a-b-c+d==7)
        printf("%d-%d-%d+%d=7",a,b,c,d);
    else if(a+b-c+d==7)
        printf("%d+%d-%d+%d=7",a,b,c,d);
    else if(a-b+c-d==7)
        printf("%d-%d+%d-%d=7",a,b,c,d);
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int R = sc.nextInt();
        int ans = 100 * (10-N) + R;
        if (N >= 10 )
            System.out.println(R);
        else
            System.out.println(ans);
    }
}


Measured memory_bytes: 21716
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

signed main(){
    int r;
    cin >> r;

    if(r < 1200){
        cout << "ABC" << endl;
        return 0;
    }

    if(r < 2800){
        cout << "ARC" << endl;
        return 0;
    }
    cout << "AGC" << endl;

    return 0;
}


Measured memory_bytes: 884
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>

const int INT_INF = 1000000000;                 // 10^9
const long long LONG_INF = 1000000000000000000; // 10^18

using namespace std;

int main()
{
    string a, b;
    cin >> a >> b;
    int ai = stoi(a), bi = stoi(b);
    vector<string> s(2, "");
    for (int i = 0; i < bi; i++)
    {
        s[0] += a;
    }

    for (int i = 0; i < ai; i++)
    {
        s[1] += b;
    }

    sort(s.begin(), s.end());

    cout << s[0] << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from itertools import product
def resolve():
    n = int(input())
    ans = [0] * (n + 1)
    for x, y, z in product(range(1, 101), repeat = 3):
        k = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
        if k <= n:
            ans[k] += 1
    print(*ans[1:], sep = '\n')
resolve()

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

int main(void){
    int n;
    cin>>n;
    vector<vector<int> > c(10, vector<int>(10));
    for(int k=1;k<=n;k++){
        string s=to_string(k);
        rep(i, 10)rep(j, 10){
            if((int)(s[0]-'0')==i&&(int)(s[s.size()-1]-'0')==j){
                c[i][j]++;
                break;
            }

        }
    }
    int ans=0;
    rep(i, 10)rep(j, 10){
        ans+=c[i][j]*c[j][i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#pragma GCC optimize("O3")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

#define DEBUG
#ifdef DEBUG
    #define IFD(...) __VA_ARGS__
    #define IFN(...)
    #define L cout<<__LINE__<<"\n";
    #define PRINT(...) __VA_ARGS__ cout<<__LINE__<" : "<<#__VA_ARGS__<<"\n"
    #define PRT(x) cout<<__LINE__<<" : "<<#x<<" = "<<x<<"\n"
#else // DEBUG
    #define IFD(...)
    #define IFN(...) __VA_ARGS__
    #define L
    #define PRINT(...) __VA_ARGS__
    #define PRT(x)
#endif // DEBUG

#define it iterator
#define rit reverse_iterator
#define mp make_pair
#define mems(a,b) memset(a,b,sizeof(a))
#define mem0(a) mems(a,0)
#define mem1(a) mems(a,1)
#define mem255(a) mems(a,255)
#define halt exit(0)
#define all(c) (c).begin() , (c).end()
#define sz(c) ((long long)((c).size()))
#define phb push_back
#define ppb pop_back
#define phf push_front
#define ppf pop_front
#define fort0(i,a,b) for(ll i=a,i##_TO=b;i<i##_TO;i++)
#define for0(i,n) fort0(i,0,n)
#define fort1(i,a,b) for(ll i=a,i##_TO=b;i<=i##_TO;i++)
#define for1(i,n) fort1(i,1,n)
#define ford(i,a,b) for(ll i=a,i##_TO=b;i>=i##_TO;i--)

using namespace __gnu_pbds;
using namespace std;

#define int ll

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template
<
    class key,
    class val=null_type,
    class comp=less<key>
>
using ord_set=tree
<
    key,
    val,
    comp,
    rb_tree_tag,
    tree_order_statistics_node_update
>;

const int N=1e5+100;

int dp[N];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        dp[i]=dp[i-1]+1;
        for(int p=6;p<=i;p*=6)
            dp[i]=min(dp[i],dp[i-p]+1);
        for(int p=9;p<=i;p*=9)
            dp[i]=min(dp[i],dp[i-p]+1);
    }
    cout<<dp[n];
}


Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	L := readString()

	result := 1
	t := 1
	for i := len(L) - 1; i >= 0; i-- {
		if L[i] == '1' {
			result = result*2 + t
			result %= 1000000007
		}
		t *= 3
		t %= 1000000007
	}
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}


Measured memory_bytes: 896
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <istream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>
#include <cstring>
#include <string.h>
#include <iomanip>
#include <queue>
#include <stack>
#include <list>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vi lnum;
typedef long double ld;

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define pb push_back
#define mp make_pair
#define pi 3.14159265358979
#define fopen freopen("input.txt", "r", stdin); freopen("output.txt","w", stdout)
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define REPR(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))
#define f first
#define s second

const int MOD9 = 1e9 + 7;
const int MOD91 = 1e9 + 9;
const ll MOD12 = 1e12 + 39LL;
const ll MOD15 = 1e15 + 37LL;
const ll INF = 1000LL * 1000* 1000* 1000* 1000* 1000;
const int base = 330;
const int MAXN = 2e5 + 6;
const double EPS = 1e-12;

using namespace std;
int Sum = 0;
const ll mod = 1000 * 1000 * 1000 + 7;
int n , a;
int ans[200000];
bool used[200000];
int main()
{
	cin >> n >> a;
	if(a == 1 || a == 2 * n - 1)
	{
		cout << "No";
		return 0;
	}
	if(n == 2)
	{
		cout << "Yes" << endl;
		cout << 1 << endl;
		cout << 2 << endl;
		cout << 3 << endl;
		return 0;
	}
	cout << "Yes" << endl;
	if(a != 2 * n - 2)
	{
		ans[n - 3] = a + 2;
		ans[n - 2] = a - 1;
		ans[n - 1] = a;
		ans[n] = a + 1;
		int cur = 1;
		for(int i = 0; i < 2 * n - 1; i++)
		{
			if(cur == a - 1)
				cur = a + 3;
			if(!ans[i])
			{
				ans[i] = cur++;
			}
		}
		for(int i = 0; i < 2 * n - 1; i++)
			cout << ans[i] << endl;
		return 0;
	}
	else
	{
		ans[n - 2] = a - 1;
		ans[n - 1] = a;
		ans[n] = a + 1;
		ans[n + 1] = a - 2;
		int cur = 1;
		for(int i = 0; i < 2 * n - 1; i++)
		{
			if(cur == a - 2)
				cur = a + 2;
			if(!ans[i])
			{
				ans[i] = cur++;
			}
		}
		for(int i = 0; i < 2 * n - 1; i++)
			cout << ans[i] << endl;
		return 0;
	}

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

	//system("pause");
}







Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
string str;
int n,k;
int main()
{
	scanf("%d",&n);
	cin>>str;
	scanf("%d",&k);
	for(int i=0;i<n;i++)
		if(str[i]==str[k-1])
			printf("%c",str[i]);
		else printf("*");
	return 0;
}

Measured memory_bytes: 256
A,B=input().split()
list_B=list(B)
if not '.' in B:
    print(0)
else:
    place = list_B.index('.')
    del list_B[place]
    if list_B[0]=='0' and list_B[1]=='0':
        del list_B[0]
        del list_B[0]
    elif list_B[0]=='0':
        del list_B[0]
    new_B = ''.join(list_B)
    number_B=int(new_B)
    answer=int(A)*number_B//100
    print(answer)
    

Measured memory_bytes: 61944