akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

from collections import Counter
from itertools import product

def main():
    N = II()
    dp = Counter()
    dp['000'] += 1
    for _ in range(N):
        pre = dp
        dp = Counter()
        for old, n in pre.items():
            for cur in 'AGCT':
                new = old[-2:] + cur
                if new in ['AGC', 'GAC', 'ACG']:
                    continue
                if old[-3] + old[-1] + cur == 'AGC':
                    continue
                if old[:-1] + cur == 'AGC':
                    continue
                dp[new] = (dp[new] + n) % MOD
    ans = sum(dp.values())

    return ans % MOD

print(main())

Measured memory_bytes: 3316
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>

#define rep(i,n) for((i)=0;i<(int)(n);i++)
using namespace std;
int i, j, k;
long long ans = 0;
int main() {
	int N;
	cin >> N;
	cout << (double)(N / 2 + N % 2)/N;
}

Measured memory_bytes: 256
n, k = gets.split(" ").map(&:to_i)
as = gets.split(" ").map(&:to_i)

h = {}
as.each do |a|
  h[a] ||= 0
  h[a] += 1

end
as.uniq!
as.sort!{|a,b| h[b] <=> h[a]}

puts n - as[0...k].reduce(0) {|a,e| a+=h[e]}

Measured memory_bytes: 42864
#include<bits/stdc++.h>
using namespace std;
long long const MAX=1e9+7;
long long dp[1002][1002]={0};
void initialize()
{long long i,j;
    for(i=0;i<1002;i++)
{for(j=0;j<1002;j++)
{dp[i][j]=0;}}
return;}
int main()
{long long i,j,x,n,r,k,p,w,y,sum,m;
initialize();
cin>>n>>m;
char s[n][m];
for(i=0;i<n;i++){
for(j=0;j<m;j++)
{cin>>s[i][j];
}}
dp[0][0]=1;
for(i=0;i<n;i++)
{for(j=0;j<m;j++)
{if(s[i][j]=='#')
{dp[i][j]=0;}
else{if(i>0)
dp[i][j]=dp[i][j]+dp[i-1][j];
if(j>0)
dp[i][j]=dp[i][j]+dp[i][j-1];
dp[i][j]=dp[i][j]%MAX;}
}}
cout<<dp[n-1][m-1];
return 0;}

Measured memory_bytes: 9088
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto A = RDA;
	auto cnt = new long[](61);
	long ans;
	foreach (i; 0..N)
	{
		foreach (j; 0..61)
		{
			auto bit = 1L << j;
			if (A[i] & bit)
			{
				long x;
				x.moda(bit);
				x.modm(i-cnt[j]);
				ans.moda(x);
				++cnt[j];
			}
			else
			{
				long x;
				x.moda(bit);
				x.modm(cnt[j]);
				ans.moda(x);
			}
		}
		debug writeln(ans);
	}

	writeln(ans);
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 18224
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define ll long long

using namespace std;

ll R_list[100000][10];
int MOD = 1000000007;

void print_array(ll* arr, int n) {
    for (int i = 0; i < n; i++) {
        cout << arr[i] << ' ';
    }
    cout << endl;
}

int main() {

    string S;
    // vector<int> Q_digit;

    // Initial Setup
    int digit_val = 1;
    for (int i = 0; i < 100000; i++) {
        for (int j = 0; j < 10; j++) {
            R_list[i][j] = (j * digit_val) % 13;
        }
        digit_val = (digit_val * 10) % 13;
    }

    getline(cin, S);
    reverse(S.begin(), S.end());

    // cout << S << endl;

    int r_sum = 0;
    ll count_r1[13];
    ll count_r2[13];
    for (int i = 0; i < 13; i++) {
        count_r1[i] = 0;
        count_r2[i] = 0;    
    }

    count_r1[0] = 1;

    bool entered = false;

    for (int i = 0; i < S.length(); i++) {
        if (S[i] == '?'){
            if (!entered) {
                for (int j = 0; j < 10; j++) {
                    count_r1[R_list[i][j]] = 1;
                }
            }
            else {
                for (int j = 0; j < 10; j++) {
                    for (int k = 0; k < 13; k++){
                        count_r2[((R_list[i][j] + k + 13) % 13)] += count_r1[k];
                    }
                    // print_array(count_r2, 13);
                }
                for (int k = 0; k < 13; k++){
                    count_r1[k] = count_r2[k] % MOD;
                    count_r2[k] = 0;
                }
            }
            // print_array(count_r1, 13);
            // print_array(R_list[i], 10);
            entered = true;
        }  
        else {
            r_sum += R_list[i][(int)(S[i] - '0')];
            // cout << R_list[i][(int)(S[i] - '0')] << endl;
        }
    }

    r_sum %= 13;
    // cout << r_sum << endl;
    cout << count_r1[(18 - r_sum) % 13]  << endl;

    return 0;
}

Measured memory_bytes: 8320
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type_a,class Type_b> bool chmax(Type_a &a,const Type_b &b){if(a<b){a=b;return true;}return false;}
template<class Type_a,class Type_b> bool chmin(Type_a &a,const Type_b &b){if(a>b){a=b;return true;}return false;}
template<class Type> Type igcd(Type x,Type y){return (y==0)?x:igcd(y,x%y);}
template<class Type> Type ilcm(Type x,Type y){return x/igcd(x,y)*y;}
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int n;
	cin>>n;
	
	vi a(n);
	REP(i,n) cin>>a[i];
	sort(ALL(a));
	
	llong ans=INF;
	for(int i=1;i<=a[n-1];++i){
		llong sum=0;
		REP(j,n) sum+=pow(abs(a[j]-i),2);
		//debug(sum);
		chmin(ans,sum);
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 256
N = int(input())
L = [ input() for _ in range(N)]
M = int(input())
K = [ input() for _ in range(M)]

dic = {}

for l in L:
    if l in dic:
        dic[l] += 1
    else:
        dic[l] = 1
        
for k in K:
    if k in dic:
        dic[k] -= 1
    else:
        dic[k] = -1

res = 0
for i in dic:
    res = max(res, dic[i])
    
print(res)

Measured memory_bytes: 3064
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    if(n==m){
        for(int i=0;i<n;i++){
            cout<<n;
        }
       cout<< endl;
    }
    else{
        int v=min(m,n);
        int c=max(m,n);
        for(int i=0;i<c;i++){
            cout<<v;
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3556
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

const long long MOD = 1000000007;

void test(int L, int R) {
    int a = 0, b = 0, c = 0;
    for(int x = L; x <= R; ++x) {
        for(int y = x; y <= R; ++y) {
            bool f = false, g = false;
            if ((x ^ y) == y % x) {
                ++a;
                f = true;
            }
            if (2 * x > y && (x & ~y) == 0) {
                ++b;
                g = true;
                cerr << x << "," << y << endl;
            }
            if (f != g) {
                ++c;
            }
        }
    }
    cerr << a << "," << b << "," << c << endl;
}

int dp[100][2][2][2];

void solve(long long L, long long R){
    int res = 0;

    int t = 62;
    dp[t][1][1][1] = 1;

    for(int i = t; i > 0; --i) {
        int ls = (L >> (i - 1)) & 1, rs = (R >> (i - 1)) & 1;

        // 0, 0, 0
        dp[i - 1][0][0][0] += dp[i][0][0][0] * 3 + rs * dp[i][1][0][0] + (1 - ls) * (dp[i][0][1][0] + dp[i][0][1][1]);
        dp[i - 1][0][0][0] %= MOD;

        // 0, 0, 1
        // This case doesn't exist

        // 1, 0, 0
        dp[i - 1][1][0][0] += (1 + rs) * dp[i][1][0][0] % MOD + rs * (1 - ls) * (dp[i][1][1][1] + dp[i][1][1][0]) % MOD;
        dp[i - 1][1][0][0] %= MOD;

        // 1, 0, 1
        // This case doesn't exist
        if (rs) {
            // 1, 0, 0
        }

        // 0, 1, 0
        dp[i - 1][0][1][0] = ((2 - ls) * dp[i][0][1][0] % MOD + ls * dp[i][0][1][1]) % MOD + rs * (1 - ls) * dp[i][1][1][0];
        dp[i - 1][0][1][0] %= MOD;
        if (!ls) {
            // 0, 1, 0
        }


        dp[i - 1][0][1][1] = (1 - ls) * (dp[i][0][1][1] + dp[i][1][1][1] * rs) % MOD;

        if (rs || !ls) {
            // 1, 1, 0
            dp[i - 1][1][1][0] = (dp[i][1][1][0] + dp[i][1][1][1] * rs * ls) % MOD;
        }

        if (rs && !ls) {
        } else if (!rs && !ls) {
            // 1, 1, 1
            dp[i - 1][1][1][1] += dp[i][1][1][1] * 1 % MOD;
            dp[i - 1][1][1][1] %= MOD;

            // 1, 1, 0
        }
    }

    for(int i = 0; i < 2; ++i) for(int j = 0; j < 2; ++j)  {
                res = (res + dp[0][i][j][0]) % MOD;
            }

    cout << res << endl;
}

signed main(){
    long long L;
    scanf("%lld",&L);
    long long R;
    scanf("%lld",&R);
    solve(L, R);
    return 0;
}


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

int main(){
        int i, n, ac, wa, tle, re;
        ac=wa=tle=re=0;
        char s[4];

        scanf("%d", &n);

        for(i=0; i<n; i++){
                scanf("%s", s);
                if(s[0]=='A'){
                        ac++;
                }else if(s[0]=='W'){
                        wa++;
                }else if(s[0]=='T'){
                        tle++;
                }else if(s[0]=='R'){
                        re++;
                }
        }

        int num[4]={ac, wa, tle, re};
        char c[4][4]={"AC", "WA", "TLE", "RE"};
        for(i=0; i<4; i++){
                printf("%s x %d", c[i], num[i]);
                if(i<3){
                        putchar('\n');
                }
        }

        return 0;
}


Measured memory_bytes: 1712
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);
parse_tuple!(A, B, C, D);

#[derive(PartialEq,PartialOrd)]
struct Of64(f64);

impl Eq for Of64 {}

impl Ord for Of64 {
    fn cmp(&self, other: &Of64) -> Ordering {
        self.partial_cmp(other).unwrap()
    }
}


// ===

struct Point {
    x: i64,
    y: i64,
    r: i64
}

impl Point {
    fn distance(&self, to: &Point) -> f64 {
        let dx = (self.x-to.x).abs();
        let dy = (self.y-to.y).abs();
        let dist: f64 = ((dx*dx+dy*dy) as f64).sqrt();
        f64::max(0.0, dist - (self.r + to.r) as f64)
    }
}



const INF: f64 = 1e18;

fn main() {
    let (xs, ys, xt, yt): (i64, i64, i64, i64) = read();
    let n = read();
    let barrier: Vec<(i64, i64, i64)> = readn(n);

    let mut points: Vec<Point> = vec![];
    points.push(Point { x: xs, y: ys, r: 0 });
    points.push(Point { x: xt, y: yt, r: 0 });
    for &b in &barrier {
        points.push(Point { x: b.0, y: b.1, r: b.2 });
    }

    let n = points.len();
    let mut graph: Vec<Vec<f64>> = vec![vec![INF; n]; n];
    for i in 0..n {
        for j in i+1..n {
            let d = points[i].distance(&points[j]);
            graph[i][j] = d;
            graph[j][i] = d;
        }
        graph[i][i] = 0.0;
    }

    let mut q = BinaryHeap::new();
    let mut dp: Vec<f64> = vec![INF; n];
    dp[0] = 0.0;

    q.push((Of64(0.0), 0));

    while let Some((Of64(md), now)) = q.pop() {
        let d = -md;
        if dp[now] < d {
            continue
        }
        for to in 0..n {
            let td = d + graph[now][to];
            if dp[to] > td {
                dp[to] = td;
                q.push((Of64(-td), to));
            }
        }
    }

    println!("{}", dp[1]);
}

Measured memory_bytes: 17656
fun main(args: Array<String>) {
    val input = readLine()?.split(" ")
    val inputInt = arrayListOf<Int>()
    input?.forEach { inputInt.add(it.toInt()) }

    println(
        when {
            inputInt[2] - inputInt[4] < 0 -> "No"
            inputInt[3] - inputInt[4] < 0 -> "No"
            inputInt[2] + inputInt[4] > inputInt[0] -> "No"
            inputInt[3] + inputInt[4] > inputInt[1] -> "No"
            else -> "Yes"
        }
    )
}



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

int main()
{
   int n,m;
   cin>>n>>m;
   int a[m+1],sum=0;
   
   for(int i=1;i<=m;i++)
   {
   	 cin>>a[i];
   	 sum+=a[i];
   }
   
   if(sum<n)  cout<<n-sum;
   else if(sum==n)  cout<<"0";
   else cout<<"-1";
   
   return 0; 
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
const int dx[4]={-1,1,0,0};
const int dy[4]={0,0,-1,1};
signed main()
{
	int n;
	cin>>n;
	cout<<1-n;
	re 0;
}


Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main(){
	string str;
	cin >> str;
	
	int s = 0;
	int len = str.size();
	for(int i = 0;i < str.size();i++){
		if(str[i] == 'S') s++;
		else{
			if(s > 0){
				len -= 2;
				s--;
			}
		}
	}
	
	cout << len << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>

#define MAX 101

int main(void){
  int Adj[MAX][MAX];
  int i, j, n, u, k, v;

  scanf("%d", &n);
  for(i=1; i<n+1; i++){
    for(j=1; j<n+1; j++){
      Adj[i][j] = 0;
    }
  }

  for(i=1; i<n+1; i++){
    scanf("%d%d", &u, &k);
    for(j=1; j<k+1; j++){
      scanf("%d", &v);
      Adj[i][v] = 1;
    }
  }

  for(i=1; i<n+1; i++){
    for(j=1; j<n+1; j++){
      if(j == n) printf("%d\n", Adj[i][j]);
      else printf("%d ", Adj[i][j]);
    }
  }

  return 0;
}

Measured memory_bytes: 636
import numpy as np

A = []
# 3行目までのinput()をsplitでばらして配列Aに格納
[A.append(list(map(int, input().split(' ')))) for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)] 
temp = [[False]*3 for _ in range(3)]

# 行単位で穴が空いているかを真偽値でtempに格納 
for i in range(3):
    for j in range(3):
        if A[i][j] in B:
            temp[i][j] = True

# bingoに行単位、列単位、対角線２本を格納
bingo = []
bingo += temp + np.array(temp).T.tolist() + [[temp[0][0], temp[1][1], temp[2][2]], [temp[0][2], temp[1][1], temp[2][0]]]

result = False
for t in bingo:
    if t.count(True) == 3:
        result = True

if result:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14216
from collections import Counter
N = int(input())
a = [int(i) for i in input().split()]
ans = dict(Counter(a))
ans1 = []
for i in range(min(a),max(a)+1):
    count = 0
    if i-1 in ans:
        count += ans[i-1]
    if i in ans:
        count += ans[i]
    if i+1 in ans:
        count += ans[i+1]
    ans1.append(count)
print(max(ans1))

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

int main(void) {
    int a, b, c, d;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b >> c >> d;
    if (abs(a - c) <= d
        || (abs(a - b) <= d && abs(b - c) <= d)) {
        cout << "Yes\n";    
    } else {
        cout << "No\n" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define ALL(v) (v).begin(),(v).end()
#define REP(i, x, n) for(ll (i)=(x); (i)<(n); (i)++)
#define RREP(i, x, n) for(ll (i)=(n)-1; (i)>=x; (i)--)
#define FOR(i, n) for(ll (i)=0; (i)<(n); (i)++)
#define RFOR(i, n) for(ll (i)=(n)-1; (i)>=0; (i)--)

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

        const long double PI = 3.14159265358979323846;
        ll a, b, h, m, tmp;
        cin >> a >> b >> h >> m;
        ld t = abs(2 * PI * ((ld)h / 12 + (ld)m / 720 - (ld)m / 60));
        cout << setprecision(20) << sqrtl(a * a + b * b - 2 * a * b * cosl(t)) << endl;

        return 0;
}

Measured memory_bytes: 4116
K=int(input())

one=['1','2','3','4','5','6','7','8','9']
for i in range(10**5+1):
    if one[i][-1]=='0':
        one.append(one[i]+'0')
        one.append(one[i]+'1')
    elif 1<=int(one[i][-1])<=8:
        one.append(one[i]+str(int(one[i][-1])-1))
        one.append(one[i]+str(int(one[i][-1])))
        one.append(one[i]+str(int(one[i][-1])+1))
    else:
        one.append(one[i]+'8')
        one.append(one[i]+'9')

print(one[K-1])

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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> d(k);
    vector<vector<int>> a(k, vector<int>(n));

    set<int> set;

    int ans;

    for (int i = 0; i < k; i++)
    {
        cin >> d.at(i);
        for (int j = 0; j < d[i]; j++)
        {
            cin >> a[i][j];
        }
    }

    for (int i = 0; i < k; i++)
    {
        for (int j = 0; j < d[i]; j++)
        {
            set.insert(a[i][j]);
        }
    }

    ans = n - set.size();

    cout << ans << endl;
}

Measured memory_bytes: 3608
n = int(input())
s = [input() for _ in range(n)]
s.sort()
s.append(0)
k = 1
m = 0
ans = []
for i in range(n):
    if s[i] == s[i+1]:
        k += 1
    else:
        if m < k:
            ans = []
            ans.append(s[i])
            m = k
        elif m == k:
            ans.append(s[i])
        k = 1
for s in ans:
    print(s)


Measured memory_bytes: 19108
n = int(input())
s = input()

count = 0
r = []
g = []
b = []

for i in range(n):
    if s[i] == 'R':
        r.append(i)
    if s[i] == 'G':
        g.append(i)
    if s[i] == 'B':
        b.append(i)

count += len(r)*len(g)*len(b)

for i in range(n-2):
    for j in range(i+1,n):
        if j+(j-i) >= n:
            continue
        k = j + (j-i)
        if (s[i] != s[j]) and (s[j] != s[k]) and (s[k] != s[i]):
            count -= 1

print(count)


Measured memory_bytes: 68176
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T &a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T &a, T b) {
	a = std::min(a, b);
}

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)
			return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)
		return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i;
		res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m=mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)
		return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod ;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937 mt32(rnd());
	std::uniform_int_distribution<int> engine(MIN, MAX);
	return engine(mt32);
}
/*--------Library Zone!--------*/


signed main() {
	int x;cin>>x;
	for(int i=x;;i++){
		if(prime(i)){
			cout<<i<<endl;return 0;
		}
	}
}


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

int main() {
  int D, G;
  cin >> D >> G;
  int p[D];
  int c[D];
  int comp[D];
  for (int i = 0; i < D; i++) {
    cin >> p[i] >> c[i];
    comp[i] = (i+1) * 100 * p[i] + c[i];
  }
  
  int bits;
  int score[1 << D];
  int solved[1 << D];
  int unsolved = 0;
  int ans = 1000;
  
  for (bits = 0; bits < (1 << D); bits++) {
    score[bits] = 0;
    solved[bits] = 0;
    for (int i = 0; i < D; i++) {
      if ((bits >> i) & 1) {
        score[bits] += comp[i];
        solved[bits] += p[i];
      }
      if (!((bits >> i) & 1)) {unsolved = i;}
    }
    
    int k = 1;
    while (score[bits] < G && k < p[unsolved]) {
      score[bits] += (unsolved+1) * 100;
      solved[bits]++;
      k++;
    }
    
    if (score[bits] >= G) {ans = min(ans, solved[bits]);}
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int W,H,x,y,r;
	scanf("%d %d %d %d %d\n",&W,&H,&x,&y,&r);
	if(W <= 100 && H <= 100 && r <= 100) {
		if(x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H) {
				printf("Yes\n");
		} else {
			printf("No\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1820
/*
    STARK_BOY
*/
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i<=b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef vector< ll > vi;
typedef vector<pair<ll,ll> > vpii;
typedef pair<ll,ll> pii;
#define all(c) c.begin(),c.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define setbitc(x) __builtin_popcount(x)
#define init(x,a) memset(x,a,sizeof(x))
#define PI           3.14159265358979323846  /* pi */
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
#define N 1000005
//Variables Start
ll inf=1e18,MOD=1e9+7;
ll n,m,k,ar[N],br[N];
string s,s1;
//Variables End

int main()
{
    ios
    int ti=1;
    //cin>>ti;
    while(ti--)
    {
    	ll a,b;
		cin>>n>>a>>b;
		if((b-a)%2==0)
		{
			cout<<(b-a)/2<<endl;
		}
		else
		{
			cout<<(b-a)/2+min(a-1,n-b)+1<<endl;
		}
    }
    return 0;
        
}

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

typedef long long ll ;
#define rep (i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

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

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

	string s;
	
	cin >> s;

	int len = s.size();
	bool is_odd = len % 2;

	if (s[0] == s[len-1])
	{
		if (is_odd)
		{
			cout << "Second" << endl;
		}
		else
		{
			cout << "First" << endl;
		}
	}
	else
	{
		if (is_odd)
		{
			cout << "First" << endl;
		}
		else
		{
			cout << "Second" << endl;
		}
		//cout << "First" << endl;
	}

	
	return 0;
}



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

using namespace std;

typedef long long int ll;

ll M=1e9+7;

int main(){
    ll n;
    cin>>n;
    ll a[n+1],pre[n+1]={0},ans=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        pre[i]=(pre[i-1]+a[i])%M;
    }
    //cout<<pre[n+1]<<"\n";
    for(int i=1;i<n;i++){
        ll sub=(pre[n]-pre[i]+M)%M;
        //cout<<a[i]<<" "<<sub<<"\n";
        ll temp=(a[i]*sub)%M;
        ans=(ans+temp+M)%M;
    }
    cout<<ans<<"\n";
    
    return 0;
}


Measured memory_bytes: 6696
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n;
  cin >> n;
  vector<int>a(n+1);
  rep(i,n)cin >> a[i+1];
  vector<int>b(n+1);
  for(int i = n;i>0;i--){
    int sum = 0;
    for(int j = n-n%i;j>i;j-=i){
      sum ^= b[j];
    }
    b[i] = a[i] ^ sum;
  }
  int m=0;
  rep(i,n)m+=b[i+1];
  cout << m << endl;
  rep(i,n)if(b[i+1]==1)cout << i + 1 << " ";
  cout << endl;
}

Measured memory_bytes: 2432
/*
Roses are red
Memes are neat
All my test cases time out
Lmao yeet
*/
import java.util.*;
import java.io.*;

   public class Main
   {
      public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int[] arr = new int[N+1];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i <= N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         int[] brr = new int[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            brr[i] = Integer.parseInt(st.nextToken());
         long res = 0L;
         for(int i=0; i < N; i++)
         {
            int pow = brr[i];
            if(pow <= arr[i])
            {
               res += pow;
               arr[i] -= pow;
               brr[i] = 0;
            }
            else
            {
               res += arr[i];
               pow -= arr[i];
               arr[i] = 0;
               if(arr[i+1] >= pow)
               {
                  res += pow;
                  arr[i+1] -= pow;
               }
               else
               {
                  res += arr[i+1];
                  arr[i+1] = 0;
               }
            }
         }
         System.out.println(res);
      }
   }

Measured memory_bytes: 41916
def warshall_floyd(d):
    r=range(M+1)
    for k in r:
        for i in r:
            for j in r:
                t=d[i][k]+d[k][j]
                if t<d[i][j]:
                    d[i][j]=t
    return d
n,*a=map(int,open(0).read().split())
a,b=a[:n],a[n:]
for x,y in zip(a,b):
    if x==y:continue
    if y>x:
        print(-1)
        exit()
    if x-y<=y:
        print(-1)
        exit()
M=max(a)
d=[]
for k in range(M-1,-1,-1):
    s=set(a)
    e=[[10**18]*(M+1)for _ in range(M+1)]
    for i in range(M+1):e[i][i]=1
    for i in d+list(range(k,0,-1)):
        t=s.copy()
        for x in s:
            e[x][x%i]=1
            t|={x%i}
        s=t
    c=warshall_floyd(e)
    for x,y in zip(a,b):
        if c[x][y]>=10**18:
            d+=k+1,
            break
print(sum(2**k for k in d))

Measured memory_bytes: 43228
n = int(input())
h = list(map(int,input().split()))

falg = 0

for i in range(n - 1):
    if h[i] < h[i+1]:
        h[i+1] -= 1
    elif h[i] > h[i+1]:
        print("No")
        exit()
            
print("Yes")


Measured memory_bytes: 14396
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            Map<String,Integer> map=new HashMap<String,Integer>();
            byte[] a=new byte[26];
        	String[] str=new String[26];
        	String resultString;
        	for(int i=0;i<a.length;i++){
        		a[i]=(byte) (i+97);
        		resultString = new String(a, "US-ASCII");
        		map.put(resultString.substring(i, i+1),0);
        		str[i]=resultString.substring(i, i+1);
        	}
            while ((line = br.readLine()) != null&&line.length()!=0) {
            	String s=line.toLowerCase();
            	for(int i=0;i<s.length();i++){
            		if(map.containsKey(s.substring(i, i+1))){
            			map.put(s.substring(i, i+1), 1+map.get(s.substring(i, i+1)));
            		}
            	}
            	
            }
            for(int i=0;i<str.length;i++){
        		System.out.println(str[i]+" : "+map.get(str[i]));
        	}
        }
    }

}

Measured memory_bytes: 24620
def main():
    a = 0
    i = 0
    s = []
    u = []
    l = raw_input()
    for c in l:
        if c == '\\':
            s.append(i)
        elif c == '/' and len(s) > 0:
            j = s.pop()
            t = i - j
            a += t
            while len(u) > 0 and u[-1][0] > j:
                t += u.pop()[1]
            u.append((j, t))
        i += 1
    u.insert(0, (0, len(u)))

    print(a)
    print(' '.join(map(lambda x: str(x[1]), u)))


if __name__ == '__main__':
    main()

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

const int MAX = 2e5 + 111;

int n;

int a[MAX], b[MAX];

int main() {
#ifdef LOCAL
    freopen("xxx.in", "r", stdin);
    freopen("xxx.out", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i)
        cin >> b[i];
    ll c1 = 0, c2 = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] <= b[i])
            c1 += (b[i] + 1 - a[i]) / 2, c2 += (b[i] - a[i]) % 2;
        else
            c2 += a[i] - b[i];
    }
    if (c1 >= c2) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 384
/*
I am not somebody you can put inside a box
And I am not somebody who will let you take my spot
It's written on my face I'm somebody who never stop
I do it because I gotta I don't do it for you props
Nah, you can keep those
I'm aiming way higher than planes in Heathrow
And I'm sorry to say but my game can't be sold
And look to be honest either you got it or don't
But if you got a dream and a vision
Put it in your mind that you gotta go out and get it
People try to stop you it's so hard in the beginning
But you said that you a winner so keep going ain't no quiting
I'm giving you the words that out me in this posotion
Some people hear and some people listen
Wanna be the best then you gotta learn the difference
*/
#include <bits/stdc++.h>                                           
 
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define int long long	
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define ll long long
#define vi vector < int >
#define pii pair < int, int > 
#define sz(s) (int)s.size()
#define all(x) x.begin(), x.end()                                                                    
#define pb push_back   
#define ppb pop_back
#define mp make_pair
#define s second
#define f first                                               
	
   
typedef tree < int, null_type, less < int >, rb_tree_tag, tree_order_statistics_node_update > ordered_set;   
   
const int N = 2e5 + 13, inf = 1e9, mod = 1e9 + 7, block = 444;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
const ll INF = 1e18;
//fucking constants
 

int n, a[N], ans;

main () {
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		if (i > 1)
			ans += max(0ll, a[i - 1] - a[i]);
		a[i] = max(a[i], a[i - 1]);
	}

	cout << ans << endl;
}

Measured memory_bytes: 5152
#include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long
#define vi vector <int>
#define pii pair <int, int>
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i,n) for (int i = 0; i < (int) (n); ++ i)
#define foreach(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); ++ it)

inline int read() {
	int x = 0, f = 1, c = getchar();
	for (;!isdigit(c);c = getchar()) if (c == '-') f ^= 1;
	for (; isdigit(c);c = getchar()) x = x * 10 + c - '0';
	return f ? x : -x;
}

int main() {
	int n = read();
	printf("%.6f\n", 1.0 * ((n + 1) / 2) / n);
	return 0;
}


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

int main(){
  int n[3] = {0};
  for(int i = 0; i < 3; i++){
    char c;
    cin >> c;
    n[c - 'a']++;
  }
  cout << (n[0] && n[1] && n[2] ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL 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;}

//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) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

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

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

#define PUTS(x) cout << (x) << endl;

const LL MOD = 1e9 + 7;
const LL M = 100;
LL n;
vector<vector<LL>> link;

LL dp[50][50][M+1] = {0};
map<LL,LL> memo[50][50];

LL f(LL i, LL j, LL k) {
    if(k < M){
        return dp[i][j][k];
    }
    if(EXIST(memo[i][j], k)){
        return memo[i][j][k];
    }
    LL x = k/2;
    LL y = k - x;
    LL sum = 0;
    REP(t,n){
        sum += (f(i, t, x) * f(t, j, y)) % MOD;
        sum %= MOD;
    }
    memo[i][j].insert(MP(k, sum));
    return sum;
}

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

    LL k;
    cin>>n>>k;
    link.resize(n);
    REP(i,n){
        REP(j,n){
            LL a;
            cin>>a;
            if(a == 1)link[i].PB(j);
        }
    }

    REP(i,n)dp[i][i][0] = 1;
    REP(len,M){
        REP(i,n){
            for(LL to : link[i]){
                REP(st, n){
                    dp[st][to][len+1] += dp[st][i][len];
                    dp[st][to][len+1] %= MOD;
                }
            }
        }
    }

    LL ans = 0;
    REP(i,n)REP(j,n){
        ans += f(i, j, k);
        ans %= MOD;
    }
    PUTS(ans);
}

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


int main(){
    double a,b,h,m;cin>>a>>b>>h>>m;
    double c,d;
    c=(h*30+m*0.5)*M_PI/180.0;
    d=m*6*M_PI/180.0;
    double nasu=min(abs(c-d),2*M_PI-abs(c-d));
    double anan=a*a+b*b-2*a*b*cos(nasu);
    anan=sqrt(anan);
    cout<<setprecision(12)<<anan<<endl;
}

    









Measured memory_bytes: 4260
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    string s,g;
    cin>>s>>g;
    int fi=s.find(g[0]);
    string k=s.substr(fi,s.size())+s.substr(0,fi);
    cout<<((g==k)?"Yes":"No");
  	return 0;
}

Measured memory_bytes: 3600
S=input()
list=[S[0],S[1],S[2]]
if list[0]!=list[1]:
    if list[1]!=list[2]:
        if list[2]!=list[0]:
            if S=="abc" or S=="acb":
                print("Yes")
            elif S=="bac" or S=="bca":
                print("Yes")
            elif S=="cab" or S=="cba":
                print("Yes")
            else:
                print("No")
            exit()
print("No")

Measured memory_bytes: 3064
#include <stdio.h>
#define TRUE 1
#define FALSE 0
typedef struct{
  char suit;
  char value;
} Card;

void bubble(Card*,int);
void selection(Card*,int);
int isStable(Card*,Card*,int);

Card C1[100],C2[100];

int main(){
  
  int n,i;
  char ch;
  char S[3];
  scanf("%d",&n);
  for(i=0;i<n;i++) {
    scanf("%s",S);
    C1[i].suit = S[0];
    C1[i].value = S[1];
  }
  for(i=0;i<n;i++) C2[i] = C1[i];

  bubble(C1,n);
  selection(C2,n);

  for(i=0;i<n-1;i++){
    S[0] = C1[i].suit;
    S[1] = C1[i].value;
    printf("%s ",S);
  }
  S[0] = C1[i].suit;
  S[1] = C1[i].value;
  printf("%s\n",S);
  printf("Stable\n");

  for(i=0;i<n-1;i++){
    S[0] = C2[i].suit;
    S[1] = C2[i].value;
    printf("%s ",S);
  }
  S[0] = C2[i].suit;
  S[1] = C2[i].value;
  printf("%s\n",S);
  if(isStable(C1,C2,n)) printf("Stable\n");
  else printf("Not stable\n");

  return 0;
}

void bubble(Card *C,int n){
  int i,j;
  Card tmp;
  for(i=0;i<n;i++){
    for(j=n-1;j>=i;j--){
      if(C[j].value < C[j-1].value){
	tmp = C[j];
	C[j] = C[j-1];
	C[j-1] = tmp;
      }
    }
  }
}

void selection(Card *C,int n){
  int i,j,minj;
  Card tmp;
  for(i=0;i<n;i++){
    minj = i;
    for(j=i;j<n;j++){
      if(C[j].value < C[minj].value) minj = j; 
    }
    tmp = C[i];
    C[i] = C[minj];
    C[minj] = tmp;
  }
}

int isStable(Card *C1,Card *C2,int n){
  int i;
  for(i=0;i<n;i++){
    if(C1[i].suit != C2[i].suit) return FALSE;
  }
  return TRUE;
}

Measured memory_bytes: 604
import sys

sys.setrecursionlimit(10000000)
from math import ceil


def grundy(a, k):
    if a < k:
        return 0
    d, m = divmod(a, k)
    if m == 0:
        return d
    d1 = d + 1
    if d > k:
        return grundy(a - d1, k)
    e = ceil(m / d1) * d1
    return grundy(a - e, k)


n = int(input())
nim = 0
for _ in range(n):
    a, k = map(int, input().split())
    nim ^= grundy(a, k)
print('Takahashi' if nim > 0 else 'Aoki')


Measured memory_bytes: 38260
#include <bits/stdc++.h>
using namespace std;
typedef long long in;
typedef pair<in,in> ii;
#define F first
#define S second
#define sqr(x) (x)*(x)
#define pb(x) push_back(x)
#define sz(x) (in)x.size()
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,x,y) for(in i=x;i<(y);++i)
#define per(i,x,y) for(in i=y;i>=(x);--i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

const in maxn = 200100;

in v[maxn];

int main()
{
	IOS;
	in n,agr = 1,ans = 0;
	cin >> n;
	rep(i,1,n+1) cin >> v[i];
	rep(i,1,n+1)
	{
		if(v[i] == agr)
		{
			agr++;
		}
		else ans++;
	}
	if (ans == n) cout << "-1\n";
	else cout << ans << "\n";
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
int main(){
    string s;
    cin >>s;
    s[5]=' ';s[13]=' ';
    cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<math.h>
#include <vector>
#include <numeric>

using namespace std;

int main() {

    int R;
    cin >> R;

    if (R < 1200) {
        cout << "ABC" << endl;

    } else if (R < 2800) {
        cout << "ARC" << endl;

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

Measured memory_bytes: 256
# https://beta.atcoder.jp/contests/abc054/tasks/abc054_b


def solve():
    n, m = map(int, input().split())
    img = []
    tmp = []

    for _ in range(n):
        img.append(list(map(str, input().split())))

    for _ in range(m):
        tmp.append(list(map(str, input().split())))

    # never matches found D:
    if n < m:
        print('No')

    loops = n - m + 1
    for loop in range(loops):
        for row in range(loops):
            match = True
            for col in range(m):
                # print('img: ', img[col+loop][0][row:row+m])
                # print('tmp: ', tmp[col][0])
                if img[col+loop][0][row:row+m] != tmp[col][0]:
                    match = False
            if match:
                print('Yes')
                return
    print('No')


if __name__ == '__main__':
    solve()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int n, m, a[100009],b[100009],p[100009],col[100009],cnts;
vector<int>x[100009],S[100009];
void dfs(int pos)
{
	if (col[pos]>=1) return;
	col[pos]=cnts;
	S[cnts].push_back(pos);
	for (int i=0;i<x[pos].size();i++) dfs(x[pos][i]);
}

int main()
{
	cin>>n>>m;
	for (int i=1;i<=n;i++) cin>>p[i];
	for (int i=1;i<=m;i++)
	{
		cin>>a[i]>>b[i];
		x[a[i]].push_back(b[i]);
		x[b[i]].push_back(a[i]);
	}
	for (int i=1;i<=n;i++)
	{
		if (col[i]==0)
		{
			cnts++;
			dfs(i);
		}
	}
	int cnt=0;
	for (int i=1;i<=n;i++)
	{
		if (col[i]==col[p[i]]) cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 12284
// Created by Tanuj Jain
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int INF = 0x3f3f3f3f;
int knight_moves[8][2]={{-2,-1},{-1,-2},{1,-2},{2,-1},{-2,1},{-1,2},{1,2},{2,1}};
int moves[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
int main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

	//#ifndef ONLINE_JUDGE
	//freopen("inputf.in","r",stdin);
	//freopen("outputf.in","w",stdout);
	//#endif

	int x,y;
	cin>>x>>y;
	int l=2*x;
	int h=4*x;
	if(y>=l && y<=h && y%2==0)
		cout<<"Yes";
	else
		cout<<"No";

	
}

Measured memory_bytes: 3644
#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; })

const ll N = 210, M = 1e5 + 10, MOD = 1e9 + 7;
ll n, a[N], dp[N][M];

ll rec(ll i, ll x) {
	if (i == n) return x;
	if (dp[i][x] != -1) return dp[i][x];

	dp[i][x] = (rec(i+1,x%a[i]) + (n-1-i)*rec(i+1,x)) % MOD;
	return dp[i][x];
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll x;
	cin >> n >> x;
	FOR(i,0,n) cin >> a[i];
	sort(a,a+n,greater<ll>());
	
	memset(dp,-1,sizeof dp);
	
	cout << rec(0,x) << endl;
}



Measured memory_bytes: 164352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const int SIZE = 100000;
int dp[3][SIZE];
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int n, k;cin>>n>>k;
   int r, s, p;cin>>r>>s>>p;
   string t;cin>>t;
   vector<bool> success;
   int ans = 0;
   for (int i=0; i<n; i++)
   {
      switch (t[i])
      {
      case 'r':
         if (i-k<0){
            ans+=p;
            success.push_back(true);
         }
         else if(t[i-k]!='r' || success[i-k]==false){
            ans+=p;
            success.push_back(true);
         }
         else success.push_back(false);
         break;
      case 's':
         if (i-k<0){
            ans+=r;
            success.push_back(true);
         }
         else if(t[i-k]!='s' || success[i-k]==false){
            ans+=r;
            success.push_back(true);
         }
         else success.push_back(false);
         break;
      case 'p':
         if (i-k<0){
            ans+=s;
            success.push_back(true);
         }
         else if(t[i-k]!='p' || success[i-k]==false){
            ans+=s;
            success.push_back(true);
         }
         else success.push_back(false);
         break;
      }
   }
   cout << ans << endl;
}

Measured memory_bytes: 3744
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <bitset>
# include <set>
# include <cmath>
# include <algorithm>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-8
# define MOD 1000000007
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FDR(i,a,n) for(int i=a; i>=n; --i)
# define bug puts("H");
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
inline int Scan() {
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}
inline void Out(int a) {
    if(a<0) {putchar('-'); a=-a;}
    if(a>=10) Out(a/10);
    putchar(a%10+'0');
}
const int N=200005;
//Code begin....

struct qnode{
   int l, r, vl, vr;
   qnode(int _l=0, int _r=0, int _vl=0, int _vr=0):l(_l),r(_r),vl(_vl),vr(_vr){}
   bool operator<(const qnode &m)const{return vl>m.vl;}
};
priority_queue<qnode>que;
struct Seg{int odd, even;}seg[N<<3];
int a[N], id[N];
VI ans;

void push_up(int p){
    seg[p].even=min(seg[p<<1].even, seg[p<<1|1].even);
    seg[p].odd=min(seg[p<<1].odd, seg[p<<1|1].odd);
}
void init(int p, int l, int r){
    if (l<r) {
        int mid=(l+r)>>1;
        init(lch); init(rch); push_up(p);
    }
    else {
        if (l&1) seg[p].even=a[l], seg[p].odd=INF;
        else seg[p].odd=a[l], seg[p].even=INF;
    }
}
int query(int p, int l, int r, int L, int R, int flag){
    if (L>r||R<l) return INF;
    if (L<=l&&R>=r) return flag?seg[p].even:seg[p].odd;
    else {
        int mid=(l+r)>>1;
        return min(query(lch,L,R,flag),query(rch,L,R,flag));
    }
}
int main ()
{
    int n, x, y, l, r, ll;
    qnode tmp;
    scanf("%d",&n);
    FOR(i,1,n) scanf("%d",a+i), id[a[i]]=i;
    init(1,1,n);
    x=query(1,1,n,1,n,1); l=id[x]; y=query(1,1,n,l+1,n,0);
    que.push(qnode(1,n,x,y));
    FOR(i,1,n/2) {
        tmp=que.top(); que.pop();
        ans.pb(tmp.vl); ans.pb(tmp.vr);
        l=id[tmp.vl]; r=id[tmp.vr];
        if (tmp.l<l-1) {
            x=query(1,1,n,tmp.l,l-1,tmp.l&1); ll=id[x]; y=query(1,1,n,ll+1,l-1,(l-1)&1);
            que.push(qnode(tmp.l,l-1,x,y));
        }
        if (l+1<r-1) {
            x=query(1,1,n,l+1,r-1,(l+1)&1); ll=id[x]; y=query(1,1,n,ll+1,r-1,(r-1)&1);
            que.push(qnode(l+1,r-1,x,y));
        }
        if (r+1<tmp.r) {
            x=query(1,1,n,r+1,tmp.r,(r+1)&1); ll=id[x]; y=query(1,1,n,ll+1,tmp.r,tmp.r&1);
            que.push(qnode(r+1,tmp.r,x,y));
        }
    }
    for (int i=0; i<ans.size(); ++i) printf(i==0?"%d":" %d",ans[i]);
    putchar('\n');
    return 0;
}


Measured memory_bytes: 9204