akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class B
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		int[] A = Enumerable.Range(0, N).Select(_ => GetInt() - 1).ToArray();
		int[] B = GetInts(N);
		int[] C = GetInts(N - 1);

		int ans = B[A[0]];
		for(int i = 1; i < N; i++)
		{
			ans += B[A[i]];
			if(A[i - 1] + 1 == A[i])
				ans += C[A[i - 1]];
		}

		Console.WriteLine(ans);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}


Measured memory_bytes: 13396
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
d = LIST()

ans = 0
# print(list(combinations(range(N), 2)))
for i, j in list(combinations(range(N), 2)):
	ans += d[i] * d[j]
print(ans)


Measured memory_bytes: 5840
import sys
input = sys.stdin.readline
from bisect import bisect_left

n, d, a = map(int, input().split())
mon = [list(map(int, input().split())) for _ in range(n)]
mon.sort(key=lambda x: x[0])
ref = [x for x, h in mon]
rem = [0] * (n + 1)
ans = 0
cur = 0
for i, (x, h) in enumerate(mon):
	cur -= rem[i]
	h = max(0, h - cur)
	t = a * (0 - -h // a)
	ans += 0 - -h // a
	cur += t
	rem[bisect_left(ref, x + 2 * d + 1)] += t
print(ans)

Measured memory_bytes: 61308
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>
#include <limits>
#include <iostream>

using namespace std;

constexpr int mod = 1'000'000'007;

char dat[1048576];

int main() {
  ios_base::sync_with_stdio(false);
  int n;
  scanf("%d", &n);
  scanf("%s", dat);
  vector<int> dir(2*n); // 0: opening, 1: closing
  char last = 'W';
  int par = 0;
  for (int i = 0; i < 2*n; i++) {
    if (dat[i] == last) {
      if (par == 0) {
        dir[i] = 1;
      } else {
        dir[i] = 0;
      }
    } else {
      if (par == 0) {
        dir[i] = 0;
      } else {
        dir[i] = 1;
      }
    }
    par = dir[i];
    last = dat[i];
  }
  int m = 2 * n;
  {
    int depth = 0;
    long long ans = 1;
    for (int i = 0; i < m; i++) {
      if (dir[i] == 0) {
        depth++;
      } else {
        ans *= depth;
        ans %= mod;
        depth--;
      }
      if (depth < 0) {
        printf("0\n");
        return 0;
      }
    }
    if (depth != 0) {
      printf("0\n");
      return 0;
    }
    for (int i = 1; i <= n; i++) {
      ans *= i;
      ans %= mod;
    }
    printf("%lld\n", ans);
  }
  return 0;
}


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

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

    if (N<=10000 && N>=1 && A<=1000 && A>=0 && N%500<=A) {
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}
        
        
    
    


Measured memory_bytes: 3604
#include<iostream>
#include<cstdio>
using namespace std;
int n,k,a[200001],ans;
int main()
{
	scanf("%d%d",&k,&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	ans=a[n]-a[1];
	for(int i=2;i<=n;i++)
		ans=min(ans,k-a[i]+a[i-1]);
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 1024
require 'pp'
n, m = gets.split.map(&:to_i)

sc = []
m.times do
  sc << gets.split.map(&:to_i)
end

a = nil
case n
when 1
  a = (0..9)
when 2
  a = (10..99)
when 3
  a = (100..999)
end

a2 = a.select{|aa|
  sc.all?{|(s,c)|
    aa.to_s[s-1].to_i == c
  }
}

if a2.size == 0
  p -1
else
  p a2[0]
end

# 702 -1 -1


Measured memory_bytes: 2300
/*
	0532:Time Card
*/
#include	<iostream>

using namespace std;

int main(void) {
	int times[3];
	
	for(int i = 0; i < 3; i++) {
		int th1, th2, th3, th4, th5, th6, s1, s2;
		cin >> th1 >> th2 >> th3 >> th4 >> th5 >> th6;
		
		s1 = 3600 * th1 + 60 * th2 + th3;
		s2 = 3600 * th4 + 60 * th5 + th6;
		
		times[i] = s2 - s1;
	}
	for(int i = 0; i < 3; i++) {
		int th1, th2, th3;
		th1 = times[i] / 3600;
		times[i] %= 3600;
		th2 = times[i] / 60;
		times[i] %= 60;
		th3 = times[i];
		cout << th1 << ' ' << th2 << ' ' << th3 << endl;
	}
	
	return 0;
}

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

int main(int argc, char const *argv[])
{
    int n = 0;
    cin >> n;

    int elems = 0;
    multiset<int> s;
    for (int i = 0; i < n; i++)
    {
        cin >> elems;
        s.insert(elems);
    }

    int q = 0;
    cin >> q;

    int elemt = 0;
    set<int> t;
    for (int i = 0; i < q; i++)
    {
        cin >> elemt;
        t.insert(elemt);
    }

    int c = 0;
    auto it = t.begin();
    while (it != t.end())
    {
        c += static_cast<int> (s.count(*(it++)) > 0);
    }

    cout << c << endl;

    return 0;
}



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

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VC> VVC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

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

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

LL Gcd(LL a, LL b) {
  if (a < b) {
    return Gcd(b,a);
  }
  if (b == 0) {
    return a;
  }
  else {
    return Gcd(b,a%b);
  }
}

LL Lcm(LL a, LL b) {
  LL abd = Gcd(a,b);
  LL x = a / abd, y = b / abd;
  
  return x*y*abd;
}


LL RepSqu(LL N, LL P, LL M) {
  if(P == 0) {
    return 1;
  }
  if(P%2 == 0) {
    LL t = RepSqu(N, P/2, M);
    return t*t % M;
  }
  return (N * RepSqu(N, P-1, M)) % M;
}

bool cont(string a,int b){
  if(toInt(a)%b == 0) {
    return true;
  }else{
    return false;
  }
}

int main() {
  
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  LL N,K,M,L=0;
  bool t=false;
  cin >> N >> K;
  VLL A(N);
  REP(i,N){
    cin >> A.at(i);
    chmax(L,A.at(i));
    if(A.at(i) == K)t=true;
  }
  M = A.at(0);
  FOR(i,1,N){
    M = Gcd(M,A.at(i));
  }
  if(K > L) cout << "IMPOSSIBLE" << endl;
  else if(t) cout << "POSSIBLE" << endl;
  else if(K%M == 0) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
  return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        long x = sc.nextLong();
        long[] v = new long[51];
        long[] b = new long[51];
        v[0] = 1;
        b[0] = 1;
        for(int i = 1; i <= 50; i++){
            v[i] += v[i-1]*2+3;
            b[i] += b[i-1]*2+1;
        }
        int now = n;
        long ans = 0;
        while(x > 0){
            if(v[now] == x){
                ans += b[now];
                x = 0;
            }else if(v[now-1]+2 <= x){
                ans += b[now-1]+1;
                x -= v[now-1]+2;
                now--;
            }else if(v[now-1]+1 == x){
                ans += b[now-1];
                x = 0;
            }else{
                now--;
                x--;
            }
        }
        System.out.println(ans);
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

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

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

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 22612
mod=1000000007
gets
a=gets.split.map(&:to_i)
ans = 0
mul = 1
61.times{|i|
  cnt = [0,0]
  a.each{|t|cnt[t[i]]+=1}
  ans += cnt[0]*cnt[1]*mul%mod
  mul = (mul*2)%mod
}
p ans%mod

Measured memory_bytes: 36892
#include<iostream>
using namespace std;
int main(){
  string S,T;
  cin>>S>>T;
  if(S.length()!=T.length()-1){
    cout<<"No"<<endl;
    return 0;
  }
  for(int i=0; i<S.length(); i++){
    if(S[i]!=T[i]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 3620
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class UnionFind {
    vector<int> p;//p[i]はiの属する組織
public:
    UnionFind(int n) {
        p = vector<int>(n);
        for (int i = 0; i < n; i++) {
            p[i] = i;
        }
        return;
    }

/* xの属する集合を返す */
    int find(int x) {
        if (p[x] == x) return x;
        return p[x] = find(p[x]);
    }

/* yにxを統合する */
    void unite(int x, int y) {
        p[find(x)] = p[find(y)];
    }

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

};

class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int N, M;
        cin >> N >> M;

        vector<pair<int, int>> vp;
        rep(i, 0, M) {
            int a, b;
            cin >> a >> b;
            a--, b--;
            vp.emplace_back(a, b);
        }

        vector<ll> sz(N, 1);
        UnionFind uf(N);


        reverse(all(vp));
        ll rest = 1ll * N * (N - 1) / 2;
        vector<ll> ans;
        for (auto e : vp) {
            int a = e.first;
            int b = e.second;

//            cout << rest << endl;
            ans.push_back(rest);
            if (!uf.same(a, b)) {
                ll tmp = sz[uf.find(a)] * sz[uf.find(b)];
                rest -= tmp;
                sz[uf.find(a)] += sz[uf.find(b)];
                sz[uf.find(b)] = sz[uf.find(a)];

                uf.unite(a, b);
            }
        }

        reverse(all(ans));

        for (auto e : ans) {
            cout << e << endl;
        }
    }
};


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

    Solve().solve();


    return 0;
}


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

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	string s; cin >> s;
	for (char c: s) {
		c -= 'A';
		c = (c + n) % 26;
		c += 'A';
		cout << char(c);
	}
	cout << endl;
}



Measured memory_bytes: 256
#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 W, T;
	int num = 0;
	cin >> W;
	W = toUpper(W);
	while (1) {
		cin >> T;
		if (T == "END_OF_TEXT")break;
		T = toUpper(T);
		if (T == W)num++;
	}
	cout << num << endl;
	return 0;
}


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

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');
            string s = str[0];
            string t = str[1];
            string output = "";
            string scur;
            string tcur;

            for(int i = 0; i<N; i++)
            {
                scur = s.Substring(i, 1);
                tcur = t.Substring(i, 1);
                output = output + scur + tcur;
            }
            
            Console.Write(output);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a*b, c*d) << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
//constexpr ll N = 2e5;
//ll a[N];

//constexpr int max = 2147483647;



int main()
{
	
	int s, w;
	cin >> s >> w;

	if (s <= w)
		cout << "unsafe";
	else
		cout << "safe";
	
	return 0;
}

Measured memory_bytes: 3620
/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;


public class Main{
	public static void main (String[] args) {
	    Scanner s=new Scanner(System.in);
	    int n=s.nextInt();
        int [] A = new int[n]; int xor=0;
        for(int i=0; i<n; i++ ) 
        { A[i] = s.nextInt();
         
       xor=myXOR(xor,A[i]);
        }
        for(int i=0;i<n;i++)
        {
            System.out.print(myXOR(xor,A[i])+ " ");
        }
	}
	static int myXOR(int x, int y) 
{ 
return (x & (~y)) | ((~x )& y); 
} 
  
}

Measured memory_bytes: 61256
#include<bits/stdc++.h>
using namespace std;
int main()
{

    long long int a,b,c,d,i,j,l;
    long double k;
    cin>>a;
    long long int a1[a];
    for(i=0;i<a;i++)
        cin>>a1[i];
    sort(a1,a1+a);
    k=a1[0];
    for(i=1;i<a;i++)
    {
        k=(long double)(k+a1[i])/2.0;
    }
    cout<<fixed<<setprecision(8)<<k;
}


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

/*                     
*/

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define len(s) s.length()
#define forp(i, a, b) for (int i = a; i <= b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define ren(i, n) for (int i = n - 1; i >= 0; i--)
#define forn(i, a, b) for (int i = a; i >= b; i--)
#define on cout << endl
#define o2(a, b) cout << a << " " << b
#define os cout << " "
#define all(v) v.begin(), v.end()
#define mem(n, m) memset(n, m, sizeof(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define sii set<int>
#define us unordered_set<int>
#define um unordered_map<int, int>
#define sll set<long long>
#define vii vector<int>
#define vll vector<long long>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ret return 0
#define present(s, x) (s.find(x) != s.end())
#define cpresent(s, x) (find(all(s), x) != s.end())
#define ford(container, it) for (__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define fors(container, it, a, b) for (__typeof(container.begin()) it = a; it != b; it++)

#define boost ios_base::sync_with_stdio(0)
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100001
#define SIZ 1000001
#define SIZE 200001

typedef long long ll;
typedef long double ldo;
typedef double db;
using namespace std;
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)

//Everything is temporary...So,enjoy little things...
void c_p_c()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
int main()
{
    c_p_c();

    double d, t, s;
    cin >> d >> t >> s;
    if (d > t * s)
    {
        cout << "No ";
        ret;
    }
    else
    {
        cout << "Yes ";
    }

    return 0;
}

Measured memory_bytes: 3736
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

int H,W;
char s[50][50];
int score[50][50] = {0};

void bfs(int h,int w,int x,int y,int ss)
{


    score[y][x] = ss+1;

    if (x+1 < w && score[y][x+1] > score[y][x] + 1 && s[y][x+1] != '#')
    {
        bfs(h,w,x+1,y,score[y][x]);
    }

    if (x-1 >= 0 && score[y][x-1] > score[y][x] + 1 && s[y][x-1] != '#')
    {
        bfs(h,w,x-1,y,score[y][x]);
    }

    if (y+1 < h && score[y+1][x] > score[y][x] + 1 && s[y+1][x] != '#')
    {
        bfs(h,w,x,y+1,score[y][x]);
    }

    if (y-1 >= 0 && score[y-1][x] > score[y][x] + 1 && s[y-1][x] != '#')
    {
        bfs(h,w,x,y-1,score[y][x]);
    }
}


int main()
{
    cin >> H >> W;

    for(int i = 0; i < H ; i++)
    {
        for(int j = 0; j < W; j++)
        {
            cin >> s[i][j];
        }
    }

    // printf("\n\n");
    // for(int i = 0; i < H ; i++)
    // {
    //     for(int j = 0; j < W; j++)
    //     {
    //         cout << s[i][j];
    //     }
    //     printf("\n");
    // }

    for(int i = 0; i < H; i++)
    {
        for(int j = 0; j < W; j++)
        {
            score[i][j] = INF;
        }
    }

    bfs(H,W,0,0,0);

    // printf("\n");
    // for(int i = 0; i < H; i++)
    // {
    //     for(int j = 0; j < W; j++)
    //     {
    //         if (score[i][j] > H*W)
    //         {
    //             cout << '&' << " ";
    //         }else
    //         {
    //             cout << score[i][j] << " ";
    //         }
    //     }
    //     printf("\n");
    // }

    if (score[H-1][W-1] > H * W)
    {
        cout << "-1" << endl;
    }else
    {
        int cnt = 0;
        for(int i = 0; i < H; i++)
        {
            for(int j = 0; j < W; j++)
            {
                if (s[i][j] == '#')
                {
                    cnt++;
                }
            }
        }
        //cout << "cnt = " << cnt << endl;
        //cout << "dist = " << score[H-1][W-1] << endl;
        cout << (H*W-cnt) - score[H-1][W-1] << endl;
    }


    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  string s;
  cin >> s;
  ll res = 0;
  for(int i = 0; i < (1<<s.size()-1);i++){//2のa乗回繰り返す(0 ~ 2^a- 1)
    string now;
    for(int j = 0;j < s.size()-1;j++){
    now = now + s[j];
    if(i & (1<<j)){//小さい方からj桁目(0から)が1であったら
      //cout << i << " " << now << endl;
      ll purasu = stod(now);
      res += purasu;
      now = "";
    }
    }
    //cout << i << " " << now << endl;
    now += s[s.size() - 1];
    //cout << i << " " << now << endl;
    ll purasu = stod(now);
    res += purasu;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int n,k,ans;
    int p=0;
    int q=0;
    scanf("%d %d",&n,&k);
  
    int S[n];
    char s[n];
    scanf("%s",s);
  
    for(int i=0;i<n;i++){
      if('L'==s[i]){
        S[i]=0;
      }else{
        S[i]=1;
      }
    }
    
    for(int i=0;i<n-1;i++){
        if(S[i]!=S[i+1]){
            p=p+1;
        }else{
          q=q+1;
        }
    }
    
    if(p<=2*k){
      ans=n-1;
    }else{
      ans=q+2*k;
    }
    
    printf("%d",ans);
    
    return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	string S;
	cin>>S;
	bool ok=false;
	for(int i=0;i<S.size();i++)
	{
		if(S[i]=='A'&&S[i+1]=='C')
			{ok=true;break;}
	}
	if(ok)
		puts("Yes");
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 998244353;
const int MAX = 10000005;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}

ll modpow(ll x, ll n){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

vector<ll> fac(MAX), finv(MAX), inv(MAX);

void comInit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(ll i=2; i<MAX; i++){
        fac[i] = fac[i-1]*i % mod;
        inv[i] = mod - inv[mod%i] * (mod/i) % mod;
        finv[i] = finv[i-1] * inv[i] % mod;
    }
}


ll com(ll n, ll k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

int main(){
    ll n; cin >> n;
    ll ans = modpow(3,n);
    comInit();
    REP(i,n/2+1,n+1){
        ll t = modpow(2,n-i)*com(n,i)*2;
        t %= mod;
        ans -= t;
        if(ans < 0) ans += mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 234624
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<vector>
#include<set>
#include<queue>

using namespace std;

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

#define f first
#define s second

int main(){
	while(1){
		int n,m;
		cin>>n>>m;
		
		if(n==0)break;
		
		vector<int> ya;
		ya.push_back(0);
		
		rep(i,n){
			int a;
			cin>>a;
			ya.push_back(a);
		}
		
		vector<int> y2;
		rep(i,ya.size()){
			rep(j,ya.size()){
				y2.push_back(ya[i]+ya[j]);
			}
		}
		
		sort(y2.begin(),y2.end());
		
		
		int maxi=0;
		
		rep(i,y2.size()){
			vector<int>::iterator a = lower_bound(y2.begin(),y2.end(),(m-y2[i]+1));
			if(a==y2.begin())continue;
			//printf("%d %d\n",y2[i],*(a-1));
			maxi= max(maxi,y2[i]+*(a-1));
		}
		printf("%d\n",maxi);
	}
}

Measured memory_bytes: 4968
def main():
    s = input()
    a, b = int(s[:2]), int(s[2:])
    if 0 < a < 13 and 0 < b < 13:
        print('AMBIGUOUS')
    elif 0 < a < 13 and (b > 12 or b == 0):
        print('MMYY')
    elif (a > 12 or a == 0) and 0 < b < 13:
        print('YYMM')
    else:
        print('NA')


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <vector>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <list>
#include <string.h>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cstdio>
#define rep(i, n) for(int i = 0; i < n; i++)
#define fi first
#define se second
//#include <Windows.h>
//#include "Library.h"
//#include "Math.h"
//#include "Othello.h"
using namespace std;
typedef long long int ll; typedef pair <int, int> P; typedef vector <int> vecint; typedef pair<int, P> P1; typedef pair<P1, int> P2;
const int inf = 1000000000;
const ll INF = 9000000000000000000;
const double EPS = 10e-9;
int main()
{
	int n; cin >> n;
	int a[100002];
	rep(i, n)
		cin >> a[i];
	sort(a, a + n);
	int last = a[0], cnt = 0, res = 0;
	rep(i, n)
	{
		if (a[i] == last) cnt++;
		else
		{
			if(cnt < last) res += cnt;
			else if (cnt > last) res += cnt - last;
			last = a[i];
			cnt = 1;
		}
	}
	if (cnt < last) res += cnt;
	else if (cnt > last) res += cnt - last;
	cout << res << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    string s, t;
    cin >> s >> t;

    sort(all(s));
    sort(all(t));
    reverse(all(t));

    cout << (s < t ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 3612
import java.util.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		
		int n=s.nextInt();
		int m=s.nextInt();
		int q=s.nextInt();
		
		int[][]d=new int[n+1][n+1];
		for(int M=0;M<m;++M) {
			int f=s.nextInt()-1,t=s.nextInt()-1;
			d[0][t]++;
			d[f+1][t]--;
		}
		
		Arrays.stream(d).forEach(o->Arrays.parallelPrefix(o,Integer::sum));
		for(int i=1;i<n;++i)
			for(int j=0;j<n;++j)
				d[i][j]+=d[i-1][j];
		
		for(int r=0;r<q;++r)
			System.out.println(d[s.nextInt()-1][s.nextInt()-1]);
	}
}


Measured memory_bytes: 165496
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i=(a); i<=(b); i++)
using namespace std;
typedef long long LL;

const int maxn = 9999999, MOD = 1000000007;
int f[maxn*3+1], S, ans, l, r, mn, mx;

inline void inc(int &a, int b) {
	a += b; if (a >= MOD) a -= MOD;
}
inline void dec(int &a, int b) {
	a -= b; if (a < 0) a += MOD;
}
inline int mul(int a, int b) {
	return 1LL * a * b % MOD;
}
inline int power(int x, int p) {
	int res = 1;
	while (p) {
		if (p & 1) res = 1LL * res * x % MOD;
		p >>= 1; x = 1LL * x * x % MOD;
	}
	return res;
}
inline void work(int k) {
	if (k <= 7) return;
	int res = mul(9, power(10, k-1));
	dec(res, S/k-1); inc(ans, res);
}

int main() {
	scanf("%lld", &S);
	rep (i, 1, maxn*3) f[i] = f[i/10] + 1;
	rep (i, 1, maxn*3) inc(f[i], f[i-1]);
	for (int l=0,r=1; r<=maxn*3; r++) {
		while (f[r] - f[l] > S) l++;
		if (l >= maxn) break;
		if (f[r] - f[l] == S) ans++;
	}
	for (int i=1; i*i<=S; i++) if (S % i == 0) {
		work(i); if (i*i != S) work(S/i);
	}
	for (int i=8; i<=S; i++) {
		mn = S / i - S % i; mx = S / i;
		if (mn > i + 1) mn %= i + 1;
		if (mn <= 0) mn += i + 1;
		if (S % i == 0) mx--;
		if (mx < mn) continue;
		inc(ans, (mx - mn) / (i + 1) + 1);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 117504
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 
 
	public static void main(String[] args) { //Partition babyyyyyyyyy
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		long cur = 0;
		int N = I.nextInt();
		long[][] job = new long[N][2]; //[Time, Deadline]
		boolean can = true;
		for (int i = 0; i < N; i++) {
			job[i][0]=I.nextLong();
			job[i][1]=I.nextLong();
		}
		Arrays.sort(job,(a,b)->Long.compare(a[1], b[1]));
		for (int i = 0; i < N; i++) {
			cur+=job[i][0]; //Current fastest time spent doing first i tasks
			if (cur>job[i][1]) {
				can=false;
				break;
			}
		}
		O.pln(can?"Yes":"No");
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
	}
}


Measured memory_bytes: 57108
#include <bits/stdc++.h>
using namespace std;
int n,a,b;vector<int> g[100005];int d1[100005],d2[100005];void dfs(int r,int f,int d,int dist[]){dist[r]=d;for(int x=0;x<g[r].size();x++)if(g[r][x]!=f)dfs(g[r][x],r,d+1,dist);}int main(){cin>>n;for(int i=0;i<n-1;i++){cin>>a>>b;a--,b--;g[a].push_back(b);g[b].push_back(a);}dfs(0,-1,0,d1);dfs(n-1,-1,0,d2);int ans=0;for(int i=0;i<n;i++)if(d1[i]<=d2[i])ans++;else ans--;if(ans>0)cout <<"Fennec"<< endl;else cout<<"Snuke"<<endl;}

Measured memory_bytes: 14336
#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 ALL(n) begin(n), end(n)
int main()
{
    // long double pi = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692;
    double pi = acos(-1);
    int A, B, H, M;
    cin >> A >> B >> H >> M;

    double rm;
    rm = double(M * 6);
    double rh;
    rh = double(H * 60 + M) / 2;
    // cout << rh << endl;
    // cout << rm << endl;

    double angle;
    angle = abs(rm - rh);
    // cout << angle << endl;
    // cout << fixed << setprecision(20) << sqrt(pow(A, 2) + pow(B, 2) - 2 * A * B * cos(pi * angle / 180)) << endl;
    // cout << fixed << setprecision(20) << static_cast<long double>(sqrt(pow(A, 2) + pow(B, 2) - 2 * A * B * cos(pi * angle / 180))) << endl;
    // printf("%.10f\n", double(A));
    // printf("%.10f\n", double(A * A + B * B));
    // printf("%.10f\n", double(2 * A * B) * cos(pi * angle / 180));
    // printf("%.20f\n", double(sqrt(double(A * A + B * B) - double(2 * A * B) * cos(double(pi * angle) / 180))));
    // printf("%.20f\n", double(sqrt(double(A * A + B * B) - double(2 * A * B) * cos(double(pi * angle) / 180))));
    cout << fixed << setprecision(20) << sqrt(double(A * A + B * B) - double(2 * A * B) * cos(pi * angle / 180)) << endl;
    // cout << fixed << setprecision(20) << sqrt(A * A + B * B - 2 * A * B * cos(pi * angle / 180)) << endl;
    // long double rad = (pi * angle) / 180;
    // double c = cos(rad);
    // double x = A * A + B * B - 2 * A * B * c;
    // // cout << fixed << setprecision(20) << static_cast<long double>(rad) << endl;
    // // cout << fixed << setprecision(20) << c << endl;
    // // cout << fixed << setprecision(20) << x << endl;
    // // cout << fixed << setprecision(20) << sqrt(x) << endl;
    // cout << fixed << setprecision(20) << static_cast<double>(sqrt(x)) << endl;
    return 0;
}

Measured memory_bytes: 4288
l = []
for c in range(65, 91): 
        l.append(c)
x = int(input())
n = input()
for i in range(len(n)):
    character = ord(n[i])
    if character+x>90:
        print(chr(l[(character+x)%90-1]),end='')
    else:
        print(chr(character+x),end='')


Measured memory_bytes: 4468
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
set<int> se;

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int a;
		scanf("%d",&a);
		if(se.find(a)==se.end()){
			se.insert(a);
		}else{
			se.erase(a);
		}
	}
	printf("%d\n",se.size());
	return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
 using namespace std;
 int main() {
  int N;
  cin >> N;
  long long A = 0;
  for(int i = 0; i < N + 1; i++){
   if(i % 3 != 0 && i % 5 != 0){
  A += i;
}
 }
cout << A << endl;
} 


Measured memory_bytes: 3636
import sys


def solve(n, k, h):
    if n <= k:
        return 0
    else:
        return sum(h[: n - k])


def main():
    input = sys.stdin.buffer.readline
    n, k = map(int, input().split())
    h = sorted(list(map(int, input().split())))
    print(solve(n, k, h))


if __name__ == "__main__":
    main()


Measured memory_bytes: 29284
#include<bits/stdc++.h>
using namespace std;
#define LL long long
LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
int main(){
	int n,m,x,w=0,w1;scanf("%d%d%d",&n,&m,&x),x/=2;
	while(x%2==0)x>>=1,w++,m/=2;
	LL lcm=x;
	for(int i=1;i<n;i++){
		scanf("%d",&x),x/=2,w1=0;
		while(x%2==0)x>>=1,w1++;
		lcm=lcm*x/gcd(lcm,x);
		if(lcm>m||w1!=w)return puts("0"),0;
	}
	printf("%d",((m/lcm)+1)/2);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,M; cin>>N>>M; 
    vint x(M); REP(i,M) cin>>x[i];
    sort(ALL(x));

    vint dx(M-1);
    REP(i,M-1) dx[i]=x[i+1]-x[i];
    sort(ALL(dx));

    int ans=0;
    REP(i,M-N) ans+=dx[i];
    cout<<ans<<endl;
 
}


Measured memory_bytes: 1792
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
#include <set>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
	int a;
    cin >> a;
    if (a >= 1 && a <= 999) cout << "ABC";
    else cout << "ABD";
}

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

ll powll(ll a,ll n){
  if(n==0)
  {
    return 1;
  }
  return powll(a,n-1)*a;
}

int main() {
   ll i,j,k;
    ll x,d;
    cin >>x ;

    d=x/100;
    if(x%100<=d*5)
    {
      cout <<  '1'<< endl;
    }else
    {
      cout << '0' << endl;
    }
  
}


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

typedef long long int lint;


int main(){
    int n;
    cin >> n;
    int arr[n];
    for(int i=0; i<n; i++) cin >> arr[i];
    int a, b, c;
    sort(arr, arr+n);
    
    lint cntr = 0;
    for(int i=0; i<n-2; i++){
        for(int j=i+1; j<n-1; j++){
            for(int k=j+1; k<n; k++){
                if(arr[i] + arr[j] > arr[k])
                    cntr++; 
            }
        }
        
    }
    cout << cntr;
    return 0;

}

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

#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

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

int main() {
    lli n, x;
    cin >> n >> x;
    lli total = 0;
    lli ans = 0;
    REP(i, 0, n) {
        lli l;
        cin >> l;
        if (total > x) {
            break;
        }
        total += l;
        ans++;
    }
    if (total <= x)
        ans++;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

long long n,p;
long long l=0,r=0;
long long a[55];
long long d[55][55];

int main()
{
    cin >> n >> p;
    for(int i=0; i<n; i++)
    {
        cin >> a[i];
        if(a[i]%2)
            l++;
        else
            r++;
    }
    d[0][0]=1;
    for(int i=1; i<51; i++)
    {
        for(int j=0; j<=i; j++)
        {
            d[i][j]=d[i-1][j]+d[i-1][j-1];
        }
    }
    long long ans=0;
    if(!p)
    {
        for(int i=0; i<=l; i+=2)
        {
            ans+=d[l][i];
        }
        for(int i=0; i<r; i++)
        {
            ans*=2;
        }
    }
    else
    {
        for(int i=1; i<=l; i+=2)
        {
            ans+=d[l][i];
        }
        for(int i=0; i<r; i++)
        {
            ans*=2;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-01 22:09:22
*/

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

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<(x)>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod) {
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod) {
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod) {
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l) {
    if (l > 0) return gcd(l, k%l);
    else return k;
}

ostringstream oss_global;
string s_global = oss_global.str();

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

    string ans;
    if (r < 1200) ans = "ABC";
    else if (r < 2800) ans = "ARC";
    else ans = "AGC";

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
// 型名の省略
typedef unsigned int uint;
typedef long long lint;
typedef unsigned long long ulint;
 
const int MOD = 1000000007;
const lint INF = 1LL << 60;
const double PI=acos(-1.0);
 
// cinとcoutの高速化
#define endl "\n"
struct cinacc{cinacc(){cin.tie(0);ios::sync_with_stdio(false);}}cinaccc;
struct coutacc{coutacc(){cout.setf(ios::fixed);cout.precision(12);}}coutaccc;
 
// 繰り返し
#define rep(i,n) for(lint i=0;i<(lint)(n);i++)
#define reps(i,n) for(lint i=0;i<=(lint)(n);i++)
#define rrep(i,n) for(lint i=(lint)(n)-1;i>0;i--)
#define rreps(i,n) for(lint i=(lint)(n)-1;i>=0;i--)

#define pb push_back

#define p pair<int, int>
#define plint pair<lint, lint>

#define ALL(s) (s.begin(), s.end())
#define SZ(s) (s.size())

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

// Union-Find-Tree
class UnionFind {
    vector<int> par;
    UnionFind(int n):par(n){rep(i,n)par[i]=i;}
    int root(int x){if(par[x]==x)return x;return par[x]=root(par[x]);}
    void unite(int x,int y){int rx=root(x);int ry=root(y);if(rx==ry)return;par[rx]=ry;}
    bool same(int x,int y){return root(x)==root(y);}
};

// Final Weapon!
// #define int lint

int main(void) {
    int a, b;
    string s;
    
    cin >> s;
  
    if(s[2] == s[3] && s[4] == s[5]) cout << "Yes";
    else cout << "No";
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int n;
	long long sum = 0;
	bool b = false;
	cin >> n;
	long long m = 100000000007;
	long long a;
	for (int i = 0; i < n; i++) {
		cin >> a;
		sum += abs(a);
		if (m > abs(a)) {
			m = abs(a);
		}
		if (a < 0) {
			b = b ^ 1;
		}
	}
	if (b) {
		sum -= m * 2;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3608
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
ll a[200000];
ll sum[200000];
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		sum[i] = a[i];
	}
	for (int i = 1; i < N; i++) {
		sum[i] += sum[i - 1];
	}
	ll ans = INF;
	for (int i = 0; i + 1 < N; i++) {
		ans = min(ans, abs(sum[i] - (sum[N - 1] - sum[i])));
	}
	cout << ans << endl;
}


Measured memory_bytes: 3328
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50


def run():
    N = int(sysread())
    A = list(map(int, sysread().split()))
    X = []
    k = 1
    S = 0
    for a in A:
        S += a * k
        k *= -1
    X.append(S)
    for a in A[:-1]:
        X.append(a * 2 - X[-1])
    print(' '.join([str(x) for x in X]))
if __name__ == "__main__":
    run()

Measured memory_bytes: 25488
#include<bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;

int main(){
	
	int n,m;
	cin >> n >> m;
	int64_t ans=1;
	for(int i=1; i<=n; i++) ans = ans * i % MOD;
	for(int j=1; j<=m; j++) ans = ans * j % MOD;
	if(abs(n-m)>1) ans=0;
	if(n==m) ans = ans * 2 % MOD;
	cout << ans << endl;
	
}

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

using ll = long long;
using ld = long double;

int main()
{
    char c;
    cin >> c;
    
    if(c =='a' || c=='e'||c=='i'||c=='o'||c=='u')
    {
        cout << "vowel" << endl;
    }
    
    else
    {
        cout << "consonant" << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <typeinfo>

using namespace std;

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

  int a=1;
  for(int i=0;i<M;i++)  a*=2;
  int ans=(1900*M+100*(N-M))*a;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

long long int gcd(long long int x, long long int y)
{
	if (y == 0) { return x; }
	return gcd(y, x % y);
}

int main(void)
{
	int a, b;
	cin >> a >> b;
	cout << max(0, a - b * 2) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
bool dp[80][80][13000]={};
int main()
{
ll h , w ;
cin >> h >> w ;
vector<vector<ll>> v(h, vector<ll>(w,0) );
rep(i,h)rep(j,w){
  ll a ;
  cin >> a ;
  v[i][j]=a;
}
rep(i,h)rep(j,w){
  ll a ;
  cin >> a ;
  v[i][j]=abs(a-v[i][j]);
}

dp[0][0][v[0][0]]=1;
rep(i,h)rep(j,w){
  rep(k,13000){
    if(i-1>=0&&dp[i-1][j][k]){
      if(abs(k-v[i][j])<13000)dp[i][j][abs(k-v[i][j])]=1;
      if(k+v[i][j]<13000)dp[i][j][k+v[i][j]]=1;
    }
    if(j-1>=0&&dp[i][j-1][k]){
      if(abs(k-v[i][j])<13000)dp[i][j][abs(k-v[i][j])]=1;
      if(k+v[i][j]<13000)dp[i][j][k+v[i][j]]=1;
    }
  }
}
rep(i,13000){
  if(dp[h-1][w-1][i]){ans=i;break;}
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 80640