akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <functional>
#include <stack>
#include <utility>
#include <map>
#include <queue>
#include <set>
#include <array>
#include <climits>

using namespace std;

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

const ll MOD = 10e9 + 7;
const ll INF = LLONG_MAX;
const ll MAX_V = 10e3;
const double EPS = 10e-6;
const double PI = 3.14159265359;

//int dx[] = { 0,1,0,-1 }, dy[] = { 1,0,-1,0 };
//int d[] = {0,1,0,-1};
//int nx = x + d[i];
//int ny = y + d[(i+1)%4]


int main() {
	int n, ans = 0;
	string s[300], t[600];
	cin >> n;
	for (int i = 0; i < n; i++)cin >> s[i];
	for (int i = 0; i < n; i++) {
		t[i] = s[i] + s[i];
		t[i + n] = s[i] + s[i];
	}
	for (int a = 0; a < n; a++) {
			bool flag = false;
			for (int i = 0; i < n; i++) {
				for (int j = i + 1; j < n; j++) {
					if (t[i][a + j] != t[j][a + i]) {
						flag = true;
						break;
					}
				}
				if (flag)break;
			}
			if (!flag)ans += n;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
let _ =
    let [a; b] = List.map int_of_string (Str.split (Str.regexp " ") (read_line ())) in
    if a mod 3 = 0 || b mod 3 = 0 || (a+b) mod 3 = 0 then print_string "Possible"
    else print_string "Impossible"

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned ui;
typedef unsigned long long ul;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<int> vi;
#define pb push_back
#define fi first
#define se second
#define do(i, j, k) for(int i = j; i <= (k); i ++)
#define open(i, j, k) for(int i = j; i < (k); i ++)
#define dec(i, j, k) for(int i = j; i >= (k); i --)
#define mfil(x, k) memset(x, k, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
#define fio(x) freopen(x".in", "r", stdin); freopen(x".out", "w", stdout)
template <class T> bool chkmin(T &x, T y)
{ return y < x ? (x = y, true) : false; }
template <class T> bool chkmax(T &x, T y)
{ return y > x ? (x = y, true) : false; }
struct __init { __init()
{
    ios::sync_with_stdio(false); cin.tie(0);
    cout.precision(16); cout << fixed;
    srand(time(0) ^ ul(new char));
} } static __init__;
/* default code ends here */

int n;
ll a, b, c, d;

void yes()
{
    cout << "YES\n";
    exit(0);
}
void no()
{
    cout << "NO\n";
    exit(0);
}

int main()
{
    cin >> n >> a >> b >> c >> d;
    n --;
    if(a < b)
        swap(a, b);
    a -= b;
    for(int i = n & 1; i <= n; i += 2)
    {
        if(a - i * c >= 0 && a - i * d <= 0)
            yes();
        if(min(abs(a - i * c), abs(a - i * d)) <= (d - c) * (n - i) / 2)
            yes();
    }
    no();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N,M;
int a[50],b[50],c[50],d[50];
main()
{
    cin>>N>>M;
    for(int i=0;i<N;++i){
        cin>>a[i]>>b[i];
    }
    for(int i=0;i<M;++i){
        cin>>c[i]>>d[i];
    }
    for(int i=0;i<N;++i){
        int p=0,v=1<<30;
        for(int j=0;j<M;++j){
            long nv=abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(nv<v){
                p=j;
                v=nv;
            }
        }
        cout<<p+1<<endl;
    }
}

Measured memory_bytes: 3596
#include <fstream>
#include <iostream>

// BE CAREFUL WITH HASH TABLE & UNORDERED MAP
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;

#define MOD 998244353
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = (b-1); i >= (a); i--)
#define RF0(i,b) RFO(i,0,b)
#define ll long long
#define pll pair<ll,ll>
#define add(a,b) ((int) (((lli) (a) + (b))%MOD))
#define mul(a,b) ((int) (((lli) (a) * (b))%MOD))
#define PB emplace_back
#define F first
#define S second

// ifstream cin ("cinput.in");
// ofstream cout ("coutput.out");

ll A1, A2, B1, B2, T1, T2;

// Helper Functions

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
    pll A = make_pair(T1*A1+T2*A2, T1*A1);
    pll B = make_pair(T1*B1+T2*B2, T1*B1);
    ll diff = max(A,B).F - min(A,B).F;
    if (!diff) cout << "infinity\n";
    else {
        ll ans = 0;
        if (min(A,B).S > max(A,B).S) {
            ans++;
            ll diff2 = min(A,B).S - max(A,B).S;
            ans += 2ll * (diff2/diff);
            if (!(diff2%diff)) ans--;
        }
        cout << ans << '\n';
    }
}

Measured memory_bytes: 3652
def calc(N, H):
    result = 0
    r = 0
    for i in range(1, N):
        if (H[i] <= H[i - 1]):
            r += 1
        else:
            result = max(result, r)
            r = 0
    return max(result, r)


N = int(input())
H = [int(s) for s in input().split()]
print(calc(N, H))

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define fastio (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long int;
using namespace std;

int main() {
    fastio;
    string s;
    cin >> s;
    cout << 700 + (int)count(s.begin(), s.end(), 'o') * 100;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,pair<int,int>>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/

int n, k, a[1111];
vector<int>v;
signed main() {
	cin >> n >> k;
	rep(i, n)cin >> a[i];
	rep(i, n) {
		int sum = 0;
		for (int j = i; j < n; j++) {
			sum += a[j]; v.push_back(sum);
		}
	}
	int ans = 0;
	for (int i = 60; i >= 0; i--) {
		vector<int>memo;
		for (int p : v) {
			if ((p >> i) & 1)memo.push_back(p);
		}
		if (memo.size() >= k) {
			v = memo;
			ans += (int)1 << i;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 6512
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<cstring>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
const int maxn = 5e5 + 5;
const int inf = 0x3f3f3f3f;
int main() {
    int n;
    cin>>n;
    vector<int>a(n+1);
    for(int i=1;i<=n;i++)
        cin>>a[i];
    int minn=inf,maxx=0;
    for(int i=1;i<=n;i++)
    {
        minn=min(a[i],minn);
        maxx=max(a[i],maxx);
    }
    int ans=inf;
    for(int i=minn;i<=maxx;i++)
    {
        int sum=0;
        for(int j=1;j<=n;j++)
        {
            sum+=(a[j]-i)*(a[j]-i);
        }
        ans=min(ans,sum);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)

int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  
  int n,m;
  cin>>n>>m;
  vector<int> a(n);
  vector<int> b(m);
  rep(i,n)
    cin>>a[i];  
  rep(i,m)
    cin>>b[i];
  
  int res = 0;
  
  rep(i,m){
    int cnt = 0;
    rep(j,n){
      int k = i + cnt;
      if(b[k] == a[j]){
        cnt++;
      }
      if(cnt > m - i + 1)
        break;
    }
    res = max(res,cnt);
  } 
  
  cout<<res<<endl;
}

Measured memory_bytes: 1232
#include <stdio.h>
int main(void){
	int A,B;
	int a,b,i;
	scanf("%d %d", &A,&B);
	
	for(i=1;i<1010;i++){
		a=i*0.08;
		b=i*0.1;
		if(A==a && B==b){
			printf("%d",i);
			return 0;
		}
	}
	
	printf("%d",-1);
	
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用

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

	ull a, b, c, d;
	cin >> a >> b >> c >> d;


	ull ans = 0;
	ans += ((b / c) * (c - 1) + b % c) - (((a-1) / c) * (c - 1) + (a-1) % c);
	ans += ((b / d) * (d - 1) + b % d) - (((a-1) / d) * (d - 1) + (a-1) % d);

	ull tmp;
	ull tmp2 = c;
	ull tmp3 = d;
	if (c < d) {
		tmp = c;
		c = d;
		d = tmp;
	}

	ull r = c % d;
	while (r!=0)
	{
		c = d;
		d = r;
		r = c % d;
	}

	ull x = tmp2 * tmp3 / d;

	ans -= ((b / x) * (x - 1) + b % x) - (((a-1) / x) * (x - 1) + (a-1) % x);

	cout << ans << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		//?§????????????????S?????????
		int time = sc.nextInt();
		//h??????
		int hour = time / 60 / 60;
		//??????
		int minutse = time / 60 % 60;
		//s?§?
		int second = time % 60;
		//???????????¨???
		System.out.println(hour+ ":"+ minutse + ":" + second);

	}
}

Measured memory_bytes: 26324
#include <bits/stdc++.h>
using namespace std;
constexpr double PI = atan2(0, -1);
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, L;
    cin >> n >> L;
    double x = 0, y = 0;
    vector<int> t(n);
    for (int i = 0; i < n; ++i)
        cin >> t[i];
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            x += cos(PI * (t[i] + t[j]) / L) * (i + n - j - 1 - (j - i - 1));
            y += sin(PI * (t[i] + t[j]) / L) * (i + n - j - 1 - (j - i - 1));
        }
    }
    x /= 1.0 * n * (n - 1) * (n - 2) / 6;
    y /= 1.0 * n * (n - 1) * (n - 2) / 6;
    cout << setprecision(10) << fixed << x << " " << y << "\n";
    return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>


using namespace std;


int main() {
    int a,b;
    cin >> a >> b;
    if ((a+b)%2==1) {
        std::cout << (a + b) / 2 + 1 << '\n';
    }
    if ((a+b)%2==0) {
        std::cout << (a + b) / 2 << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
 
#define M 1000007
#define L 14
 
char H[M][L]; /* Hash Table */
 
int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}
 
/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}
 
int h1(int key){ return key%M; }
int h2(int key){ return (1+key)%(M-1); }
 
int find(char str[]){
  long long trip; 
  int i = 0;
  long long sum = getKey(str);
  
  while(1){
    trip = (h1(sum)+ i * h2(sum)) % M;
    if(strcmp(H[trip], str) == 0) return 1;
    if(H[trip][0] == '\0') return 0;
    i++;
  }
  return 0;
}
 
int insert(char str[]){
  int i = 0;
  long long ago;
  long long sum = getKey(str);
   
  while(1){
    ago = (h1(sum)+ i * h2(sum)) % M;
    if(H[ago][0] == '\0' || strcmp(H[ago],str) == 0){
      strcpy(H[ago], str);
      break;
    }
    i++;
  }
}
 
int main(){
  int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
     
    scanf("%d", &n);
     
    for ( i = 0; i < n; i++ ){
      scanf("%s %s", com, str);
       
      if ( com[0] == 'i' ){
    insert(str);
      } else {
    if (find(str)){
      printf("yes\n");
    } else {
      printf("no\n");
    }
      }
    }
     
    return 0;
}



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

typedef long long ll;
#define int ll
const int inf = 1e18;


signed main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	

	string s,t;
	cin>>s>>t;
	for(int i=0;i<s.size();i++){
		if (s[i] != t[i]){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";


	return 0;


}



Measured memory_bytes: 3612
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
struct Node{
    int x;
    int y;
}a[100005];
int n,m,ans,du[100005],h[100005],f[100005];
vector<int>v[100005],k[100005];
queue<int>q;
int main(){
    in(n);in(m);
    for(int i=1;i<=m;i++){
        in(a[i].x);in(a[i].y);
        v[a[i].x].push_back(a[i].y);
        k[a[i].y].push_back(a[i].x);
        du[a[i].y]++;
    }
    for(int i=1;i<=n;i++)if(du[i]==0)q.push(i),h[++h[0]]=i;
    while(!q.empty()){
        int l=q.front();
        q.pop();
        for(int i=0;i<v[l].size();i++){
            int u=v[l][i];
            du[u]--;
            f[u]=max(f[u],f[l]+1);
            if(du[u]==0){
                q.push(u);
                h[++h[0]]=u;
            }
        }
    }
    for(int i=1;i<=n;i++)ans=max(ans,f[i]);
    printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 13184
#include <stdio.h>
#include <string.h>
#include <string>
#include <iostream>
#include <array>

int main(void)
{
	std::string s;
	std::cin >> s;

	auto N = s.size();
	std::array<int,100000 + 1> k;

	std::fill(k.begin(), k.end(),0);

	int i, r, l, j;
	int r_w, l_w, esp;
	int c = 0;
	r = l = i = 0;

	while (i != N) {

		r = l = 0;
		while (s[i + r] != 'L')	r++;
		(r_w = i + r - 1), (l_w = i + r);

		while (s[i + r + l] != 'R')
		{
			l++;
			if (i + r + l == N) break;
		}

		i = i + r + l;
		k[r_w] += r / 2;

		if (r % 2 == 1)k[r_w]++;
		k[l_w] += r - k[r_w];

		esp = k[l_w];

		k[l_w] += l / 2;
		if (l % 2 == 1) k[l_w]++;
		k[r_w] += l - k[l_w] + esp;

	}
	for (i = 0; i < N - 1; i++)	std::cout << k[i] << " ";
	std::cout << k[N - 1];

	return 0;
}


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

// 最大公約数
ll gcd(ll a, ll b){
	if(b == 0) return a;
	return gcd(b, a%b);
}

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	
	vector<int> left(n-1);
	vector<int> right(n-1);
	left[0] = a[0];
	right[0] = a[n-1];
	
	for(int i=1; i<n-1; i++){
		left[i] = gcd(left[i-1],a[i]);
		right[i] = gcd(right[i-1],a[n-1-i]);
	}
	
	vector<int> m(n);
	rep(i,n){
		if(i==0) m[i] = right[n-2];
		else if(i==n-1) m[i] = left[n-2];
		else m[i] = gcd(left[i-1], right[n-2-i]);
	}
	
	sort(m.begin(), m.end());
	cout << m.back() << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cmath>
using namespace std;
int main(){

  int m,n,v,m2,n2;
  double rad,S1,S2;
  
  while(1){
    
    cin >>m;
    
    if(m == 0)break;
    
    S1=0;
    S2=0;
    m2=360;
    n2=360;
    
    for(int i=0 ; i < m-1 ; i++){
      cin >>v;
      m2-=v;
      rad=v*(M_PI/180);
      S1+=sin(rad)/2;
    }
    
    rad=m2*(M_PI/180);
    S1+=sin(rad)/2;
    
    cin >>n;
    
    for(int i=0 ; i < n-1 ; i++){
      cin >>v;
      n2-=v;
      rad=v*(M_PI/180);
      S2+=sin(rad)/2;
    }
    
    rad=n2*(M_PI/180);
    S2+=sin(rad)/2;
    
    if(fabs(S1-S2) < 10e-8 ){
      cout <<"0"<<endl;
    }else if ( S1 > S2 ){
      cout <<"1"<<endl;
    }else{
      cout <<"2"<<endl;
    }
    
  }
  
  return 0;
}

Measured memory_bytes: 1188
import java.io.*;
import java.util.Scanner;

public class Main{
               public static void main(String args[]) throws IOException{
                     int W = 0;
                     int H = 0;
                     int x = 0;
                     int y = 0;
                     int r = 0;

                     Scanner in = new Scanner(System.in);
                     
                     String buf1 = in.next();
                     String buf2 = in.next();
                     String buf3 = in.next();
                     String buf4 = in.next();
                     String buf5 = in.next();
                     
                     W = Integer.parseInt(buf1);
                     H = Integer.parseInt(buf2);
                     x = Integer.parseInt(buf3);
                     y = Integer.parseInt(buf4);
                     r = Integer.parseInt(buf5);

                     if(r <= x && x <= W-r && r <= y && y <= H-r){
                          System.out.println("Yes");
                     }else{
                          System.out.println("No");
                     }

            }
   }

Measured memory_bytes: 26168
#include<stdio.h>
int main(){
	long int s;
	int a,b,c;
	while(scanf("%d",&a)!=EOF){
		s=0;
		b=600/a;
		for(c=0;c<b;c++){
			s+=a*a*a*c*c;
		}
		printf("%ld\n",s);
	}
	return 0;
}

Measured memory_bytes: 596
#include<stdio.h>

#define MAX 300
#define MIN 1

int main(void)
{
	int height, width;
	
	while(1)
	{
		if( scanf("%d %d", &height, &width)==2 )
		{
			if((height==0) && (width==0))
			{
				break;
			}
			else if((height>=MIN) && (height<=MAX) &&
				(width>=MIN) && (width<=MAX))
			{
				for(int i=0; i<height; i++)
				{
					for(int j=0; j<width; j++)
					{
						if( ((i%2==0) && (j%2==0)) ||
							((i%2==1) && (j%2==1)) )
						{
							printf("%c", '#');
						}
						else
						{
							printf("%c", '.');
						}
					}
					printf("\n");
				}
				printf("\n");
			}
			else
			{
				return -1;
			}
		}
		else
		{
			return -1;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1748
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
using namespace std;
#define ll long long
int main(){
	ll N;
	deque < string > deq;
    string s;
    cin >> s;
    ll i;
    for(i=0;i<s.size();i++){
        deq.push_back(s.substr(i,1));
    }
    ll tmp;
    ll r=0;
    ll Q,f;
    cin >> Q;
    for(i=0;i<Q;i++){
        cin >> tmp;
        if(tmp==1){
            r=(r+1)%2;
        }
        if(tmp==2){
            cin >> f;
            cin >> s;
            if((r+f)%2==0)deq.push_back(s);
            if((r+f)%2==1)deq.push_front(s);
        }
    }
    string ans;
    if(r==0){
        for(auto itr=deq.begin();itr!=deq.end();++itr){
            cout << *itr;
        }
    }
    if(r==1){
        for(auto itr=deq.rbegin();itr!=deq.rend();++itr){
            cout << *itr;
        }
    }
    return 0;
}


Measured memory_bytes: 17280
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
typedef unsigned long long ull ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define rrep(i , n) for ( int i = n-1; i >=0 ; i--)

#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

class UnionFind {
private:
	ull size_; 
	std::vector<ull> par, rank, count;

public:
	UnionFind() : size_(0), par(std::vector<ull>()), rank(std::vector<ull>()), count(std::vector<ull>()) {};
	UnionFind(ull size__) : size_(size__) {
		par.resize(size_); rank.resize(size_); count.resize(size__);
		for (ull i = 0; i < size_; i++) par[i] = i, rank[i] = 0, count[i] = 1;
	}
	ull size() { return size_; }
	// ull root(ull x) { return par[x] == x ? x : par[x] = root(par[x]); }
	
	ull root(ull x)
	{
		while(par[x] != x)
		{
			par[x] = par[par[x]];
			x = par[x];
		}
		return x;
	}
	
	bool same(ull x, ull y) { return root(x) == root(y); }

	void unite(ull x, ull y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y, count[y]+=count[x], count[x]=0;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++, count[x]+=count[y], count[y]=0;
		else par[y] = x, count[x] += count[y], count[y] = 0;
	}

	ull size__(ull x)
	{
		return count[root(x)];
	}

	bool operator==(const UnionFind &u) { return par == u.par; }
	bool operator!=(const UnionFind &u) { return par != u.par; }
};
/*
maybe sth wrong 
got wa in one problem
*/
ll modpow(ll a, ll b)
{
	if (b == 0)
	{
		return 1;
	}

	if (b % 2)
	{
		return a * modpow(a, b-1) % MOD;
	}
	else
	{
		ll halfB = b / 2;
		ll half = modpow(a, halfB);
		return half * half % MOD;
	}
}

ll calcComb(ll n, ll m)
{
	if (m > n-m)
	{
		return calcComb(n, n-m);
	}

	ll ansMul = 1;
	ll ansDiv = 1;

	rep(i, m)
	{
		ansMul *= (n-i);
		ansDiv *= (i+1);
		ansMul %= MOD;
		ansDiv %= MOD;
	}

	return ansMul * modpow(ansDiv, MOD - 2) % MOD;
}

__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}


int main()
{
	int H, W, N;
	
	cin >> H >> W >> N;

	int a[N];
	rep(i, N)
	{
		cin >> a[i];
	}

	int id = 0;
	rep(i, H)
	{
		vector<int> c;
		rep(j, W)
		{
			c.pb(id+1);
			a[id]--;
			if (a[id] == 0)
			{
				id++;
			}
		}

		if (i & 0x01)
		{
			reverse(c.begin(), c.end());
		} 
		rep(k, W)
		{
			cout << c[k] << " ";
		}
		cout << endl;
	}

	
	return 0;
}


Measured memory_bytes: 384
from collections import deque

n, q = map(int, input().split())
dist = [[] for i in range(n)]
for i in range(n - 1):
    a, b = map(int, input().split())
    dist[a - 1].append(b - 1)
    # aftercontest対策
    dist[b - 1].append(a - 1)
value = [0 for i in range(n)]

# 1つ目の[1, 10]と2つ目の[1, 10]混ぜても問題なし
for i in range(q):
    p, x = map(int, input().split())
    value[p - 1] += x
#  重複を防ぐ
ignore = [0] * n
ignore[0] = 1

pos = deque([0])
# 上から順に自身のvalueの値を子のvalueに加算していく
# value [100, 10, 1, 0]
# pos.popleft() = 1 → [100, 10 + 100, 1 + 100, 0 + 100]
# pos.popleft() = 2 → [100, 110, 101 + 10, 100 + 10]
while len(pos) > 0:
    u = pos.popleft()
    for i in dist[u]:
        if ignore[i] == 0:
            ignore[i] = 1
            value[i] += value[u]
            pos.append(i)
# 覚える
print(*value)


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

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

    int H, W;
    string s = "";
    while(1){
        cin >> H >> W;
        if(H == 0 and W == 0) break;
        else{
            for(int i = 0; i < H; i++){
                for(int j = 0; j < W; j++){
                    if(i == 0 or i == H - 1){
                        s += "#";
                    }else{
                        if(j == 0 or j == W - 1){
                            s += "#";
                        }else{
                            s += ".";
                        }
                    }
                }
                cout << s << endl;
                s = "";
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3136
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cassert>
#include<ctime>
using namespace std;

#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define absd(x) (x<0?-(x):x)
#define pow2(x) ((x)*(x))
#define rep(i,n) for(int i=0; i<n; ++i)
#define repr(i,n) for(int i=n-1; i>=0; --i)
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define replr(i,s,n) for(int i=n; i>=s; --i)
#define repf(i,s,n,j) for(int i=s; i<=n; i+=j)
#define repe(e,obj) for(auto e : obj)

#define SP << " " <<
#define COL << " : " <<
#define COM << ", " <<
#define ARR << " -> " <<
#define PNT(STR) cout << STR << endl
#define POS(X,Y) "(" << X << ", " << Y << ")"
#define DEB(A) " (" << #A << ") " << A
#define DEBREP(i,n,val) for(int i=0; i<n; ++i) cout << val << " "; cout << endl
#define ALL(V) (V).begin(), (V).end()
#define INF 1000000007
#define INFLL 1000000000000000007LL
#define EPS 1e-9

typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define P_TYPE int
typedef pair<P_TYPE, P_TYPE> P;
typedef pair<P, P_TYPE> PI;
typedef pair<P_TYPE, P> IP;
typedef pair<P, P> PP;
typedef priority_queue<P, vector<P>, greater<P> > pvqueue;

int main() {
  int n;
  while(cin >> n && n) {
    set<int> s;
    repl(x, 1, n-1) {
      s.insert(x*x % n);
    }
    vector<int> c((n-1)/2+1);
    repe(a, s) {
      repe(b, s) {
        if(a == b) continue;
        if(a < b) {
          c[mind(b - a, n + a - b)]++;
        } else {
          c[mind(a - b, n + b - a)]++;
        }
      }
    }
    repl(x, 1, (n-1)/2) {
      cout << c[x] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3368
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,an;
	cin>>n>>an;
	for(int x=0;x<=n;x++)
	{
		for(int y=0;y<=n-x;y++)
		{
			int z=n-x-y;
			if(10000*x+5000*y+1000*z==an)
			{
				printf("%d %d %d\n",x,y,z);
				return 0;
			}
		}
	}
	printf("-1 -1 -1\n");
	return 0;
}

Measured memory_bytes: 256
<?php
//error_reporting(0);
$N = trim(fgets(STDIN));
//list($N,$K) =  explode(" ",trim(fgets(STDIN)));
//$B = explode(" ",trim(fgets(STDIN)));

if ($N == 'Sunny') {
  printf("Cloudy\n");
  exit;
}
if ($N == "Cloudy") {
  printf("Rainy\n");
  exit;
}
if ($N == "Rainy") {
  printf("Sunny\n");
  exit;
}


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

int A[100010], cnt[100010];

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int N, K, Q;

	cin >> N >> K >> Q;
	for(int i = 0; i < Q; i++) cin >> A[i];

	for(int i = 0; i < Q; i++) cnt[A[i]]++;

	for(int i = 1; i <= N; i++) cout << (Q - cnt[i] >= K ? "No" : "Yes") << "\n";
	return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vi p(n);
    rep(i,n){
        int a; cin>>a;
        p[a-1]++;
    }
    sort(all(p));
    vi sum(n+1,0);
    rep(i,n) sum[i+1]=sum[i]+p[i];
    FOR(k,1,n){
        int l=0, r=n/k+1; //L OK, R NG
        while(r-l>1){
            int mid = (l+r)/2;
            auto itr = lower_bound(all(p),mid);
            ll val = sum[itr-p.begin()]+(p.end()-itr)*mid;
            if (val>=mid*k){
                l = mid;
            }else{
                r = mid;
            }
        }
        cout<<l<<endl;
    }
    return 0;
}


Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a == b && b == c) System.out.println("Yes");
        else System.out.println("No");
        sc.close();
    }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)
#define ll long long
#define ld long double
#define MAX (int)(2*pow(10,5)+10)
#define pb(a) push_back(a)
// #define cout out
// #define cin in
ll inf = pow(10,9);
ll INF = inf;
ll modulo = pow(10,9)+7;
double eps = 1e-10;
ifstream in;
ofstream out;


ll pow_mod(ll a, ll b){
	a = a%modulo;
	ll mx = 0;
	ll has = 1;
	for(ll i = 62; i>-1; i--){
		has*=has;
		has%=modulo;
		if(((ll)1<<i)&b)
			has*=a, has%=modulo;
	}
	return has;
}

ll inv(ll a){
	return pow_mod(a,modulo-2);
}

ll fkt[MAX];
 
void pre(){
	fkt[0] = 1;
	for(ll i = 1; i<MAX; i++)
		fkt[i] = (fkt[i-1]*i) % modulo;
}

ll kmb(ll i , ll j){
	if(i<j)
		return 0;
	return fkt[i] * inv(fkt[j]) % modulo * inv(fkt[i-j]) % modulo;
}

void display(vector<ll>& all){
	fori(all.size())
		cout<<all[i]<<' ';
	cout<<endl;
}

void deal(){
	pre();
	ll w,b;
	cin>>b>>w;
	ll n = b+w;
	vector<ll> dpw(n+1,0), dpb(n+1, 0), dpn(n+1, 0), dpt(n+1, 0); // at exactly i : whites have ended, blacks "" "" , neither "" "" , total number of ways to come to i 
	{
		ll sum = 0;
		for(ll i = 1; i<=n; i++){
			dpb[i] = kmb(i, b) - sum;
			dpb[i] = (dpb[i]%modulo + modulo) % modulo;
			sum += dpb[i];
			sum %= modulo;
		}
	}
	{
		ll sum = 0;
		for(ll i = 1; i<=n; i++){
			dpw[i] = kmb(i, w) - sum;
			dpw[i] = (dpw[i]%modulo + modulo)%modulo;
			sum += dpw[i];
			sum %= modulo;
		}
	}
	{
		ll nei = 1;
		dpn[0] = nei;
		for(ll i = 1; i<=n ; i++){
			nei*=2;
			nei%=modulo;
			nei-=dpw[i];
			nei-=dpb[i];
			nei = (nei%modulo + modulo)%modulo;
			dpn[i] = nei;
		}
		dpn[n] = 0;
	}
	{
		ll sum  = 0;
		for(ll i = 1; i<=n ; i++){
			if(i != n)
				sum+=(dpw[i] + dpb[i]);
			sum%=modulo;
			dpt[i] = (dpn[i] + sum) % modulo;
		}
	}
/*
	cout<<"blacks ending "<<endl;
	display(dpb);
	cout<<"whites ending "<<endl;
	display(dpw);
	cout<<"neither ending "<<endl;
	display(dpn);
	cout<<"total "<<endl;
	display(dpt);
*/	{
		ll sum = 0;
		for(ll i =1; i<=n; i++){
			ll cur = sum + dpn[i-1]*inv(pow_mod(2,i));
			cur%=modulo;
			cout<<cur<<'\n';
			sum+=dpw[i]*inv(pow_mod(2,i));
			sum%=modulo;
		}
	}
}


void test(){
	for(ll i = 1; i<=10; i++){
		cout<<pow_mod(i,modulo-2)<<' ';
	}
	cout<<endl;
}

int main(){
//	test();
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
}



/*
	
*/

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

using namespace std;

#define long long long
#define INF 2e18
#define MOD (long) (1e9 + 7)
#define umap unordered_map

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

    long t = 1;
    //cin >> t;

    while (t--) {
        long n;
        cin >> n;

        long ans = (n + 1) / 2;
        printf("%lld\n", ans);
    }
}


Measured memory_bytes: 3752
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <climits>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define scn(t) scanf("%d", &t)
#define scnld(t) scanf("%ld", &t)
#define scnlld(t) scanf("%lld", &t)
#define scnc(t) scanf("%c", &t)
#define scns(t) scanf("%s", t)
#define scnf(t) scanf("%f", &t)
#define scnlf(t) scanf("%lf", &t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define nloop(i, j, k, in) for (int i = j; i < k; i += in)
#define rloop(i, j, k, in) for (int i = j; i >= k; i -= in)
#define rep(i, j) nloop(i, 0, j, 1)
#define rrep(i, j) rloop(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert(B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define fast  \
    ios_base::sync_with_stdio(false);\
    cin.tie(NULL);
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
const double pi = acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int, int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;

int main()
{
    fast
    int n;
    cin>>n;
    string s;
    unordered_set<string> ss(n);
    rep(i, n)
    {
        cin>>s;
        ss.insert(s);
    }
    cout<<ss.size();
    return 0;
}

Measured memory_bytes: 17120
N,M = gets.split.map(&:to_i)
xs = Array.new(1e5+1,0)
gets.split.each{ |a|
  xs[a.to_i] += 1
}
pairs = Array.new(M, 0)
singles = Array.new(M, 0)
xs.each_with_index { |n,i|
  pairs[i%M] += n/2
  singles[i%M] += n%2
}
#p pairs, singles

ans = 0
ans += pairs[0] + singles[0]/2
if M%2 == 0
  ans += pairs[M/2] + singles[M/2]/2
end
(1...(M+1)/2).each{ |k|
  #p ans
  le,ma = k,M-k
  if singles[k] > singles[M-k]
    le,ma = ma,le
  end
  ans += singles[le]
  ans += pairs[ma]
  ans += pairs[le]
  ans += [pairs[le], (singles[ma] - singles[le])/2].min
}
p ans

Measured memory_bytes: 12180
n, m, k = map(int, input().split())
a_m, b_m = [], []
c_k, d_k = [], []
def minus(x):
    return int(x)-1

friends_list = [[] for i in range(n)]
block_list = [[] for i in range(n)]
for i in range(m):
    a_m.append(0)
    b_m.append(0)
    a_m[i], b_m[i] = map(minus, input().split())
    friends_list[a_m[i]].append(b_m[i])
    friends_list[b_m[i]].append(a_m[i])
for i in range(k):
    c_k.append(0)
    d_k.append(0)
    c_k[i], d_k[i] = map(minus, input().split())
    block_list[c_k[i]].append(d_k[i])
    block_list[d_k[i]].append(c_k[i])

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents =[-1 for i in range(n)]
    # どのグループに属しているかを返す
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
        return True

    def size(self, x):
        return -self.parents[self.find(x)]

def blocks_in_union(x):
    count = 0
    for block in block_list[x]:
        if uf.find(x) == uf.find(block):
            count += 1
    return count

uf = UnionFind(n)
for i in range(m):
    uf.unite(a_m[i], b_m[i])
for i in range(n):
    print(uf.size(i)-1-len(friends_list[i])-blocks_in_union(i), end=' ')


Measured memory_bytes: 140828
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
//ll mod = 1e9+7;
ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    vector<vector<ll>> dp(3001, vector<ll>(3001, 0));
    dp[a][b] = 1;
    for (int i = 1; i <= c; ++i) {
        for (int j = 1; j <= d; ++j) {
            dp[i][j] = (dp[i][j] + (j * dp[i-1][j]) % mod) % mod;
            dp[i][j] = (dp[i][j] + (i * dp[i][j-1]) % mod) % mod;
            ll tmp = (dp[i][j] - ((((i-1) * (j-1)) % mod) * dp[i-1][j-1]) % mod);
            if ( tmp < 0) {
                dp[i][j] = tmp + mod;
            }
            else {
                dp[i][j] = tmp;
            }
        }
    }
    cout << dp[c][d] << endl;
    return 0;
}


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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;

using namespace std;

int power(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

bool vowel(char c)
{
    return(c=='a' or c=='e' or c=='i' or c=='o' or c=='u' or c=='A' or c=='E' or c=='I' or c=='U' or c=='O');
}

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);


    int n;
    cin>>n;

    if(n>=1800) cout<< "1";
    else if(n>=1600) cout<< "2";
    else if(n>=1400) cout<< "3";
    else if(n>=1200) cout<< "4";
    else if(n>=1000) cout<< "5";
    else if(n>=800) cout<< "6";
    else if(n>=600)  cout<< "7";
    else if(n>=400) cout<< "8";


    return 0;
}


Measured memory_bytes: 3648
n,m = map(int,input().split())
a = list(map(int,input().split()))
s = [0]*(n+1)
for i in range(1,n+1):
  s[i] = (s[i-1]+a[i-1])%m
s.sort()
t = 0
i = 0
while i<n+1:
  j = i
  while j<n+1 and s[j] == s[i]:
    j += 1
  t += (j-i)*(j-i-1)//2
  i = j
print(t)

Measured memory_bytes: 14252
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cstring>
#include<map>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()
const int OPEN = 1, CLOSE = 0;

typedef pair<string, int> pp;

int main()
{
	int n, m;
	string s;
	map<string, int> l;
	cin >> n;
	REP(n){ cin >> s ; l.insert(pp(s, 1));}
	cin >> m;
	int f = CLOSE;
	REP(m)
	{
		cin >> s;
		if(l.find(s) == l.end())
			cout << "Unknown " << s << endl;
		else
		{
			if(f == CLOSE){	cout <<"Opened by " << s << endl;  f = OPEN;}
			else { cout << "Closed by " << s << endl; f = CLOSE;}
		}
	}

	return 0;
}

Measured memory_bytes: 1236
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String[] temp = br.readLine().split(" ");
		sb.append(temp[2]).append(" ").append(temp[0]).append(" ").append(temp[1]);
		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 21204
object Main {
    def main(args: Array[String]) {
        val num = scala.io.StdIn.readInt()

        if(num < 105) {
            println("0")
        }
        else {
            var count = 0
            for(i <- 105 to num if i %2 == 1)
            {
                var check_count = 0
                for(j <- 1 to Math.sqrt(i).toInt) {
                    if(i%j == 0){
                        if(i/j == j) {check_count += 1}
                        else         {check_count += 2}
                    }
                }

                if(check_count == 8) {count += 1}
            }

            println(count)
        }
    }
}

Measured memory_bytes: 25404
how_many = int(input())
least, biggest = [],[]
for i in range(how_many):
    nums = input().split()
    nums = [int(num) for num in nums]
    least.append(nums[0])
    biggest.append(nums[1])
least.sort()
biggest.sort()
if how_many % 2 == 1:
    print(biggest[int((how_many-1) / 2)] - least[int((how_many-1) / 2)] + 1)
else:
    l = (least[int(how_many / 2)] + least[int(how_many / 2 - 1)]) / 2
    b = (biggest[int(how_many / 2)] + biggest[int(how_many / 2 - 1)]) / 2
    print(int((b-l) / 0.5 + 1))

Measured memory_bytes: 25360
#include<stdio.h>

int main()
{	
	int i,num[3],flag,keta;
	
	while(scanf("%d %d",&num[0],&num[1])!= EOF)
	{
		keta = 0;
		
		flag = 1;
		
		num[2] = num[0] + num[1];
		
		while(flag)
		{
			num[2] = num[2] / 10;
			
			keta++;
			
			if(num[2] == 0)
				flag = 0;
		}

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

	return 0;

}

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

ts, xs, ys = [], [], []
for _ in range(N):
    t, x, y = map(int, input().split())
    xs.append(x)
    ys.append(y)
    ts.append(t)

dt = ts[0]
dist = abs(xs[0]) + abs(ys[0])

if dist > dt:
    print("No")
    exit()
if (dt % 2) != (dist % 2):
    print("No")
    exit()

for t in range(N-1):
    dt = ts[t+1] - ts[t]
    dist = abs(xs[t+1]-xs[t]) + abs(ys[t+1]-ys[t])

    if dist > dt:
        print("No")
        exit()

    if (dt % 2) != (dist % 2):
        print("No")
        exit()

print("Yes")


Measured memory_bytes: 11736
#include<stdio.h>
int main(){
  int w,n,temp,i,j;
  char dast;
  scanf("%d",&w);
  scanf("%d",&n);
  int tate[w],a,b;
  for(i=0;i<w;i++){
    tate[i]=i+1;
  }
  for(i=0;i<n;i++){
    scanf("%d%c%d",&a,&dast,&b);
    temp=tate[a-1];
    tate[a-1]=tate[b-1];
    tate[b-1]=temp;
  }
  for(i=0;i<w;i++){
    printf("%d\n",tate[i]);
  }
  return(0);
}

Measured memory_bytes: 596
#include <iostream>
using namespace std;
int a,b,c,d,l,r;
int main()
{
	cin>>a>>b>>c>>d;
	l=a+b,r=c+d;
	if(l>r) cout<<"Left"<<endl;
	else if(l<r) cout<<"Right"<<endl;
	else cout<<"Balanced"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

public class Main{

    static StringBuilder sb;

    public static void main(String[] args) {
    try {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        List<String> lines = new ArrayList<String>();
        String line = "";

        while((line = br.readLine()) != null){
            lines.add(line);
        }
        br.close();

        //lines.add("40 42 -1");
        //lines.add("20 30 -1");
        //lines.add("0 2 -1");
        //lines.add("-1 -1 -1");

        for (int i = 0; i < lines.size(); i++) {
        Integer m = Integer.parseInt(lines.get(i).split(" ")[0]);
        Integer f = Integer.parseInt(lines.get(i).split(" ")[1]);
        Integer r = Integer.parseInt(lines.get(i).split(" ")[2]);

        if (m == -1 && f == -1 && r == -1) {
            System.exit(0);
        } else if (m == -1 || f == -1) {
            System.out.println("F");
        } else if (m+f >= 80) {
            System.out.println("A");
        } else if (65 <= m+f && m+f < 80) {
            System.out.println("B");
        } else if (50 <= m+f && m+f < 65) {
            System.out.println("C");
        } else if (30 <= m+f && m+f < 50) {
            if (r != -1 && r >= 50) {
            System.out.println("C");
            } else {
            System.out.println("D");
            }
        } else {
            System.out.println("F");
        }
        }

        System.exit(0);

    } catch (Exception e) {
        System.out.println(e.getMessage());
        System.out.println(Arrays.toString(e.getStackTrace()));
        System.exit(0);
    }
    }
}


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

const int N=2e+5+5;
int f[N],n,bc,r[2][N];

int main()
{
	string x;
	cin>>n>>x;
	for(int i=1;i<=n;i++)
	{
		int g=__builtin_popcount(i);
		f[i]=1+f[i%g];
	}
	//cout<<f[1]<<" ";
	for(auto it:x)
		bc+=it-'0';
	int r1=0,r0=0;
	bc++;
	for(int i=n-1;i>=0;i--)
	{
		r[0][i]=(r[0][i+1]*2)%bc;
		r[0][n-1]=1;
	}		
	for(int i=0;i<=n-1;i++)
		r0=(r0+(x[i]-'0')*r[0][i])%bc;
	bc--;
	bc--;
	for(int i=n-1;i>=0&&bc>0;i--)
	{
		r[1][i]=(r[1][i+1]*2)%bc;
		r[1][n-1]=1;
	}
	for(int i=0;i<=n-1&&bc>0;i++)
		r1=(r1+((x[i]-'0')*r[1][i]))%bc;
	bc++;
	//cout<<r1<<" "<<r0<<" ";
	for(int i=0;i<n;i++)
	{		
		int g=0;
		if(x[i]=='1')
		{
			bc--;
			if(bc>0)
				g=((r1-r[1][i])%bc+bc)%bc;
			//cout<<bc<<" "<<r[1][i]<<" ";
			bc++;
		}
		else
		{
			bc++;
			g=(r0+r[0][i])%bc;
			//cout<<bc<<" "<<r[0][i]<<" ";
			bc--;
		}
		if(bc>1||x[i]=='0')
		{
			//cout<<bc<<" ";	
			cout<<f[g]+1<<"\n";
		}
		else 
			cout<<0<<"\n";
	}
}



Measured memory_bytes: 6056
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
			
			int n = sc.nextInt();
			for(int i = 0 ; i < n ; i++ ) {
				int a = sc.nextInt();
				
				if ( a % 2 == 0 ) {
					if ( a % 3 == 0 || a % 5 == 0 ) {
						//ok continue
					}
					else {
						System.out.println("DENIED");
						return;
					}
				}
			}
			
			System.out.println("APPROVED");
		}
	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
const double pi=std::acos(-1);
double calcAngle(int h, int m) 
{ 

	if (h == 12) h = 0; 
	if (m == 60) m = 0;  
	double hour_angle = 0.5 * double(h * 60 + m); 
	double minute_angle =double (6 * m); 

	double angle = abs(hour_angle - minute_angle); 

	angle = min(360 - angle, angle); 

	return angle; 
}

int main()
{
  int a,b,hour,min;
  cin>>a>>b>>hour>>min;
  double angle=calcAngle(hour,min);
  double ang=double((pi/180)*angle);
  double c;
  a=double(a);
  b=double(b);
  c=double(a*a)+double(b*b);
    c=double(c)-  double(2*a*b*cos(ang));
  cout << fixed << setprecision(20) << sqrt(c) ;
  return 0;
 
}

Measured memory_bytes: 4224
#include <stdio.h>

int main () {
  int a, b;
  char op;
  scanf ("%d %c %d", &a, &op, &b);

  if(op == '+'){
    printf("%d\n", a+b);
  }
  else {
    printf("%d\n", a-b);
  }
  return 0;
}

Measured memory_bytes: 128
import collections
n = int(input())
a = list(map(int, input().split()))
d = {}
ans = 0
for i in range(n):
  d[i + 1] = a[i]
for i in range(n):
  if d[d[i + 1]] == i + 1:
    ans += 1
ans //= 2
print(ans)

Measured memory_bytes: 24732
package main

import "fmt"

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

	var o = make([]int, 3)
	for i := 0; i < 3; i++ {
		if n%10 == 1 {
			o[i] = 9
			n /= 10
		} else if n%10 == 9 {
			o[i] = 1
			n /= 10
		} else {
			o[i] = n % 10
			n /= 10
		}
	}
	n = o[2]*100 + o[1]*10 + o[0]
	fmt.Println(n)

}

Measured memory_bytes: 512
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0

for i in range(n):
    ans += b[a[i] - 1]
    if i != 0 and a[i] == a[i - 1] + 1:
        ans += c[a[i - 1] - 1]

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int a, b;

  scanf("%d", &a);
  if(a == 1)
    a = 14;
  scanf("%d", &b);
  if(b == 1)
    b = 14;

  if (a > b)
    printf("Alice\n");
  else if(a == b)
    printf("Draw\n");
  else
    printf("Bob\n");

  return 0;
}


Measured memory_bytes: 128
num = gets.to_i
h = 0
m = 0
s = 0

while num > 0
  if num >= 3600 
    h += 1
    num -= 3600
  elsif num >= 60
    m += 1
    num -= 60
  else
    s += 1
    num -= 1
  end
end

print h
print ":"
print m
print ":"
print s
puts ""




Measured memory_bytes: 6876