akhauriyash/Code-Regression huggingface dataset:
N=int(input())

for i in range(0,10):
    for j in range(0,10):
        for k in range(0,10):
            if N==100*i+10*j+k:
                if i==7 or j==7 or k==7:
                    print("Yes")
                else:
                    print("No")
            else:
                pass


Measured memory_bytes: 9172
def solve():
    a = input()
    q = int(input())
    
    top = []
    tail = []
    rev = 0
    for _ in range(q):
        _q = [i for i in input().split()]
        t, f, c =0, 0, 0
        t = int(_q[0])
        if t == 2:
            f, c = int(_q[1]), _q[2]
        
        if t == 1:
            rev = 1 - rev
        elif t == 2:
            if (f + rev) % 2 == 1:
                top.append(c)
            else:
                tail.append(c)
                
    if rev == 1:
        a = a[::-1]
        _top = tail
        tail = top
        top = _top
    
    print("".join(list(reversed(top))), end="")
    print(a, end="")
    print("".join(tail))


if __name__ == "__main__":
    solve()

Measured memory_bytes: 6336
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
using namespace std;
const int MAXN=1e5+10;
struct Node{
	int v,nu;
};
Node c[MAXN],d[MAXN];
int m,n,l,p,k,ans,tot,a,b;
int inline read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
bool inline cmp(Node x,Node y)
{
	return x.v>y.v;
}
int main()
{
	n=read();
	n/=2;
	for (int i=0;i<=100000;i++) c[i].v=0,d[i].v=0;
	for (int i=1;i<=n;i++)
	{
		a=read();
		b=read();
		c[a].v++;
		c[a].nu=a;
		d[b].v++;
		d[b].nu=b;
	}
	sort(c+1,c+1+100000,cmp);
	sort(d+1,d+1+100000,cmp);
	if (c[1].nu==d[1].nu)
	{
		tot=max(c[2].v,d[2].v);
		ans=n*2-tot-c[1].v;
	}
	else
	{
		ans=n*2-c[1].v-d[1].v;
	}
	printf("%d",ans);
	


	return 0;
}



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int N;
string S;
double A;
vector<ll> V;
ll num[60][60];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) {
		cin>>A;
		ll B=A*1000000000LL+0.5;
		
		int a2=0,a5=0;
		while(B%2==0) a2++,B/=2;
		while(B%5==0) a5++,B/=5;
		num[a2][a5]++;
	}
	
	ll ret=0;
	int x2,y2;
	FOR(x,60) FOR(y,60) FOR(x2,60) FOR(y2,60) {
		if(x+x2>=18 && y+y2>=18) {
			if(x==x2&&y==y2) {
				ret+=num[x][y]*(num[x][y]-1);
			}
			else {
				ret+=num[x][y]*num[x2][y2];
			}
		}
	}
	ret/=2;
	
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3792
#include <iostream>
using namespace std;
int main() {
    int m, f, r;
    while(true){
        char result;
        cin >> m >> f >> r;
        if(m == -1 && f == -1 && r == -1) break;
        else if(m == -1 || f == -1 || m + f < 30) result = 'F';
        else if(m + f >= 80) result = 'A';
        else if(m + f >= 65 && m + f < 80) result = 'B';
        else if(m + f >= 50 && m + f < 65) result = 'C';
        else if(m + f >= 30 && m + f < 50){
            if(r >= 50) result = 'C';
            else result = 'D';
        }
        else{
            continue;
        }
        cout << result << endl;
    }
    return 0;
}



Measured memory_bytes: 3100
#include <iostream>


using namespace std;

int main(){
	int N,M;
	while(cin >> N,N){
		int map[21][21]={0},num = 0,l;
		int x,y;
		for(int i = 0;i < N;i++,num++) {
			cin >> x >> y;
			map[x][y] = 1;
		}
		x = 10;
		y = 10;
		cin >> M;
		char d;
		for(int i = 0;i < M;i++){
			cin >> d >> l;
			for(;l > 0;l--){
				if(d == 'N') y++;
				if(d == 'E') x++;
				if(d == 'S') y--;
				if(d == 'W') x--;
				num -= map[x][y];
				map[x][y] = 0;
			}
		}
		if(num == 0) cout << "Yes" << endl;
		else cout << "No" << endl;
        }
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] ballInfo = new int[n +1];
		boolean[] redBallInfo = new boolean[n +1];
		redBallInfo[1] = true;
		for(int i =1;i <=n;i++) {
			ballInfo[i] = 1;
		}
		for(int i =0;i < m;i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			if(redBallInfo[x]) {
				if(ballInfo[x] ==1) {
					redBallInfo[x] = false;
				}
				redBallInfo[y] = true;
			}
			ballInfo[x]--;
			ballInfo[y]++;
		}
		int answer = 0;
		for(boolean redBall :redBallInfo) {
			if(redBall) {
				answer++;
			}
		}

		System.out.println(answer);
	}
}

Measured memory_bytes: 65472
#include <bits/stdc++.h>
#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 all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
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; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

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

int time = 1900*M + 100*(N-M);
int ans = time*pow(2,M);

cout << ans << endl;

return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define run(a) for(int k=head[a];k;k=e[k].ne)
#define v e[k].t
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef double db;
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<ll,ll> pa;
const int N=1e4+5,M=5e3+5,INF=1e9,mod=998244353;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);}
int n,c[N],D;
void die(){puts("Impossible");exit(0);}
int main(){
	read(n);rep(i,1,n){int x=read();gmax(D,x);c[x]++;}
	int mn=1e9;
	rep(i,0,D){
		int tl=max(i,D-i);
		gmin(mn,tl);
		if(!c[tl])die();
		c[tl]--;
	}
	rep(i,1,mn)if(c[i])die();
	puts("Possible");
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define ll long long
using namespace std; 
  
  ll fun(ll n)
  {
      ll i, note;
      for(i=1; i<=100000; i++)
      {
          if(i*(i+1)/2>n)
          {
              note=i-1;
              break;
          }
      }
      return note;
  }
// A function to prll all prime  
// factors of a given number n  
ll primeFactors(ll n)  
{  
    ll c=0, s=0;
    // Prll the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        s++;
        //cout << 2 << " ";  
        n = n/2;  
    }  
    c+=fun(s);
    // n must be odd at this poll. So we can skip  
    // one element (Note i = i +2)  
    
    for (ll i = 3; i <= sqrt(n); i = i + 2)  
    {  
        s=0;
        // While i divides n, prll i and divide n  
        while (n % i == 0)  
        {  
            s++;
            //cout << i << " ";  
            n = n/i;  
        }  
        c+=fun(s);
    }  
    
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)
    c++;
        //cout << n << " ";  
        return c;
}  
  
/* Driver code */
int main()  
{  
    ll n;
    cin>>n;
    cout<<primeFactors(n);  
    return 0;  
}  

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

int d[100], a[100];
map<vector<int>, int>id;
vector<int>re[5040];
int dp[100][5040];

int main() {
	int n; scanf("%d", &n);
	rep(i, n)scanf("%d", &d[i]);
	rep(i, n)scanf("%d", &a[i]);
	vector<int>v(7); rep(i, 7)v[i] = i;
	int p = 0;
	do {
		id[v] = p; re[p] = v;
		int cnt = 0;
		bool t[7]{};
		for (int i : v) {
			rep(j, 7) {
				if (t[j] && abs(j - i) <= d[j])cnt += a[j];
			}
			t[i] = 1;
		}
		dp[0][p] = cnt;
		p++;
	} while (next_permutation(v.begin(), v.end()));
	int ans = 0;
	for (int i = 1; i + 6 < n; i++)rep(j, 5040)rep(k, 8) {
		auto t = re[j].begin();
		int cnt = 0, o = 0;
		bool p[8]{};
		vector<int>q(7);
		rep(l, 8) {
			if (k == l) {
				rep(y, 8) {
					if (p[y] && y + d[i - 1 + y] >= 7)
						cnt += a[i - 1 + y];
				}
				p[7] = 1; q[o++] = 6;
			}
			else {
				if (p[7] && 7 - d[i + 6] <= *t)cnt += a[i + 6];
				p[*t] = 1;
				if (*t)q[o++] = *t - 1;
				t++;
			}
		}
		int v = id[q];
		dp[i][v] = max(dp[i][v], dp[i - 1][j] + cnt);
		ans = max(ans, dp[i][v]);
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 6092
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int X;

int main() {
    cin >> X;
    int n = X / 100;
    int m = X % 100;
    if (n * 5 < m)
        cout << 0 << endl;
    else
        cout << 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

string field[2160];
int l[2160][2160];
int r[2160][2160];
int u[2160][2160];
int d[2160][2160];

int main(){
    int h, w;
    cin >> h >> w;
    for(int i = 0;i < h;i++){
        cin >> field[i];
    }
    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            if(field[i][j] == '#'){
                l[i][j] = 0;
                u[i][j] = 0;
            }
            else{
                u[i][j] = (i==0)?1:u[i-1][j] + 1;
                l[i][j] = (j==0)?1:l[i][j-1] + 1;
            }
        }
    }
    
    for(int i = h-1;i >= 0;i--){
        for(int j = w-1;j >= 0;j--){
            if(field[i][j] == '#'){
                r[i][j] = 0;
                d[i][j] = 0;
            }
            else{
                d[i][j] = (i==h-1)?1:d[i+1][j] + 1;
                r[i][j] = (j==w-1)?1:r[i][j+1] + 1;
            }
        }
    }
    int res = 0;
    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            if(field[i][j] == '#')continue;
            res = max(res, r[i][j] + l[i][j] + d[i][j] + u[i][j] - 3);
        }        
    }
    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 76032
import sys
import itertools
 
A = list(sys.stdin.readline().strip())
B = list(sys.stdin.readline().strip())
C = list(sys.stdin.readline().strip())
 
def can_match(x,y):
    return x == '?' or y == '?' or x == y

M = 2020
def solve(A,B,C,LA,LB,LC):
    B_from_A = [True] * (M+1)
    for i in range(M+1):
        B_from_A[i] = all(can_match(x,y) for x, y in zip(A[i:], B))
    C_from_A = [True] * (M+M+1)
    for i in range(M+M+1):
        C_from_A[i] = all(can_match(x,y) for x, y in zip(A[i:], C))
    C_from_B = [True] * (M+1)
    for i in range(M+1):
        C_from_B[i] = all(can_match(x,y) for x, y in zip(B[i:], C))
    for i in range(M):
        if not B_from_A[i]:
            continue
        for j in range(M):
            if not C_from_B[j]:
                continue
            if not C_from_A[i+j]:
                continue
            yield max(LA, LB+i, LC+i+j)
            break
 
answer = float("inf")
for A,B,C in itertools.permutations([A, B, C]):
    LA = len(A)
    LB = len(B)
    LC = len(C)
    x = min(solve(A, B, C, LA, LB, LC))
    answer = min(answer, x)
print(answer)

Measured memory_bytes: 90204
import sys
f = sys.stdin

def is_odd(num):
    return num % 2

n,_,_ = map(int,f.readline().split())#_は読み飛ばし
a = list(map(int, f.readline().split()))
q = list(map(int, f.readline().split()))

s = list(range(n))

pos = 0
for ai in a:
    pos += -ai if is_odd(ai) else ai
    pos %= len(s)
    s.pop(pos)

for qi in q:
    print(1 if qi in s else 0)

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

int main() {
  int N;
  cin >> N;

  int a[N];

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

  string ans = "APPROVED";

  rep(i,N) {
    if (a[i]%2==0) {
      if ((a[i]%3==0)||a[i]%5==0) {
        continue;
      }
      else {
        ans = "DENIED";
        break;
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#include<set>
#include<math.h>
#include<string>
#include<cstdlib>
#include<sstream>

typedef long long ll;

using namespace std;

int main()
{
	float d, t, s, x;

	cin >> d >> t >> s;

	x = d/s;

	if(x<=t)
		cout << "Yes";	
	else
	{
		cout << "No";
	}
	
}



Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(b-a+1>c*2){
    for(int i = 0;i<=c-1;i++)
      cout << a + i << endl;
    for(int i = c-1;i>=0;i--)
      cout << b-i << endl;
  }
  else{
    for(int i = a ;i<=b;i++)
      cout << i << endl;
  }
    
}


Measured memory_bytes: 256
/*
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineerin College
    Date:13/03/2020
*/
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long 
#define ld long double
#define ff first
#define ss string 
#define se second
#define alt(v) v.begin(),v.end()
#define pb emplace_back
#define mp make_pair
#define tc(t) cin>>t;while(t--)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define fab(i,a,b) for(ll i=(a);i<(b);i++)
#define fba(i,a,b) for(ll i=(b);i>=(a);i--)
#define arr(i,n) fab(i,0,n)
ll max(ll a,ll b){if(a>b)return a;else return b;} 
ll min(ll a,ll b){if(a<b)return a;else return b;}
const ll inf=0x3f3f3f3f;

vector<int>primeFactorization(int n)
{
    vector<int>prime_fact;
    for(int i=2;i<=sqrt(n);++i)
    {
        while(n%i==0)
        {
            prime_fact.push_back(i);
            n/=i;
        }
    }
    if(n!=1)
    prime_fact.push_back(n);
    return prime_fact;
}

vector<int>sieve(int n)
{
    bool primes[n+5];
    memset(primes,true,sizeof(primes));
    vector<int>res;//res vector all the prime no between 1 to n
    for(int i=2;i<=sqrt(n);++i)
    {
        if(primes[i]==true)
        {
            res.push_back(i);
            for(int j=i*2;j<=n;j+=i)
            primes[j]=false;
        }
    }
    return res;
}








ll const Mxn=100000;
bool test=0;
void solve()
{
    ll n,f=0,q,c,ans=0,i;
    cin>>n;
    ll dp[3][100000];
    fab(i,0,n)
      cin>>dp[0][i]>>dp[1][i]>>dp[2][i];
    fab(i,1,n)
    {
        dp[0][i]=dp[0][i]+max(dp[1][i-1],dp[2][i-1]);
        dp[1][i]=dp[1][i]+max(dp[0][i-1],dp[2][i-1]);
        dp[2][i]=dp[2][i]+max(dp[0][i-1],dp[1][i-1]);
        
    }
    cout<<max(max(dp[0][n-1],dp[1][n-1]),dp[2][n-1]);
    
}





























int main()
{
    fio;
    ll t=1,s;
    if(test)
    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 2560
#include<cstdio>
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
#define MP make_pair
long long int map[1002][1002], mmap[1002][1002], tai = 1;
int main()
{
	int n, w, h, s,x,y,siz,cnt=0,flg=0;
	char c[2002];
	pair<int, int> q;
	queue<pair<int,int> > que;
	queue<int>quec;
	quec.push(0);
	scanf("%d %d %d", &h, &w, &n);
	for (int i = 1; i <= h; i++)
	{
		scanf("%s", c);
		for (int j = 1; j <= w; j++)
		{

			if (c[j - 1] == 'S')
			{
				que.push(MP(i, j));
			}
			if (c[j-1] == 'X')
				map[i][j] = -1;
			s = c[j-1];
			if (s > 48 && s < 58)
				map[i][j] = s - 48;
		}
	}
	for (int i = 0; i <= h + 1; i++)
	{
		map[i][0] = -1;
		map[i][w + 1] = -1;
	}
	for (int i = 0; i <= w + 1; i++)
	{
		map[0][i] = -1;
		map[h + 1][i] = -1;
	}
/*	for (int i = 0; i <= h + 3; i++)
	{
		for (int j = 0; j <= w + 3; j++)
		{
			printf("%2lld", map[i][j]);
		}
		cout << endl;
	}*/
	while (!que.empty())
	{
		x = que.front().first;
		y = que.front().second;
		flg = 0;
		cnt = quec.front();
		quec.pop();
		que.pop();
		mmap[x][y] = -1;
		if (map[x - 1][y] != -1&&mmap[x-1][y]!=-1&&flg==0)
		{
			que.push(MP(x - 1, y));
			quec.push(cnt + 1);
			mmap[x - 1][y] = -1;
			if (map[x - 1][y] == tai)
			{
				flg = 1;
				tai++;
				for (int i = 1; i <= h; i++)
				{
					for (int j = 1; j <= w; j++)
					{
						mmap[i][j] = 0;
					}
				}
				while (que.size() > 1)
				{
					que.pop();
					quec.pop();
				}
			}
		}
		if (map[x][y+1] != -1 && mmap[x][y+1] != -1&&flg==0)
		{
			que.push(MP(x , y+1));
			quec.push(cnt + 1);
			mmap[x][y+1] = -1;
			if (map[x][y+1] == tai)
			{
				flg = 1;
				tai++;
				for (int i = 1; i <= h; i++)
				{
					for (int j = 1; j <= w; j++)
					{
						mmap[i][j] = 0;
					}
				}
				while (que.size() > 1)
				{
					que.pop();
					quec.pop();
				}
			}

		}
		if (map[x+1][y] != -1 && mmap[x+1][y] != -1&&flg==0)
		{
			que.push(MP(x + 1, y));
			quec.push(cnt + 1);
			mmap[x+1][y] = -1;
			if (map[x+1][y] == tai)
			{
				flg = 1;
				tai++;
				for (int i = 1; i <= h; i++)
				{
					for (int j = 1; j <= w; j++)
					{
						mmap[i][j] = 0;
					}
				}
				while (que.size() > 1)
				{
					que.pop();
					quec.pop();
				}
			}
		}
		if (map[x][y-1] != -1 && mmap[x][y-1] != -1&&flg==0)
		{
			que.push(MP(x , y-1));
			quec.push(cnt + 1);
			mmap[x][y-1] = -1;
			if (map[x][y-1] == tai)
			{
				flg = 1;
				tai++;
				for (int i = 1; i <= h; i++)
				{
					for (int j = 1; j <= w; j++)
					{
						mmap[i][j] = 0;
					}
				}
				while (que.size() > 1)
				{
					que.pop();
					quec.pop();
				}
			}
		}
		if (tai == n + 1)
			break;
	}
	printf("%d\n", quec.front());
	return 0;
}

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

int main(){

	int a, b;
	char op;

	while (true){

		cin >> a >> op >> b;
		
		if (op == '+'){
			cout << a + b << endl;
		}
		else if (op == '-'){
			cout << a - b << endl;
		}
		else if (op == '*'){
			cout << a*b << endl;
		}
		else if (op == '/'){
			cout << a / b << endl;
		}
		else {
			break;
		}
	}

	return 0;
}


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

int main() {
	int a, b, n;
	cin >> a >> b;
	n = a * b;
	if (n % 2 == 1) {
		cout << "Odd" << endl;
	}
	else {
		cout << "Even" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#include <iomanip>
#include <limits>
#include <string>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
const long long INF = 1LL << 60;
ll mod=1e9+7;
using namespace std;

int main(){
	int n; cin >>n;
	vector<int> a(n);
	cinf(n,a);
	map<int,int> mp;
	for(int i=0;i<n;i++){
		mp[a[i]]++;
	}
	bool flg=false;
	for(auto p:mp){
		if(n%2==1){
			int m=p.first;
			if(m%2==1){
				cout << 0 << endl;
				return 0;
			}
			if(p.second!=2&&p.first!=0){
				cout << 0 << endl;
				return 0;
			}
			if(p.second==1&&p.first==0){
				flg=true;
			}
		}
		if(n%2==0){
			int m=p.first;
			if(m%2==0){
				cout << 0 << endl;
				return 0;
			}
			if(p.second!=2){
				cout << 0 << endl;
				return 0;
			}
		}
	}
	ll ans=1;
	for(int i=0;i<n/2;i++){
		ans*=2;
		ans%=mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef  long long  ll;
int main(){
  ll t1,t2,a1,a2,b1,b2;
  cin >> t1 >> t2;
  cin >> a1 >> a2;
  cin >> b1 >> b2;
  ll tmp;
  ll asd=0;
  //tmp = (b1-a1)*t1+(b2-a2)*t2;
  //cout << (b1-a1)*t1 << endl;
  //cout << b2 - a2 << endl;
  //cout << (b2-a2)*t2 << endl;
  //cout << tmp << endl;
  if((a1-b1)*t1==(b2-a2)*t2)cout << "infinity" << endl;
  else if(a1<b1&&(((b1-a1)*t1+(b2-a2)*t2)>0)) cout << 0 << endl;
  else if(b1<a1&&((a1-b1)*t1+(a2-b2)*t2)>0) cout << 0 << endl;
  else if(b1<a1){
    //tmp = (b1*t1+b2*t2)-(a1*t1+a2*t2);
    tmp = (b1-a1)*t1+(b2-a2)*t2;
    if(((a1-b1)*t1)%tmp==0)asd=1;
    cout << 1 + 2*(((a1-b1)*t1)/tmp)-asd << endl;
  }
  else if(a1<b1){
    //tmp = (a1*t1+a2*t2)-(b1*t1+b2*t2);
    tmp = (a1-b1)*t1+(a2-b2)*t2;
    if(((b1-a1)*t1)%tmp==0)asd=1;
    cout << 1 + 2*(((b1-a1)*t1)/tmp)-asd << endl;
  }
}


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

typedef long long int int64;
static const int64 mod = 1000000007LL;
int64 dp[1000003][3];
int64 fac[1000003],inv[1000003],invfac[1000003];
int n;
int64 choice(int a,int b)
{
	return fac[a]*invfac[b]%mod*invfac[a-b]%mod;
}
int main()
{
	scanf("%d",&n);
	fac[0] = fac[1] = invfac[0] = invfac[1] = inv[1] = 1;
	for(int i = 2;i <= 1000000;++i) {
		fac[i] = (fac[i-1]*i)%mod;
		inv[i] = (mod-mod/i)*inv[mod%i]%mod;
		invfac[i] = (invfac[i-1]*inv[i])%mod;
	}
	dp[0][0] = 1;
	for(int i = 0;i < n;++i) {
		for(int k = 0;k < 3;++k) for(int l = 0;l < 3;++l) if(k != l) {
			dp[i+1][l] = (dp[i+1][l] + dp[i][k]) % mod;
		}
	}
	int64 ans = 0;
	for(int i = 1;i <= n;++i) {
		ans += choice(n,i) * dp[i][1] % mod * inv[i] % mod;
	}
	ans %= mod;
	for(int i = 0;i < n;++i) {
		ans = ans * inv[3] % mod;
	}
	ans = ans * inv[n] % mod;
	printf("%lld\n", ans);
}


Measured memory_bytes: 47104
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

ll a,b,x;

int main(){
    cin>>a>>b>>x;
    if(a==0){
        out(b/x+1);
    }
    else{
    out(b/x-(a-1)/x);
    }
}


Measured memory_bytes: 256
mod = 10**9+7

N,M=gets.split(" ").map{|i| i.to_i}
A=gets.split(" ").map{|i| i.to_i}
B=gets.split(" ").map{|i| i.to_i}
cells = N*M
iA = Array.new(cells){false}
iB = Array.new(cells){false}
sumA = Array.new(cells){0}
sumB = Array.new(cells){0}
for i in 0..(N-1)
	if(iA[A[i]-1])
		puts 0
		exit(0)
	end
	iA[A[i]-1] = true
	sumA[A[i]-1] = 1
end
(cells-2).downto(0){|i|
	sumA[i] += sumA[i+1]
}
for j in 0..(M-1)
	if(iB[B[j]-1])
		puts 0
		exit(0)
	end
		iB[B[j]-1] = true
	sumB[B[j]-1] = 1
end
(cells-2).downto(0){|j|
	sumB[j] += sumB[j+1]
}
# p iA
# p iB
# p sumA
# p sumB
comb = 1
filled = 0
(cells).downto(0){|n|
	i = n-1
	if(iA[i] && iB[i])
		comb = comb
	elsif(iA[i])
		comb = comb * sumB[i] % mod
	elsif(iB[i])
		comb = comb * sumA[i] % mod
	else
		poss = sumA[i] * sumB[i] - filled
		poss = 0 if poss < 0
		comb = comb * poss % mod
	end
	filled += 1
}
puts comb




Measured memory_bytes: 33276
#include <iostream>

int main(){
   int N;
   std::cin >> N;
   int X[N];
   int min = 100;
   int max = 1;
   for(int i=0; i<N; ++i){
      std::cin >> X[i];
      min = std::min(min, X[i]);
      max = std::max(max, X[i]);
   }

   int ans = 1e7;
   for(int i=min; i<=max; ++i){
      int sum = 0;
      for(int j=0; j<N; ++j){
         sum += (X[j] - i) * (X[j] - i);
      }
      ans = std::min(ans, sum);
   }
   std::cout << ans << std::endl;
   return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
// long long mod = 998244353;
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define rep(i, a, n) for (long long i = a; i < (n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
long long mod = 1000000007;
long long modpow(long long m, long long n, long long modvalue) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2, modvalue);
        return t * t % modvalue;
    } else {
        return modpow(m, n - 1, modvalue) * m % modvalue;
    }
}

long long moddiv(long long a, long long b, ll modvalue) { return (a * modpow(b, mod - 2, modvalue)) % modvalue; }

const ll INF = 1LL << 60;

string change_binary(long long a) {
    string ret;
    for (int i = 31; i >= 0; i--) {
        ret += (a >> i & 1) + '0';
    }
    return ret;
}

ll nCkmod(ll n, ll k, ll modvalue) {
    ll numera = 1;
    for (int i = n; i > n - k; i--) {
        numera *= i;
        numera %= modvalue;
    }
    ll denomi = 1;
    REP(i, k) {
        denomi *= (i + 1);
        denomi %= modvalue;
    }
    return moddiv(numera, denomi, modvalue);
}

map<ll, ll> cnt;
void primeFactors(long long n) {
    while (n % 2 == 0) {
        cnt[2]++;
        n = n / 2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2) {
        while (n % i == 0) {
            cnt[i]++;
            n = n / i;
        }
    }
    if (n > 2) {
        cnt[n]++;
    }
}
vector<ll> dijkstra(vector<vector<P>> graph, ll s) {
    vector<ll> ans(graph.size(), -1);
    priority_queue<P, vector<P>, greater<P>> pq;
    pq.push({0, s});
    while (pq.size() > 0) {
        ll cur1 = 0;
        ll cur2 = 0;
        if (ans[pq.top().second] != -1) {
            pq.pop();
        } else {
            cur1 = pq.top().first;
            cur2 = pq.top().second;
            pq.pop();
            ans[cur2] = cur1;
            for (ll i = 0; i < graph[cur2].size(); i++) {
                pq.push({cur1 + graph[cur2][i].first, graph[cur2][i].second});
            }
        }
    }
    return ans;
}
vector<string> maze;
ll h, w;
bool check(ll y, ll x) {
    if (x < 0 || x >= w || y < 0 || y >= h || maze[y][x] == '#') {
        return false;
    }
    return true;
}
signed main() {
    ll x;
    cin >> x;
    if (x == 1) {
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }
}

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

using namespace std;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)
typedef long long ll;
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;



int main() {
	int n;
	cin >> n;
	int a[100];
	REP(i, 100)a[i] = 0;
	FOR(i, 2, n + 1) {
		int j = 2;
		int k = i;
		while (k != 1) {
			if (k%j == 0) {
				a[j]++;
				k /= j;
			}
			else j++;
		}
	}
	int ans = 0;
	REP(i, 100) {
		if (a[i] >= 74)ans++;
	}
	REP(i, 100) {
		REP(j, 100) {
			if (i != j) {
				if (a[i] >= 24 && a[j] >= 2)ans++;
			}
		}
	}
	REP(i, 100) {
		REP(j, 100) {
			if (i != j) {
				if (a[i] >= 14 && a[j] >= 4)ans++;
			}
		}
	}
	REP(i, 100) {
		REP(j, 100) {
			FOR(k,j+1, 100) {
				if (i != j && j != k && k != i) {
					if (a[i] >= 2 && a[j] >= 4 && a[k] >= 4)ans++;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
<?php
 
$input = trim(fgets(STDIN));

$inputs = explode(' ',trim(fgets(STDIN)));
$count = 0;
for($x = 0;$x < $input - 2;$x++){

  if(
    ($inputs[$x + 1] > $inputs[$x] && $inputs[$x + 1] < $inputs[$x + 2]) ||
    ($inputs[$x + 1] < $inputs[$x] && $inputs[$x + 1] > $inputs[$x + 2])
  ){
    $count++;
  }

}

print $count;

Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef long long ll;
ll l, r, ans = 1e18, mod = 2019;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> l >> r;
    if(r - l + 1 >= mod)
        return cout << 0, 0;
    for(ll i = l;i <= r;++i)
        for(ll j = i + 1;j <= r;++j)
            ans = min(ans, ((i % mod) * j) % mod);
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define INF 1e18
using namespace std;

vector<vector<long long>>dp;

long long dp_func(int arr[], int i, int j)
{
    
    if(i==j)
        return dp[i][j]=arr[i];
    
    if(dp[i][j]!=INF)
    return dp[i][j];
    long long ans=0;
    
    ans = max((long long)arr[i]-dp_func(arr,i+1,j), (long long)arr[j]-dp_func(arr,i,j-1));
    return dp[i][j]=ans;
    
}

int main() {
	
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
    	cin>>arr[i];
	
	dp.assign(n,vector<long long>(n,INF));
	
	cout<<dp_func(arr,0,n-1);
	
	return 0;
}

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

const int N = 200 * 1000 + 20, mod = 1e9 + 7, X = 4000 + 20;
int x[N], y[N], dp[X][X], fact[N], factRev[N], n, ans;

int sum(int a, int b) {
    return ((1LL * a + b) % mod + mod) % mod;
}

int mul(int a, int b) {
    return ((1LL * a * b) % mod + mod) % mod;
}

int pw(int a, int b) {
    int res = 1, tmp = a;
    while (b) {
        if (b & 1)
            res = mul(res, tmp);
        tmp = mul(tmp, tmp);
        b >>= 1;
    }
    return res;
}

int c(int a, int b) {
    return mul(fact[a], mul(factRev[b], factRev[a - b]));
}

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> x[i] >> y[i];
    fact[0] = 1;
    for (int i = 1; i <= 8000; i++)
        fact[i] = mul(fact[i - 1], i);
    factRev[8000] = pw(fact[8000], mod - 2);
    for (int i = 8000 - 1; ~i; i--)
        factRev[i] = mul(factRev[i + 1], i + 1);
    for (int i = 0; i < n; i++)
        dp[2000 - x[i]][2000 - y[i]]++;
    for (int i = 0; i <= 4000; i++)
        for (int j = 0; j <= 4000; j++) {
            if (i)
                dp[i][j] = sum(dp[i][j], dp[i - 1][j]);
            if (j)
                dp[i][j] = sum(dp[i][j], dp[i][j - 1]);
        }
    for (int i = 0; i < n; i++)
        ans = sum(ans, dp[x[i] + 2000][y[i] + 2000]);
    for (int i = 0; i < n; i++)
        ans = sum(ans, -c((x[i] + y[i]) * 2, x[i] * 2));
    ans = mul(ans, pw(2, mod - 2));
    return cout << ans << "\n", 0;
}

Measured memory_bytes: 65024
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------

void _main() {
	int A, B;
	cin >> A >> B;

	int maxC = A+B;
	chmax(maxC, A - B);
	chmax(maxC, A*B);

	cout << maxC << endl;
}

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

#define sp <<" "
#define el <<"\n"
#define S second
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define obit __builtin_popcount
#define pof pop_front
#define mod (int)1e9 + 7
#define For(i,a,n) for(i=a;i<n;i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned short int us;
typedef short int ss;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    /*
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    //*/
    ll a;
    cin>>a;
    cout<<(a*(a-1))/2;
    return 0;
}

Measured memory_bytes: 256
while gets
  n=$_.to_i
  if n==0
    puts 0
    next
  end
  ts = gets.split.map(&:to_i)
  ts.sort!
  ps = (0..n-1).inject([0]){|seq,i| seq<<(seq[i]+ts[i])}
  total = ps.inject{|x,y| x+y}
  puts total
end

Measured memory_bytes: 2492
def dfs(i,j,vis,e):
  q=[(i,j)]
  while q:
    x,y=q.pop()
    vis[x][y]=0
    for dx in [-1,0,1]:
      for dy in [-1,0,1]:
        nx=x+dx
        ny=y+dy
        if 0<=nx<h and 0<=ny<w and vis[nx][ny] and e[nx][ny]=='1':q+=[(nx,ny)]
  return 1
def main(w,h):
  e=[input().split() for _ in range(h)]
  vis=[[1]*w for _ in range(h)]
  cnt=0
  for i in range(h):
    for j in range(w):
      if vis[i][j] and e[i][j]=='1':cnt+=dfs(i,j,vis,e)
  print(cnt)
while True:
  w,h=map(int,input().split())
  if (w,h)==(0,0):break
  main(w,h)


Measured memory_bytes: 6036
use std::io::{self, BufRead, BufWriter, Write};

fn solve<R, W>(reader: R, mut writer: W)
where
    R: BufRead,
    W: Write,
{
    let mut lines = reader.lines();
    let n: i32 = lines.next().unwrap().unwrap().parse().unwrap();

    let ans = if n % 2 == 0 { n / 2 - 1 } else { (n - 1) / 2 };

    writeln!(&mut writer, "{}", ans).unwrap();
}

fn main() {
    let stdio = io::stdin();
    let input = stdio.lock();

    let stdout = io::stdout();
    let output = BufWriter::new(stdout.lock());

    solve(input, output);
}

#[cfg(test)]
mod tests {
    use super::*;

    const TESTS: &'static [(&'static [u8], &'static [u8])] = &[
        (
            br"4", br"1
",
        ),
        (
            br"999999",
            br"499999
",
        ),
    ];

    #[test]
    fn test_a() {
        for &(input, expected) in TESTS {
            let mut output = Vec::new();
            solve(input, &mut output);
            let expected_str = String::from_utf8(expected.to_vec()).unwrap();
            let output_str = String::from_utf8(output).unwrap();
            assert_eq!(expected_str, output_str);
        }
    }
}


Measured memory_bytes: 4352
s = input()
ans = 0
if s == "RRR":
  ans = 3
if s == "RRS":
  ans = 2
if s == "RSR":
  ans = 1
if s == "RSS":
  ans = 1
if s == "SRR":
  ans = 2
if s == "SRS":
  ans = 1
if s == "SSR":
  ans = 1
if s == "SSS":
  ans = 0
print(ans)

Measured memory_bytes: 61712
def main():
	H, W = map(int, input().split())
	S = [list(input()) for _ in range(H)]

	D = [[0]*W for j in range(H)]

	D[0][0] = 1
	L = [(0,0)]

	#黒の数をカウント
	sum_black = 0
	for h in range(H):
		for w in range(W):
			if ('#'==S[h][w]):
				sum_black += 1

	for k in range(2,H*W):
		L_next = []
		for l in L:
			w = l[0]
			h = l[1]
			#上
			if (0 < h):
				if ((0 == D[h-1][w]) and ('.'==S[h-1][w])):
					D[h-1][w] = k
					L_next.append((w,h-1))
			#左
			if (0 < w):
				if ((0 == D[h][w-1]) and ('.'==S[h][w-1])):
					D[h][w-1] = k
					L_next.append((w-1,h))
			#下
			if (h < (H - 1)):
				if ((0 == D[h+1][w]) and ('.'==S[h+1][w])):
					D[h+1][w] = k
					L_next.append((w,h+1))
			#右
			if (w < (W - 1)):
				if ((0 == D[h][w+1]) and ('.'==S[h][w+1])):
					D[h][w+1] = k
					L_next.append((w+1,h))
		L = L_next
		if (0 != D[H-1][W-1]):
			break
		if (not L):	#リストが空
			return -1

	return W*H - D[H-1][W-1] - sum_black

print(main())


Measured memory_bytes: 3188
"use strict";
function main(input) {
    var line = input.split(" ");
    let a = parseInt(line[0]);
    let b = parseInt(line[1]);
    let h = parseInt(line[2]);
    let m = parseInt(line[3]);
    
    var angle = 0.5*(60*h - 11*m);
    if(angle>180) angle = angle-360;
    //convert into degree
    angle = (angle*3.14159265359)/180;
    var cost = Math.cos(angle);
    var sqs = (a*a)+(b*b) - (2*a*b*(cost));
    var ans = Math.sqrt(sqs);
    console.log(ans.toPrecision(20));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

public class Main {
	public static void main(String[] args) throws IOException {
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		String s = sc.next();
		
		Stack<Character> stack = new Stack<>();
		for(int i = 0; i < n; i++) {
			if(stack.isEmpty())
				stack.add(s.charAt(i));
			else {
				char c = stack.peek();
				if(c != s.charAt(i))
					stack.add(s.charAt(i));
			}
		}
		
		System.out.println(stack.size());
	}
}


Measured memory_bytes: 26316
<?php
fscanf(STDIN,"%s", $s);
$a = str_split($s, 2);
if($a[1]>=1 && $a[1]<=12){
	if($a[0]>=1 && $a[0]<=12) $output = "AMBIGUOUS";
	else $output = "YYMM";
}
else{
	if($a[0]>=1 && $a[0]<=12) $output = "MMYY";
	else $output = "NA";
}
echo $output;


Measured memory_bytes: 4728
#include <iostream>
#include <stdio.h>


int main()
{
    using namespace std;

    int x;
    int i=1;
    while (1)
    {
        cin >> x;
        if (x)
        {
            printf("Case %d: %d\n", i, x);
            i++;
        }
        else if(!x)
        {
            break;
        }
    }
}


Measured memory_bytes: 3020
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
int N,M;
vector<pair<int,int> >Es;
main()
{
	cin>>N>>M;
	for(int i=0;i<M;i++)
	{
		int u,v;cin>>u>>v;
		u--,v--;
		Es.push_back(make_pair(u,v));
	}
	int ans=0;
	for(int i=0;i<M;i++)
	{
		vector<vector<int> >G(N);
		for(int j=0;j<M;j++)
		{
			if(i!=j)
			{
				int u=Es[j].first,v=Es[j].second;
				G[u].push_back(v);
				G[v].push_back(u);
			}
		}
		queue<int>P;P.push(0);
		vector<bool>vis(N,false);
		vis[0]=true;
		int cnt=1;
		while(!P.empty())
		{
			int u=P.front();P.pop();
			for(int v:G[u])
			{
				if(!vis[v])
				{
					vis[v]=true;
					P.push(v);
					cnt++;
				}
			}
		}
		if(cnt<N)ans++;
	}
	cout<<ans<<endl;
}


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

#define rep(i, n) for(int i = 0; i < n; i++)

// void func(type &variable)とすることで参照渡しとなる。
void STLSort(vector<int> &x){
    sort(x.begin(), x.end());
}

void printVec(vector<int> x, int n){
    for(int i = 0; i < n - 1; i++){
        cout << x.at(i) << " ";
    }
    cout << x.at(n - 1);
}
void insertionSort(vector<int> &x, int n){
    //
    for(int i = 1; i < n; i++){
        printVec(x, n);
        cout << endl;

        int v = x.at(i);
        int j = i - 1;
        while(j  >= 0 && x.at(j) > v){
            x.at(j + 1) = x.at(j);
            j--;
        }
        x.at(j + 1) = v;
    }
}

int bubbleSort(vector<int> &x, int n){
    int flag = 1;
    int cnt = 0;
    // swapが無くなったらループ終了
    while(flag){
        flag = 0;
        for(int j = n - 1; j > 0; j--){
            if(x.at(j) < x.at(j-1)){
                int tmp = x.at(j-1);
                x.at(j-1) = x.at(j);
                x.at(j) = tmp;
                flag = 1;
                cnt++;
            }
        }
    }
    return cnt;
}

int main(){
    int n; cin >> n;
    vector<int> x(n);

    rep(i, n){
        cin >> x.at(i);
    }

    int swap_cnt = 0;

    swap_cnt = bubbleSort(x, n);
    printVec(x, n);
    cout << endl;
    cout << swap_cnt << endl;

}



Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

// chmax, chmin
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;
}

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail {
template <typename T, std::size_t NDIMS>
struct vector_builder {
  using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
    if (!dims.empty()) dims.pop_back();
    return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
  }
};

template <typename T>
struct vector_builder<T, 1> {
  using type = std::vector<T>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    return type(dims.empty() ? 0 : dims.back(), v);
  }
};
}  // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T& v, SIZE_T... dims) {
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T& data, vector<int>& iter) {
  cout << data << " ";
}
template <typename T>
void dump(const vector<T>& data, vector<int>& iter) {
  for (auto elem : data) dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>>& data, vector<int>& iter) {
  for (auto elem : iter) {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++) {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T>& data, int dummy) {
  for (int i = 0; i < data.size(); i++) {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T& data) {  // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

bool isM(string s) {
  if ("01" <= s && s <= "12") return true;
  return false;
}

void solve(string S) {
  vector<string> ans = {"NA", "YYMM", "MMYY", "AMBIGUOUS"};
  int score = 0;
  if (isM(S.substr(0, 2))) score += 2;
  if (isM(S.substr(2, 2))) score += 1;
  cout << ans[score] << endl;
}

int main() {
  cout << setprecision(10);
  string s;
  cin >> s;
  solve(s);
  return 0;
}


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

int main(){
	int h,w,z,x,y,res,a;
	while(1){
		res = 100000;
		bool f = true;
		cin >> h >> w;
		if(h == 0)break;
		z = h*h + w*w;
		for(int i = 1;i < 151;i++){
			for (int j = i+1; j < 151;j++){
				a = (i*i) + (j*j);
				if(a == z && i > h){
					res = min(res,a);
					x = j;
					y = i;
					f = false;
					break;
				}
			}
		if(f == false)break;
		}
		if(f == false){
			cout << y << " " << x << endl;
			continue;
		}
		for(int i = 1;i < 151;i++){
			for(int j = i+1;j < 151;j++){
				a = (i*i)+(j*j);
				if(z < a){
					if(res == a)continue;
					res = min(res,a);
					if(res == a){
						x = j;
						y = i;
					}
				}
			}
		}
		cout << y << " " << x << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
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 long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,cnta=0,cntb=0,cnt=0;
	cin >> n;
	vector<ll>p(n),q(n),w;
	rep(i, n)cin >> p[i];
	rep(i,n)cin >> q[i];
	rep(i, n)w.push_back(i+1);
	do {
			cnt++;
			if (p == w)cnta = cnt;
			if (q == w)cntb = cnt;
	}while(next_permutation(all(w)));
	cout << abs(cntb - cnta) << endl;
} 




Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define ctoi(n) ((n)-'0')

int main(int argc, char const* argv[])
{
	char sr[5]={},sa[5]={};
	scanf("%s %s",sr,sa);
	while (atoi(sr)) {
		char *pr, *pa;
		unsigned h = 0,b = 0;
		unsigned n[10] = {};
		pr = sr;
		pa = sa;
		do {
			if (*pr==*pa) {
				h++;
			}
			else {
				n[ctoi(*pr)]++;
			}
		} while ((( *++pr ) && ( *++pa ))) ;
		pa = sa;
		do {
			if (n[ctoi(*pa)]) {
				b++;
			}
		} while (*++pa) ;
		printf("%d %d\n", h, b);
		scanf("%s %s",sr,sa);
	}
	return 0;
}

Measured memory_bytes: 548
# coding: utf-8
# Your code here!
odd={0:1}
even={0:1,1:3}
M=10**9+7
def memo(N):
    if N ==0:
        return 1
    if N==1:
        return 2
    return (memoodd((N-1)//2)+memoeven(N//2))%M


def memoodd(N):
    if N in odd:
        return odd[N]
#    a=memoodd((N-1)//2)
#    b=memoeven(N//2)
    odd[N] = memo(N)
    return odd[N]

def memoeven(N):
    if N in even:
        return even[N]
#    a=memoodd((N-1)//2)
#    b=memoeven(N//2)
#    c=memoodd((N-2)//2)
#    d=memoeven((N-1)//2)
#    return a+b+c+d
    even[N] = (memo(N)+memo(N-1))%M
    return even[N]

n=int(input())

print(memo(n))


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

long long dp[3002][3005];
long long a[100005];
long long w[100005];
long long v[100005];

int main()
{
    string s , t;

    cin >> s >> t;

    string ans;

    for(int i = 1 ; i<=s.size() ; i++)
    {
        for(int j = 1 ; j<=t.size() ; j++)
        {
            if(s[i-1]==t[j-1])
            {
                dp[i][j] = dp[i-1][j-1] + 1;
                //ans = ans + s[i-1];
            }
            else
            {
                if(dp[i-1][j]>=dp[i][j-1])
                {
                    dp[i][j] = dp[i-1][j];
                    //ans = ans + s[i-1];
                }
                else
                {
                    dp[i][j] = dp[i][j-1];
                    //ans = ans + t[j-1];
                }
            }
        }
    }

    for(int i = s.size() , j=t.size() ; i>=1 && j>=1 ; )
    {
            if(dp[i-1][j]==dp[i][j])
            {
                i--;
            }
            else if(dp[i][j]==dp[i][j-1])
            {
                j--;
            }
            else if(s[i-1]==t[j-1])
            {
                ans = ans + s[i-1];
                i--;
                j--;
            }

    }

    reverse(ans.begin() , ans.end());

    cout << ans;
    return 0;
}


Measured memory_bytes: 71040
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

const string NO = "IMPOSSIBLE";

void solve(long long A, long long B){
    if ((A + B) % 2 != 0) {
        cout << "IMPOSSIBLE" << endl;
    } else {
        cout << (A + B) / 2 << endl;
    }
}

signed main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256