akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

//---------------------------------------------------------------
// ------ graph ------ //
using Weight = int;
using Flow = int;
struct Edge {
    int src, dst;
    Weight weight;
    Flow cap;
    Edge() : src(0), dst(0), weight(0) { }
    Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) { }
};
bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // pqが降順のため
        e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;
void add_edge1(Graph &g, int a, int b, Weight w = 1) {
    g[a].emplace_back(a, b, w);
}
void add_edge2(Graph &g, int a, int b, Weight w = 1) {
    g[a].emplace_back(a, b, w);
    g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) {
    g[a].emplace_back(a, b, w);
}
//---------------------------------------------------------------

vector<int> bfs(int src, Matrix &M) {
    int n = M.size();
    vector<int> dist(n, -1);
    queue<int> Q;
    dist[src] = 0;
    Q.push(src);
    while (!Q.empty()) {
        int cur = Q.front(); Q.pop();
        for (int nxt = 0; nxt < n; nxt++) {
            if (M[cur][nxt] && dist[nxt] < 0) {
                dist[nxt] = dist[cur] + 1;
                Q.push(nxt);
            }
        }
    }
    return dist;
}

int main() {
    int n; cin >> n;
    Matrix M(n, Array(n, 0));
    for (int i = 0; i < n; i++) {
        int u, k; cin >> u >> k;
        while (k--) {
            int v; cin >> v; M[u - 1][v - 1]++;
        }
    }
    vector<int> dist = bfs(0, M);
    for (int i = 0; i < n; i++) {
        cout << i + 1 << " " << dist[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3156
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define ll long long
#define P pair<int, int>
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
    
}
int main(){
    ll ans;
    ll K;
    cin >> K;
    ans = 0;
    for(int i = 1; i <= K; i++){
        for(int j = 1; j <= K; j++ ){
            for(int k = 1; k <= K; k++){
                ans += gcd(i, gcd(j, k));
            }
        }
    }
    cout << ans << endl;
    solve();
    return 0;
}



Measured memory_bytes: 3624
import sys
import math
import time
sys.setrecursionlimit(int(1e6))
if False:
    dprint = print
else:
    def dprint(*args):
        pass

N = list(map(int, input().split()))[0]
s = list(input())

w = 0
r = s.count('R')
min_op = max(w, r)
dprint('w, r = ', w, r)

p = 0
while(p < N):
    if (s[p] == 'W'):
        w = w + 1
    else: # (s[p] = 'R')
        r = r - 1
    min_op = min(min_op, max(w, r))
    dprint('p, w, r = ', p, w, r)
    
    p = p + 1

print(min_op)


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define INF 2000000000000000000LL
#define EPS 1e-9
#define debug(a) cerr<<#a<<"="<<(a)<<"\n"
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL);

typedef long long ll;
typedef unsigned long long ull;
typedef complex<double> cd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll mod = 998244353 ;
const double PI = acos(-1);

int n,i,j,k,t;
int a[3002];
ll dp[3002][3002];

ll solve(int st, int ed){
    ll &ans = dp[st][ed];
    if(ans == -1){
        if(st > ed)
            ans = 0;
        else{
            if(((ed-st)&1) == (n&1))
                ans = min(solve(st+1, ed) - a[st], solve(st, ed-1) - a[ed]);
            else
                ans = max(solve(st+1, ed) + a[st], solve(st, ed-1) + a[ed]);
        }
    }
    return ans;
}

int main(){
    memset(dp, -1, sizeof dp);
    scanf("%d", &n);
    for(i=0;i<n;++i)
        scanf("%d", a+i);
    // cout<<"masuk"<<endl;
    ll ans = solve(0, n-1);
    // cout<<"keluar"<<endl;
    printf("%lld\n", ans);
    return 0;
}

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

int main() {
	int n , k ;
	cin >> n >> k ;
	vector<pair<int,int>> v ;
	for(int i = 1 ; i < n ; i++){
		v.push_back({1,i+1}) ;
	}
	stack<pair<int,int>> st ;
	for(int i = 1 ; i < n ; i++){
		for(int j = i + 1 ; j < n ; j++) st.push({i+1,j+1}) ;
	}
	
	if(k <= st.size()){
		while(st.size() > k){
			v.push_back(st.top()) ;
			st.pop() ;
		}
		cout << v.size() << endl ;
		for(auto i : v){
			cout << i.first << ' ' << i.second << '\n' ;
		}
	}else{
		cout << -1 ;
	}
	return 0;
}


Measured memory_bytes: 384
package main

import "fmt"

func main() {
	var l, r int
	fmt.Scan(&l, &r)

	lap := min(l+(2019*2), r)
	ans := 2020

	for i := l; i <= lap; i++ {
		for j := i + 1; j <= lap; j++ {
			ans = min(((i%2019)*(j%2019))%2019, ans)
		}
	}

	fmt.Print(ans)
}

func min(i int, j int) int {
	if i < j {
		return i
	} else if i > j {
		return j
	}

	return i
}


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

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)


void func(long long N, std::vector<long long> X){
    double Avg = 0;
    rep(i,N) Avg += X[i];
    Avg /= N;

    long long a = Avg/1;
    if (Avg > a + 0.5) a +=1;
    long long ans = 0;
    rep(i,N) ans += (X[i] - a) * (X[i] - a);
    cout << ans << endl;
}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::vector<long long> X(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
    }
    func(N, std::move(X));
    return 0;
}


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

const ll M = 1000000007;

ll power(int m, int n){
    ll res = 1;
    if(n > 0){
        res = power(m, n/2);
        if(n % 2 == 0) res = (res * res) % M;
        else res = (((res*res)%M) * m) % M;
    }
    return res;
}

int main()
{
    int m, n; cin >> m >> n;
    cout << power(m, n) << endl;
}


Measured memory_bytes: 3112
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)

	for x := N; x < 1000; x++ {
		a := x % 10
		b := (x / 10) % 10
		c := (x / 100) % 10
		if a == b && b == c && a == c {
			fmt.Println(x)
			return
		}
	}
}


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

#define ll long long

using namespace std;

int M = 100'005;
int n;
vector<pair<int, int>> b;

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        b.push_back({a, i + 1});
    }
    sort(b.begin(), b.end());
    for (auto x : b)
        cout << x.second << " ";

    return 0;
}


Measured memory_bytes: 1780
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

class question {
public:
	int H, W;
	vector<vector<int>> A;
	int di[2] = { 1,0 };
	int dj[2] = { 0,1 };
	void dfs() {
		stack<P> st;
		st.push(P(0, 0));
		A[0][0] = 1;
		P prev;
		while (!st.empty()) {
			int i = st.top().first, j = st.top().second;
			if (i == H - 1 && j == W - 1) {
				A[H - 1][W - 1] = 1;
				return;
			}
			REP(k, 3) {
				if (k < 2) {
					int i0 = i + di[k], j0 = j + dj[k];
					if (i0 < H && j0 < W && !A[i0][j0]) {
						A[i0][j0] = 1;
						prev = P(i, j);
						st.push(P(i0, j0));
						break;
					}
				}
				else {
					A[i][j] = -1;
					return;
				}
			}
		}
	}
	void ans() {
		cin >> H >> W;
		A.resize(H, vector<int>(W));
		REP(i, H)REP(j, W) {
			char c;
			cin >> c;
			if (c == '.') A[i][j] = 1;
			else A[i][j] = 0;
		}
		dfs();
		string res = "Possible\n";
		REP(i, H)REP(j, W) {
			if (A[i][j] <= 0) res = "Impossible\n";
		}
		cout << res;
	}
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	question q;
	q.ans();
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++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(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

// 整数スキャン（複数）
/*
int x;
scanf("%d",&x);
int y;
scanf("%d",&y);
int z;
scanf("%d",&y);

// n個の整数のスキャン
/*
ll a[n] = {};
rep(i,n){
    scanf("%lld",&a[i]);
}
*/

// 文字列スキャン
/*
string s;
cin >> s;
*/


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



    int ans = 0;

    ans = n+1-i;

    cout << ans << endl;
   
    return 0;
}
 
 


Measured memory_bytes: 256
from collections import deque
d = deque()
n, quantum = map(int,input().split())
for i in range(n):
    n, t = input().split()
    d.append([n, int(t)])

total_flame = 0
while d:
    processing = d.popleft()
    if processing[1] <= quantum:
        print(processing[0], total_flame + processing[1])
        total_flame += processing[1]
    else:
        d.append([processing[0],processing[1]-quantum])
        total_flame += quantum


Measured memory_bytes: 13304
function last_zero_count(str) {
  n=0;
  for (hoge of str.split('').reverse()){if(hoge=='0'){n++;}if(hoge=='1'){break;}}
  return n;
}


function main(input) {
  const args = input.split("\n");
  const line_count = args[0];
  const numbers = args[1].split(' ')

  const zero_count_array = numbers.map(x => last_zero_count(parseInt(x).toString(2)));
  
  console.log(Math.min.apply(null, zero_count_array));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 8868
#include<iostream>
#include<queue>

using namespace std;

bool finish;
int set;
int* put;

int hasSet(int j, int *a)
{
    for (int i = 0; i < set; i++)
    {
        if (j == a[i])
        {
            return 1;
        }
    }
    return 0;
}
int isCorrect(int i, int j, int(*Q)[8])
{
    int s, t;
    for (s = i, t = 0; t < 8; t++)
        if (Q[s][t] == 1 && t != j)
            return 0;
    for (t = j, s = 0; s < 8; s++)
        if (Q[s][t] == 1 && s != i)
            return 0;
    for (s = i - 1, t = j - 1; s >= 0 && t >= 0; s--, t--)
        if (Q[s][t] == 1)
            return 0;
    for (s = i + 1, t = j + 1; s < 8 && t < 8; s++, t++)
        if (Q[s][t] == 1)
            return 0;
    for (s = i - 1, t = j + 1; s >= 0 && t < 8; s--, t++)
        if (Q[s][t] == 1)
            return 0;
    for (s = i + 1, t = j - 1; s < 8 && t >= 0; s++, t--)
        if (Q[s][t] == 1)
            return 0;

    return 1;
}

void Queue(int j, int(*Q)[8])
{
    int i, k;
    if (j == 8 && !finish) {
        finish = true;
        for (i = 0; i < 8; i++) {

            for (k = 0; k < 8; k++)
            {
                if (Q[i][k] == 1)
                    cout << "Q";
                else
                    cout << ".";
            }
            cout << endl;
        }
        return;
    }
    if (hasSet(j,put))
    {
        Queue(j + 1, Q);
    }
    else
    {
        for (i = 0; i < 8; i++) {
            if (isCorrect(i, j, Q)) {
                Q[i][j] = 1;
                Queue(j + 1, Q);
                Q[i][j] = 0;
            }
        }
    }
}

int main()
{
    cin >> set;
    int Q[8][8];
    for (int i = 0; i < 8; i++)
        for (int j = 0; j < 8; j++)
            Q[i][j] = 0;
    put = new int[set];
    for (int i = 0; i < set; i++)
    {
        int a, b;
        cin >> a >> b;
        Q[a][b] = 1;
        put[i] = b;
    }
    bool finish = false;
    Queue(0, Q);
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  string s, t, u;
  int a, b, c, d, n, m, x, y, z;

  cin >> n;
  cout << n*n*n << endl;
}


Measured memory_bytes: 892
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int modpow(ll a, ll n, ll p){
	if(n==0) return 1;
	if(n%2) return (a*modpow(a, n-1, p))%p;
	if(!(n%2)){
		ll t=modpow(a, n/2, p);
		return (t*t)%p;
	}
}

int main(){
  int N;
  cin >> N;
  int D[N]; ll cnt[N]={0};
  rep(i, N){
    cin >> D[i];
    cnt[D[i]]++;
  }
  ll ans = 1;
  bool can = true, zerokana=false;
  for(int i=1; i<N; i++){
    if(D[i]!=1) can=false;
    if(D[i]==0) zerokana=true;
  }
  if((zerokana) || D[0]!=0) cout << 0 << endl;
  else if(can) cout << 1 << endl;
  else{
    int maxcnt;
    rep(i, N){
      if(cnt[i]!=0) maxcnt=i;
    }
    for(int i=1; i<maxcnt; i++){
      ans *= modpow(cnt[i], cnt[i+1], 998244353);
      ans %= 998244353;
    }
    cout << ans << endl;
  }
  
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    ld t[N], v[N];
    rep(i, N) cin >> t[i];
    rep(i, N) cin >> v[i];
    //a[i]:=t[i-1]が終わった直後の速度
    ld a[N+1];
    a[0] = a[N] = 0;
    rep2(i, 1, N-1){
        a[i] = min(v[i-1], v[i]);
    }
    while(true){
        bool update = false;
        rep(i, N){
            if(abs(a[i+1]-a[i]) > t[i]){
                if(a[i+1] > a[i]) a[i+1] = a[i]+t[i];
                else a[i] = a[i+1]+t[i];
                update = true;
            }
        }
        if(!update) break;
    }
    ld ans = 0;
    rep(i, N){
        ld x = a[i]-a[i+1], tmp = 0;
        ld t1 = (t[i]-x)/2, t2 = (t[i]+x)/2, Mv = a[i] + t1;
        tmp += (a[i]+Mv)*t1/2 + (a[i+1]+Mv)*t2/2;
        if(Mv > v[i]){
            tmp -= (Mv-v[i])*(Mv-v[i]);
        }
        ans += tmp;
    }
    cout << sp(10) << ans << endl;
}

Measured memory_bytes: 256
s = input()
a = [0]*(len(s)+1)
for i in range(len(s)):
  if s[i]=="<":
    a[i+1]=a[i]+1
for i in range(len(s)-1,-1,-1):
  if s[i]==">":
    a[i]=max(a[i],a[i+1]+1)
print(sum(a))


Measured memory_bytes: 46320
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

const int N = 1e5+5;
vector<int> g[N];
ll dp[N][2];
int mod = 1e9+7;
bool hasCh[N];

void dfs(int u, int p){
    for(int v: g[u]){
        if(v == p)continue;
        hasCh[u] = true;
        dfs(v, u);
    }
}


ll f(int u, int p, int col){
    if(!hasCh[u])return 1;
    ll &ans = dp[u][col];
    if(ans != -1)return ans;
    ans = 1;
    for(int v: g[u]){
        if(v == p)continue;
        ll aux = 0;
        if(!col)aux = f(v, u, col);
        aux = (aux+f(v, u, !col))%mod;
        ans = (ans*aux)%mod;
    }
    return ans;
}

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

  int n, u, v;
  cin >> n;
  forn(i, 0, n-1){
      cin >> u >> v;
      u--,v--;
      g[u].pb(v);
      g[v].pb(u);
  }
  memset(dp, -1, sizeof dp);
  dfs(0, -1);
  ll ans = f(0, -1, 0);
  ans = (ans + f(0, -1, 1))%mod;
  cout << ans << endl;


}





Measured memory_bytes: 18908
#include <iostream>
#include <algorithm>
#include <queue>
#include <tuple>
#include <stack>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <numeric>

#define INF INT_MAX>>1 
#define SIZE 100001;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

typedef long long ll;

using namespace std;

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

int main(void){
	ll a, b, c, d; cin >> a >> b >> c >> d;
	a--;
	ll modc = b/c - a/c;
	ll modd = b/d - a/d;
	ll lcm = c*d / gcd(c, d);
	ll modcd = b/lcm - a/lcm;

	cout << (b-a) - modc - modd + modcd;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll N,K;
ll A[100000];
ll gcd (ll a, ll b){
    if (b==0) return a;
    return gcd(b, a%b);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N>>K;
    rep(i,0,N) cin>>A[i];
    if(N==1){
        if(A[0]==K) cout <<"POSSIBLE"<<"\n";
        else cout <<"IMPOSSIBLE"<<"\n";
    }
    else{
    ll m=max(A[0],A[1]);
    ll g=gcd(A[0],A[1]);
    rep(i,2,N){
        m=max(m,A[i]);
        g=gcd(g,A[i]);
    }
    if(m<K) cout <<"IMPOSSIBLE"<<"\n";
    else{
        if(K%g==0) cout <<"POSSIBLE"<<"\n";
        else cout <<"IMPOSSIBLE"<<"\n";
    }
    }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
std::vector<int>G[100010];
bool vis[100010],cxk[100010];
std::vector<int>A,B;
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n=gi(),m=gi(),a,b;
	for(int i=1;i<=m;++i)a=gi(),b=gi(),G[a].push_back(b),G[b].push_back(a);
	A.push_back(a),B.push_back(b);vis[a]=vis[b]=1;
	while(1){
		if(!cxk[a]){
			bool flg=1;
			for(int i:G[a])if(!vis[i]){vis[a=i]=1;A.push_back(a);flg=0;break;}
			if(flg)cxk[a]=1;
		}
		if(cxk[a]&&!cxk[b]){
			bool flg=1;
			for(int i:G[b])if(!vis[i]){vis[b=i]=1;B.push_back(b);flg=0;break;}
			if(flg)cxk[b]=1;
		}
		if(cxk[a]&&cxk[b])break;
	}
	printf("%d\n",A.size()+B.size());
	for(int i=A.size()-1;~i;--i)printf("%d ",A[i]);
	for(int i:B)printf("%d ",i);
	return 0;
}


Measured memory_bytes: 6904
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll int64_t
#define ull uint64_t
using namespace std;
using namespace std;

int main()
{
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    freopen("err.txt","w",stderr);
  #endif
  int n;
  cin>>n;
  vector<ll> si;
  if(n<=2)
  	{cout<<"0";return 0;}
  map<ll,int> mp; 
  for(int i=0;i<n;i++)
  {
  	ll temp;
  	cin>>temp;
  	mp[temp]++;
  }
  for(auto it=mp.begin();it!=mp.end();it++)
  {
  	si.push_back(it->first);
  }
  sort(si.begin(),si.end());
  int count = 0; 
    for (int i = n - 1; i >= 1; i--) { 
        int l = 0, r = i - 1; 
        while (l < r) { 
            if (si[l] + si[r] > si[i] && (si[i]!=si[r] && si[i]!=si[l] && si[l]!=si[r])) 
            { 
            	for(int k=l;k<r;k++)
            		count+=mp[si[k]]*mp[si[r]]*mp[si[i]];
                r--; 
            } 
            else
                l++; 
        } 
    } 
    cout<<count<<endl;
    return 0;
} 

Measured memory_bytes: 3632
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int main(void) {
    string s, t;
    cin >> s >> t;
    const int N = s.size(), M = t.size();

    set<char> sc, tc;
    for (int i=0;i<N;i++) {
        sc.insert(s[i]);
    }
    for (int j=0;j<M;j++) {
        if (sc.find(t[j]) == sc.end()) {
            cout << -1 << endl;
            return 0;
        }
    }
    ll ans = 0;
    string::size_type itr = -1;
    for (int j=0;j<M;j++) {
        itr = s.find(t[j],itr+1);
        if (itr == string::npos) {
            ans += (ll)N;
            itr = s.find(t[j],0);
        }
#ifdef DEBUG
        cout << t[j] << ": " << ans << " + " << itr << endl;
#endif
    }
    ans += (ll)itr;
    cout << ans+1LL << endl;

    return 0;
}


Measured memory_bytes: 640
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;
import java.util.regex.*;

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

    int H = scanner.nextInt();
    int W = scanner.nextInt();

    StringBuilder sb = new StringBuilder();
    for(int i=0;i<W+2;i++) {
      sb.append('#');
    }
    final String HEAD_FOOT = sb.toString();

    System.out.println(HEAD_FOOT);
    for(int i=0;i<H;i++) {
      System.out.print("#");
      System.out.print(scanner.next());
      System.out.println("#");
    }
    System.out.println(HEAD_FOOT);

    scanner.close();
  }
}


Measured memory_bytes: 21712
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,b,j;
    cin>>n;
    int a[n];
    for(i=1;i<=n;i++)
    {
        cin>>b;
        j=b-1;
        a[j]=i;

    }
    for(i=0;i<n;i++)
        cout<<a[i]<<" ";
    cout<<endl;
    return 0;

}


Measured memory_bytes: 1152
#include <iostream>                                          
#include <cstdio>                                            
using namespace std;                                         
                                                             
int main(void) {                                             
  while (true) {                                             
    int H,W;                                                 
    cin >> H >>W;                                            
    if (H==0 && W==0) {                                      
      break;                                                 
    }                                                        
    for (int i=0; i<H; i++) {                                
      for(int j=0; j<W; j++) {                               
        printf("#");                                         
      }                                                      
      printf("\n");                                          
    }                                                        
    printf("\n");                                            
  }                                                          
  return 0;                                                  
}                       

Measured memory_bytes: 3028
A, B, C, D = map(int, input().split())
max_cnt = B - A + 1
import fractions
lcm = int(C * D / fractions.gcd(C, D))
cnt_2 = B//C - (A-1)//C
cnt_3 = B//D - (A-1)//D
cnt_4 = B//lcm - (A-1)//lcm
print(max_cnt - cnt_2 - cnt_3 + cnt_4)

Measured memory_bytes: 5104
#include <iostream>
#include <vector>
#include <complex>
using namespace std;

#define X real()
#define Y imag()
#define EPS (1e-10)

typedef complex<double> P;
typedef P Vec;

double dot(Vec v1, Vec v2) {
  return (v1*conj(v2)).X;
}

double cross(Vec v1, Vec v2) {
  return (v1*conj(v2)).Y;
}

const int COUNTER_CLOCKWISE = 0,
  CLOCKWISE    = 1,
  ONLINE_FRONT = 2,
  ONLINE_BACK  = 3,
  ON_SEGMENT   = 4;

int ccw(P p0, P p1, P p2) {
  Vec a = p1 - p0;
  Vec b = p2 - p0;
  if(cross(a, b) > EPS) return CLOCKWISE;
  if(cross(a, b) < -EPS) return COUNTER_CLOCKWISE;
  if(dot(a, b) < -EPS) return ONLINE_BACK;
  if(norm(a) < norm(b)) return ONLINE_FRONT;
  return ON_SEGMENT;
}

void putResult(int x) {
  if(x == COUNTER_CLOCKWISE) cout << "COUNTER_CLOCKWISE" << endl;
  if(x == CLOCKWISE) cout << "CLOCKWISE" << endl;
  if(x == ONLINE_FRONT) cout << "ONLINE_FRONT" << endl;
  if(x == ONLINE_BACK) cout << "ONLINE_BACK" << endl;
  if(x == ON_SEGMENT) cout << "ON_SEGMENT" << endl;
}

int main() {
  double x, y;
  P p0, p1;
  
  cin >> x >> y; p0 = P(x, y);
  cin >> x >> y; p1 = P(x, y);
  
  int n;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> x >> y;
    P p2 = P(x, y);
    
    putResult( ccw(p0, p1, p2) );
  }
  
  return 0;
}

Measured memory_bytes: 1240
h, w = map(int,input().split())
a_complex = []
for i in range(h):
    a_row = list(input())
    a_complex+=[a_row]

#print(a_complex)
count = 0
for i in range(h):
    if not ("#" in a_complex[i-count]):
        del a_complex[i-count]
        count += 1
#print(a_complex)
ver = []
count = 0
for i in range(w):#列
    for j in range(len(a_complex)):  #行
        ver += [a_complex[j][i-count]]
    if not ("#" in ver):
        for u in range(len(a_complex)):
            del a_complex[u][i - count]
        count+=1
    ver = []
#print(a_complex)
for i in range(len(a_complex)):
    for j in range(len(a_complex[0])):
        print(a_complex[i][j], end="")
    print("")

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

int main()
{
    string S;
    cin>>S;
    for(int i=0;i<S.size();i++){
        bool j;
        j=(i%2==1 && S[i]=='R') || (i%2==0 && S[i]=='L');
        if(j){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}





Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;

class UnionFind {
public:
  UnionFind(int size) : par(size, -1) {}

  bool same(int x, int y) {
    return root(x) == root(y);
  }
  void unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return;
    if (x > y) { swap(x, y); }
    // here, x < y
    par[y] = x;
  }
  int root(int x) {
    if (par[x] < 0) {
      return x;
    } else {
      return par[x] = root(par[x]);
    }
  }

private:
  vector<int> par;
};

vector<int> cnt;
vector< vector<int> > tree;
vector<P> ans;

void dfs(int now, int p) {
  for (int x : tree[now]) {
    if (x != p) {
      dfs(x, now);
    }
  }

  if (now == 0) { return; } // Skip root

  if (cnt[now] % 2 == 0) { // even
    ans.push_back({ p + 1, now + 1 });
    ++cnt[p];
  } else { // odd
    ans.push_back({ now + 1, p + 1 });
    ++cnt[now];
  }

}

int main(int argc, char** argv) {
  int N, M;
  cin >> N >> M;
  if (M % 2 == 1) {
    cout << -1 << endl;
    return 0;
  }

  cnt.resize(N);
  tree.resize(N);

  UnionFind un(N);
  rep(i, M) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    if (un.same(a, b)) {
      ans.push_back({ a + 1, b + 1 });
      ++cnt[a];
    } else {
      un.unite(a, b);
      tree[a].push_back(b);
      tree[b].push_back(a);
    }
  }

  dfs(0, -1);
  for (auto e : ans) {
    cout << e.first << " " << e.second << endl;
  }
}


Measured memory_bytes: 14576
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		if ((N * A) <= B) {
			System.out.print(N * A);
		} else {
			System.out.print(B);
		}
	}
}


Measured memory_bytes: 21844
N = int(input())
W = list(map(int, input().split()))

total_sum = sum(W)
S1 = 0
ans = total_sum
for i in range(N):
    S1 += W[i]
    S2 = total_sum - S1
    if abs(S2 - S1) < ans:
        ans = abs(S2 - S1)

print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int X , Y ;
    cin >> X >> Y ;
    bool flag = false ;
    for(int i = 0 ; i < X + 1 ; i++){
        if(i * 4 + (X - i) * 2 == Y){
            flag = true ;
        }
    }
    if(flag == true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3604
#include<bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
#define mod 1000000007
int main() 
{  
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    

   int n,a,b;
   cin>>n>>a>>b;
   cout<<min(n*a,b);




    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define Endl endl
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
int dp[3141][3141];
signed main(){
	int n,t;
	cin>>n>>t;
	vector< pair<int,int> > fd;
	for(int i=0;i<n;i++){
		int a,b;
		cin>>a>>b;
		fd.pb(mp(a,b));
	}
	sort( fd.begin(), fd.end() );
	int ans = 0;
	for(int i=0;i<n;i++){
		for(int j=0;j<=t-1;j++){
			if( dp[i][j] + fd[i].second > ans ) ans = dp[i][j] + fd[i].second;
		}
		for(int j=0;j<=t-1;j++){
			if( j+fd[i].first <= t ){
				dp[i+1][j+fd[i].first] = max( dp[i+1][j+fd[i].first], dp[i][j] + fd[i].second );
			}
			dp[i+1][j] = max( dp[i+1][j], dp[i][j] );
		}
	}
	cout<<ans<<Endl;
	return 0;
}

Measured memory_bytes: 74112
n = int(input())
d = [26**i for i in range(15)]
for i in range(14):
    d[i+1] += d[i]
for i in range(14):
    if d[i]<=n<d[i+1]: break
ans = ""
a = ['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']

res = n-d[i]
for i in range(i+1):
    r = res//(26**i)
    ans += a[(r%26)]
print(ans[::-1])

Measured memory_bytes: 9144
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if (
  b-a<=k and c-a<=k and d-a<=k and e-a<=k and
  c-b<=k and d-b<=k and e-b<=k and 
  d-c<=k and e-c<=k and
  e-d<=k
):
  print("Yay!")
else:
  print(":(")
  

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

int main()
{
	int a;
	int r, l;

	while (cin >> a && (a != 0)){
		int rsum, lsum;
		rsum = 0;
		lsum = 0;
		for (int i = a; i > 0; i--){

			cin >> r;
			cin >> l;
			if (r > l){
				rsum += r + l;
			}
			else if (l > r){
				lsum += r + l;
			}
			else{
				rsum += r;
				lsum += l;
			}
		}
		cout << rsum << ' ' << lsum << endl;
	} 
}

Measured memory_bytes: 3096
import java.io.*;


public class Main{
  public static void main(String args[])throws Exception{
  BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
   String [] input = br.readLine().split(" ");
    int n= Integer.parseInt(input[0]);
    int k = Integer.parseInt(input[1]);
    int [] dl= new int[k];
    input = br.readLine().split(" ");
    for(int i=0;i<k;i++){
      dl[i] = Integer.parseInt(input[i]);
    }
    boolean istrue  = false;
    n--;
    do {
    	n++;
    	istrue=isLiked(n,dl);
    }while(istrue == false);
    System.out.println(n);
    
  }
public static boolean isLiked(int n,int []dl){
  char [] str = Integer.toString(n).toCharArray();
  for(int i=0;i<str.length;i++) {
	  for(int j=0;j<dl.length;j++) {
		  if(Integer.parseInt(Character.toString(str[i]))==dl[j]) {
			  return false;
		  }
	  }
  }
  return true;
}
  
}

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

int main(){
    int n;
    vector<int>  dp(3);
    cin>>n;

    for(int day=0; day<n; day++){
        vector<int> c(3);
        vector<int> new_dp(3,0);

        for(int i=0; i<3; i++)
            cin>>c[i];

        for(int i=0; i<3; i++){
            for(int j=0; j<3; j++){
                if(i != j){
                    new_dp[j] = max(new_dp[j], dp[i] + c[j]);
                }
            }
        }

        dp = new_dp;
    }
    cout<<max(dp[0], max(dp[1], dp[2]))<<endl;

}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;


public class Main {
	
	public static final int MAX = 123456;
	public static final int MAX_2 = MAX * 2;
	public static final int SQ = (int) (Math.ceil(Math.sqrt(MAX_2)));
	
	public static void main(String[] args) {
		int[] prime_count = new int[MAX_2 + 1];
		
		Arrays.fill(prime_count, 1);
		prime_count[0] = prime_count[1] = 0;
		
		for(int i = 0; i <= SQ; i++){
			if(prime_count[i] != 0){
				for(int j = 2 * i; j <= MAX_2; j += i){
					prime_count[j] = 0;
				}
			}
		}
		
		for(int i = 1; i <= MAX_2; i++){
			prime_count[i] += prime_count[i-1];
		}
		
		Scanner sc = new Scanner(System.in);
		
		while(true){
			final int n = sc.nextInt();
			
			if(n == 0){
				break;
			}
			
			System.out.println(prime_count[2*n] - prime_count[n]);
		}
		
		sc.close();
	}

}

Measured memory_bytes: 23336
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func min(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v < ret {
			ret = v
		}
	}
	return ret
}

func nextPermutation(a []int) bool {
	n := len(a)
	reverse := func(begin, end int) {
		for i := 0; i < (end-begin)/2; i++ {
			a[begin+i], a[end-1-i] = a[end-1-i], a[begin+i]
		}
	}
	for i := n - 2; i >= 0; i-- {
		if a[i] < a[i+1] {
			var j int
			for j = n - 1; a[i] >= a[j]; j-- {
			}
			a[i], a[j] = a[j], a[i]
			reverse(i+1, n)
			return true
		}
	}
	return false
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	N, M, R := nextInt(), nextInt(), nextInt()
	r := make([]int, R)
	for i := range r {
		r[i] = nextInt() - 1
	}
	sort.Sort(sort.IntSlice(r))
	cost := make([][]int, N)
	for i := range cost {
		cost[i] = make([]int, N)
		for j := range cost[i] {
			cost[i][j] = 1 << 60
		}
	}
	for i := 0; i < M; i++ {
		a, b, c := nextInt()-1, nextInt()-1, nextInt()
		cost[a][b], cost[b][a] = c, c
	}

	// ワーシャルフロイド
	for k := 0; k < N; k++ {
		for i := 0; i < N; i++ {
			for j := 0; j < N; j++ {
				cost[i][j] = min(cost[i][j], cost[i][k]+cost[k][j])
			}
		}
	}

	var ans int
	for i := 0; i < R-1; i++ {
		ans += cost[r[i]][r[i+1]]
	}
	// 順列全探索
	for nextPermutation(r) {
		x := 0
		for i := 0; i < R-1; i++ {
			x += cost[r[i]][r[i+1]]
		}
		ans = min(ans, x)
	}

	puts(ans)
}


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

using namespace std;

int main ()
{
  int a, b, c;
  cin >> a >> b >> c;
  int ans;
  ans = a - b - c;
  if(ans > 0)
    ans = 0;
  else
    ans = -ans;
  cout << ans << endl;
}


Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let s: Vec<char> = iterator.next().unwrap().chars().collect();
    let t: Vec<char> = "CODEFESTIVAL2016".chars().collect();

    let mut ans = 0;
    for i in 0..16 {
        if s[i] != t[i] {
            ans += 1;
        }
    }
    return ans.to_string();
}


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


int main(){
  long a, b, x,z;
  z = 0;
  cin >> a >> b >>x;
  long p, q;
  if(a%x==0)
    p = a;
  else
    p = x*(a/x+1);
  if (b % x == 0){
    q = b ;
  }
  else
  q = x*(b/x);
  cout << max((q-p)/x+1,z) << endl;
}


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

int main(){
	int t, s, e, r, n, m;
	string cntr;
	while(cin >> n, n != 0){
		r = 1;
		t = 1;
		s = 2;
		e = 3;
		for(int i = 1; i <= n; i++){
			cin >> cntr;
			m = t;
			if(cntr == "North"){
				t = s;
				s = 7-m;
			}
			else if(cntr == "East"){
				t = 7-e;
				e = m;
			}
			else if(cntr == "West"){
				t = e;
				e = 7-m;
			}
			else if(cntr == "South"){
				t = 7-s;
				s = m;
			}
			else if(cntr == "Right"){
				m = s;
				s = e;
				e = 7-m;
			}
			else if(cntr == "Left"){
				m = e;
				e = s;
				s = 7-m;
			}
			r += t;	
		}
		cout <<  r << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
import java.util.Scanner;

class Main {

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

        while (true) {
            int height = scan.nextInt();
            int width  = scan.nextInt();

            if (height == 0 && width == 0) {
                break;
            }

            writeRectangle(height, width);
        }
        scan.close();
    }

    public static void writeRectangle(int height, int width) {
        for (int i = 0; i < height; i++){
            switch (i % 2) {
            case 0:
                for (int j = 0; j < width; j++) {
                    switch (j % 2) {
                    case 0:
                        System.out.print("#");
                        break;

                    case 1:
                        System.out.print(".");
                        break;
                    }
                }
                break;

            case 1:
                for (int j = 0; j < width; j++) {
                    switch (j % 2) {
                    case 0:
                        System.out.print(".");
                        break;

                    case 1:
                        System.out.print("#");
                        break;
                    }
                }
                break;
            }
            System.out.println();
        }
        System.out.println();
    }

}

Measured memory_bytes: 36992
#include <iostream>
#define For(i,x,y) for(register int i=(x); i<=(y); i++)
using namespace std;
const int maxn=2e5+10;
int a[maxn];
int main()
{
    int n;
    cin>>n;
    For(i,2,n)
    {
        int t;
        cin>>t;
        a[t]++;
    }
    For(i,1,n)cout<<a[i]<<endl;
    return 0;
}


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

typedef int LONG;

LONG a[100010];

int main(void)
{
    int n, k;
    int i;
    LONG max;

    
    while (1){
        scanf("%d%d", &n, &k);
        if (n == 0 && k == 0){
            break;
        }
        
        memset(a, 0, sizeof(a));
        for (i = 1; i <= n; i++){
            scanf("%d", &a[i]);
        }
        
        for (i = 1; i <= n; i++){
            a[i] += a[i - 1];
        }
        max = a[k] - a[0];
        for (i = 1; i <= n - k + 1; i++){
//            printf("<%d>", a[i + k - 1] - a[i - 1]);
            if (max < a[i + k - 1] - a[i - 1]){
                max = a[i + k - 1] - a[i - 1];
            }
        }
        
        printf("%d\n", max);
    }
    return (0);
}

Measured memory_bytes: 996
package main

import "fmt"

func main() {
  var a, b int
  var ans1, ans2 int
  var ans3 float64

  fmt.Scan(&a, &b)
  
  ans1 = a / b
  ans2 = a % b
  ans3 = float64(a) / float64(b)

  fmt.Printf("%d %d %f\n", ans1, ans2, ans3)
}



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

int main() {
  int a[6];
  cin >> a[0] >> a[1];
  cin >> a[2] >> a[3];
  cin >> a[4] >> a[5];
  sort(a, a + 6);
  int co = 0;
  for(int i = 0; i < 4; i++) {
    if(a[i] == a[i+1] && a[i+1] != a[i+2]) co++;
  }
  if(co == 2) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  int H, W;
  cin >> H >> W;
  vector<string> s(H);
  REP(h,H) cin >> s[h];
  REP(w,W+2) cout << "#";
  cout << endl;
  REP(h,H){
    cout << "#";
    cout << s[h];
    cout << "#";
    cout << endl;
  }
  REP(w,W+2) cout << "#";
  cout << endl;
  
    return 0;
}

Measured memory_bytes: 3624
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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;}

const ll mod=1e9+7;

int main(){
    ll d;
    cin >> d;
    vector<pll> c;
    rep(i,26){
        ll t;
        cin >> t;
        c.push_back(make_pair(t,i+1));
    }
    vector<vector<pll>> s(d);
    rep(i,d){
        rep(j,26){
            ll v;
            cin >> v;
            s[i].push_back(make_pair(v,j+1));
        }
        sort(s[i].rbegin(),s[i].rend());
    }
    vector<ll> ans,used(26);
    ll tot=d;
    ll cnt=0;
    sort(c.rbegin(),c.rend());
    rep(i,d){
        //cout << ans[i] << endl;
    }
    vector<ll> per(26);
    rep(i,26){
        per[i]=i+1;
    }
    do{
        rep(i,26){
            ans.push_back(per[i]);
            cnt++;
            if(cnt==d) break;
        }
        if(cnt==d) break;
    }while(next_permutation(per.begin(),per.end()));
    rep(i,d){
        cout << ans[i] << endl;
    }
    return 0;
} 


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

string FMT_F = "%.10f";

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

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

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

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

void main()
{
	auto N = RD;
	long x;
	long pos;
	foreach (i; 0..N)
	{
		x += i+1;
		pos = i+1;
		if (x >= N)
			break;
	}
	long y = x - N;
	foreach (i; 0..pos)
	{
		if (i+1 == y) continue;
		writeln(i+1);
	}

	stdout.flush;
	debug readln;
}

Measured memory_bytes: 256