akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll A,B,C;
	while(cin>>A>>B>>C) {
		VI cs = {A,B,C};
		sort(ALL(cs));
		ll a=(cs[2]-cs[0])/2;
		ll b=(cs[2]-cs[1])/2;
//		DD(a);DD(b);DD(cs);
		ll rest = cs[2]-(cs[0]+2*a)+cs[2]-(cs[1]+2*b);
//		DD(rest);
		VI tb={0,2,1};
		ll ans=a+b+tb[rest];
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
n=int(input())

if n<=6:
    print(1)
elif n<=11:
    print(2)
else:
    count = (n//11)*2
    if n%11 == 0:
        print(count)
    elif n%11 <= 6:
        print(count+1)
    else:
        print(count+2)

Measured memory_bytes: 38384
s=input()
mae=s[0:2]
ushiro=s[2:]
if int(mae)==0:
    if 1<=int(ushiro)<=12:
        print("YYMM")
    else:
        print("NA")
elif int(ushiro)==0:
    if 1<=int(mae)<=12:
        print("MMYY")
    else:
        print("NA")
elif int(mae)<=12:
    if 1<=int(ushiro)<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif 1<=int(ushiro)<=12:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3064
import java.util.stream.*;
import java.io.*;

public class Main {

  static int n, pos, ansInp;
  static int[] pre, inp, post;

  static void reconstruction(int l, int r){
    if(l >= r) return;

    int c = pre[pos++], m = 0;
    for(; m < n; m++){
      if(inp[m] == c) break;
    }

    reconstruction(l, m);
    reconstruction(m+1, r);

    post[ansInp++] = c;
    return;
  }
  
  public static void main(String[] args) throws Exception {
    
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] in = br.readLine().split(" ");
    n = Integer.parseInt(in[0]);
    in = br.readLine().split(" ");
    pre = Stream.of(in).mapToInt(Integer::parseInt).toArray();
    in = br.readLine().split(" ");
    inp = Stream.of(in).mapToInt(Integer::parseInt).toArray();
    post = new int[n];

    br.close();

    pos = 0;
    ansInp = 0;
    reconstruction(0, n);

    for(int i = 0; i < n; i++){
      if(i > 0) System.out.print(" ");
      System.out.print(post[i]);
    }

    System.out.println();

  }
}


Measured memory_bytes: 30980
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
from collections import defaultdict
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N, P = map(int, readline().split())
    A = list(map(int, readline().split()))
    odd = 0
    even = 0
    for a in A:
        if a&1:
            odd += 1
        else:
            even += 1

    fact = [1, 1]
    for i in range(2, odd + 1):
        fact.append(fact[-1] * i)

    def nCr(n,r):
        return fact[n]//(fact[r]*fact[n-r])

    if P==0:
        tmp = 0
        for i in range(0, odd+1, 2):
            tmp += nCr(odd,i)
        ans = 2**even*tmp
    else:
        tmp = 0
        for i in range(1, odd+1, 2):
            tmp += nCr(odd,i)
        ans = 2**even*tmp

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9428
#include"bits/stdc++.h"
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(x) x.begin(),x.end()

using namespace std;
typedef long long ll;

template<typename T>
T gcd(T a, T b) {
	if (a % b == 0) {
		return(b);
	}
	else {
		return(gcd(b, a % b));
	}
}


template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}

int main(void) {
	ll n;
	cin >> n;
	vector<char>ans;
	while (n) {
		--n;
		ll a = n % 26;
		n /= 26;
		ans.push_back(char(a + 'a'));
	}
	for (ll i = ans.size() - 1; i >= 0; --i) {
		cout << ans[i];
	}
}

/*

*/


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
	string input;
	char data[16]={'q','w','e','r','t','a','s','d','f','g','z','x','c','v','b'};
	while(1){
		int ans=0;
		cin>>input;
		if(input=="#")break;
		bool key=false;
		for(int i=0;i<15;i++){
			if(data[i]==input[0])key=true;
		}
/*		if(key)cout<<"Left"<<endl;
		else cout<<"Right"<<endl;*/
		for(int i=1;i<input.length();i++){
			bool f=false;
			for(int j=0;j<15;j++){
				if(data[j]==input[i]){
					f=true;
				}
			}
/*			if(f)cout<<"Left"<<endl;
			else cout<<"Right"<<endl;*/
			if(f^key)ans++;
			key=f;
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1184
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
#include <map>
using namespace std;

const double PI=acos(-1);

int main(){
    int n, m;
    cin >> n;
    map<string, int> l;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        l[s]++;
    }
    cin >> m;
    for(int i = 0; i < m; i++){
        string s;
        cin >> s;
        l[s]--;
    }
    int max = 0;
    for(auto a : l){
        //cout << a.first << " : " << a.second << endl;
        if(a.second < 0) continue;
        else max = std::max(max, a.second);
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
    string s,r;
    cin>>s>>r;
    int c=0;
    for(int i=0;i<3;i++)
    {
        if(s[i]==r[i])
            c++;
    }
    cout<<c<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	string s;
	
	cin>>s;
	
	if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) cout<<"Bad"<<endl;
	else cout<<"Good"<<endl;
	
	
	return 0;
}

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

int N;


int main(){
	cin >> N;

	vector<int> A (N);
	vector<int> sA (N);

	for(int i = 0;i < N; i++){
		cin >> A[i];
		sA[i] = A[i];
	}
	sort(sA.begin(), sA.end());
	if(A == sA) {cout << "YES"; return 0;}
	//
	for(int i = 0; i < N; i++){
		for(int j = i+1; j < N; j++){
			swap(A[i], A[j]);
			if(A == sA) {cout << "YES"; return 0;}
			swap(A[i], A[j]);
		}
	}
	//
	cout << "NO";
	return 0;
}

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

const int MAX = 10005;
int V, E, s, t;
int indeg[MAX];
vector<int> G[MAX];
queue<int> S;//用于记录入度为0且未访问过的结点

void bfs(int u)
{
    for(int i=0; i<G[u].size(); i++)
    {
        if(!indeg[G[u][i]]) continue;
        indeg[G[u][i]]--;
        if(!indeg[G[u][i]])
        {
            S.push(G[u][i]);
        }
    }
}

void topologicalSort()
{
    int u;
    while(!S.empty())
    {
        u = S.front(); S.pop();
        printf("%d\n", u);
        bfs(u);//将u的邻接点的入度减一，若为0则入栈
    }
}

int main()
{
    memset(indeg, 0, sizeof(indeg));
    scanf("%d %d", &V, &E);
    for(int i=0; i<E; i++)
    {
        scanf("%d %d", &s, &t);
        indeg[t]++;
        G[s].push_back(t);
    }
    for(int i=0; i<V; i++)
    {
        if(!indeg[i])
            S.push(i);
    }
    topologicalSort();
    return 0;
}



Measured memory_bytes: 3948
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
struct edge {
    int to; 
    int weight;
    edge(int t, int w) : to(t),weight(w) {}
};
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;
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; }

int main(){

    int n,h; cin >> n >> h;
    vector<int> a(n),b(n);
    rep(i,n) cin >> a.at(i) >> b.at(i);
    sort(all(a));sort(all(b));
    reverse(all(a));reverse(all(b));
    ll cnt = 0;
    int i = 0;

    while(i < n && b.at(i) >= a.at(0)){
        h -= b.at(i);
        cnt++;
        i++;
        if(h <= 0) break;
    }
    while(h > 0){
        h -= a.at(0);
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = ~(1<<31);
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main(){
	string s,t;
	cin >> s >> t;
	cout << t << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

template<class T, class U>
void print(pair<T,U> &p){
    print(p.first, p.second);
}


int main(){
    ll n,a,b; cin >> n >> a >> b;
    if(a + b - 1 > n || a * b < n){
        cout << -1 << endl;
        return 0;
    }
    if(a == 1 || b == 1){
        vector<ll> ans(n);
        iota(all(ans), 1);
        if(b == 1){
            print(ans); 
            return 0;
        }
        reverse(all(ans));
        print(ans);
        return 0;
    }
    
    ll k = (n - b) / (a - 1);
    // if(a * k > n)k--;
    ll r = (n - b + 1) - k * (a - 1);
    debug(k);debug(r);
    vector<ll> ans;
    ll max_ = n;
    rep(i,k){
        for(int j = max_ - a + 1; j <= max_; j++)ans.emplace_back(j);
        max_ -= a;
    }
    if(max_ == 0){
        print(ans);
        return 0;
    }
    for(int i = max_ - r + 1; i <= max_; i++)ans.emplace_back(i);
    max_ -= r;

    debug(max_);

    while(max_){
        ans.emplace_back(max_);   
        max_--;
    }

    print(ans);
}

Measured memory_bytes: 6128
#include <iostream>
#include <vector>
#include <algorithm>
struct E {
    long long a, b;
};
int main() {
    int n, m;
    std::cin >> n >> m;
    std::vector<E> v(n);
    for (int i = 0; i < n; i++) std::cin >> v[i].a >> v[i].b;
    std::sort(v.begin(), v.end(), [](E &x, E &y){ return x.a < y.a; });
    long long count = 0, yen = 0;
    for (auto &e: v) {
        if (count + e.b >= m) {
            yen += (m - count) * e.a;
            break;
        }
        count += e.b;
        yen += e.a * e.b;
    }
    std::cout << yen;
}


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

int main(){
  int n;
  cin >> n;
  ll a[n], b[n];
  priority_queue<P> que;
  bool can = true;
  rep(i,n) cin >> a[i];
  rep(i,n) {
    cin >> b[i];
    if(a[i] > b[i]) can = false;
    que.push(P(b[i],i));
  }
  if(!can) {
    cout << -1 << endl;
    return 0;
  }
  ll d = 0;
  while(!que.empty()) {
    P p = que.top();
    que.pop();
    int l = (p.second-1+n) % n, r = (p.second+1) % n;
    ll s = b[l] + b[r];
    ll c = min(b[p.second]/s,(b[p.second]-a[p.second])/s);
    if(c != 0) {
      b[p.second] -= s*c;
      que.push(P(b[p.second],p.second));
      d += c;
    } 
  }
  rep(i,n) {
    if(a[i] != b[i]) can = false;
  }
  cout << (can? d : -1) << endl;
  return 0;
}

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

char str[1000005];
int a[1000005];
int b[1000005];

int memo[1005][1005];

int parity[1000005];

int x(int i, int j){
    if(i == 0){
        return a[j];
    }else if(memo[i][j] != -1){
        return memo[i][j];
    }else{
        return memo[i][j] = abs(x(i-1, j)-x(i-1, j+1));
    }
}

int calcFactPow2(int k){
    int ans = 0;
    while(k){
        k >>= 1;
        ans += k;
    }
    return ans;
}

int cnt[4];

int main(){
    int N;
    scanf("%d", &N);

    for(int i = 0; i < N; i ++){
        parity[i] = calcFactPow2(N-1) == calcFactPow2((N-1-i))+calcFactPow2(i);
        //printf("%d", parity[i]);
    }
    //printf("\n");

    scanf(" %s", str);

    for(int i = 0; i < N; i ++){
        a[i] = str[i]-'1';
    }

    if(N == 1){
        printf("%d", a[0]+1);
        return 0;
    }

    bool got2 = false;
    for(int i = 0; i < N; i ++){
        if(a[i] == 1){
            got2 = true;
            break;
        }
    }

    //memset(memo, -1, sizeof(memo));
    //printf("debug: %d\n", x(N-1, 0));

    if(!got2){
        for(int i = 0; i < N; i ++){
            if(a[i] == 2){
                a[i] = 1;
            }
        }
    }

    int ans = 0;
    for(int i = 0; i < N; i ++){
        ans += parity[i]*a[i];
    }
    printf("%d\n", (ans%2)*(2-got2));

    //for(int i = 0; i < 1; i ++){
        //random_shuffle(a, a+N);

    //}

    /*for(int i = 0; i < N; i ++){
        for(int j = 0; j < N-i; j ++){
            printf("%d", x(i, j));
        }
        printf("\n");
    }*/

    /*cnt[1] = 0;
    cnt[2] = 0;
    cnt[3] = 0;
    int ans = a[0];
    cnt[a[0]] ++;
    for(int i = 1; i < N; i ++){
        ans += cnt[1]*abs(a[i]-1) + cnt[2]*abs(a[i]-2) + cnt[3]*abs(a[i]-3);
        printf("debug %d: result=%d ans=%d\n", i, x(i, 0), ans);
    }*/

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


Measured memory_bytes: 10752
#include <stdio.h>
int main(){
	int n, x, min;
	scanf("%d%d",&n,&x);
	int m[n];
	for (int i = 0;i < n;i++){
		scanf("%d",&m[i]);
		x -= m[i];
		}
	min = m[0];
	for (int i = 1;i < n;i++){
		if (min > m[i])
		min = m[i];
		}
	x /= min;
	printf("%d",n + x);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;

  vector<int> prefs(M);
  vector<int> years(M);

  int p, d;
  for (int m = 0; m < M; m++) {
	cin >> p >> d;
	prefs[m] = p;
	years[m] = d;
  }

  vector<vector<int>> a(N, vector<int>(0));
  for (int i = 0; i < M; i++) {
	a[prefs[i]-1].push_back(years[i]);
  }

  for (int i = 0; i < N; i++) {
	sort(a[i].begin(), a[i].end());
  }

  for (int i = 0; i < M; i++) {
	auto itr = lower_bound(a[prefs[i]-1].begin(), a[prefs[i]-1].end(), years[i]);
	printf("%06d%06d\n", prefs[i], distance(a[prefs[i]-1].begin(), itr) + 1);
  }


  return 0;
}


Measured memory_bytes: 7808
n, m = map(int, input().split())

graph = [list() for i in range(n+1)]

for i in range(m):
    a, b = map(int, (input().split()))
    graph[a] += [b]
    graph[b] += [a]

for i in graph[1]:
    if n in graph[i]:
        print("POSSIBLE")
        exit()
        
print("IMPOSSIBLE")

Measured memory_bytes: 38320
#!/usr/bin/python

import re
import sys

def main(argv):
    line = sys.stdin.readline()
    while line:
        S = line.rstrip("\n")
        T = sys.stdin.readline().rstrip("\n")

        pattern = "(.*)("
        for t in T:
            pattern = "{0}(?:{1}|\?)".format(pattern, t)
        pattern = "{0}(.*))".format(pattern)
        regex = re.compile(pattern)
        match = regex.search(S)
        if match:
            print("{0}{1}{2}".format(match.group(1), T, match.group(3)).replace("?", "a"))
        else:
            print("UNRESTORABLE")

        line = sys.stdin.readline()

if __name__ == "__main__":
    main(sys.argv)

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

int main(){
	int sheet[101][101];
	int r, c;
	int sum;
	
	cin >> r >> c;
	for(int i = 0; i < r; i++){
		sum = 0;
		for(int j = 0; j < c; j++){
			cin >> sheet[i][j];
			sum += sheet[i][j];
		}
		sheet[i][c] = sum;
	}
	for(int i = 0; i <= c; i++){
		sum = 0;
		for(int j = 0; j < r; j++){
			sum += sheet[j][i];
		}
		sheet[r][i] = sum;
	}
	
	for(int i = 0; i <= r; i++){
		for(int j = 0; j <= c; j++){
			cout << sheet[i][j];
			if(j != c) cout << ' ';
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1196
n,y = map(int,input().split())
num = 0
for i in range(n+1):
    for k in range(n-i+1):
        if 10000*i + 5000 *k + 1000 * (n-i-k) == y:
            print(i,k,n-i-k)
            exit()
        else:
            pass
print('-1 -1 -1 ')


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int first = c / b, second = a / d;
  if (c % b != 0){
    first += 1;
  }
  if (a % d != 0){
    second += 1;
  }
  if (first <= second){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = LLONG_MAX;
const ll MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    ll h, n, w;
    cin >> N;
    for (h = 1; h <= 3500; ++h) {
        for (n = 1; n <= 3500; ++n) {
            if (4 * h * n - N * n - N * h != 0) {
                w = (N * h * n) / (4 * h * n - N * n - N * h);
                if (w > 0 && (N * h * n) % (4 * h * n - N * (n + h)) == 0) {
                    printf("%lld %lld %lld\n", h, n, w);
                    return 0;
                }
            }
        }
    }
    return 0;
}

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

int main() {

  int A1,A2,A3,Sum;
  cin>>A1>>A2>>A3;
  
 Sum=A1+A2+A3;
  
  if (Sum >= 22) { cout<<"bust"<<endl;} else {cout<<"win"<<endl;};

  
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX 100000000000000
using namespace std;
int main(void)
{
  int n, a[200000];
  long sum = 0, st = 0, mst = MAX;
  cin >> n;
  for(int i = 0; i != n; i++){
    cin >> a[i];
    sum += a[i];
  }
  for(int i = 0; i != n - 1; i++){
    st += a[i];
    long k = abs(sum - st * 2);
    if(k < mst) mst = k;
  }
  cout << mst << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<ll,ll>
#define INT_MAX 2147483647
#define MOD 1000000007
#define PI 3.14159265358979323846
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;

#define MAX 1000000000000


int main(void) {
	rep(i, 5) {
		int x; cin >> x;
		if (x == 0) {
			cout << i + 1 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define mod (long)(1e9 + 7)
using namespace std;

long dp[2][100001];

int main() {
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int n, k;
	cin >> n >> k;
	long a[n];
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	memset(dp, 0, sizeof dp);
	dp[1][0] = 1;
	for(int i = 0; i < n; ++i) {
		int curr = i & 1;
		vector<long> prefix;
		long sum = 0;
		for(int j = 0; j <= k; ++j) {
			sum = (sum + dp[curr ^ 1][j]) % mod;
			prefix.push_back(sum);
			if(j == 0) dp[curr][0] = 1;
			else {
				dp[curr][j] = (prefix[j] - (j - a[i] - 1 < 0 ? 0 : prefix[j - a[i] - 1]) + mod) % mod;
			}
			// cout<<dp[i][j] <<" ";
		}
		// cout<<endl;
	}
	cout<<dp[(n - 1)&1][k];
	return 0;
}

Measured memory_bytes: 6684
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<ctime>
using namespace std;

typedef long long ll;

bool debug = false;
const int NIL = -1;
const ll INF = 400000000000;
const int NUM = 101;
clock_t START, END;

ll G[NUM][NUM], v[NUM][NUM];

int main(void)
{
	if (debug) {
		START = clock();
		freopen("in44.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	}
	int V, E, s, t;
	ll d;
	bool negative = false;
	cin >> V >> E;
	for (int i = 0; i < E; i++) {
		cin >> s >> t >> d;
		G[s + 1][t + 1] = d;
		v[s + 1][t + 1]++;
	}
	for (int i = 1; i <= V; i++) {
		for (int j = 1; j <= V; j++) {
			if (!v[i][j]) {
					G[i][j] = INF;
			}
			if (i == j)
				G[i][j] = 0;
		}
	}
	for (int k = 1; k <= V; k++) {
		for (int i = 1; i <= V; i++) {
			for (int j = 1; j <= V; j++) {
				G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
			}
		}
	}
	for (int i = 1; i <= V; i++) {
		if (G[i][i] < 0) {
			negative = true;
			break;
		}
	}
	if (negative)
		cout << "NEGATIVE CYCLE" << endl;
	else {
		for (int i = 1; i <= V; i++) {
			for (int j = 1; j <= V; j++) {
				if (j - 1)
					cout << " ";
				if (G[i][j] > 200000000000)
					cout << "INF";
				else
					cout << G[i][j];
			}
			cout << endl;
		}
	}
	if (debug) {
		END = clock();
		double endtime = (double)(END - START) / 1000;
		printf("total time = %lf s", endtime);
	}
	return 0;
}


Measured memory_bytes: 3264
#include<bits/stdc++.h>
#define N 1000005
using namespace std;
const int mod=1e9+7;
int dp[N];
long long S;
int main(){
	int n;cin>>n;
	dp[1]=n;dp[2]=n*1LL*n%mod;
	S=dp[1]+dp[2];
	for(int i=3;i<=n;i++)
		dp[i]=((n-1)*1LL*n-(i-1-2)+S-dp[i-2])%mod,S+=dp[i];
	cout<<dp[n]<<endl;
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define bzero(p, n) memset(p, 0, n)
#define all(a) begin(a),end(a)
template<class T> inline void sort_uniq(T& c) { sort(ALL(c)); c.erase(unique(ALL(c)), c.end()); }
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
inline int powi(int x,int y) {int p=1; while(y--) p*=x; return p;}
inline ll powll(ll x,ll y) {ll p=1; while(y--) p*=x; return p;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}

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

    int N, M; cin >>N >>M;
    vector<pair<int, int>> PY(M);
    vector<int> PY_sorted_i(M);
    rep(i, M) {
        cin >> PY[i].first >> PY[i].second;
    }
    iota(all(PY_sorted_i), 0);
    sort(all(PY_sorted_i), [&](int a, int b) { return PY[a] < PY[b]; });

    map<pair<int, int>, int> x_map;
    int P_prev = -1;
    int x;
    rep(i, M) {
        const pair<int, int>& py = PY[PY_sorted_i[i]];
        //cout << FMT2(py.first, py.second) << endl;
        if (py.first != P_prev) {
            x = 1;
        } else {
            x++;
        }
        x_map.emplace(py, x);
        P_prev = py.first;
    }

    rep(i, M) {
        printf("%06d%06d\n", PY[i].first, x_map[PY[i]]);
        //cout << setw(6) << setfill('0') << PY[i].first  << setw(6) << setfill('0') << x_map[PY[i]] << endl;
    }
}


Measured memory_bytes: 8960
#include <iostream>
#include <string>

using namespace std;

int main() {
    string s;
    string t;

    cin >> s;
    cin >> t;
    
    //tの末尾の文字を削除
    t.pop_back();

    if (s == t) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;
typedef vector<map<lli,lli> > graph;

lli n;
graph g;
lli u,k,v,c;
priority_queue<pll,vector<pll>,greater<pll> > q;
vbl vis;
vll ans;

int main(){
    cin >> n;
    g = graph(n);
    for(lli i = 0;i < n;i++){
        cin >> u >> k;
        for(lli i = 0;i < k;i++){
            cin >> v >> c;
            g[u][v] = c;
        }
    }
    vis = vbl(n);
    ans = vll(n);
    q.push(pll(0,0));
    while(!q.empty()){
        lli d = q.top().first;
        lli p = q.top().second;
        q.pop();
        if(vis[p]) continue;
        vis[p] = true;
        ans[p] = d;
        for(auto itr = g[p].begin();itr != g[p].end();itr++){
            if(!vis[itr->first]) q.push(pll(d+itr->second,itr->first));
        }
    }
    for(lli i = 0;i < n;i++) cout << i << " " << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 38136
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << 1110 - n;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int>s(n);
    for(int i=0;i<n;i++)
    cin>>s[i];
    int q;
    cin>>q;
    vector<int>t(n);
    for(int i=0;i<q;i++)
        cin>>t[i];
    int cnt=0;
    for(int i=0;i<q;i++)
    {
        if(binary_search(s.begin(),s.end(),t[i]))
            cnt++;
    }
    cout<<cnt<<"\n";
    }



Measured memory_bytes: 3540
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define N 100010
#define LL long long
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
struct note{
	int to,next;
	LL val;
};note edge[N*2];
int tot,head[N];
int i,j,k,n,m,t,u,v,w;
int mx[N],siz[N],fa[N],dep[N],hv,hv0;
LL ans,kk;
int read(){
	int rs=0,fh=1;char ch;
	while((ch<'0'||ch>'9')&&(ch^'-'))ch=getchar();
	if(ch=='-')fh=-1,ch=getchar();
	while(ch>='0'&&ch<='9')rs=(rs<<3)+(rs<<1)+(ch^'0'),ch=getchar();
	return fh*rs;
}
void lb(int x,int y,LL z){
	edge[++tot].to=y;
	edge[tot].next=head[x];
	edge[tot].val=z;
	head[x]=tot;
}
void dg(int x){
	int i;
	siz[x]=1;
	for(i=head[x];i;i=edge[i].next)
	    if(fa[x]!=edge[i].to){
	    	fa[edge[i].to]=x;
	    	dg(edge[i].to);
	    	siz[x]+=siz[edge[i].to];
	    	mx[x]=mx[x]>siz[edge[i].to]?mx[x]:siz[edge[i].to];
		}
	mx[x]=mx[x]>n-siz[x]?mx[x]:n-siz[x];
	if(mx[hv]>mx[x])hv=x,hv0=0;else
	if(mx[hv]==mx[x])hv0=x;
}
void dg1(int x){
	int i;
	siz[x]=1;
	for(i=head[x];i;i=edge[i].next)
	    if(fa[x]!=edge[i].to){
	    	fa[edge[i].to]=x;
	    	dep[edge[i].to]=dep[x]+1;
	    	dg1(edge[i].to);
	    	siz[x]+=siz[edge[i].to];
	    	ans+=(LL)min(siz[edge[i].to],(n-siz[edge[i].to]))*edge[i].val;
		}
}
int main(){
	n=read();
	fo(i,1,n-1){
		u=read(),v=read(),w=read();
		lb(u,v,w);
		lb(v,u,w);
	}
	mx[0]=2147483647;
	dg(1);
	memset(fa,0,sizeof(fa));
	dg1(hv);
	if(hv&&hv0){
		for(i=head[hv];i;i=edge[i].next)
		    if(edge[i].to==hv0){
		    	kk=edge[i].val;
		    	break;
			}
	}else{
		kk=2147483647;
		for(i=head[hv];i;i=edge[i].next)
		    kk=kk<edge[i].val?kk:edge[i].val;
	}
	ans*=2;
	printf("%lld",ans-kk);
	return 0;
}

Measured memory_bytes: 9344
#pragma region

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++)
#define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long long>>;
using vvb = vector<vector<bool>>;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &pair) {
  cin >> pair.first >> pair.second;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

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

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

void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(16);
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

int main() {
  init();

  double A, B, H, M;
  cin >> A >> B >> H >> M;

  out(sqrt(A * A + B * B - 2 * A * B * cos((H + M / 60.0) * M_PI / 6.0 - M * M_PI / 30.0)));
}


Measured memory_bytes: 4232
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#define N 200

int A[N];
int top;

void initialize(){
	top = 0;
}

int isEmpty(){
	return top == 0;
}

int isFull(){
	return top >= N-1;
}

void push(int a){
	if(isFull()){
		printf("error\n");
	}else{
		top++;
		A[top] = a;
	}
}

int pop(){
	if(isEmpty()){
		printf("error\n");
	}else{
		top--;
		return A[top+1];
	}
}

int main(){
	char c;
	int x;
	int tmp;

	while ((c=getchar())!=EOF){
                if (isdigit(c)){
                        ungetc(c, stdin);
                        scanf("%d", &x);
                        push(x);
                }
                else{
                    switch(c) {
                        case '+':
                        	push(pop()+pop());
                            break;
                        case '-':
                        	tmp = pop();
							push(pop() - tmp);
							break;
                        case '*':
                        	push(pop()*pop());
                        	break;
                        case ' ':
                        	break;
                        case '\n':
                        	break;
                        default:
                        	printf("no input\n");
                        	break;
                    }
                }
    }

	printf("%d\n",pop());
}

Measured memory_bytes: 1852
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int A,B;

signed main(){
	cin>>A>>B;
	for(int i=1;i<=1000000;i++){
		int d1=((double)i*0.08);
		int d2=((double)i*0.10);
		if(d1==A&&d2==B){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}


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

int main() {
  int a;
  cin>>a;
  if(a<1200){
    cout<<"ABC"<<endl;
  }
  else if(a<2800){
    cout<<"ARC"<<endl;
  }
  else{
    cout<<"AGC"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    ll a, b, c;
    cin >> a >> b >> c;
    cout << max(0LL, c - max(0LL, a - b)) << endl;
    return 0;
}


Measured memory_bytes: 256
// ====================================
    //   author: M_sea
    //   website: https://m-sea-blog.com/
    // ====================================
    #include <bits/stdc++.h>
    #define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
    #define debug(...) fprintf(stderr,__VA_ARGS__)
    using namespace std;
    typedef long long ll;
     
    int read() {
    	int X=0,w=1; char c=getchar();
    	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    	return X*w;
    }
     
    template<typename T>
    void chkmax(T& x,T y) { if (y>x) x=y; }
     
    const int N=100+10;
     
    int n,W,w[N],v[N];
    int dp[N][N][N*3];
     
    int main() {
    	n=read(),W=read();
    	for (int i=1;i<=n;++i) w[i]=read(),v[i]=read();
    	memset(dp,0xc0,sizeof(dp)); dp[0][0][0]=0;
    	for (int i=0;i<n;++i)
    		for (int j=0;j<=i;++j)
    			for (int k=0;k<=3*j;++k) {
    				chkmax(dp[i+1][j][k],dp[i][j][k]);
    				chkmax(dp[i+1][j+1][k+w[i+1]-w[1]],dp[i][j][k]+v[i+1]);
    			}
    	int ans=0;
    	for (int i=0;i<=n;++i)
    		for (int j=0;j<=3*i;++j)
    			if (1ll*i*w[1]+j<=W) ans=max(ans,dp[n][i][j]);
    	printf("%d\n",ans);
    	return 0;
    }

Measured memory_bytes: 19348
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  ll x,sum=0;
  cin >> x;
  sum += 2*(x/11);
  x %= 11;
  if(x>6){
    sum += 2;
  }else if(x>0){
    sum += 1;
  }
  cout << sum << endl;
}


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

template<class like_bool> inline void YES(like_bool condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class like_bool> inline void Yes(like_bool condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class like_bool> inline void POSS(like_bool condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class like_bool> inline void Poss(like_bool condition){ if(condition)cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class like_bool> inline void First(like_bool condition){ if(condition)cout << "First" << endl; else cout << "Second" << endl; }
template<class like_bool, class output> inline void negative(like_bool condition, output num){ if(condition)cout << -1 << endl; else cout << num << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
long gcd(long a, long b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
#define mod long(1e9 + 7)
#define bitcount(n) __builtin_popcount(n)

int main(){
    int x, y;
    cin >> x >> y;
    cout << gcd(x, y) << endl;
}




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

#define ll long long
#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define repr(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back
#define debug(x) cout << x << endl;
#define END cout << endl;
#define sorti(x) sort(x.begin(), x.end())

ll dp[100010];
int n;

int main() {
  cin >> n;
  vector<int> h(n);
  rep(i,n) cin >> h[i];

  ll ans = 0;
  dp[0] = 0, dp[1] = abs(h[0] - h[1]);
  for (int i = 2; i < n; ++i) {
    dp[i] = min(dp[i-1] + abs(h[i-1] - h[i]), dp[i-2] + abs(h[i-2] - h[i]));
  }
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
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 dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int main(){
  int n,m;  cin >> n >> m;
  string s[n], t[m];
  rep(i,0,n){
    cin >> s[i];
  }
  rep(i,0,m){
    cin >> t[i];
  }
  rep(i,0,n)rep(j,0,n){
    bool ok = true;
    if(i+m-1<n && j+m-1<n){
      rep(i2,0,m)rep(j2,0,m){
        if(t[i2][j2] != s[i+i2][j+j2]){
          ok = false;
          break;
        }
      }
      if(ok){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


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

int main(int argc, char** argv) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if (argc == 2 && atoi(argv[1]) == 123456789)
        freopen("d:\\code\\cpp\\stdin", "r", stdin);

    int n;
    cin >> n;

    vector<int> v(n);
    for(int i=0; i<n; i++)
        cin >> v[i];

    map<int, int> h0, h1;
    for(int i=0; i<n; i++){
        if (i%2){
            h1[v[i]]++;
        } else
            h0[v[i]]++;
    }

    vector<pii> v0, v1;
    for(auto it : h0){
        v0.push_back(make_pair(-it.second, it.first));
    }
    v0.push_back(make_pair(0,-1));
    sort(v0.begin(), v0.end());
    for(auto it : h1){
        v1.push_back(make_pair(-it.second, it.first));
    }
    v1.push_back(make_pair(0,-1));
    sort(v1.begin(), v1.end());

    if (v0[0].second == v1[0].second){
        cout << min(n + v1[1].first + v0[0].first, n + v1[0].first + v0[1].first) << endl;
    } else
        cout << n + v1[0].first + v0[0].first << endl;
    return 0;
}


Measured memory_bytes: 6524
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    while(true) {
        int n, m; cin >> n >> m;
        if (n==0 && m==0) break;
        map<int, int> taro, hanako;
        int taro_total = 0, hanako_total = 0;
        rep(i, n) {
            int x; cin >> x;
            taro[x]++;
            taro_total+=x;
        }
        rep(i, m) {
            int x; cin >> x;
            hanako[x]++;
            hanako_total+=x;
        }

        int dif = taro_total - hanako_total;
        if (dif%2 != 0) {
            cout << -1 << endl;
            continue;
        }

        dif /= 2;
        if (dif<0) {
            dif *= -1;
            bool ok = false;
            for(const auto t: taro) {
                int num = t.first;
                if (hanako.count(num+dif)) {
                    cout << num << " " << num+dif << endl;
                    ok = true;
                    break;
                }
            }
            if (!ok) cout << -1 << endl;
        } else {
            bool ok = false;
            for(const auto t: hanako) {
                int num = t.first;
                if (taro.count(num+dif)) {
                    cout << num+dif << " " << num << endl;
                    ok = true;
                    break;
                }
            }
            if (!ok) cout << -1 << endl;
        }
    }
}


Measured memory_bytes: 3080
s = input()

idx = 0
ans = [0 for _ in range(len(s))]

if s.find('R') == -1:
    ans[0] = len(s)
elif s.find('L') == -1:
    ans[len(s)-1] = len(s)
else:
    while(idx<=len(s)-1):
        lr_idx = idx
        if s[idx] == 'R':
            lr_idx = s.find('L', idx)
        elif s[idx] == 'L':
            lr_idx = s.find('R', idx)

        
        num = lr_idx - idx

        if s[idx] == 'R':
            if lr_idx == -1:
                ans[len(s)-1] += len(s) - idx
            else:
                ans[lr_idx] += num//2
                ans[lr_idx-1] += num//2
                if num%2 == 1:
                    ans[lr_idx-1] += 1

        elif s[idx] == 'L':
            if lr_idx == -1:
                num = len(s) - idx
            if idx>0:
                ans[idx] += num//2
                ans[idx-1] += num//2
                if num%2 == 1:
                    ans[idx] += 1
            else:
                ans[0] += num
                
        idx = lr_idx
        if lr_idx == -1:
            break

for i in ans:
    print(i, end=' ')

      

Measured memory_bytes: 4976
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <locale>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const long long int INF = 1e9;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

struct Point{
	int x,y;
};

bool vector_finder(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
    }
  else { // 発見できなかったとき
    return false;
    }
}

ll factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
    }
    return ans;
}

ll extended_factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
        ans %= (ll)(1e9+7);
    }
    return ans;
}

vector<ll> Eratosthenes(ll N){
    bool arr[N+1];
    //initialization
    arr[0] = false;
    arr[1] = false;
	for(ll i = 2; i < N+1; i++){
		arr[i] = true;
	}
    //eratosthenes
	for(ll i = 2; i <= sqrt(N); i++){
		if(arr[i]){
			for(ll j = 0; i * (j + 2) <= N; j++){
				arr[i *(j + 2)] = false;//not prime number
			}
		}
	}
    vector<ll> prime;
    llRep(i,N){
        if (arr[i]==true){
            prime.push_back(i);
        }
    }
    return prime;
}

ll gcd(ll a, ll b){
  ll temp;
	while (a % b != 0){
		temp = b;
		b = a % b;
		a = temp;
	}
	return b;
}

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

char alphabet[] = {
    'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'
};


int main(){
    ll N;
    cin  >> N;
    if (N==1){
        cout << 0 << endl;
        return 0;
    }
    cout << N*(N-1) /2<< endl;
    return 0;
}


Measured memory_bytes: 256