akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string S;
  cin >> N >> S;
  int W=0;
  for(int i=0;i<N;i++){if(S[i]=='W')W++;}
  int E=N-W;
  int w=0; int e=0; int m=400000;
  for(int i=0;i<N;i++){
    int q=E+w;
    if(S[i]=='E'){q--;}
    m=min(q,m);
    if(S[i]=='W'){w++;}
    else{E--;}
  }
  cout << m << endl;
}

Measured memory_bytes: 900
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    a, b, c = LI()
    if a + b >= c:
        print("Yes")
    else:
        print("No")
    return

#B
def B():
    n = II()
    s = SR(n)
    m = II()
    t = SR(m)
    ans = 0
    for si in s:
        ans = max(ans, s.count(si) - t.count(si))
    print(ans)
    return

#C
def C():
    n = II()
    ab = LIR(n)
    cd = LIR(n)
    ab.sort()
    cd.sort()
    check = [0 for i in range(n)]
    ans = 0
    for _, c in enumerate(cd):
        d = c[1]
        c = c[0]
        maxy = -1
        x = -1
        for k, a in enumerate(ab):
            b = a[1]
            a = a[0]
            if maxy < b and c > a and check[k] == 0 and d > b:
                maxy = b
                x = k
        if x != -1:
            ans += 1
            check[x] += 1
    print(ans)


    return

#D
def D():
    N = II()
    a = LI()
    b = LI()
    ans = 0
    t = 1
    for i in range(29):
        a2 = [A & ((t << 1) - 1) for A in a]
        b2 = [B & ((t << 1) - 1) for B in b]
        a2.sort(reverse=True)
        b2.sort()
        ansb, r1, r2, r3 = 0, 0, 0, 0
        for A in a2:
            while r1 < N and A + b2[r1] < t:
                r1 += 1
            while r2 < N and A + b2[r2] < 2*t:
                r2 += 1
            while r3 < N and A + b2[r3] < 3*t:
                r3 += 1
            ansb += r2 ^ r1 ^ N ^ r3
            ansb = ansb & 1
        ans += (ansb << i)
        t = t << 1
    print(ans)
    return

#Solve
if __name__ == '__main__':
    D()


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

using namespace std;

void perform();

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string number;//testcases
    cin>>number;
    int n=number.length();
    string ans="No";
    for(int i=0;i<n;i++){
		if(number[i]=='7'){
			ans = "Yes";
		}
	}
	cout << ans;
	return 0;
}



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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//-----------------------------------------------------------------------------

int n,a,b;

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

	while(true) {
		cin>>n;
		if(n==0) break;
		int A=0,B=0;
		REP(i,n) {
			cin>>a>>b;
			if(a>b) A+=a+b;
			else if(a<b) B+=a+b;
			else A+=a,B+=b;
		}
		cout<<A<<' '<<B<<endl;
	}

	return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
	int n, m;
	cin >> n >> m;
	priority_queue<int> pq;
	long long int res = 0;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		pq.push(t);
	}
	for (int i = 0; i < m; i++) {
		int t = pq.top();
		pq.pop();
		pq.push(t / 2);
	}
	while (pq.size() > 0) {
		int t = pq.top();
		res += t;
		pq.pop();
	}
	cout << res << endl;
}


Measured memory_bytes: 3904
#include <iostream>
#include<string>
#include<sstream>
#include<fstream>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<set>
#include<algorithm>
#include<iomanip>
typedef long long ll;
using namespace std;

int main()
{
    int A;
    cin>>A;
    cout<<A+pow(A,2) + pow(A,3)<<endl;
    return 0;
}



Measured memory_bytes: 4080
fun main(args: Array<String>) {
    val (H, W, N) = readLine()!!.split(" ").map { it.toInt() }
    val (sr, sc) = readLine()!!.split(" ").map { it.toInt() }
    val S = readLine()!!
    val T = readLine()!!

    fun f(l: Int, c: Char, d: Char, mx: Int): Boolean {
        var a = l
        for (i in S.indices) {
            if (S[i] == c) {
                a--
            }

            if (a <= 0) {
                return false
            }

            if (T[i] == d) {
                a = Math.min(a + 1, mx)
            }
        }
        return true
    }

    val res = f(H - sr + 1, 'D', 'U', H) && f(sr, 'U', 'D', H) &&
            f(sc, 'L', 'R', W) && f(W - sc + 1, 'R', 'L', W)

    println(if (res) "YES" else "NO")
}


Measured memory_bytes: 41444
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

string S;

int main(){
    cin>>S;

    if(S=="Sunny") cout<<"Cloudy"<<endl;
    if(S=="Cloudy") cout<<"Rainy"<<endl;
    if(S=="Rainy") cout<<"Sunny"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
 
template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr long long inf = 3e18;

int H,W,N;
int v[3005][3005];
int dp[3005][3005][4];
signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	cin>>H>>W>>N;
	rep(i,N){
		int a,b,c;cin>>a>>b>>c;a--;b--;
		v[a][b]=c;
	}
	rep(i,H)rep(j,W)rep(k,4){
		if(v[i][j]&&k<3){
			chmax(dp[i][j+1][k+1],dp[i][j][k]+v[i][j]);
			chmax(dp[i+1][j][0],dp[i][j][k]+v[i][j]);
		}
		chmax(dp[i][j+1][k],dp[i][j][k]);
		chmax(dp[i+1][j][0],dp[i][j][k]);
	}
	cout<<dp[H][W-1][0]<<endl;
}

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

int main(){
    using namespace std;
    using cmp = complex<unsigned long>;
    constexpr unsigned long MOD{1000000007};
    unsigned long S;
    cin >> S;
    const auto& mod_pow = [MOD](cmp a, unsigned long n, const cmp& b) -> cmp {
        a += MOD;
        cmp r{b + MOD};
        while(n){
            if(n & 1) { 
                r *= a;
                r.real(r.real() % MOD + MOD);
                r.imag(r.imag() % MOD);
            }
            a *= a;
            a.real(a.real() % MOD + MOD);
            a.imag(a.imag() % MOD);
            n >>= 1;
        }
        return r;
    };
    cout << (mod_pow(622947620, S, 451009450) + 2UL * mod_pow({188526194, 594405036}, S, {274495279, 16512442})).real() % MOD << endl;
    return 0;
}

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

int H, W;
int HW[1010][1010];
unsigned long long dp[1010][1010];

unsigned long long search()
{
    dp[0][0] = 1;
    for(int h = 0; h < H; h++)
    {
        for(int w = 0; w < W; w++)
        {
             if(HW[h][w] == 1) dp[h][w] = 0;
             else
             {
                if(h > 0) dp[h][w] += dp[h - 1][w] % 1000000007;
                if(w > 0) dp[h][w] += dp[h][w - 1] % 1000000007;
             }
        }
    }
    unsigned long long res = dp[H - 1][W - 1] % 1000000007;
    return res;
}

int main ()
{
    cin >> H >> W;
    for(int i = 0; i < H; i++)
    for(int j = 0; j < W; j++)
    {
        char c;
        cin >> c;
        if(c == '.') HW[i][j] = 0;
        else HW[i][j] = 1;
    }

    cout << search() << endl;
}

Measured memory_bytes: 12160
//https://atcoder.jp/contests/abc158/tasks/abc158_a
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s , a, b ;
    a = "AAA";
    b = "BBB";
    cin >> s ;
    if(s == a or s == b) cout << "No";
    else cout << "Yes";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double pi=3.14159265358979323846;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
int main(){
    char c;cin>>c;
    out(char(c+1));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=1000000000000LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<int,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
ll n;
ll al[30]={};
string str;
ll ans=1;
bool l=false;
int main() {
	cin>>n>>str;
	rep(i,0,n){
		al[str[i]-'a']++;
	}
	rep(i,0,30){
		ans*=al[i]+1;
		ans%=r197;
	}
	cout<<ans-1<<endl;
	return 0;
}


Measured memory_bytes: 512
while 1:
    n = int(input())
    if n == 0: break
    for i in range(n):
        pm, pe, pj = map(int, input().split())
        k = pm+pe+pj
        if pm == 100 or pe == 100 or pj == 100: print("A")
        elif pm + pe >= 90*2: print("A")
        elif k >= 80*3: print("A")
        elif k >= 70*3: print("B")
        elif k >= 50*3 and (pm >= 80 or pe >= 80): print("B")
        else: print("C")


Measured memory_bytes: 5608
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n, ans=0; cin >> n;
    vector<int> h(n+1);
    for(int i = 1; i <= n; i++){
        cin >> h[i];
        if(h[i] > h[i-1]) ans += h[i] - h[i-1];
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

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

ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    ll res = 1;
    rep (i, n) {
        ll t;
        cin >> t;
        res = lcm(res, t);
    }
    cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;

class Program
{
    static void Main(string[] args)
    {
        //入力を受け取る
        var HW = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        var H = HW[0];
        var W = HW[1];
      
        //Wを固定して探索
        var A = Search(H,W);
        var B = Search(W,H);
        Console.WriteLine(Math.Min(A,B));
    }
  
    static long Search(long H,long W){
      //Hの長さごとに最大値を求める
      var res = long.MaxValue;
      for(long i = 1; i < H ; i++){
        
        var rec1 = W*i;
        var rec2 = (H-i)*(W/2);
        var rec3 = (H-i)*(W/2);
        if(W%2 != 0){
          rec3 = (H-i)*(W/2+1);
        }
        var can1 = Math.Max(rec1,Math.Max(rec2,rec3))-Math.Min(rec1,Math.Min(rec2,rec3));
        
        var rec4 = ((H-i)/2)*W;
        var rec5 = ((H-i)/2)*W;
        if((H-i)%2 != 0){
          rec5 = ((H-i)/2+1)*W;
        }
        var can2 = Math.Max(rec1,Math.Max(rec4,rec5))-Math.Min(rec1,Math.Min(rec4,rec5));
        
        var can = Math.Min(can1,can2);
        if(res > can){
          res = can;
        }
      }
      return res;
    }
}


Measured memory_bytes: 13396
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    diff_AB = sum(A) - sum(B)

    if diff_AB < 0:
        print(-1)
        exit()

    Diff = []
    for i in range(n):
        Diff.append(A[i] - B[i])

    Diff.sort()

    res = 0
    for j in range(n):
        if Diff[j] < 0:
            res += 1
        else:
            if Diff[j] <= diff_AB:
                diff_AB -= Diff[j]
            else:
                diff_AB = 0
                res += 1

    if diff_AB > 0:
        res += 1

    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 19112
N = input()
a = map(int, raw_input().split())
a1, a2, a4 = [], [], []
for i in range(N):
    if a[i] % 4 == 0:
        a4.append(a[i])
    elif a[i] % 2 == 0:
        a2.append(a[i])
    else:
        a1.append(a[i])
if N % 2 == 0:
    if len(a1) <= len(a4):
        print "Yes"
    else:
        print "No"
else:
    if len(a1) <= len(a4):
        print "Yes"
    elif len(a1) == len(a4) + 1:
        print "Yes" if (len(a2) % 2 == 0) else "No"
    else:
        print "No"

Measured memory_bytes: 11320
a = {}
for i = 1, 9 do
  a[i] = io.read("*n")
end
n = io.read("*n")
t = {}
for i = 1, n do
  v = io.read("*n")
  t[v] = true
end
z = {
  {1, 2, 3},
  {4, 5, 6},
  {7, 8, 9},
  {1, 4, 7},
  {2, 5, 8},
  {3, 6, 9},
  {1, 5, 9},
  {3, 5, 7}
}
v = false
for i = 1, 8 do
  if t[a[z[i][1]]] and t[a[z[i][2]]] and t[a[z[i][3]]] then
    v = true
  end
end
print(v and "Yes" or "No")


Measured memory_bytes: 760
def select_next_player(cards):
	next_player = cards.pop(0)
	return next_player

Sa = list(str(input()))
Sb = list(str(input()))
Sc = list(str(input()))

expected_all_turn = len(Sa)+len(Sb)+len(Sc)

next = ""

for i in range(expected_all_turn):
	
	if i == 0 :
		next = select_next_player(Sa)
		continue
	
	if next == "a":
		if len(Sa) == 0:
			print("A")
			break
		next = select_next_player(Sa)
	elif next == "b":
		if len(Sb) == 0:
			print("B")
			break
		next = select_next_player(Sb)
	else:
		if len(Sc) == 0:
			print("C")
			break
		next = select_next_player(Sc)

Measured memory_bytes: 3064
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        int[] abcd = Console.ReadLine().Select(x => x - '0').ToArray();
        for (int i = 0; i < (1 << 3); i++)
        {
            string s = abcd[0].ToString();
            int res = abcd[0];
            for (int j = 0; j < 3; j++)
            {
                var op = (i >> j & 1);
                s += op == 1 ? '+' : '-';
                s += abcd[j + 1];
                res += (op == 1 ? 1 : -1) * abcd[j + 1];
            }
            if (res == 7)
            {
                Console.WriteLine($"{s}=7");
                return;
            }
        }
        throw new Exception();
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
const long double PI = (acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int ctoi(char c)
{
    switch (c)
    {
    case '0':
        return 0;
    case '1':
        return 1;
    case '2':
        return 2;
    case '3':
        return 3;
    case '4':
        return 4;
    case '5':
        return 5;
    case '6':
        return 6;
    case '7':
        return 7;
    case '8':
        return 8;
    case '9':
        return 9;
    default:
        return 0;
    }
}
int main()
{
    int w, h, n;
    cin >> w >> h >> n;
    int board[h + 1][w + 1];
    rep(i, h + 1)
    {
        rep(j, w + 1)
        {
            board[i][j] = 0;
        }
    }
    for (int i = 0; i < n; i++)
    {
        int x, y, a;
        cin >> x >> y >> a;
        if (a == 1)
        {
            for (int j = 1; j <= h; j++)
            {
                for (int k = 1; k <= x; k++)
                {
                    board[j][k] = 1;
                }
            }
        }
        else if (a == 2)
        {
            for (int j = 1; j <= h; j++)
            {
                for (int k = x + 1; k <= w; k++)
                {
                    board[j][k] = 1;
                }
            }
        }
        else if (a == 3)
        {
            for (int j = 1; j <= y; j++)
            {
                for (int k = 1; k <= w; k++)
                {
                    board[j][k] = 1;
                }
            }
        }
        else
        {
            for (int j = y + 1; j <= h; j++)
            {
                for (int k = 1; k <= w; k++)
                {
                    board[j][k] = 1;
                }
            }
        }
    }
    int ans = 0;
    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            if (board[i][j] == 0)
            {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

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

//for loop
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//abbreviati
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

//constant
const int INF = 1<<30;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

/***Snippet**************************************
ifelse, isprime, torad, todeg, lcm, bfs
************************************************/

//adjacency list
vector<int> to[100005];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;cin >> n;
    vector<ll> a(n);
    rep(i,0,n) cin >> a[i];
    ll cub=0;
    ll money=1000;

    rep(i,0,n-1){
        cub=0;
        if(a[i]<a[i+1]){
            cub=money/a[i];
            money-=cub*a[i];
        }
        if(i<n-1)money+=cub*a[i+1];

    }

    cout << money ENDL;
    
    return 0;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var A = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var B = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            var M1 = A[0];
            var D1 = A[1];
            var M2 = B[0];
            var D2 = B[1];

            if(D2 == 1)
            {
                Console.WriteLine(1);
            }
            else
            {
                Console.WriteLine(0);
            }

        }

    }

}


Measured memory_bytes: 11092
n = int(input())
C = list(input())
l, r, c = 0, n-1, 0
while l < r:
    if C[l] == 'W' and C[r] == 'R':
        C[l], C[r] = C[r], C[l]
        l += 1
        r -= 1
        c += 1
    elif C[l] != 'W': l += 1
    elif C[r] != 'R': r -= 1
print(c)


Measured memory_bytes: 10620
import math

N=int(input())

ANS=[0,1, 3, 2, 7, 4, 3, 6, 15, 8, 4, 10, 8, 12, 7, 5, 31, 16, 8, 18, 15, 6, 11, 22, 15, 24, 12, 26, 7, 28, 15, 30, 63, 11, 16, 14, 8, 36, 19, 12, 15, 40, 20, 42, 32, 9, 23, 46, 32, 48, 24, 17, 39, 52, 27, 10, 48, 18, 28, 58, 15, 60, 31, 27, 127, 25, 11, 66, 16, 23, 20, 70, 63, 72, 36, 24, 56, 21, 12, 78, 64, 80, 40, 82, 48, 34, 43, 29, 32, 88, 35, 13, 23, 30, 47, 19, 63, 96, 48, 44, 24]


if N==1:
    print(ANS[N])
    exit()


def ff(x):
    L=int(math.sqrt(x))

    FACT=dict()

    for i in range(2,L+2):
        while x%i==0:
            FACT[i]=FACT.get(i,0)+1
            x=x//i

    if x!=1:
        FACT[x]=FACT.get(x,0)+1

    return FACT

# 拡張ユークリッドの互除法.ax+by=gcd(a,b)となる(x,y)を一つ求め、(x,y)とgcd(x,y)を返す.
def Ext_Euc(a,b,axy=(1,0),bxy=(0,1)): # axy=a*1+b*0,bxy=a*0+b*1なので,a,bに対応する係数の初期値は(1,0),(0,1)
    # print(a,b,axy,bxy)
    q,r=divmod(a,b)

    if r==0:
        return bxy,b # a*bxy[0]+b*bxy[1]=b
   
    rxy=(axy[0]-bxy[0]*q,axy[1]-bxy[1]*q) # rに対応する係数を求める.
    return Ext_Euc(b,r,bxy,rxy)

FACT=ff(N*2)
LIST=[]
for f in FACT:
    LIST.append(f**FACT[f])
    
L=len(LIST)

LANS=1<<60

for i in range(1,(1<<L)-1):
    A=1
    B=1
    for j in range(L):
        if i & (1<<j)!=0:
            A*=LIST[j]
        else:
            B*=LIST[j]
    #print(A,B)
    #print(Ext_Euc(A,-B))
    x,_=Ext_Euc(A,-B)
    x,y=x[0],x[1]
    # ANS=x+B*k

    if x<0:
        x+=(1+abs(x)//B)*B
    #k=(B+x-1)//x
    #ANS=x+B*k
    #print(x,B,k,ANS)
    LANS=min(LANS,x*A)

print(LANS)
    


Measured memory_bytes: 72032
from collections import Counter
n = int(input())
a = list(map(int,input().split()))

c = Counter(a)
twice_num = c.most_common(1)[0][0]

left_cnt = 0
right_cnt = 0
state = 0
for i in a:
    if i == twice_num and state == 0:
        state = 1
        continue
    if i == twice_num and state == 1:
        state = 2
        continue

    if state == 0:
        left_cnt += 1
    if state == 2:
        right_cnt += 1


#modありのコンビネーション計算
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9 + 7
N = n+2 #必要な数
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


for i in range(1,n+2):
    print((cmb(n+1,i,mod) - cmb(left_cnt + right_cnt,i-1,mod))%mod)


Measured memory_bytes: 28252
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        if(a*b<=c){
            System.out.println(a*b);
        }else{
            System.out.println(c);
        }
    }
}

Measured memory_bytes: 21844
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main(){
  
    char x,y;
    cin>>x>>y;
    
    if(x>y){
        cout<<">"<<endl;
    }else if(x<y){
        cout<<"<"<<endl;
    }else{
        cout<<"="<<endl;
    }
    
    return 0;
}







Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)

struct pyr
{
    int x;
    int y;
    int h;
};
int main(void)
{
    int N;
    cin >> N;
    pyr *P;
    P = new pyr[N];
    for (int i = 0; i < N; i++)
    {
        cin >> P[i].x >> P[i].y >> P[i].h;

    }
  	pyr pi ={0,0,0};
  	for(int i=0;i<N;i++){
  		if(P[i].h>=1){
        	pi ={P[i].x, P[i].y, P[i].h};
          	break;
        }
    }
    sort(P, P + N, [](const pyr &a, const pyr &b) { return a.h < b.h; });
    //pyr tmp = {P[0].x, P[0].y, P[0].h};
    int H = P[0].h;
    int Cx = 0;
    int Cy = 0;
    for (int i = 0; i <= 100; i++)
    {
        for (int j = 0; j <= 100; j++)
        {
          lli tmpH = pi.h + abs(pi.x-i) + abs(pi.y-j);
          tmpH = max(tmpH,0LL);
          bool f = true;
            for (int k = 0; k < N; k++)
            {
                lli H = tmpH - abs(P[k].x - i) - abs(P[k].y - j);
              	H = max(H,0LL);
                if(P[k].h!=H){
                	f = false;
                }
            }
          	if(f==true){Cx=i;Cy=j;H=tmpH;}
        }
    }

    cout << Cx << " " << Cy << " " << H << endl;
    return 0;
}

Measured memory_bytes: 256
n=gets.to_i
a=[0]+gets.split.map(&:to_i)+[0]
s=a.map.with_index{ |_,i| a[i+1].nil? ? 0: (a[i]-a[i+1]).abs }.inject(:+)

1.upto(n){ |i|
  p s+(a[i-1]-a[i+1]).abs-(a[i-1]-a[i]).abs-(a[i]-a[i+1]).abs
}


Measured memory_bytes: 17924
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int N=0;
	int n;
	string S;
	cin>>S;
	for(char s : S){
		n=s-'0';
		N+=n;
	}
	if(N%9==0)cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 3720
// Problem : C - management
// Contest : AtCoder - AtCoder Beginner Contest 163
// URL : https://atcoder.jp/contests/abc163/tasks/abc163_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize("O3")  
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define pii pair<int,int>
#define S second
#define endl "\n"
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define mem(z,i) memset(z,i,sizeof(z))
#define eps 1e-7
#define I (int)
#define mod 1000000007
#define YES "YES"
#define NO "NO"
const long long INF = 1000000000000000000LL;
//const int WASTE=∞;
ll power(ll a,ll b){
	ll i=1;
	while(b){
		if(b%2)
			i=(i*a)%mod;
		b/=2;
		a=(a*a)%mod;
	}
	return i;
}
ll mulmod(ll a, ll b) { 
    ll res = 0;
    a = a % mod; 
    while (b > 0) {
        if (b % 2 == 1) 
            res = (res + a) % mod; 
        a = (a * 2) % mod; 
        b /= 2; 
    }
    return res % mod; 
} 
const int N=2e5+5;
signed main() {
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
  	// cout<<fixed;
  	// cout.precision(10);
   	
   	int n;
   	cin>>n;
   	int z[N]; mem(z,0);
   	int i;
   	for(int x=1;x<n;x++) cin>>i,z[i]++;
   	for(int x=1;x<=n;x++) cout<<z[x]<<endl;
   	
   	
   	
   	
   	
   	
   	
   	
   	
   	
  	return 0;
}



Measured memory_bytes: 4444
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int co=0;
  for(int i=1;i<=n;i++)
  {

      int p;
      cin>>p;
      if(i&1)
      {
          if(p&1)
            co++;
      }
  }
  cout<<co<<endl;
}

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

using namespace std;

struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }
    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};

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

    vector<int> fnum(N, 0);
    vector<vector<int>> block(N);
    UnionFind u(N);

    for (int i = 0; i < M; ++i) {
        int A, B;
        cin >> A >> B;
        --A;
        --B;
        ++fnum[A];
        ++fnum[B];
        u.unite(A, B);
    }
    for (int i = 0; i < K; ++i) {
        int C, D;
        cin >> C >> D;
        --C;
        --D;
        block[C].push_back(D);
        block[D].push_back(C);
    }

    for (int i = 0; i < N; ++i) {
        int ans = u.size(i) - 1 - fnum[i];
        for (auto& b : block[i]) {
            if (u.same(i, b)) {
                --ans;
            }
        }
        cout << ans << " ";
    }
    cout << endl;
}


Measured memory_bytes: 6784
var a,b,k,i:longint;

begin
readln(a,b,k);
if a+k-1>=b-k+1 then begin
    for i:= a to b do writeln(i);
end
else begin
    for i:= a to a+k-1 do writeln(i);
    for i:= b-k+1 to b do writeln(i);
end;
end.

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

int main(){
	int a,b;
	cin>>a>>b;
	if(a+b==3){
		cout<<3;
	}
	else if(a+b==4){
		cout<<2;
	}
	else cout<<1;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int a,b,c,x,i,j,k,sum;
  int ans=0;
  scanf("%d %d %d %d",&a,&b,&c,&x);
  for(i=0;i<=a;i++){
    for(j=0;j<=b;j++){
      for(k=0;k<=c;k++){
        sum= 500*i + 100*j + 50*k;
        if(sum==x) ++ans;
        }
      }
    }

  printf("%d",ans);
  return 0;
}

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

using namespace std;

typedef long long int ll;

int main () {
  ios_base::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);

  int n;
  cin >> n;
  multiset < int > s;
  vector < int > a (n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    s.insert (a[i]);
  }

  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    int num = a[i];
    vector < int > factors;
    for (int j = 1; j <= sqrt (num); j++) {
      if (num % j == 0) {
        factors.push_back (j);
        factors.push_back (num / j);
      }
    }

    bool ok = true;
    s.erase (s.lower_bound (num));
    for (auto j : factors) {
      if (s.count(j)) ok = false;
    }
    s.insert (num);
    if (ok) cnt++;
  }

  cout << cnt << '\n';
}


Measured memory_bytes: 13460
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <ctime>
#include <cmath>
#include <iomanip>
#include <queue>
#include <deque>
#include <fstream>
#include <bitset>
#include <cassert>
using namespace std;
 
#define int long long
#define double long double
#define mp make_pair
#define all(a) a.begin(), a.end()
#define pb push_back
#define debug(x) cerr << #x << ": " << x << '\n';
#define ppoint(p) cout << #p << ' ' << p.x << ' ' << p.y << '\n';
#define fi first
#define se second
#define FOR(i, n) for (int i = 0; i < n; ++i)
//typedef long long ll;
typedef pair<int, int> pii;
 
template<typename T1, typename T2> inline bool chkmin(T1 &x, T2 y) { return y < x ? (x = y, true) : false; };
template<typename T1, typename T2> inline bool chkmax(T1 &x, T2 y) { return y > x ? (x = y, true) : false; };
 
void fast() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
}

const int mod = 1e9 + 7;
const int N = 2e6 + 10;
int f[N], rf[N];

int mult(int a, int b) {
	return a * b % mod;
}

int c(int n, int k) {
	return mult(mult(f[n], rf[k]), rf[n - k]);
}

int binpow(int a, int b) {
	if (b == 0) return 1;
	if (b & 1) return mult(binpow(a, b - 1), a);
	return binpow(mult(a, a), b / 2);
}

int get(int a, int b) {
	int res = 0;
	for (int i = 1; i <= a + 1; i++) {
		res += c(i + b, i);
	}
	return res;
}

int md(int x) {
	x %= mod;
	x += mod;
	x %= mod;
	return x;
}

signed main() {
	fast();
	f[0] = 1;
	for (int i = 1; i < N; i++) f[i] = mult(i, f[i - 1]);
	rf[N - 1] = binpow(f[N - 1], mod - 2);
	for (int i = N - 2; i >= 0; i--) rf[i] = mult(i + 1, rf[i + 1]);
	for (int i = N - 10; i <= N - 1; i++) {
	//	debug(mult(f[i], rf[i]))
	}
	int r1, r2, c1, c2;
	cin >> r1 >> c1 >> r2 >> c2;
	cout << md(get(r2, c2) - get(r1 - 1, c2) - get(r2, c1 - 1) + get(r1 - 1, c1 - 1)) << '\n';
	return 0;
}

Measured memory_bytes: 31488
# coding: utf-8

import math

length = int(input())
total = 0
str = input()
table = list(str)
for i in range(length - 2):
    if table[i] == "A":
        if table[i+1] == "B":
            if table[i+2] == "C":
                total += 1

print(total)

Measured memory_bytes: 9072
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    int n,c,k;cin>>n>>c>>k;
    int tmp=0,lim=0,res=0;
    vector<int> T(n);
    rep(i,n) cin>>T[i];
    sort(T.begin(),T.end());
    lim=T[0];
    rep(i,n){
        int t=T[i];
        if(t>lim+k){
            lim=t;
            tmp=1;
            res++;
        }else if(tmp==c){
            lim=t;
            tmp=1;
            res++;
        }else{
            tmp++;
        }
    }
    if(tmp>0)res++;
    cout<<res<<endl;
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10**6)
n, q = map(int, input().split())
G = [[] for i in range(n)]
for i in range(n-1):
    a, b = map(lambda x: x-1, map(int, input().split()))
    G[a].append(b)
    G[b].append(a)

ans = [0]*n
for i in range(q):
    p, x = map(int, input().split())
    ans[p-1] += x

def dfs(v, pre=-1):  
    for nx in G[v]:
        if nx==pre:
            continue
        ans[nx] += ans[v]
        dfs(nx,v)
dfs(0)
print(*ans)

Measured memory_bytes: 282912
n, m = map(int, input().split())
if n== 1 and m == 1 :
    print(1)
elif n==2 or m ==2:
    print(0)
elif m == 1:
    print(n-2)
elif n == 1:
    print(m-2)
else:
    print((n-2)*(m-2))

Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <string>
#include <numeric>
#include <algorithm>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <complex>
#include <ctime>
#define ll long long
#define inf 0x3f3f3f3f
#define N 200010
using namespace std;
char s[N];

int main(){
	int n;
	scanf("%d",&n);
	getchar();
	scanf("%s",s+1);
	int len=strlen(s+1);
	int sum1=0,num10=0,flag=0,num0=0;
	for(int i=1;i<=len;i++)
    {
        if(s[i]=='W')
        {
            sum1++;
            flag=1;
        }
        else if(flag)
            num10++;
    }
    for(int i=len-sum1+1;i<=len;i++)
    {
        if(s[i]=='R')
            num0++;
    }
    int ans=min(num10,num0);
    printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3960
#include<iostream>
using namespace std;
int main(){
	int N,M,a,count=0;
	cin >> N >> M ;
	for(int i=0;i<M;i++){
		cin >> a;
	}
	while(1){
		N = N/2;
		count = count + N;
		if(N==1)	break;
	}
	cout << count-M << "\n";
	return 0;
}

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

int main() {
  int N;
  cin>>N;
  vector<string> S(N);
  int count =0;
  for(int i=0; i<N;i++){
    cin>>S.at(i);
  }
  sort(S.begin(), S.end());
  for(int i=0; i<N-1; i++){
    if(S.at(i)==S.at(i+1)) count++;
  }

   
  cout<<N-count;
}
        
    
  


    


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

using namespace std;

int main(){
    char s[3];
    int counter =0;
    cin>>s[0]>>s[1]>>s[2];
    if(s[0]=='1'){
        counter++;
    }
    if(s[1]=='1'){
        counter++;
    }
    if(s[2]=='1'){
        counter++;
    }

    cout<<counter<<endl;
}

Measured memory_bytes: 256
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
  return list(map(int,input().split()))
def m(): #複数文字
  return map(int,input().split())
def onem(): #Nとかの取得
  return int(input())
def s(x): #圧縮
  a = []
  if len(x) == 0:
    return []
  aa = x[0]
  su = 1
  for i in range(len(x)-1):
    if aa != x[i+1]:
      a.append([aa,su])
      aa = x[i+1]
      su = 1
    else:
      su += 1
  a.append([aa,su])
  return a
def jo(x): #listをスペースごとに分ける
  return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
  return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
  ll = 0
  rr = r
  while True:
    mid = (ll+rr)//2

  if rr == mid:
    return ll
  if (ここに評価入れる):
    rr = mid
  else:
    ll = mid+1
"""
n = onem()
su = 0
for i in range(1,n+1):
  if i % 3 != 0 and i % 5 != 0:
    su += i
print(su)






Measured memory_bytes: 67836
a=''
for _ in[0]*int(input()):
 X,z=input(),[]
 for y in input():
  s=i=0
  for k in z:
   t=X.find(y,s)+1
   if t<1:break
   if t<k:z[i]=t
   s=k;i+=1
  else:
   t=X.find(y,s)+1
   if t:z+=[t]
 a+=f'\n{len(z)}'
print(a[1:])


Measured memory_bytes: 5628
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<cmath>
#include<cstdio>
#include<set>
#include<map>
#include<iomanip>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++) 
#define lint long long
#define all(x) (x).begin(), (x).end()


int main(){
    int n; cin>>n;
    vector<int> p; int sum = 0;
    rep(i, n){int q; cin>>q; p.push_back(q); sum+=q;}
    sort(all(p)); sum-=p[n-1]/2; cout<<sum<<endl;
}

Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
#define fori(n) for ( int i = 0; i < (n);i++)
#define forj(n) for ( int j = 0; j < (n);j++)
#define fork(n) for ( int k = 0; k < (n);k++)
#define forghj(n) for ( int ghj = 0; ghj < (n);ghj++)
#define fori1(n) for ( int i = (n)-1; i >= 0;i--)
#define all(vector) (vector).begin(),(vector).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
/*
                            |~~~~~~~|
                            |       |
                            |       |
                            |       |
                            |       |
                            |       |
 |~.\\\_\~~~~~~~~~~~~~~xx~~~         ~~~~~~~~~~~~~~~~~~~~~/_//;~|
 |  \  o \_         ,XXXXX),                         _..-~ o /  |
 |    ~~\  ~-.     XXXXX`)))),                 _.--~~   .-~~~   |
  ~~~~~~~`\   ~\~~~XXX' _/ ';))     |~~~~~~..-~     _.-~ ~~~~~~~
           `\   ~~--`_\~\, ;;;\)__.---.~~~      _.-~
             ~-.       `:;;/;; \          _..-~~
                ~-._      `''        /-~-~
                    `\              /  /
                      |         ,   | |
                       |  '        /  |
                        \/;          |
                         ;;          |
                         `;   .       |
                         |~~~-----.....|
                        | \             \
                       | /\~~--...__    |
                       (|  `\       __-\|
                       ||    \_   /~    |
                       |)     \~-'      |
                        |      | \      '
                        |      |  \    :
                         \     |  |    |
                          |    )  (    )
                           \  /;  /\  |
                           |    |/   |
                           |    |   |
                            \  .'  ||
                            |  |  | |
                            (  | |  |
                            |   \ \ |
                            || o `.)|
                            |`\\\\) |
                            |       |
                            |       |
                            |       |
*/


int main() {
    ios::sync_with_stdio(false);
    int n,m;
    vector < vector < int > > a;
    cin >> n >> m;
    a.resize(n);
    fori(n) {
        a[i].resize(m);
        char c;
        forj(m) {
            cin >> c;
            if (c == '.') a[i][j] = 0;
            else a[i][j] = 1;
        }
    }
    fori(n) {
        forj(m) {
            if (a[i][j] == 0) continue;
            int kol = 0;
            if (i!=0) kol += a[i-1][j];
            if (i!=n-1) kol += a[i+1][j];
            if (j!=0) kol += a[i][j-1];
            if (j!=m-1) kol += a[i][j+1];
            if (kol == 0) {
                cout << "No\n";
                return 0;
            }
        }
    }
    cout << "Yes\n";
    return 0;
}














Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n, m, d;
int main(){
	scanf("%d%d%d", &n, &m, &d);
	string s = "RYGB";
	for(int i = 1; i <= n; i ++){
		for(int j = 1; j <= m; j ++){
			int x = (i + j + 10000) / d, y = (i - j + 10000) / d;
			x &=1, y &= 1;
			printf("%c", s[x * 2 + y]);
		}printf("\n");
	}
		
	
	
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int prm[300100];
int main () {
	long long a;
	for(int i=6;i<300100;i++)prm[i]=1;
	for(int i=6;i<300100;i++) {
		if(prm[i]==1&&(i%7==1||i%7==6)) {
			for(int j=1;i*(j*7-1)<300100;j++){
				prm[i*(j*7-1)]=0;
				if(i*(j*7+1)<300100)prm[i*(j*7+1)]=0;
			}
		}else{
			prm[i]=0;
		}
	}
	while(cin>>a&&a!=1){
		int n=a;
		printf("%d:",n);
		vector<int> v;
		int i=2;
		while(i<=a) {
			if(a%i==0&&prm[i]==1){
				cout<<" "<<i;
			}
			i++;
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 2364
N, M = map(int, input().split())
LR = [[int(x) for x in input().split()] for _ in range(M)]

left = 1
right = 10**5

for l, r in LR:
    left = max(left, l)
    right = min(right, r)
ans = right - left + 1
if ans<0:
    print(0)
else:
    print(ans)

Measured memory_bytes: 23204
n, m = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(m)]

l_max = 0
r_min = n
for l, r in lst:
    l_max = max(l_max, l)
    r_min = min(r_min, r)
print(max(r_min-l_max+1, 0))

Measured memory_bytes: 27332
X = int(input())
ans = 0
def prime(x):
  ret = True
  for j in range(2,int(x**(1/2)+1)):
    if i%j==0:
      ret = False
      break
  return ret

for i in range(X,(10**5)+100):
  if prime(i):
    ans = i
    break
    
print(ans)

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

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

int main() {
	int N;
	cin >> N;
	vector<int>A(N), L(N), R(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	L[0] = A[0];
	R[N - 1] = A[N - 1];
	for (int i = 1; i < N; i++) {
		L[i] = gcd(L[i - 1], A[i]);
		R[N - i - 1] = gcd(R[N - i], A[N - i - 1]);
	}

	int ans = 0;
	for (int i = 0; i < N; i++) {
		int GCD;
		if (i == 0) GCD = R[1];
		else if (i == N - 1) GCD = L[N - 2];
		else GCD = gcd(L[i - 1], R[i + 1]);
		ans = max(GCD, ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1408
program main
  
  implicit none
  integer :: k, a, b,i,n 
  
  read(*,*) k 
  read(*,*) a, b
  
  n = 0
  do i = a, b
    if( mod(i,k) == 0 ) n = n + 1
  end do
   
  if( n > 0 ) then
    print*, "OK"
  else
    print*, "NG"
  end if

end program main


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

template <typename CLASS1, typename CLASS2>
bool operator==(const HOGE<CLASS1, CLASS2> &hoge1, const HOGE<CLASS1, CLASS2> &hoge2){
  return hoge1.value == hoge2.value;
};

template <typename CLASS1, typename CLASS2>
bool operator<(const HOGE<CLASS1, CLASS2> &hoge1, const HOGE<CLASS1, CLASS2> &hoge2){
  return hoge1.value < hoge2.value;
};

template <typename CLASS1, typename CLASS2>
bool operator>(const HOGE<CLASS1, CLASS2> &hoge1, const HOGE<CLASS1, CLASS2> &hoge2){
  return hoge1.value > hoge2.value;
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N,M;
  IN(N,M);
  vll dp(N+2, 0);
  REP(i,M){
    ll L, R;
    IN(L,R);
    dp[L]+=1;
    dp[R+1]-=1;
  }

  REP(i,N+1){
    dp[i+1] += dp[i];
  }

  ll ans = 0;
  REP(i,N+2){
    if(dp[i]==M) ans++;
  }

  OUT(ans);


  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main()
{
    int h, w;
    scanf("%d%d", &h, &w);
    char a[100][101];
    int x[100] = {};
    int y[100] = {};
    int i, j, k, l;

    for (i=0; i<h; i++)
    {
        scanf("%s", a[i]);
    }

    for (i=0; i<h; i++)
    {
        for (j=0; j<w; j++)
        {
            if (a[i][j] == '#') y[i] = 1;
        }
    }

    for (i=0; i<w; i++)
    {
        for (j=0; j<h; j++)
        {
            if (a[j][i] == '#') x[i] = 1;
        }
    }

    for (i=0; i<h; i++)
    {
        for (j=0; j<w; j++)
        {
            if (x[j] && y[i])
            printf("%c", a[i][j]);
        }
        if (y[i]) printf("\n");
    }

    return 0;
}


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

#define all(x) x.begin(),x.end()
int main(){
	int n;	cin>>n;
	vector<int> A(n),dp(n,0);	for(int i=0;i<n;i++)	cin>>A[i];
	dp[n-1] = 0;
	for(int i=n-2;i>=0;i--){
		if(A[i] >= A[i+1])	dp[i] = dp[i+1]+1;
		else dp[i] = 0;
	}
	cout<<*max_element(all(dp))<<endl;
}


Measured memory_bytes: 1024
var
    a,b,p:longint;
    s:string;
    minus:boolean;
begin
    readln(s);
    p:=pos('+',s);
    if p=0 then begin p:=pos('-',s); minus:=true; end;
    val(copy(s,1,p-2),a);
    val(copy(s,p+2,length(s)-p-1),b);
    if minus then writeln(a-b) else writeln(a+b);
end.

Measured memory_bytes: 128