akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

// using lnt = long long;
#define lnt long long
using Real = long double;

#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)

#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)

constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;

template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

// using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
#define plnt pair<long long, long long>
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

lnt powmod(lnt a, lnt p, lnt m){
	lnt res = 1, tmp = a;
	while(p != 0){
		if(p % 2) res = (res*tmp) % m;
		tmp = (tmp*tmp) % m;
		p /= 2;
	}
	return res;
}

int main(){
	summon_tourist;

	lnt N; cin >> N;

	lnt c00 = 0, c01 = 0, c10 = 0;
	vector<plnt> X;
	map<plnt, lnt> mp;

	REP(i, N){
		lnt a, b; cin >> a >> b;
		if(a==0 and b==0) c00++;
		else if(a==0) c01++;
		else if(b==0) c10++;
		else X.pb(make_pair(a, b));
	}

	for(plnt &p: X){
		lnt a = p.first, b = p.second;
		lnt g = GCD(abs(a), abs(b));
		a /= g; b /= g;
		if(a < 0){
			a*=-1; b*=-1;
		}
		mp[make_pair(a, b)]++;
		if(b < 0){
			lnt ta = -b, tb = a;
			a = ta; b = tb;
		}
		p = make_pair(a, b);
	}
	sort(ALL(X));
	X.erase(unique(ALL(X)), X.end());
	lnt ans = (powmod(2, c01, MOD) + powmod(2, c10, MOD) - 1 + MOD) % MOD;
	for(plnt p: X){
		lnt a = p.first, b = p.second;
		cerr << a << ' ' << b << ln;
		lnt A = b, B = -a;
		lnt c0 = mp[p], c1 = mp[make_pair(A, B)];
		ans = ans * ((powmod(2, c0, MOD) + powmod(2, c1, MOD) - 1 + MOD) % MOD) % MOD;
	}
	
	cout << (ans-1+c00+MOD) % MOD << ln;
}

Measured memory_bytes: 35884
#include<iostream>
#include<vector>
#include<queue>
#include<cstdlib>

using namespace std;

bool isNum(char c){
	int N[] = {'2','3','4','5','6','7','8','9'};
	for (int i = 0; i < 8; i++){
		if (c == N[i]) return true;
	}
	return false;
}

int MCXItoi(string str){
		int ans = 0;
		int tmp1 = 1;
		bool flag = false;
		for (int i = 0; i < str.size(); i++){
			if (flag) tmp1 = 1;

			if (isNum(str[i])){
				tmp1 *= (int)str[i] - 48;
				flag = false;
			}else{
				if (str[i] == 'm'){
					tmp1 *= 1000;
				}else if (str[i] == 'c'){
					tmp1 *= 100;
				}else if (str[i] == 'x'){
					tmp1 *= 10;
				}else if (str[i] == 'i'){
					tmp1 *= 1;
				}
				ans += tmp1;
				flag = true;
			}	
		}
	return ans;		
}
int main(){
	int n; cin >> n;
	for (int i = 0; i < n; i++){
		int  ans = 0;
		string str[2]; cin >> str[0] >> str[1];
		for (int s = 0; s < 2; s++){
			 ans += MCXItoi(str[s]);	
		}
		int keta = 1000;
		char C[] = {'m','c','x','i'};
		for (int i = 0; i < 4; i++){
			if (ans / keta != 0){
				if ((ans % (keta * 10)) / keta == 1){
				cout << C[i];
				}else if ((ans % (keta * 10)) / keta){
				cout << (ans % (keta * 10)) / keta;
				cout << C[i];
				}
			}
			keta /= 10;
		}
		cout << endl;
	}
return 0;
}

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

// 出力
void print() { std::cout << '\n'; }
template <class T>void print(const T &x) {std::cout << x <<'\n';}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}

void solve(std::string S){
    map<string, int> week;
    week.insert(make_pair("MON", 0));
    week.insert(make_pair("TUE", 1));
    week.insert(make_pair("WED", 2));
    week.insert(make_pair("THU", 3));
    week.insert(make_pair("FRI", 4));
    week.insert(make_pair("SAT", 5));
    week.insert(make_pair("SUN", -1));
    print(6 - week[S]);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

int main(){
    char moji1[4],moji2[4];
    scanf("%s",moji1);
    scanf("%s",moji2);
    char tmp=moji2[0];
    moji2[0]=moji2[2];
    moji2[2]=tmp;
    if(strcmp(moji1,moji2)==0){
        printf("YES");
    }else{
        printf("NO");
    }
    return 0;
}

Measured memory_bytes: 128
///http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_2_A
#include <bits/stdc++.h>
using namespace std;

int main(){

    int a, b;

    cin >> a >> b;

    if(a>b) cout << "a > b" << endl;
    else if(a<b) cout << "a < b" << endl;
    else  cout << "a == b" << endl;
    return 0;
}



Measured memory_bytes: 3080
import java.util.*;
public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();

    if (C <= A + B) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }
}

Measured memory_bytes: 21332
#include<stdio.h>
#include<math.h>

int main(){
    
	long int X;
	scanf("%ld",&X);

	long int ans = 100;
	long int  count =0;
	while(ans<X){
	count += 1;
	ans = ans *1.01;
}

printf("%ld",count);

return 0;

}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define modulo 1000000007
#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
using namespace std;
int main(){
	fast_io;
	ll n,ans=1;
	string s;
	cin>>n>>s;
	for (int i = 1; i < n; ++i){
		if(s[i]!=s[i-1])
			ans++;
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(n+1);
	rep(i,n) cin >> a.at(i+1);
	int ans=0;
	for(int i=1;i<=n;++i){
		if(i==a.at(a.at(i))) ans++;
	}
	cout << ans/2 << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
using ll = long long;
constexpr ll LINF = 1LL << 60;

int V, E, r;
vector<vector<pair<int, int>>> graph;
vector<ll> dist;

void dijkstra(int s) {
    dist.assign(V, LINF);
    dist[s] = 0;
    priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq;
    pq.emplace(0, s);
    int cnt_visited = 0;

    while (!pq.empty()) {
        auto v = pq.top(); pq.pop();
        if (v.first > dist[v.second]) continue;
        else if (++cnt_visited == V) break;

        for (auto& u : graph[v.second]) {
            if (v.first + u.first < dist[u.second]) {
                dist[u.second] = v.first + u.first;
                pq.emplace(v.first + u.first, u.second);
            }
        }
    }
}

int main() {
    cin >> V >> E >> r;
    graph.resize(V);
    for (int i = 0; i < E; ++i) {
        int s, t, d;
        cin >> s >> t >> d;
        graph[s].emplace_back(d, t);
    }

    dijkstra(r);

    for (ll d : dist) {
        if (d == LINF) cout << "INF" << endl;
        else cout << d << endl;
    }
}


Measured memory_bytes: 14436
#include <bits/stdc++.h>
using namespace std;
vector<int> edge[100000];
int d[2][100000];

void dfs(int idx, int n, int p, int dis) {
  d[idx][n] = dis;
  for (auto &e: edge[n]) {
    if (e == p)
      continue;
    dfs(idx, e, n, dis+1);
  }
  return ;
}

int main() {
  int N, a, b;
  cin >> N;
  for (int i=0; i<N-1; i++) {
    cin >> a >> b;
    a--;
    b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  dfs(0, 0, -1, 0);
  dfs(1, N-1, -1, 0);
  int cnt = 0;
  for (int i=0; i<N; i++) {
    if (d[0][i] > d[1][i])
      continue;
    cnt++;
  }
  if (N - 2*cnt < 0)
    cout << "Fennec\n";
  else
    cout << "Snuke\n";
  return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using llong = long long;
using P = pair<int, int>;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

int main() {
   int n;
   cin >> n;
   vector<int> a(n);
   rep(i, n) cin >> a[i];
   reverse(a.begin(), a.end());
   rep(i, n) { printf("%d%c", a[i], i == n - 1 ? '\n' : ' '); }
   return 0;
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+5;
int a[maxn];
int nex[maxn],head[maxn],to[maxn];
int e=1;
inline void add(int x,int y){
	nex[++e]=head[x];
	head[x]=e;
	to[e]=y;
}
void dfs(int x,int fa){
	for(int i=head[x];i;i=nex[i]){
		int u=to[i];
		if(u==fa)continue;
		a[u]+=a[x];
		dfs(u,x);
	}
}
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y);
		add(y,x);
	}
	for(int i=1;i<=m;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		a[x]+=y;
	}
	dfs(1,0);
	for(int i=1;i<=n;i++)printf("%d ",a[i]);
	return 0;
}

Measured memory_bytes: 25600
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <functional>
#include "math.h"
#include <set>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MB 1000000007
#define NB 1000000000

char N,M;
vector<double> A;
int a[70];
int main()
{

	cin >> N >> M;
	string s;
	if(N > M){
		REP(i,N-'0'){
			s += (char)M;
		}
	} else{
		REP(i,M - '0'){
			s += (char)N;
		}
	}
	cout << s;
//	cout << fixed << setprecision(0) <<  N > M ? "No" : "Yes";


}







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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto& e : a) {
    cin >> e;
  }
  vector<int> r;
  while (!a.empty()) {
    bool b = true;
    for (int i = a.size() - 1; i >= 0; i--) {
      if (a[i] == i + 1) {
        a.erase(begin(a) + i);
        r.push_back(i + 1);
        b = false;
        break;
      }
    }
    if (b) break;
  }
  if (r.size() == n) {
    reverse(begin(r), end(r));
    for (auto e : r) {
      cout << e << endl;
    }
  } else {
    cout << -1 << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
vector<int> d;
int n, k, cnt = -1;
long long dp[12911], ans;
map<int, int> id;

inline long long fpow(int a, int b){
	long long ret = 1, tmp = a;
	while(b){
		if(b & 1) ret = ret * tmp % mod;
		tmp = tmp * tmp % mod; b >>= 1;
	}
	return ret;
}

int main()
{
	scanf("%d%d", &n, &k); int sq = sqrt(n);
	if(n == 1){printf("%d", k); return 0;}
	for(int i = 1; i <= sq; ++i) 
		if(n % i == 0){d.push_back(i); id[i] = ++cnt;}
	for(int i = d.size() - 1; i >= 0; --i) 
		if(n / d[i] > sq){d.push_back(n / d[i]); id[n / d[i]] = ++cnt;}
	int llppdd = d.size() - 1;
	for(int i = 0; i <= llppdd; ++i){
		int now = d[i];
		if((n / now) & 1) 
		dp[i] = fpow(k, (now + 1) / 2);
		else 
		dp[i] = fpow(k, now);
		sq = sqrt(now);
		for(int j = 1; j <= sq; ++j){
			if(now % j != 0 || j == now) continue;
			dp[i] = (dp[i] - dp[id[j]] + mod) % mod;
			if(now / j > sq && j != 1) dp[i] = (dp[i] - dp[id[now / j]] + mod) % mod;
		}
		ans = (ans + dp[i] * now) % mod;
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 384
import sys
input = sys.stdin.readline
from collections import defaultdict
N, = map(int, input().split())
d = defaultdict(int)
for _ in range(N):
    s = input().strip()
    d[s] += 1
mx = 0
for k in d:
    mx = max(d[k], mx)
rs = set()
for k in d:
    if d[k] == mx:
        rs.add(k)
rs = list(rs)
rs.sort()
for r in rs:
    print(r)




Measured memory_bytes: 95576
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 1000000000
#define MOD 1000000007
#define ll long long int
using namespace std;

//ユークリッドの互除法
ll gcd(ll a,ll b)
{
	if (a%b==0)
	{
		return(b);
    }
	else
	{
		return(gcd(b,a%b));
    }
}

int main(){
  ll N; cin>>N;
  vector <ll> T;T.resize(N);
  for(int i=0;i<N;i++) cin>>T[i];
  sort(T.begin(),T.end());
  reverse(T.begin(),T.end());

  for(int i=1;i<N;i++){
    ll pre = (T[i-1] / gcd(T[i],T[i-1])) *T[i];
    T[i] = pre;
  }

  cout<<T[N-1]<<endl;
  return 0;
  
}

Measured memory_bytes: 256
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n = ni()
    table = [na() for _ in range(n)]

    dp = [0 for _ in range(2 ** n)]
    dp[2 ** n - 1] = 1

    for i in range(2 ** n - 1, 0, -1):
        j = n - format(i, "b").count("1")
        for j, val in enumerate(table[j]):
            if val:
                if i & 1 << j:
                    tmp = i ^ 1 << j
                    dp[tmp] += dp[i]
                    dp[tmp] %= MOD

    print(dp[0])


if __name__ == '__main__':
    main()


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

int main()
{
	int a = 0, b = 0, c = 0;
	cin >> a >> b >> c;
	if (a >= b&&b >= c)
		cout << c << " " << b << " " << a << endl;
	else if (b >= a&& a >= c)
		cout << c << " " << a << " " << b << endl;
	else if (c >= b&& b >= a)
		cout << a << " " << b << " " << c << endl;
	else if (a >= c&&c >= b)
		cout << b << " " << c << " " << a << endl;
	else if (b >= c&&c >= a)
		cout << a << " " << c << " " << b << endl;
	else
		cout << c << " " << b << " " << a << endl;
		
		

	return 0;
}


Measured memory_bytes: 3032
#include<iostream>
#include<array>
#include<stdlib.h>

using namespace std;

int main(){

    int N, M;
    cin >> N >> M;
    int A[M];
    int SUM = 0;
    int i = 0;
    
    while(i != M){
        cin >> A[i];
        SUM += A[i]; 
        i++;
    }

    if(N >= SUM) cout << N - SUM << endl;
    else cout << -1 << endl;
    
    return 0;
}

Measured memory_bytes: 3676
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int32_t main(){
    IOS;
    int n;
    cin >> n;
    int arr[n];
    for(int &x : arr) cin >> x;
    sort(arr,arr+n);
    int ans = 0;
    for(int i = 0; i<n; i++){
        for(int j=i+1; j<n; j++){
            int sum = 0;
            if(arr[i] != arr[j]) sum = arr[i] + arr[j];
            else continue;
            for(int k = j+1; k<n; k++){
                if(arr[j] == arr[k]) continue;
                else{
                    if(arr[k] < sum) ans++;
                }
            }
        }
    }
    cout << ans << endl;

    return 0;    
}



Measured memory_bytes: 3656
#include <bits/stdc++.h>
 
using namespace std;
 
template< class t>
long long int gcd( t g,t h )
{
    return ( h==0 ? g : gcd(h,g%h) );
}
 
 
struct Comp {
  bool operator()(const std::pair<int, int> &a, const std::pair<int, int> &b) {
    if (a.first != b.first) {
      return a.first < b.first;
    }
    return a.second > b.second;
  }
 
}comp_functor;

 
int main() 
{
    ios_base::sync_with_stdio(false) ; cin.tie(0) ;
    
    long long int i,j,t,n,l,c=0,q,ans=0,a[200005]={0},f=0,x,temp,h[200005]={0};
    
    string s;
    
   // cin>>n;
    
    for(i=0;i<3;i++)
    {
        cin>>a[i];
    }
    
    sort(a,a+3);
    
    ans+=abs(a[2]-a[1]);
    ans+=abs(a[1]-a[0]);
    
    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std ;
int main ()
{
char s1[10],s2[10],s3[10];
char a1,a2,a3;
scanf("%s %s %s",&s1,&s2,&s3);
a1=s1[0];
a2=s2[0];
a3=s3[0];
//for(int i=0;i<3;i++)
printf("%c%c%c",a1-32,a2-32,a3-32);


}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <string>

using namespace std;

int main() {
  int64_t N, K, R, S, P;
  string T;
  cin >> N >> K >> R >> S >> P >> T;
  reverse(T.begin(), T.end());
  int64_t point = 0;
  for (int64_t k = 0; k < K; ++k) {
    int64_t idx = k;
    char pre = '-';
    while (idx < N) {
      if (T[idx] == 'r' && pre != 'r') {
        point += P;
        pre = T[idx];
      } else if (T[idx] == 's' && pre != 's') {
        point += R;
        pre = T[idx];
      } else if (T[idx] == 'p' && pre != 'p') {
        point += S;
        pre = T[idx];
      } else {
        pre = '-';
      }
      idx += K;
    }
  }
  cout << point << endl;
  
  return 0;
}


Measured memory_bytes: 3756
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication11 {
    class Program {
        static void Main(string[] args) {
            new Program().solve();
        }

        void solve() {
            while (true) {
                string input = Console.ReadLine();
                if (input == "0") {
                    return;
                }
                string[] splitInput = input.Split(' ');
                int[] numericInput = new int[splitInput.Length];
                for (int i = 0; i < splitInput.Length; i++) {
                    numericInput[i] = int.Parse(splitInput[i]);
                }
                Console.WriteLine(calcPoints(numericInput));
            }
        }

        int calcPoints(int[] hand) {
            int point = 0;
            int numAce = 0;
            for (int i = 0; i < hand.Length; i++) {
                if (hand[i] == 1) {
                    numAce++;
                    point += 11;
                }else if(hand[i] >= 10) {
                    point += 10;
                }else  point += hand[i];
            }

            while (numAce > 0 && point > 21) {
                point -= 10;
                numAce--;
            }
            if (point > 21) {
                return 0;
            } else return point;
        }
    }
}

Measured memory_bytes: 9132
#include <stdio.h>
#include <math.h>

#define MAX_N 1000000


int solve(int n, int d, int x[], int y[]);


int main ()
{
    int n, d;
    int x[MAX_N];
    int y[MAX_N];
    
    scanf("%d %d", &n, &d);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &x[i]);
        scanf("%d", &y[i]);
    }

    printf("%d\n", solve(n, d, x, y));

    return 0;
}

int solve(int n, int d, int x[], int y[])
{
    int count = 0;
    for (int i = 0; i < n; i++)
    {
        if (sqrt((long)x[i] * x[i] + (long)y[i] * y[i]) <= (float)d)
        {
            count++;
        }
    }

    return count;
}


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

int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if (A + B > C + D)
        cout << "Left" << endl;
    else if (A + B == C + D)
        cout << "Balanced" << endl;
    else
        cout << "Right" << endl;
    return 0;
}

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

int main()
{

  int N;
  cin >> N;
  int max =0;
  int tmp = 0;
  vector<int> V(N);
  for(int i =0;i < N;i++){
    cin >> V.at(i);
  }
  for(int i =0;i < N;i++){
    cin >> tmp;
    if(V.at(i) > tmp){
      max += V.at(i) - tmp;
    }
  }
  cout << max << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        final long INF = (long) 1e15;

        Scanner sc = new Scanner(System.in);
        String number = sc.next();
        int[] digits = new int[number.length()+1];
        
        for(int i = 0 ; i < number.length() ; i++){
            digits[i] = number.charAt(number.length()-1-i) - '0';
        }
        
        int bills = 0;
        for(int i = 0 ; i <= number.length() ; i++){
            if(digits[i] == 10){
                digits[i+1]++;
                digits[i] = 0;
            }
            
            if(digits[i] < 5){
                bills += digits[i];
            }else if(digits[i] == 5){
                if(digits[i+1] >= 5){
                    digits[i+1]++;
                }
                bills += 5;
            }else{
                digits[i+1]++;
                bills += 10 - digits[i];
            }
        }

        System.out.println(bills);
    }
}



Measured memory_bytes: 36820
#include<bits/stdc++.h>
using namespace std;
int main()
{int n;
 cin>>n;
 int ar[n],l,r;long long sum1=0;
 for(int i=0;i<n;i++)
   cin>>ar[i];
 long long dp[n+1][n+1];
 dp[0][0]=0;
 long long pre[n+1];
 pre[0]=ar[0],sum1=0;
 for(int i=1;i<n;i++)
   pre[i]=pre[i-1]+ar[i];
 for(int i=0;i<=n;i++)
 {for(int j=0;j<=n;j++)
   dp[i][j]=0;
 }
 for(int k=1;k<n;k++)
 {for(int i=0;i<n;i++)
 {if(i+k<n)
 { l=i;r=i+k;
  if(i==0)
    sum1=pre[r];
  else
    sum1=pre[r]-pre[i-1];
  for(int j=l;j<r;j++){if(dp[l][r]!=0)
    dp[l][r]=min(dp[l][r],(dp[l][j]+dp[j+1][r]+sum1));
    else
    dp[l][r]=(dp[l][j]+dp[j+1][r]+sum1);
  //  cout<<l<<" l_r "<<r<<" dp "<<dp[l][r]<<endl;
 }}}}
  cout<<dp[0][n-1]<<endl;
 return 0;}
  
  
  
  
  

Measured memory_bytes: 1536
#include <stdio.h>
#include <stdlib.h>
typedef long long ll;

int compare_ll(const void *a, const void *b){
    return *(ll*)a - *(ll*)b;
}

int main(){
    int n, ans=0;
    ll a[100001]={0};
    scanf("%d",&n);
    for(int i=0; i<n; i++){ scanf("%lld",&a[i]); }
    qsort( a, n, sizeof(ll), compare_ll );

    int cnt=1, tmp=a[0];
    for(int i=1; i<=n; i++){
        if( tmp==a[i] ){ cnt++; }
        else{
            if( cnt&1 ){ ans++; }
            tmp=a[i];
            cnt=1;
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3016
n,k = map(int,input().split())
A = sorted(list(map(int,input().split())))
F = sorted(list(map(int,input().split())),reverse=True)

low = -1
high = 10**12

while high - low > 1:
    score = (low+high)//2
    training = 0
    for i in range(n):
        if A[i]*F[i] > score:
            training += A[i] - score//F[i]
    if training <= k:
        high = score
    else:
        low = score
        
print(high)

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

int color[9] = {0};
int flag = 0;
int up3200 = 0;
void hantei(int r);

int main() {
  int N;

  cin >> N; // 人数
  for(int i=0; i<N; i++) {
    int r;
    cin >> r;
    hantei(r);
  }

  int min;
  int cnt = 0;
  for(int i=0; i<9; i++) {

    if(flag == 0) {
      cnt += color[i];
      min = cnt;
    }else {
      cnt += color[i];
      if(i < 8) min += color[i];
    }
  }
  
  if(up3200 == N) {
    min = 1;
  }

  cout << min << " " << cnt << endl;

  return 0;
}

void hantei(int r) {
  if(r < 400) color[0] = 1;
  else if(r < 800) color[1] = 1;
  else if(r < 1200) color[2] = 1;
  else if(r < 1600) color[3] = 1;
  else if(r < 2100) color[4] = 1;
  else if(r < 2400) color[5] = 1;
  else if(r < 2800) color[6] = 1;
  else if(r < 3200) color[7] = 1;
  else {
    color[8] += 1;
    flag = 1;
    up3200++;
  }
}

Measured memory_bytes: 256
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

c = Counter(A)

# 帽子の種類数を取得する
c_set = set(A)

# 帽子の種類数が1個の時、数値が0なら条件を満たす
if len(c_set) == 1:
    if c[0] != 0:
        print('Yes')
        exit(0)

# 帽子の種類数が2個の時、数値が0の帽子がN/3なら条件を満たす
elif len(c) == 2:
    if c[0] == N//3:
        print('Yes')
        exit(0)

# 帽子の種類数が3個の時、x^y^z=0で条件を満たす
elif len(c) == 3:
    check = -1
    check_list = []
    for a in c_set:
        check_list.append(a)
        if check == -1:
            check = c[a]
        else:
            if check != c[a]:
                print('No')
                exit(0)

    # 同じ個数ずつあった時に、x^y^z=0であるか
    if check_list[0] ^ check_list[1] ^ check_list[2] == 0:
        print('Yes')
        exit(0)
print('No')


Measured memory_bytes: 14468
#include <cassert>
#include <cstdint>
#include <limits>
#include <utility>

class montgomery_fp {
  using Self = montgomery_fp;

  using u64 = std::uint64_t;
  using u32 = std::uint32_t;
  using i32 = std::int32_t;

  static u32 mod;
  static u32 inv;
  static u32 r2;

  static u32 reduce(const u64 x) noexcept {
    const u32 y = u32(x >> 32) - u32(u64(u32(x) * inv) * mod >> 32);
    return i32(y) < 0 ? y + mod : y;
  }

  u32 v;

public:
  montgomery_fp(const u32 x = 0) noexcept : v(reduce(u64(x) * r2)) {}

  u32 value() const noexcept { return reduce(v); }

  Self operator+(const Self r) const noexcept { return Self(*this) += r; }
  Self operator-(const Self r) const noexcept { return Self(*this) -= r; }
  Self operator*(const Self r) const noexcept { return Self(*this) *= r; }
  Self operator/(const Self r) const noexcept { return Self(*this) /= r; }

  Self &operator+=(const Self r) noexcept {
    v += r.v;
    if (v >= mod)
      v -= mod;
    return *this;
  }
  Self &operator-=(const Self r) noexcept {
    if (v < r.v)
      v += mod;
    v -= r.v;
    return *this;
  }
  Self &operator*=(const Self r) noexcept {
    v = reduce(u64(v) * r.v);
    return *this;
  }
  Self &operator/=(const Self r) noexcept {
    u32 a = mod;
    u32 b = reduce(reduce(r.v));
    u32 s = 0;
    u32 t = 1;
    while (b != 1) {
      const u32 q = a / b;
      std::swap(a -= q * b, b);
      std::swap(s -= q * t, t);
    }
    if (i32(t) < 0)
      t += mod;
    v = reduce(u64(v) * t);
    return *this;
  }

  static void set_mod(const u32 m) noexcept {
    assert(m < u32(1) << 31);
    assert(m % 2 == 1);
    mod = m;
    inv = m;
    for (u32 i = 0; i != 4; i += 1)
      inv *= u32(2) - inv * m;
    r2 = -u64(m) % m;
  }
  static u32 get_mod() noexcept { return mod; }
};
typename montgomery_fp::u32 montgomery_fp::mod;
typename montgomery_fp::u32 montgomery_fp::inv;
typename montgomery_fp::u32 montgomery_fp::r2;

#include <utility>

template <class T, class U> constexpr T power(T x, U exp) {
  T ret = static_cast<T>(1);
  while (exp) {
    if (exp % static_cast<U>(2) == static_cast<U>(1))
      ret *= x;
    exp /= static_cast<U>(2);
    x *= x;
  }
  return ::std::move(ret);
}

#include <iostream>
#include <vector>

int main() {
  using mint = montgomery_fp;
  mint::set_mod(1000000007);

  int b, w;
  std::cin >> b >> w;
  int n = b + w;

  std::vector<mint> fact(n);
  fact[0] = 1;
  for (int i = 1; i < n; ++i) {
    fact[i] = fact[i - 1] * i;
  }
  const auto comb = [&fact](int n, int r) {
    return fact[n] / fact[r] / fact[n - r];
  };

  mint p = 0, q = 0;

  for (int i = 1; i <= n; ++i) {
    std::cout << ((mint(1) - p + q) / 2).value() << std::endl;

    if (i >= b) {
      p += comb(i - 1, b - 1) / power(mint(2), i);
    }
    if (i >= w) {
      q += comb(i - 1, w - 1) / power(mint(2), i);
    }
  }

  return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll INF = 1e9+7;
ll MOD = 998244353;
typedef pair<ll,ll> ii;
#define iii pair<ii,ll>
#define f(i,a,b) for(long long i = a;i < b;i++)
#define rf(i,a,b) for(long long i=a;i>=b;i--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define w(t) while(t--)
#define c(n); cin>>n;
#define p(n) cout<<n;
#define pl(n) cout<<n<<"\n";
#define ps(n); cout<<n<<" ";
#define F first
#define S second
#define pb(a) push_back(a)
#define all(x) (x).begin(), (x).end()
#define ull unsigned long long
#define vll vector<ll>
#define vii vector<ii>
#define mkp make_pair
#define ld double
#define arrin(a,n) f(i,0,n){cin>>a[i];}
#define arrout(a,n) f(i,0,n){cout<<a[i]<<" ";}
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define PI (2*acos(0))
#define EPS 1e-18
///I hope I will get uprating and don't make mistakes
///I will never stop programming
///sqrt(-1) Love C++
///Please don't hack me
///@TheofanisOrfanou Theo830
///Training
int main(void){
    fastio;
    ll a,b;
    cin>>a>>b;
    cout<<a*b;
}



Measured memory_bytes: 3656
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>
using namespace std;

int main(){
	long long int N,T,t[200000],ans;
	cin>>N>>T;
	for(int i=0;i<N;i++){
		cin>>t[i];
	}
	ans=T;
	for(int i=0;i<N-1;i++)
	if(t[i+1]-t[i]<T){
		ans+=t[i+1]-t[i];
	}else{
		ans+=T;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, m = LI()
G = [[] for _ in range(n)]
for _ in range(m):
    l, r, c = LI()
    G[l - 1] += [(r - 1, c)]


for i in range(n - 1):
    G[i + 1] += [(i, 0)]


def dijkstra(G, s=0):
    hq = [(0, s)]
    dist = [INF] * n
    dist[s] = 0
    checked = [0] * n
    while hq:
        min_dist, u = heappop(hq)
        if checked[u]:
            continue
        checked[u] = 1
        for v, c in G[u]:
            if checked[v]:
                continue
            elif dist[u] + c < dist[v]:
                dist[v] = dist[u] + c
                heappush(hq, (dist[u] + c, v))
    return dist


ans = dijkstra(G)[-1]
if ans == INF:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 79008
#include<iostream>
#define F(a,b,c,d)!(d<a||b<c)
using namespace std;
main()
{
	double a,b,c,d,e,f,g,h;
	while(cin>>a>>b>>c>>d>>e>>f>>g>>h)
	{
		cout<<(F(a,c,e,g)&&F(b,d,f,h)?"YES":"NO")<<endl;
	}
}



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

//SET PRECIOSION   cout << fixed ;  cout << setprecision(n) << ans << endl;
#define ll long long
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
vector <ll> v;
ll x,y,z,a,b,c,sum,ans,total,t,cnt,n,m,k,p,kase;
string s1,s2;
map<ll,ll> mp;
set<ll> s;
map<ll,ll> :: iterator itr1, ptr1;
set<ll> :: iterator itr, ptr;
int main()
{
	FAST;
	cin>>a>>b;
	cout<<a-b+1<<endl;
	//clear vectors and maps you idiot
	// check array size dumb
	// use long long instead of int too
	return 0;
}

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

int main(){
  int N, t, A;
  cin >> N;
  cin >> t >> A;
  vector<double> num;
  for(int i = 0; i < N; i++){
    int x;
    cin >> x;
    double avg = t - x * 0.006;
    num.push_back(avg);
  }
  int ans = 0;
  double min = abs(A - num.at(0));
  for(int i = 1; i < num.size(); i++){
    double sa = abs(A - num.at(i));
    if(min > sa){
      min = sa;
      ans = i;
    }
  }
  cout << ans + 1 << endl;
}

Measured memory_bytes: 256
from collections import deque
import sys

H,W  = map(int, input().split())
sx, sy = 1,1
gx, gy = W,H
count=-1
maze=[0]*(H+2)
maze[0] = list("#"*(W+2))
for i in range(1,H+1):
    maze[i] = list("#"+input()+"#")
    count+=maze[i].count('.')
maze[H+1] = list("#"*(W+2))
ans = [[-1 for i in range(W+2)] for j in range(H+2)]
q = deque()
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
q.append((sx, sy))
ans[sx][sy] = 0
 
while q:
    cx, cy = q.popleft()
    if cx == gx and cy == gy:
        print(count-ans[gy][gx])
        sys.exit()
    for i in range(4):
        nx, ny = cx + dx[i], cy + dy[i]
        if ans[ny][nx] == -1 and maze[ny][nx] != "#":
            q.append((nx, ny))
            ans[ny][nx] = ans[cy][cx] + 1
print(-1)

Measured memory_bytes: 3316
// author-Shivam gupta

#include <bits/stdc++.h>


using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))

#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)

#define IN(A, B, C) assert( B <= A && A <= C)

#define MP make_pair
#define FOR(i,a) for(int i=0;i<a;i++)

#define FOR1(i,j,a) for(int i=j;i<a;i++)

#define EB emplace_back

#define INF (int)1e9

#define EPS 1e-9

#define PI 3.1415926535897932384626433832795

#define MOD 1000000007

#define read(type) readInt<type>()
#define max1 1000008
#define out(x) cout<<x<<'\n'
#define out1(x) cout<<x<<" "
#define END cout<<'\n'
typedef long int li;

typedef unsigned long int uli;

typedef long long int ll;

typedef unsigned long long int  ull;


void fast(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
ll check(ll n,ll b){
  ll ans=0;
  while (n>0){
    ans+=n%b;
    n/=b;
  }
  return ans;
}
ull na(ull m, ull n)
{
    // We have to calculate m+n-2 C n-1 here
    // which will be (m+n-2)! / (n-1)! (m-1)!
    ull path = 1;
    for (ull i = n; i < (m + n - 1); i++) {
        path *= i;
        path /= (i - n + 1);
    }
    return path;
}

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

    int N = 1 << (s.size() - 1);
    ll ans = 0;
     FOR(x, N){
        int n = x;
        ll tmp = s[0] - '0';
        FOR1(i, 1, s.size()) {
            if (n & 1) {
                ans += tmp;
                tmp = s[i] - '0';
            } else {
                tmp = 10 * tmp + s[i] - '0';
            }
            n >>= 1;
        }
        ans += tmp;
    }
    cout << ans << endl;}







Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
ary  = Array.new(m, 0)
n.times do
  ans = gets.split.map(&:to_i)
  for i in 1 .. ans[0]
    ary[ans[i] - 1] += 1
  end
end
cnt = 0
ary.each do |a|
  if a == n
    cnt += 1
  end
end
puts cnt


Measured memory_bytes: 1788
#include<stdio.h>
int main(void)
{
	int n;
	int max;
	int sum = 0;
	int l[200];
	int i, j, k;

	scanf("%d", &n);

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

	max = l[0];

	for (i = 1; i < n; i++) {
		if (max < l[i]) {
			max = l[i];
		}
	}


	for (i = 0; i < n; i++) {
			sum = sum + l[i];
	}

	sum = sum - max;

	if (sum > max) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}

	return 0;


}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;
//const int MOD = 998244353;

// Lib
//

struct FloatingMedian{
    priority_queue<ll> zen;
    priority_queue<ll, vector<ll>, greater<ll> > kou;
    ll zensum = 0;
    ll kousum = 0;

    ll const med(){
        return zen.top();
    }

    void push(ll n){
        if (zen.size() > kou.size()) {
            // kou に
            int t = zen.top();
            if (n >= t) {
                kou.push(n); kousum += n;
            }
            else {
                zen.pop(); zensum -= t;
                zen.push(n); zensum += n;
                kou.push(t); kousum += t;
            }
        }
        else {
            // zen に
            if (zen.empty()){
                zen.push(n);
                zensum += n;
            }
            else {
                int t = kou.top();
                if (n <= t) {
                    zen.push(n); zensum += n;
                }
                else {
                    kou.pop(); kousum -= t;
                    kou.push(n); kousum += n;
                    zen.push(t); zensum += t;
                }
            }
        }
    }
};

int main(){
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int Q; cin >> Q;

    long long sum = 0;
    FloatingMedian floatingmedian;

    for (int i = 0; i < Q; ++i) {
        ll type; cin >> type;
        if (type == 1) {
            ll a, b; cin >> a >> b;
            floatingmedian.push(a);
            sum += b;
        }
        else {
            ll x = floatingmedian.med();
            ll tmp1 = x * floatingmedian.zen.size() - floatingmedian.zensum;
            ll tmp2 = x * floatingmedian.kou.size() - floatingmedian.kousum;
            ll res = tmp1 - tmp2 + sum;
            cout << x << " " << res << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3828
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] p = new int[N];
		int max = 0;
		int total = 0;
		for(int i = 0; i < N; i++) {
			p[i] = sc.nextInt();
			max = Math.max(max, p[i]);
			total += p[i];
		}
		total = total - max + max / 2;
		System.out.println(total);
	}

}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    string s;cin>>s;
    int p=s[0]==s[s.size()-1];
    if(p%2==s.size()%2)cout<<"Second"<<endl;
    else cout<<"First"<<endl;
    return 0;
}


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

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


Measured memory_bytes: 1664
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>

using namespace std;

int main() {
#ifdef _75108D01685041AA959399A981476AD7
  std::freopen("input.txt", "r", stdin);
#endif

  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);

  int n;
  cin >> n;
  int msf = 0;
  int res = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    res += (x >= msf);
    msf = max(msf, x);
  }

  cout << res << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
	int N,A,B;
	scanf("%d%d%d",&N,&A,&B);
	if(A > B||(A!=B && N == 1)){printf("0");}
	else{
		long long l = ((LL)A*(N-1))+B,r = (LL)B*(N-1)+A;
		if(l > r)printf("0");
		else printf("%lld",r-l+1);
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int n;cin >> n;
  cout << n/2+n%2 << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cctype>
#include <ctime>
#include <bitset>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define eps 1e-9

typedef long long ll;
typedef pair<int, int> pii;

const int INF = 0x7fffffff;
int n, m, d, x, y;
char s[] = {'B', 'G', 'Y', 'R'};

int main() {
#ifdef __AiR_H
    freopen("B.in", "r", stdin);
//    freopen("out.txt", "w", stdout);
#endif // __AiR_H
    scanf("%d %d %d", &n, &m, &d);
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            x = (i + j - 1) / d; y = (n - i + j) / d;
            if (x % 2 == 1) {
                if (y % 2 == 1) { printf("%c", s[0]); } else { printf("%c", s[1]); }
            } else {
                if (y % 2 == 1) { printf("%c", s[2]); } else { printf("%c", s[3]); }
            }
        }
        printf("\n");
    }
#ifdef __AiR_H
    printf("Time used = %.2fs\n", (double)clock() / CLOCKS_PER_SEC);
#endif // __AiR_H
    return 0;
}


Measured memory_bytes: 512
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let n: String = read();
    let s: String = read();
    println!("{}", s.matches("ABC").count());
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int N; cin >> N;
    for (int i=0; i<N; ++i) {
        int l[3];
        cin >> l[0] >> l[1] >> l[2];
        
        sort(l, l+3);
        
        if (l[0]*l[0] + l[1]*l[1] == l[2]*l[2]) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
    return 0;
}

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

using namespace std;

//FILE *fi=freopen("1.txt","r",stdin);

long long n,k,d;

void process()
{
    long long l=min(k,n/d);
    k-=l;
    long long x=n-l*d;
    if (k%2==0) cout<<x;
    else cout<<d-x;
}

int main()
{
    cin>>n>>k>>d;
    if (n<0) n=-n;
    process();
    return 0;
}


Measured memory_bytes: 3572
import java.util.*;
import java.math.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();

    int a = 0;
    int b = 0;

    for (int i = 0; i < s.length(); i++) {
      if (s.charAt(i) == 'A') {
        a++;
      } else if (s.charAt(i) == 'B') {
        b++;
      }
    }

    if (a == 3 || b == 3) {
      System.out.println("No");
    } else {
      System.out.println("Yes");
    }

  }
}


Measured memory_bytes: 21332
N,W=map(int,input().split())
w=[0]*(N+1)
v=[0]*(N+1)
for i in range(N):
  w[i+1],v[i+1]=map(int,input().split())
res=0

dp=[[float("inf") for _ in range(sum(v)+1)] for _ in range(N+1)]
dp[0][0]=0

for i in range(1,N+1):
  for j in range(0,sum(v)+1):
    dp[i][j]=min(dp[i][j],dp[i-1][j])
    if j-v[i]<0: continue
    dp[i][j]=min(dp[i][j],dp[i-1][j-v[i]]+w[i])

#print("---")
for i in range(sum(v)+1):
#  print("w=",dp[N][i],"v=",i)
  if dp[N][i]>W: continue
  res=i

print(res)

Measured memory_bytes: 319088
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	// input = input.split("\n");
	input = input.split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var a = parseInt(input[0], 10);
	var b = parseInt(input[1], 10);
	var c = parseInt(input[2], 10);
  	var cal = a + b + c;
	//出力
  	if(cal > 21) {
      console.log('bust');
    } else {
      console.log('win');
    }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

int main()
{
	int n,k;
	cin>>n>>k;
	vector<int> v;
	for(int i=0;i<n;i++)
	{
		int l;
		cin>>l;
		v.push_back(l);
	}
	sort(v.begin(),v.end());
	int ans=0;
	for(int i=0;i<k;i++)ans+=v[n-i-1];
	cout<< ans<<endl;

	return 0;
}


Measured memory_bytes: 256
n, yen = gets.split.map(&:to_i)

a = b = c = 0

k = yen / 1000

tmp = k - n

(0..tmp/9).each do |i|
  
  tmp = k - n
  tmp -= 9 * i
  if tmp % 4 == 0
    a = i
    b = tmp / 4
    c = n - a - b
    
    if c >= 0
      puts [a, b, c] * " "
      # puts a + b + c
      exit
    end
  end
end

puts Array.new(3, -1) * " "


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define REP(i,x) for(int i=0,i##_len=(x);i<i##_len;++i)
#define rep(i,a,b) for(int i=(a),i##_len(b);i<i##_len;++i)
#define All(x) begin(x),end(x)
#define rAll(x) rbegin(x),rend(x)
using namespace std;
using ll = long long;

int main(){
    int H,W,K;cin>>H>>W>>K;
    vector<string> S(H);
    REP(i,H) cin>>S[i];
    int ans=H+W;
    vector<int> sec(H-1);
    REP(bit,1<<(H-1)){
        int cnt=__builtin_popcount(bit);
        sec.assign(cnt+1,0);
        int tmp=cnt;
        int l=0;
        bool ok=true;
        REP(j,W){
            int now=0;
            REP(i,H){
                if(S[i][j]=='1') sec[now]++;
                if(sec[now]>K){
                    if(l==j){
                        ok=false;
                        break;
                    }
                    l=j;
                    tmp++;
                    sec.assign(cnt+1,0);
                    j--;
                    break;
                }
                if(bit>>i&1) now++;
            }
            if(!ok) break;
        }
        if(ok) ans=min(ans,tmp);
    }
    cout<<ans<<endl;
}


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

int main(){
    int l,r,diff,minmod = inf,x;
    cin>>l>>r;
    diff = r-l+1;
    if(diff > 2019) diff = 2019;
    vector<int> a(diff);
    rep(i,diff){
        a[i] = (l+i)%2019;
    }
    rep(i,diff){
        for(int j=i+1;j<diff;j++){
            x = (a[i]*a[j])%2019;
            minmod = min(minmod,x);
        }
    }
    cout<<minmod<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define N 100010
#define ll long long
using namespace std;

inline int read() {
	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;
}

int n, A[N], f[N];

int main() {
	n = read(); for (int i = 1; i <= n; ++i)A[i] = read();
	f[1] = 0, f[2] = fabs(A[1] - A[2]);
	for (int i = 3; i <= n; ++i)f[i] = min(f[i - 1] + fabs(A[i] - A[i - 1]), f[i - 2] + fabs(A[i] - A[i - 2]));
	printf("%d\n", f[n]);
	return 0;
}


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

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

template<class T> using v2d = vector <vector <T> >;
template<class T> bool uin(T &a, T b)
{
    return a > b ? (a = b, true) : false;
}
template<class T> bool uax(T &a, T b)
{
    return a < b ? (a = b, true) : false;
}

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 2e5 + 10;
const ll mod = 1e9 + 7;

int n;
ll a[maxN];
ll fact[1000010], ifact[1000010];

ll power(ll a, ll b)
{
    ll r = 1;
    while (b)
    {
        if (b & 1)
        {
            r = r * a % mod;
        }
        b /= 2;
        a = a * a % mod;
    }
    return r;
}

void init()
{
    fact[0] = 1;
    for (int i = 1; i <= 1e6; ++i)
    {
        fact[i] = fact[i - 1] * i % mod;
    }
    ifact[1000000] = power(fact[1000000], mod - 2);
    for (int i = 999999; i >= 0; --i)
    {
        ifact[i] = ifact[i + 1] * (i + 1) % mod;
    }
}

ll nCk(int n, int k)
{
    return fact[n] * ifact[k] % mod * ifact[n - k] % mod;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    init();
    cin >> n;
    for1(i, n)
    {
        cin >> a[i];
    }
    sort(a + 1, a + n + 1, greater <ll>());
    ll ans = 0;
    for1(i, n)
    {
        ans += a[i] * (i + 1) % mod * power(4, n - 1) % mod;
        ans %= mod;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 17408