akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1;} return 0;}
struct init{init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}}init_;

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll dp[100004][3];

int main() {
    ll N, K;
    cin >> N >> K;
    vl A(3);
    rep(i, 3) cin >> A[i];
    string S;
    cin >> S;
    vl T(N);
    rep(i, N) {
        if(S[i] == 'r')
            T[i] = 2;
        else if(S[i] == 's')
            T[i] = 0;
        else
            T[i] = 1;

    }

    rep(i, N){
        ll pi = 0;
        if (i >= K) pi = i - K + 1;
        
        rep(j, 3) rep(k, 3) {
            if (j == k) continue;
            if (j == T[i])
                chmax(dp[i + 1][j], dp[pi][k] + A[j]);
            else
                chmax(dp[i + 1][j], dp[pi][k]);
        }
    }

    ll ans = 0;
    repe(i, N - K, N) ans += *max_element(dp[i + 1], dp[i + 1] + 3);
    cout << ans << endl;
}

Measured memory_bytes: 6688
#include<bits/stdc++.h>
using namespace std;
const int N =2e5,OO=0x3f3f3f3f;
int t,a,b,c;
map<int,int>mp;
int main()
{
    cin>>a>>b>>c;
    mp[a]++;
    mp[b]++;
    mp[c]++;
    if(mp[5]==2 && mp[7]==1)puts("YES");
    else puts("NO");
}


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

int main(){
    int sum = 0, min, a, i, j;
    cin >> a;
    min = a;
    for(i = 0; i < 4; i++){ 
        cin >> a;
        if(a%10 < min%10 && a % 10 != 0){
            sum += (min/10)*10+10;
            min = a;
        }else{
      		if(a % 10 == 0)	sum += a;
      		else sum += (a/10)*10+10;
        }
    }
    cout << sum+min << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

#define ll long long
const long long llINF = 1LL << 60;
const int iINF = 1LL << 20;
template<class T> inline bool chmin(T& a, T b) { if (b < a) { 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; }

void execute();
int main() 
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);// cin と scanfの併用禁止
    cout << fixed << setprecision(15);
    execute();
    return 0;
}


void execute()
{
    int N;
    ll K;
    cin >> N;
    cin >> K;

    int A[200000];
    for(int i = 0l; i < N; i++){
        cin >> A[i];
        A[i]--;
    }

    int l = 0;
    ll c = 1;
    int T[200000]={0};
    T[l] = c++;
    for(;;){
        l = A[l];
        if(T[l] != 0){
            break;
        }
        T[l] = c++;
    }
    c--;

    int begin = T[l] - 1;

    if(K <= begin){
        int v = 0;
        for(int i = 0; i < K; i++){
            v = A[v];
        }
        cout << v + 1 << endl; 
        return;
    }

    K -= begin;
    ll n = (c-begin == 0) ? K : K % (c-begin);
    int v = 0;
    for(int i = 0; i < n + begin; i++){
        v = A[v];
    }

    cout << v + 1 << endl; 
}


Measured memory_bytes: 5204
#include <bits/stdc++.h>
#include <queue>
using namespace std;
int N; 
int f(int x){
	if(x == -1) return N-1; 
	if(x == N) return 0; 
	else return x; 
}
int main(){
	cin >> N; 
	long long int A[200010] = {}; 
	long long int B[200010] = {}; 
	long long int C[200010] = {}; 	
	for(int i = 0; i < N; i++){
		cin >> A[i];
	}
	for(int i = 0; i < N; i++){
		cin >> B[i]; C[i] = B[i]; 
	}
	priority_queue<pair<long long int, int>, vector<pair<long long int, int>>> que; 
	for(int i = 0; i < N; i++){
		que.push(make_pair(B[i], i)); 
	}
	bool ok = true; 
	long long int ans = 0; int update = 0; 
	while(que.size() > 0 && ok){
		pair<long long int, int> p = que.top(); 
		if(p.first == A[p.second]){ 
			que.pop(); update = 0; 
		}
		else if(p.first < C[f(p.second - 1)] + C[f(p.second + 1)]){
			ok = false; 
		}
		else{
			long long int now = p.first;
			long long int a = C[f(p.second - 1)] + C[f(p.second + 1)];
			long long int goal = A[p.second]; 
			long long int tmp = now % a;
			if(tmp == goal){
				C[p.second] = tmp; que.pop(); 
				ans += now / a; update = 0; 
			}
			else if(tmp > goal){
				C[p.second] = tmp; que.pop(); ans += now / a; 
				que.push(make_pair(tmp, p.second)); update = 0; 
			}
			else{
			    //ok = false; 
				C[p.second] = tmp + (goal - tmp + a - 1) / a * a; 
				ans += (now - C[p.second]) / a; 
				que.pop(); if(now != C[p.second]) update = 0; 
				que.push(make_pair(tmp + (goal - tmp + a - 1) / a * a, p.second)); 
			}
			update ++; 
			if(update >= N * 3) ok = false; 
		}
	}
	if(ok) cout << ans << endl; 
	else cout << -1 << endl; 
}

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

if 1<=N and N<=9:
  result=N
elif 10<=N and N<100 :
  result=9
elif 100<= N and N<1000:
  result=N-90
elif 1000<=N and N<10000:
  result=909
elif 10000<=N and N<100000:
  result=N-9090
elif N==100000:
  result=90909
  
print(result)

Measured memory_bytes: 3060
using System;

namespace abc127A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            if (A >= 13)
            {
                Console.WriteLine(B);
            }
            else if(12 >= A && A >= 6)
            {
                Console.WriteLine(B / 2);
            }
            else
            {
                Console.WriteLine(0);
            }
        }
    }
}


Measured memory_bytes: 11092
#include <cstdio>
#include <cstdlib>
#include <vector>

constexpr int MAX = 304 * 304;

int X[MAX];
int Y[MAX];

typedef long long ll;

std::vector<ll> v[MAX];

int main(void) {
    int n, m, D;
    scanf("%d%d%d", &n, &m, &D);
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j) {
            int a;
            scanf("%d", &a);
            --a;
            X[a] = j;
            Y[a] = i;
        }


    for (int a = 0; a < D; ++a) {
        int x = X[a];
        int y = Y[a];

        v[a].push_back(0);
        for (int b = a + D; b < n * m; b += D) {
            int nx = X[b];
            int ny = Y[b];
            int cost = abs(nx - x) + abs(ny - y);
            v[a].push_back(v[a].back() + cost);
            x = nx;
            y = ny;
        }
    }

    int Q;
    scanf("%d", &Q);
    for (int i = 0; i < Q; ++i) {
        int a, b;
        scanf("%d%d", &a, &b);
        --a;
        --b;

        int mod = a % D;
        printf("%lld\n", v[mod][b / D] - v[mod][a / D]);
    }

    return 0;
}


Measured memory_bytes: 6144
H,W = map(int,input().split())
mas = [list(input()) for i in range(H)]
new_mas = [row for row in mas if "#" in row]
new_mas2 = [column for column in list(zip(*new_mas)) if "#" in column]
for i in list(zip(*new_mas2)):
    for j in i:
        print(j,end="")
    print()


Measured memory_bytes: 4724
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
int f[9]={0,1800,1600,1400,1200,1000,800,600,400};
int main()
{
	int i,x;
	scanf("%d",&x);
	for(i=1;i<=8;i++)
		if(x>=f[i])
			break;
	printf("%d",i);
	return 0;
 } 

Measured memory_bytes: 3812
a,b,c,d=list(map(int,input().split(" ")))
if c%b==0:
  taro=c//b
else:
  taro=c//b+1
if a%d==0:
  sasaki=a//d
else:
  sasaki=a//d+1

if taro<=sasaki:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9188
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

  public static void main(String[] args) {
    Main main = new Main();
    try {
      main.run(args);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

  private void run(String[] arguments) throws Exception {
    MyScanner sc = new MyScanner();
    PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
    String s = sc.next();
    char[] letters = s.toCharArray();

    int diff = 0;
    for (int i = 0; i < letters.length / 2; i++) {
      char font = letters[i];
      char back = letters[letters.length - i - 1];
      if (font != back) {
        diff++;
      }
    }

    out.println(diff);
    out.flush();

  }

  /*
   * Form: http://codeforces.com/blog/entry/7018
   */
  private class MyScanner {

    BufferedReader br;
    StringTokenizer st;

    MyScanner() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }

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

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

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

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

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }
  }
}


Measured memory_bytes: 23124
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int flag=1;
	int n;
	cin>>n;
	int a[n];
	for(int i=0; i<n; i++)
		cin>>a[i];
	int m;
	cin>>m;
	int b[m];
	for(int i=0; i<m; i++)
		cin>>b[i];
	sort(a, a+n);
	for(int i=0; i<m; i++){
		int right=n;
		int left=0;
		while(left<right){
			int middle=(left+right)/2;
			if(a[middle]<b[i]){
				left=middle+1;
			}
			else if(a[middle]>b[i]){
				right=middle;
			}
			else
				break;
		}
		if(left==right){
			flag=0;
			break;
		}
	}
	if(flag)
		cout<<1<<endl;
	else
		cout<<0<<endl;
	return 0;
}


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

int main() {
  string s;
  cin >> s;
  
  string t;
  for(int i=0; i<s.size(); i++) {
    if(s[i]=='0' || s[i]=='1') t += s[i];
    else if(t.size() > 0) t.pop_back();
  }
  cout << t << endl;
  return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  
  vector<int> A(N);
  
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int tmp;
      cin >> tmp;
      ++A.at(tmp - 1);
    }
  }
  
  int sum = 0;
  for (int i = 0; i < N; i++) {
    if(A.at(i) == 0) {
      ++sum;
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

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


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    float a, b, c ,d;
    cin >> a >> b >> c >> d;

    float a_t, b_t;
    a_t = ceil(c/b);
    b_t = ceil(a/d);
    if (a_t <= b_t) {
        cout << "Yes";
    }else{
        cout << "No";
    }
}


Measured memory_bytes: 3228
#!/usr/bin/env python3
import sys, math, fractions, itertools, collections

MOD = 1000000007  # type: int

def mpow(n, base):
    res = 1
    for i in range(n):
        res = res * base % MOD
    return res

def solve(N: int, A: "List[int]"):
    A.sort()
    if N % 2 == 0:
        for i in range(0, N//2):
            if A[2*i] != 2*i+1 or A[2*i+1] != 2*i+1:
                print(0)
                return
        print(mpow(N//2, 2))
    else:
        for i in range(0, N//2):
            if i == 0:
                if A[0] != 0:
                    print(0)
                    return
                else:
                    continue
            if A[2*i] != 2*i or A[2*i-1] != 2*i:
                print(0)
                return
        print(mpow(N//2, 2))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


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

void requestAns(int num,map<int,int> dataMap,list<int> dataList){
	int count=0;
	for(;;count++){
		map<int,int> tmpMap;
		list<int> tmpList;
		list<int>::iterator it=dataList.begin();
		for(;it!=dataList.end();it++){
			int tmp=dataMap[*it];

			if(tmpMap[tmp]==0){
				tmpMap[tmp]++;
			}
			else tmpMap[tmp]++;
			tmpList.push_back(tmp);
		}

		if(tmpList==dataList)break;
		dataMap=tmpMap;
		dataList=tmpList;
	}
	cout<<count<<endl;
	list<int>::iterator it=dataList.begin();
	for(int i=0;it!=dataList.end();it++,i++){
		if(i)cout<<" ";
		cout<<dataMap[*it];
	}
	cout<<endl;

}


int
main(){
	int num;
	while(cin>>num&&num){
		map<int ,int> dataMap;
		list<int> dataList;

		for(int i=0;i<num;i++){
			int tmp;
			cin>>tmp;
			if(dataMap[tmp]==0){
				dataMap[tmp]++;
			}
			else dataMap[tmp]++;
			dataList.push_back(tmp);
			list<int>::iterator it=dataList.begin();
		}

		requestAns(num,dataMap,dataList);
	}


	return 0;
}

Measured memory_bytes: 0
def find(x):
    if x != T[x][0]:
        while x!=T[x][0]:
            x = T[x][0]
    return x
def union(x,y):
    rt0 = find(x)
    rt1 = find(y)
    if T[rt0][1]>T[rt1][1]:
        T[rt1][0] = rt0
    elif T[rt0][1]==T[rt1][1]:
        T[rt1][0] = rt0
        T[rt0][1] += 1
    else:
        T[rt0][0] = rt1
        
N,M = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
B = []
for j in range(M):
    T = {i:[i,0] for i in range(1,N+1)}
    for i in range(M):
        if i==j:continue
        a,b = A[i]
        union(a,b)
    R = [0 for _ in range(N+1)]
    for k in range(1,N+1):
        rt = find(k)
        if R[rt]==0:
            R[rt]=1
    if sum(R)>1:
        B.append(j)
print(len(B))

Measured memory_bytes: 43100
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define m_k make_pair
using namespace std;
const int N=2*1e5+100;
int n,a[N],b[N],l,r,c[N];
int ta[N],tb[N],tmp[N],del;
set <pair<int,int> > s;
signed main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]),ta[a[i]]++;
	for (int i=1;i<=n;i++) scanf("%d",&b[i]),tb[b[i]]++;
	bool bl=1;
	for (int i=1;i<=n;i++)
	{
		if (ta[i]+tb[i]>n)
		{
			bl=0;
			break;
		}
	}
	if (!bl)
	{
		printf("No\n");
		return 0;
	}
	for (int i=1;i<=n;i++)
	{
		if (tb[i])
		{
			s.insert(m_k(n-ta[i],i));
			tmp[i]=n-ta[i];
		}
	}
	for (int i=1;i<=n;i++)
	{
		set <pair<int,int> > :: iterator it;
		if ((*s.begin()).first<=del)
		{
			bl=0;
			break;
		}
		it=s.begin();
		if ((*it).second==a[i]) it++;
		if (it==s.end())
		{
			bl=0;
			break;
		}
		pair <int,int> x=*it;
		s.erase(it);
		tb[x.second]--;c[i]=x.second;
		if (tb[x.second]) s.insert(x);
		del++;
		it=s.lower_bound(m_k(tmp[a[i]],a[i]));
		if ((*it).second==a[i])
		{
			x=*it;
			x.first++;
			tmp[a[i]]++;
			s.erase(it);
			s.insert(x);
		}
	}
	if (!bl)
	{
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	for (int i=1;i<=n;i++) printf("%d ",c[i]);
	printf("\n");
}

Measured memory_bytes: 17764
#include<bits/stdc++.h>
namespace ZDY{
    #pragma GCC optimize(3)
    #define il __inline__ __attribute__ ((always_inline))
    #define rg register
    #define ll long long
    #define ull unsigned long long
    #define db double
    #define sht short
    #define MB template <class T>il
    #define Fur(i,x,y) for(int i=x;i<=y;++i)
    #define Fdr(i,x,y) for(int i=x;i>=y;--i)
    #define fl(i,x) for(int i=head[x],to;to=e[i].to,i;i=e[i].nxt)
    #define clr(x,y) memset(x,y,sizeof(x))
    #define cpy(x,y) memcpy(x,y,sizeof(x))
    #define fin(s) freopen(s".in","r",stdin)
    #define fout(s) freopen(s".out","w",stdout)
    #define fcin ios::sync_with_stdio(false)
    #define l2(n) (int(log2(n)))
    #define inf 0x3f3f3f3f
    MB T ABS(T x){return x>0?x:-x;}
    MB T MAX(T x,T y){return x>y?x:y;}
    MB T MIN(T x,T y){return x<y?x:y;}
    MB T GCD(T x,T y){return y?GCD(y,x%y):x;}
    MB void SWAP(T &x,T &y){T t=x;x=y;y=t;}
}using namespace ZDY;using namespace std;
namespace IO{const char* ln="\n";const int str=1<<20;struct IN{char buf[str],*s,*t;bool _;IN():s(buf),t(buf),_(0){}il char gc(){return s==t&&((t=(s=buf)+fread(buf,1,str,stdin))==s)?EOF:(*s++);}IN&operator>>(char&ch){if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)_=1;else ch=c;return *this;}IN& operator>>(char* ch){clr(ch,0);if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)return _=1,*this;*ch=c;ch++;while((c=gc())!=EOF&&!isspace(c))*ch=c,ch++;if(c==EOF)_=1;return *this;}IN& operator>>(string& ch){if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)return _=1,*this;ch+=c;while((c=gc())!=EOF&&!isspace(c))ch+=c;if(c==EOF)_=1;return *this;}template<typename T>IN&operator>>(T&x){if(_)return *this;char c=gc();bool ff=0;while(c!=EOF&&(c<'0'||c>'9'))ff^=(c=='-'),c=gc();if(c==EOF){_=1;return *this;}x=0;while(c!=EOF&&'0'<=c&&c<='9')x=(x<<3)+(x<<1)+c-48,c=gc();if(c==EOF)_=1;if(ff)x=-x;return *this;}}in;struct OUT{char buf[str],*s,*t;OUT():s(buf),t(buf+str){}~OUT(){fwrite(buf,1,s-buf,stdout);}void pt(char c){(s==t)?(fwrite(s=buf,1,str,stdout),*s++=c):(*s++=c);}OUT&operator<<(const char*s){while(*s)pt(*s++);return *this;}OUT&operator<<(char*s){while(*s)pt(*s++);return *this;}OUT&operator<<(string s){for(int i=0;s[i];i++)pt(s[i]);return *this;}template<typename T>OUT&operator<<(T x){if(!x)return pt('0'),*this;if(x<0)pt('-'),x=-x;char a[30],t=0;while(x)a[t++]=x%10,x/=10;while(t--)pt(a[t]+'0');return *this;}}out;}using namespace IO;
#define N 1011
int n,k;
int main(){
    int x,ans=0;
    cin>>n>>k;
    Fur(i,1,n){
        cin>>x;
        if(x>=k)ans++;
    }
    cout<<ans<<ln;
}

Measured memory_bytes: 256
#include <cstdio>

int main() {
  int n, m, d;
  scanf("%d%d%d", &n, &m, &d);
  if (d % 2 == 1) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        putchar("RG"[(i + j) & 1]);
      }
      puts("");
    }
    return 0;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if ((i + j) % 2 == 0) {
        int first = (i + j) % (2 * d);
        int second = ((i - j) % (2 * d) + 2 * d) % (2 * d);
        int color = (first < d) * 2 + (second < d);
        putchar("RGBY"[color]);
      } else {
        int first = (i - 1 + j) % (2 * d);
        int second = (((i - 1) - j) % (2 * d) + 2 * d) % (2 * d);
        int color = (first < d) * 2 + (second < d);
        putchar("RGBY"[color]);
      }
    }
    puts("");
  }
}


Measured memory_bytes: 384
def readinput():
    n=int(input())
    a=[]
    l=list(map(int,input().split()))
    a.append(l)
    l=list(map(int,input().split()))
    a.append(l)
    return n,a

def main(n,a):
    s0=[0]*(n+1)
    s1=[0]*(n+1)
    for i in range(n):
        s0[i+1]=s0[i]+a[0][i]
        s1[i+1]=s1[i]+a[1][i]
    maxa=0
    for i in range(1,n+1):
        ame=s0[i]+s1[n]-s1[i-1]
        maxa=max(maxa,ame)
    return maxa

if __name__=='__main__':
    n,a=readinput()
    ans=main(n,a)
    print(ans)


Measured memory_bytes: 9124
import java.io.*;
import java.math.*;
import java.util.*;
public class Main{

	public static void main(String[] args) { 
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		long[] a = new long[N];
		long[] b = new long[N];
		long[] d = new long[N];
		boolean[] vis = new boolean[N];
		long Sa = 0;
		long Sb = 0; //Total sums of arrays (use longs for this) 10^9*10^5 = 10^14
		int ans = 0;
		for (int i = 0; i < N; i++) {
			a[i]=input.nextLong();
			Sa+=a[i];
		}
		for (int i = 0; i < N; i++) {
			b[i]=input.nextLong();
			Sb+=b[i];
		}
		if (Sb>Sa) ans=-1;
		else {
			for (int i = 0; i < N; i++) {
				d[i]=a[i]-b[i];
			}
			Arrays.sort(d);
			int L = 0;
			int R = N-1;
			while (true) {
				if (d[L]>=0) break;
				long min = Math.min(Math.abs(d[L]), d[R]);
				d[L]+=min;
				d[R]-=min;
				if (!vis[L]) ans++;
				if (!vis[R]) ans++;
				vis[L]=true;
				vis[R]=true;
				if (d[R]==0) R--;
				if (d[L]==0) L++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 53120
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const double PI=3.14159265358979323846;
ll dp;

int main(){
   ll n,k,ans=0;
   string s;
   
   map<string,int> m{};

   cin>>n;
   rep(i,n){
      cin>>s;
      if(m[s]==0){
         
      
         m[s]=1;
         ans++;
      }
   }
   cout<<ans<<endl;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> r(n);
    for (int i = 0; i < n; i++) {
        cin >> r.at(i);
    }

    int max_profit = -1000000000;
    int min_r = r.at(0);
    for (int i = 1; i < n; i++) {
        int profit = r.at(i) - min_r;
        max_profit = max(max_profit, profit);
        min_r = min(min_r, r.at(i));
    }

    cout << max_profit << endl;
}


Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main()
{
	string str;
	cin >> str;
	
	int count = 0;
	int last = 0;
	for (int i = 0; i < str.size() ; i++)
	{
		if (str[i] == 'R')
			count++;
		if (str[i] == 'S')
		{
			if (count >= last)
				last = count;
			count = 0;
		}
	}
	if (count >= last)
		last = count;
	cout << last << endl;
	return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
const ll inf = 1e9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const ll MAX = 1e7 + 20;
#define fast ios_base:: sync_with_stdio( false ); cin.tie(0); cout.tie(0);
#define eb              emplace_back
#define em              emplace
#define pb              push_back
#define Mp              make_pair
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep1(i,n)       for(int i=1;i<=n;i++)
#define rrep(i,a,n)     for(int i=a;i<=n;i++)
#define per(i,n,a)      for(int i=n;i>=a;i--)
#define pf(n)           printf("%lld",n)
#define pfi(n)          printf("%d",n)
#define sp              printf(" ")
#define ln              "\n"

template< class T > T gcd(T a, T b)
{
    return (b != 0 ? gcd<T>(b, a%b) : a);
}
template< class T > T lcm(T a, T b)
{
    return (a / gcd<T>(a, b) * b);
}
const int N = 200200;

int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast

    ll a,b,c;
    vector<ll>v;
    cin>>a;
    for(int i=0; i<a; i++)
    {
        cin>>b;
        v.push_back(b);
    }
    sort(v.begin(),v.end());
    ll sum=0;
    for(int i=0; i<v.size(); i++)
    {
        sum=sum+v[i]-1;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 384
X,N = map(int,input().split())
if N > 0:
    A = list(map(int,input().split()))
    d = {}
    for i in range(102):
        d[i] = 0
    for a in A:
        d[a] = 1
    for i in range(0,100):
        x = X - i
        y = X + i
        if d[x] == 0:
            print(x)
            quit()
        if d[y] == 0:
            print(y)
            quit()
else:
    print(X)

Measured memory_bytes: 9144
#include <iostream>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>
#include <cstdarg>
#include <set>

using namespace std;
#define INF 2e9 + 9
#define MOD 1000000007
#define ALL(v) v.begin() , v.end()
#define Int int64_t
#define pll pair<Int,Int>
template<class T> using pql = priority_queue<T, vector<T>>;
template<class T> using pq = priority_queue<T, vector<T>, greater<T>>;
#define ll(n) Int n; cin >> n;
#define LL(...) Int __VA_ARGS___; cin >> __VA_ARGS___;
#define OUT(...) cout << __VA_ARGS___;
#define RP(n, i, s) for(Int i = s ;i < n ;i++)
#define REP(n, i) for (Int i = 0; i < n; i++)
#define REPe(n, i) for (Int i = 1; i <= n; i++)
#define RPe(n, i, s) for (Int i = s; i <= n; i++)
#define upd_max(maxer, updater) if (maxer < updater) maxer = updater;

struct node {
    Int to;
    Int length;
};


vector<Int> divisor(Int n) {
    vector<Int> ret;
    for (Int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    return (ret);
}

/*
vector<vector<int>> to;
vector<int> flag;
vector<int> c;


Int dfs(int from, int mae) {
    flag[from] = 1;
    Int mini = 0;
    for (auto next : to[from]) {
        if (next == mae) continue;
        if (flag[next] == 1) {
            return -1;
        } else {
            mini = min(mini, dfs(next, from));
        }
    }
    return mini;
}*/

int dx8[8] = {0, -1, -1, -1, 0, 1, 1, 1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};

struct datas{
    Int max;
    Int size;
};

int main(void) {
    Int n;
    cin >> n;
    REPe(9,i){
        if (n % i == 0 && n / i < 10 && n / i > 0) {
            cout << "Yes"  << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2>
bool chmin(T1 &l, const T2 &r);
template <class T1, class T2>
bool chmax(T1 &l, const T2 &r);
template <class T1, class T2>
void vadd(vector<T1> &v, T2 x);

#define int long long int

// E[s] := sにいるときのNに到達するまでに通る通路の期待値
// E[N] = 0
//

double dp[605];
double coef[605];
vector<int> e[606];
vector<int> re[606];
double dfs1(int u, pair<int, int> dame = make_pair(-1, -1))
{
  double &ret = dp[u];
  if (ret >= 0)
    return ret;
  ret = 0.0;
  double p = 1.0 / (e[u].size() - (dame.first == u));
  for (auto s : e[u])
  {
    if ((make_pair(u, s) != dame))
      ret += p * (dfs1(s, dame) + 1.0);
  }
  return ret;
}

void solve(long long N, long long M, std::vector<long long> s,
           std::vector<long long> t)
{
  rep(i, N) dp[i] = -1;
  dp[N - 1] = 0.0;
  vadd(s, -1);
  vadd(t, -1);
  map<int, map<int, int>> id;
  rep(i, M) e[s[i]].push_back(t[i]), re[t[i]].push_back(s[i]);
  rep(i, M) id[s[i]][t[i]] = i;

  coef[0] = 1.0;
  rep(i, N)
  {
    double p = 1.0 / e[i].size();
    for (auto s : e[i])
      coef[s] += p * (coef[i] + 1);
  }
  rep(i, N) dfs1(i);
  double ret = dp[0];
  vector<int> cand;
  rep(i, N)
  {
    double ma = -1;
    int idx = -1;
    for (auto s : e[i])
    {
      if (chmax(ma, dp[s]))
        idx = s;
    }
    if (idx >= 0 && e[i].size() > 1)
      cand.push_back(id[i][idx]);
  }
  for (auto j : cand)
  {
    rep(i, N - 1) dp[i] = -1.0;

    double tp = dfs1(0, make_pair(s[j], t[j]));
    if (tp > 0)
      chmin(ret, tp);
  }
  printf("%.10f\n", ret);
}
signed main()
{
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> s(M);
  std::vector<long long> t(M);
  for (int i = 0; i < M; i++)
  {
    scanf("%lld", &s[i]);
    scanf("%lld", &t[i]);
  }
  solve(N, M, std::move(s), std::move(t));
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2>
bool chmin(T1 &l, const T2 &r)
{
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2>
bool chmax(T1 &l, const T2 &r)
{
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2>
void vadd(vector<T1> &v, T2 x)
{
  for (auto &s : v)
    s += T2(x);
}


Measured memory_bytes: 18560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

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

int fac2(ll x){
  int count = 0;
  while(x%2 == 0){
    x>>=1;
    ++count;
  }
  return count;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;
  ll M;
  cin >> N >> M;

  vector<ll> v(N);
  rep(i,N)cin >> v[i],v[i] = v[i]/2;
  int fac20  = fac2(v[N-1]);
  rep(i,N-1){
    if(fac2(v[i]) != fac20){
      cout << 0 << endl;
      return 0;
    }
  }
  ll LCM = 1ll;
  rep(i,N){
    ll GCD = gcd(LCM,v[i]);
    LCM = LCM/GCD*v[i];
    if(LCM > M){
      cout << 0 << endl;
      return 0;
    }
  }
  ll num = M/LCM;
  cout << (num+1ll)/2ll << endl;
  return 0;
}


Measured memory_bytes: 1152
from collections import Counter
from math import factorial
N, A, B = map(int, input().split())
V = sorted(list(map(int, input().split())), reverse=True)

MAX_AVE = sum(V[:A]) / A
C = Counter(V)


def nCr(n, r):
    return int(factorial(n) / (factorial(r) * factorial(n - r)))


Ath_V = V[A - 1]
if Ath_V == max(V):
    ans = 0
    for r in range(A, min(B + 1, C[Ath_V] + 1)):
        ans += nCr(C[Ath_V], r)
    print(MAX_AVE)
    print(ans)

else:
    print(MAX_AVE)
    for i, v in enumerate(V):
        if v == Ath_V:
            used = i
            break
    print(nCr(C[Ath_V], A - used))


Measured memory_bytes: 3316
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

typedef long long i64;

int main()
{
	int n;
	vector<pair<int,int>> ta;

	scanf("%d", &n);
	ta.resize(n);
	for(int i = 0; i < n; ++i)
		scanf("%d%d", &ta[i].first, &ta[i].second);

	i64 x = 1, y = 1;

	for(int step = 0; step < n; ++step) {
		i64 rx = ta[step].first;
		i64 ry = ta[step].second;
		i64 cx = (x + rx - 1) / rx;
		i64 cy = (y + ry - 1) / ry;
		i64 c = max(cx, cy);
		x = rx * c;
		y = ry * c;
	}

	printf("%lld\n", x + y);

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////
double A,B,C;
double f(double t) {
    return A*t + B*sin(C*t*PI);
}
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int H,W,N,sr,sc; cin >> H >> W >> N >> sr >> sc;
    sr--; sc--;
    string S,T; cin >> S >> T;

    vector<vector<int>> check(N, vector<int>(4));
    check[N-1][0] = -1;
    check[N-1][1] = -1;
    check[N-1][2] = W;
    check[N-1][3] = H;
    vector<char> c = {'L','U','R','D'};
    bool ok = true;
    for (int i = N-1; i >= 0; i--) {
        if (i != N-1) {
            if (T[i] == c[0]) check[i][2] = min(check[i+1][2]+1,W);
            else check[i][2] = check[i+1][2];
            if (T[i] == c[1]) check[i][3] = min(check[i+1][3]+1,H);
            else check[i][3] = check[i+1][3];
            if (T[i] == c[2]) check[i][0] = max(check[i+1][0]-1,-1);
            else check[i][0] = check[i+1][0];
            if (T[i] == c[3]) check[i][1] = max(check[i+1][1]-1,-1);
            else check[i][1] = check[i+1][1];
        }
        rep(j,4) {
            if (S[i] == c[j]) {
                if (j < 2) check[i][j]++;
                else check[i][j]--;
            }
        }
        if (check[i][0]+1 == check[i][2] || check[i][1]+1 == check[i][3]) ok = false;
    }
    if (check[0][0] >= sc || check[0][1] >= sr || check[0][2] <= sc || check[0][3] <= sr) ok = false;

    cout << (ok ? "YES" : "NO") << endl;
}

Measured memory_bytes: 11544
#include <iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int i,a[5];
    for(i=0;i<5;i++){
        cin>>a[i];
    }
    sort(a,a+5);
    for(i=4;i>=0;i--){
        if(i==0)cout<<a[i];
      else  cout<<a[i]<<" ";
    }
    cout<<endl;
     return 0;
}

Measured memory_bytes: 3156
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
using namespace std;
int top, S[200];//?????¶??????top?????¨??\?????¨??°???????????´??´?????°???S
void push(int x)
{
	 top++;
	S[top] = x; //??\?????¶?????????????????°???
}
int pop()
{ 
	int x= S[top];
	top--;//????????¶??????????????°?????????????????????
	return x;
}
int main()
{
	int a, b;
	top = 0;//?????????
	int i = 0;
	char s[100];
	//cout << "---";
	while (scanf("%s",s)!=EOF)
	{

		if (s[0] == '+')
		{
			a = pop();

			b = pop();
	
			push(a + b);
		
		}
		else if (s[0] == '-')
		{
			b = pop();
		
			a = pop();
		
			push(a - b);
		
		}
		else if (s[0] == '*')
		{
			a = pop();
		
			b = pop();
		
			push(a*b);
		
		}
		else
		{
			push(atoi(s));

		}
		i++;
	}
	printf("%d\n", pop());
	return 0;

}

Measured memory_bytes: 2720
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(int i=1,i##_len=(n); i<=i##_len; ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for(int i=(s);i<(t);++i)
#define rng(obj) (obj).begin(), (obj).end()
#define maxs(x,y) (x=max((x),(y)))
#define mins(x,y) (x=min((x),(y)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T>>
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vp = vector<pii>;
template <class T> inline istream& operator>>(istream&i,v(T)&v)
{ rep(j,sz(v))i>>v[j];return i;}
template <class T> string join(const v(T)&v)
{ stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template <class T> inline ostream& operator<<(ostream&o,const v(T)&v)
{ if(sz(v))o<<join(v); return o;}
template <class T1,class T2> inline istream& operator>>(istream&i ,pair<T1,T2>&v)
{ return i>>v.fi>>v.se;}
template <class T1,class T2> inline ostream& operator<<(ostream&o ,pair<T1,T2>&v)
{ return o<<v.fi<<","<<v.se;}
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const double eps = 1e-10;
bool comp(pii a,pii b){
  return a.se<b.se;
}
//----------------------------------------------------------------

#define fileio ifstream fio; if(argc>=2){fio.open(argv[1]); std::cin.rdbuf(fio.rdbuf());}
#define fastio ios_base::sync_with_stdio(false);
#define MOD 1000000007
//----------------------------------------------------------------
void Main(){
  int n; cin>>n;
  unordered_map<int,int> m1,m2;
  rep(i,n){
    int v; cin>>v;
    if(i%2==0) m1[v]++;
    else m2[v]++;
  }
  pii p1 = *max_element(rng(m1),comp);
  pii p2 = *max_element(rng(m2),comp);
  if(p1.fi==p2.fi){
    if(comp(p1,p2)){
      m1[p1.fi]=0;  p1 = *max_element(rng(m1),comp);
    }else if(p1.se>p2.se){
      m2[p2.fi]=0;  p2 = *max_element(rng(m2),comp);
    }else{
      pii pk1 = p1, pk2 = p2;
      m1[p1.fi]=0;  p1 = *max_element(rng(m1),comp);
      m2[p2.fi]=0;  p2 = *max_element(rng(m2),comp);
      if(comp(p1,p2)){
        p1 = pk1;
      }else{
        p2 = pk2;
      }
    }
  }
  cout<<n-p1.se-p2.se<<endl;
} int main(int argc,char* argv[]){ 
    fastio; fileio; Main();}

Measured memory_bytes: 4376
use std::io::{BufReader, Read};

fn read() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s);
    s.trim().to_string()
}
fn main() {
    let s = read();
    let chars: Vec<char> = s.chars().collect();
    let mut stack: String = String::new();
    for i in 0..chars.len() {
        match chars[i] {
            'B' => {
                stack.pop();
                ()
            }
            ch @ _ => {
                stack.push(ch);
            }
        }
    }
    println!("{}", stack);
}


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

int main() 
{
    int n;
    cin >> n;
    vector<tuple<int,int,int>> v(n);
    int t0=0, x0=0, y0=0;
    bool z = true;
    for (int i=0; i<n; i++)
    {
        int t, x, y;
        cin >> t >> x >> y;
        int difft = abs(t-t0);
        int diffx = abs(x-x0);
        int diffy = abs(y-y0);
        int sumdiff = diffx + diffy;
        // cout << difft;
        if (sumdiff > difft)
            z = false;
        // cout << difft << " " << sumdiff << endl;
        if (sumdiff < difft)
        {
            if (difft%2==0 && sumdiff%2==1)
                z = false;
            if (difft%2==1 && sumdiff%2==0)
                z = false;
        }
        t0 = t;
        x0 = x;
        y0 = y;
    }
    // cout << z;
    cout << (z?"Yes":"No");
    return 0;
}

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

int main() {
	int N;
	long long K;
	cin >> N >> K;
	vector<long long> A(N);
	for (int i = 0; i < N; i++) cin >> A[i], A[i]--;
	vector<long long> X;
	vector<bool> B(N, false);
	X.push_back(0);
	B[0] = true;
	int NOW = 0;
	while (1) {
		NOW = A[NOW];
		if (B[NOW]) break;
		B[NOW] = true;
		X.push_back(NOW);
	}
	int P, Q;
	for (int i = 0; i < X.size(); i++) {
		if (X[i] == NOW) {
			P = i;
			break;
		}
	}
	Q = (int)X.size() - P;
	if (P > K) cout << X[K] + 1 << endl;
	else {
		cout << X[((K - P) % Q) + P] + 1 << endl;
	}
}

Measured memory_bytes: 6960
#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 < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() { int A, B;
  cin >> A >> B;
  if(10<=A+B){
    puts("error");
    return 0;
  }
  cout << A + B << endl;
  
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String input = "";
		String[] input_data = new String[3]; // 入力された中間、期末、再テストの得点を一時的にString型で格納する配列
		int MAX_DATA = 50;
		int data_count = 0;
		int m = 0; // 中間テストの得点
		int f = 0; // 期末テストの得点
		int r = 0; // 再テストの得点
		int sum = 0; // 中間テストと期末テストの合計の得点
		boolean judge = true; // 入力されたデータが条件範囲内に収まっているかを判定するための変数

		String[] output = new String[MAX_DATA];

		out: for (int i = 0; i < MAX_DATA; i++) {
			input = sc.nextLine();
			input_data = input.split(" ");
			sum = 0;
			m = Integer.parseInt(input_data[0]);
			f = Integer.parseInt(input_data[1]);
			r = Integer.parseInt(input_data[2]);

			// 入力の終わりを示しているのかのチェック
			if (m == -1 && f == -1 && r == -1) {
				break out;
			}

			// 中間試験の得点が条件範囲内に収まっているかのチェック
			if (m < -1 && m > 50) {
				judge = false;
				break out;
			}

			// 期末試験の得点が条件範囲内に収まっているかのチェック
			if (f < -1 && f > 50) {
				judge = false;
				break out;
			}

			// 再試験の得点が条件範囲内に収まっているかのチェック
			if (r < -1 && r > 100) {
				judge = false;
				break out;
			}
			data_count++; // 入力値に問題がなければデータを1つカウントする

			// 成績の判定
			sum = m + f;
			if (m == -1 || f == -1) {
				output[i] = "F";
			} else if (sum >= 80) {
				output[i] = "A";
			} else if ((sum >= 65 && sum < 80)) {
				output[i] = "B";
			} else if (sum >= 50 && sum < 65) {
				output[i] = "C";
			} else if (sum >= 30 && sum < 50) {
				output[i] = "D";
				if (r >= 50) {
					output[i] = "C";
				}

			} else {
				output[i] = "F";
			}

		} // out: for文ここまで
		if (judge == true) {
			for (int j = 0; j < data_count; j++) {
				System.out.println(output[j]);

			}
		}

	}
}



Measured memory_bytes: 26176
import sys
from collections import deque
import copy

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [long(input_raw[0])]
    A = []
    input_raw = read_func().strip().split()
    S = 0.0
    for i in range(N):
        A.append(int(input_raw[i]))
        S += int(input_raw[i])
    Ave = S/N

    min_err = float(sys.maxint)
    min_idx = 0
    for i in range(N):
        err = abs(A[i] - Ave)
        if err < min_err:
            min_err = err
            min_idx = i
    print min_idx



if __name__ == '__main__':
    main()

Measured memory_bytes: 2932
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

func min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}

func max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func newScanner(r io.Reader) *bufio.Scanner {
	return bufio.NewScanner(r)
}

func nextLine(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func newSplitScanner(r io.Reader) *bufio.Scanner {
	sc := bufio.NewScanner(r)
	sc.Split(bufio.ScanWords)
	return sc
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	//	str := `
	//3
	//28 27 24
	//`
	//	var sc = newSplitScanner(strings.NewReader(str))
	//
	var sc = newSplitScanner(os.Stdin)
	n := nextInt(sc)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
	}

	fmt.Println(solve(n, a))
}

func solve(n int, as []int) string {
	for _, v := range as {
		if v%2 != 0 {
			continue
		}
		if v%3 != 0 && v%5 != 0 {
			return "DENIED"
		}
	}
	return "APPROVED"
}


Measured memory_bytes: 640
//標準関数をすべてインクルードする。
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;

const int_least64_t INF = 10000000;

int main(){
    //cin coutを高速化
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout.tie(0);

    int n;
    cin >> n;
    vector<int> a(n);
    int sum = 0;

    rep(i, n){
        cin >> a[i];
        sum += a[i];
    }

    int mini = sum;
    int presum = 0;

    rep(i, n){
        presum += a[i];
        mini = min(mini, abs(presum - (sum - presum)));
    }

    cout << mini << endl;

    return 0;
}



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

int main() {
  ll r, g, b, n, cnt = 0;
  cin >> r >> g >> b >> n;
  rep(i, n / r + 1) rep(j, n / g + 1) {
    if ((n - r * i - g * j) % b == 0 && 0 <= (n - r * i - g * j)) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
n,m,c=map(int, input().split())
B=list(map(int, input().split()))
A=[]
for i in range(n):
    A.append(list(map(int, input().split())))
ans=0
for i in range(n):
    x=0
    for j in range(m):
        x+=A[i][j]*B[j]
    if x+c>0:
        ans+=1
print(ans)

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

using namespace std;
using ll=long long;


void solve() {
    ll x,y;
    cin >> x >> y;
    if (x<y) swap(x,y);
    bool res;
    res = x-y>1;
    cout << (res?"Alice":"Brown");
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

using namespace std;

char a[7],b[7];
int ans;

int main() {
	scanf("%s%s",a,b);
	for (int i=0; i<3; i++)
		ans+= (a[i]==b[i]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256