akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int a,b,c,d,e,f;
	set<int> w;
	set<int> s;
	cin >> a >> b >> c >> d >> e >>f;
	for(int i = 0; i <= f/a; i++) {
		for(int j = 0; j <= f/b; j++) {
			int tmp = a*i + b*j;
			if (tmp <= f && tmp != 0){
				w.insert(tmp);
			}
		}
	}

	for(int i = 0; i <= f/c; i++) {
		for(int j = 0; j <= f/d; j++) {
			int tmp = c*i + d*j;
			if (tmp <= f){
				s.insert(tmp);
			}
		}
	}
	// for(auto  itr = w.begin(); itr != w.end(); itr++) {
	// 	cout << *itr << endl;
	// }

	// for(auto  itr = s.begin(); itr != s.end(); itr++) {
	// 	cout << *itr << endl;
	// }

	float x = (float(100*e))/(float(100+e));
	int water = a*100;
	int sugar = 0;
	float max = 0.0;
	for(auto  itr = w.begin(); itr != w.end(); itr++) {
		for(auto  itr2 = s.begin(); itr2 != s.end(); itr2++) {
			float tmp = (float(100*(*itr2)))/(float((*itr)*100+(*itr2)));
			if (tmp <= x && tmp > max && *itr * 100 + (*itr2) <= f){
				water = *itr * 100;
				sugar = *itr2;
				max = tmp;
				if(tmp == x){
					break;
				}
			}
		}
	}
	cout << water + sugar << " " << sugar << endl;
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#define N 105

void makeG(int *,int,int);

int main (){
  int n,p,q,i,j,data[N][N];

  scanf("%d",&n);


  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      data[i][j]=0;
    }
  }

  
  for(i=0;i<n;i++){
    scanf("%d%d",&p,&q);
      makeG(data[p],p,q);
    }
  

  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      printf("%d",data[i][j]);
      if(j!=n) printf(" ");
    }
    printf("\n");
  }
  


  return 0;
}


void makeG(int *data,int p,int q){
  int i,m[N];
  
  for(i=0;i<q;i++){
    scanf("%d",&m[i]);
  data[m[i]]=1;
}
}



Measured memory_bytes: 2128
#include <stdio.h>

int main(void) 
{
	int n, count;

	while (scanf("%d", &n), n != 0) {
		count = 0;
		while (n != 1) {
			if (n % 2 == 0) {
				n /= 2;
			} else {
				n = 3 * n + 1;
			}
			count++;
		}
		printf("%d\n", count);
	}
	return 0;
}

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

ll a, b, c, k, total = 0;

int main()
{
    ios_base::sync_with_stdio(false);
    cin >> a >> b >> c >> k;
    total += 1 * min(a, k);
    k -= min(a, k);
    if (k > 0)
    {
        total += 0 * min(b, k);
        k -= min(b, k);
    }
    if (k > 0)
    {
        total += -1 * min(c, k);
        k -= min(c, k);
    }
    cout << total;
    cin >> a;
}

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

int main(void)
{
    char s[200001];
    int i,f,l;
    gets(s);
    for(i=0;;i++){
        if(s[i]=='A'){
            f=i;
            break;
        }        
    }
    for(i=strlen(s)-1;;i--){
        if(s[i]=='Z'){
            l=i;
            break;
        }
    }
    printf("%d",l-f+1);
    return 0;
}

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


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

    int sum = (L + (L + N - 1)) * N / 2;

    int removed;
    if(L <= 0){
        removed = min(0, L + N - 1);
    }else{
        removed = L;
    }

    cout << sum - removed << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
ll n,m,k;
int main()
{
	cin >>n>>m>>k;
	ll x=min(n,k);
	n-=x,k-=x;
	m-=min(m,k);
	cout <<n<<" "<<m;
	return 0;
}

Measured memory_bytes: 256
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
ll a[100005][5];
ll dp[100005][5];
ll
sol (int i, int ind)
{
  ll res = 0;
  if (i >= n)
    return 0;
  if (dp[i][ind] != -1)
    return dp[i][ind];
  for (int j = 0; j < 3; j++)
    {
      if (j != ind)
	res = max (res, sol (i + 1, j) + a[i][j]);
    }
  return dp[i][ind] = res;
}


int
main ()
{
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 3; j++)
      cin >> a[i][j];
  memset (dp, -1, sizeof dp);
  cout << sol (0, 5);
}


Measured memory_bytes: 15872
#!/usr/bin/env python3
INF=1e10

def comb(a, b):
    res=1
    for i in range(b):
        res*=(a-i)
    for i in range(b):
        res//=(b-i)
    return res

from collections import defaultdict
N,A,B=map(int, input().split())
V=list(map(int, input().split()))
V=sorted(V, reverse=True)
cnts = defaultdict(lambda: 0)
for v in V:
    cnts[v]+=1

ans, cnt = -INF, 0
for n in range(A, B+1):
    tmp = sum(V[:n])/n
    if tmp < ans:
        continue
    if tmp > ans:
        ans=tmp
        cnt=0
    nb = 0
    for i in range(n):
        if V[i]==V[n-1]:
            nb+=1
    cnt += comb(cnts[V[n-1]], nb)
print(ans)
print(cnt)
        


Measured memory_bytes: 3316
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX(a,b) (a > b) ? a : b
#define MIN(a,b) (a < b) ? a : b
const int inf = 1000000000; // 10^9

int main(){
   int h,w;scanf("%d%d",&h,&w);
   char a[101][101];
   for(int i = 0;i < h;i++)scanf("%s",a[i]);
   for(int i = 0;i < w+2;i++){
      printf("#");
   }
   printf("\n");
   for(int i = 0;i < h;i++){
      printf("#");
      printf("%s",a[i]);
      printf("#\n");
   }
   for(int i = 0;i < w+2;i++){
      printf("#");
   }
}

Measured memory_bytes: 128
import java.util.Scanner;
import java.util.function.Function;

public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    Scanner sc = new Scanner(System.in);

    void solve() {
        String str = sc.nextLine();
        char[] c = str.toCharArray();
        for (int i = 0; i < str.length(); ++i) {
            System.out.print(converter(c[i]));
        }
        System.out.println("");
    }

    char converter(char c) {
        if (Character.isUpperCase(c))
            return Character.toLowerCase(c);
        if (Character.isLowerCase(c))
            return Character.toUpperCase(c);
        return c;
    }
}






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

int main() {
    int a, b;
    cin >> a >> b;

    if(a > b) {
        int tmp = a;
        a = b;
        b = tmp;
    }

    for(int i = 0; i < b; i++) cout << a;
    cout << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
struct point
{
    int x,y;
};


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,m;
    cin >> n >> m;
    vector<point> a(n),b(m);
    for(int i=0; i<n; ++i)
    {
        point k;
        cin >> k.x >> k.y;
        a[i]=k;
    }
    for(int i=0; i<m; ++i)
    {
        point k;
        cin >> k.x >> k.y ;
        b[i]=k;
    }

    for(int i=0; i<n; ++i)
    {
        int len = 1e9;
        int id=0;
        for(int j=0; j<m; ++j)
        {
            int dis = abs(b[j].x-a[i].x) + abs(b[j].y-a[i].y);
            if (dis < len)
            {
                len = dis;
                id =j;
            }
        }
        cout << id+1 << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

int main() {
  int X, Y;
  cin >> X >> Y;

  cout << X+Y/2 << endl;
  
}

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

struct UF{
    vector<int> d;
    UF(int n):d(n,-1){}
    bool set(int x,int y){
        x=root(x),y=root(y);
        if(x!=y){if(d[y]<d[x])swap(x,y);d[x]+=d[y];d[y]=x;}
        return x!=y;
    }
    bool find(int x,int y){return root(x)==root(y);}
    int root(int x){
        while(d[x]>=0){if(d[d[x]]>=0)d[x]=d[d[x]];x=d[x];}
        return x;
    }
    int size(int x){return -d[root(x)];}
};

int main () {
  int i,n,q;cin>>n>>q;
  UF uf(10000);
  for(i = 0;i < q; ++i) {
    int a,x,y;cin>>a>>x>>y;
    if(a == 0) {
      uf.set(x,y);
    }else {
      cout<<(uf.find(x,y)?1:0)<<endl;
    }
  }
}

Measured memory_bytes: 3116
from sys import stdin

def S(): return stdin.readline().rstrip()

n = S()
l = len(n)

p = int(n[l-1])
a = {0:'pon',1:'pon',2:'hon',3:'bon',4:'hon',5:'hon',6:'pon',7:'hon',8:'pon',9:'hon'}
print(a[p])

Measured memory_bytes: 9188
N, M = map(int, input().split())

m = M//N

# def prime_factors(n):
#     i = 2
#     factors = OrderedDict()
#     while i * i <= n:
#         if n % i:
#             i += 1
#         else:
#             n //= i
#             if i in factors:
#               factors[i] += 1
#             else:
#               factors[i] = 1
#     if n > 1:
#       if n in factors:
#         factors[n] += 1
#       else:
#         factors[n] = 1
#     return factors

def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a

if M == 1:
  print(1)
  exit()

fct = factorize(M)
current_n = 1

for div in divisorize(fct):
    n = num(div)
    if n <= m and current_n < n:
      current_n = n

print(current_n)

# for x in range(m, 0, -1):
#   if M % x == 0:
#     print(x)
#     break



Measured memory_bytes: 3064
// in the name of Allah ;
#include<bits/stdc++.h>
using namespace std ;
const int maxn = 1e5 + 10 , rem = 1e9 + 7 ;
long long arr[maxn] , t[maxn] , n , tt = 0 , num[maxn] ;
void tavan2 () 
{
	t[0]  = 1 ;
	for ( int i = 0 ; i < n ; i++ ) 
		t[i+1] = t[i]*2 , t[i+1] %= rem ;
}
int main ()
{
	cin >> n ;
	tavan2();
	for ( int i = 0 ; i < n ; i++ )
		cin >> arr[i] , num[arr[i]]++;
	if ( ( n % 2 == 1 && num[0] != 1 ) || ( n % 2 == 0 && num[0] != 0 ) ) 
	{		
		cout << 0 << endl;
		return 0 ;
	}
	for ( int i = 0 ; i < n ; i++ )
		if ( n % 2 == arr[i] && num[arr[i]]  )
		{
			cout << 0 << endl;
			return 0 ;
		} 
	for ( int i = 1 ; i < n ; i++ ) 
	{
		if ( num [i] && num[i] != 2 )
		{
			cout << 0 << endl;
			return 0 ;
		}
		else if ( num[i] ) 
			tt++;
	}
	cout << t[tt] << endl;
}

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

using namespace std;

int s[42][42];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      int c = getchar();
      while (c <= 32) c = getchar();
      s[i][j] = c;
    }
  }
  if (s[0][0] != '#') {
    puts("Impossible");
    return 0;
  }
  for (int i = 0, j = 0; i + 1 < n || j + 1 < m; ) {
    s[i][j] = '.';
    if (i + 1 < n && s[i + 1][j] == '#') {
      i++;
    } else if (j + 1 < m && s[i][j + 1] == '#') {
      j++;
    } else {
      puts("Impossible");
      return 0;
    }
  }
  s[n - 1][m - 1] = '.';
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (s[i][j] == '#') {
        puts("Impossible");
        return 0;
      }
    }
  }
  puts("Possible");
}


Measured memory_bytes: 764
while True:
    n, x = map(int,input().split())
    if n == 0 and x == 0:
        break
    ans = 0
    for i in range(1,n+1):
        for j in range(1,i):
            for k in range(1,j):
                if i + j + k == x:
                    ans += 1
    print(ans)


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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

pii expr(const string& s,int i);

pii fact(const string& s,int i)
{
	//dump(mp(__func__,i));
	const int n=s.size();
	if(i==n) throw "fact: out of range";
	if(s[i]=='('){
		int x,j; tie(x,j)=expr(s,++i);
		int c=0,ok=false;
		repi(k,i,j){
			if(s[k]=='(') c++;
			if(s[k]==')') c--;
			if(c==0 && strchr("+-*",s[k])) ok=true;
		}
		if(!ok) throw "fact: '(' number ')' is invalid";
		return mp(x,j+1);
	}
	if(!isdigit(s[i])) throw "fact: invalid char";
	int x=0;
	for(;i<n && isdigit(s[i]);i++){
		(x<<=1)+=s[i]-'0';
		if(x<0 || 1024<=x) throw "fact: overflow";
	}
	return mp(x,i);
}

pii term(const string& s,int i)
{
	//dump(mp(__func__,i));
	const int n=s.size();
	if(i==n) throw "term: out of range";
	int x; tie(x,i)=fact(s,i);
	while(i<n && strchr("*",s[i])){
		char op=s[i++];
		int y; tie(y,i)=fact(s,i);
		x*=y;
		if(x<0 || 1024<=x) throw "term: overflow";
	}
	return mp(x,i);
}

pii expr(const string& s,int i)
{
	//dump(mp(__func__,i));
	const int n=s.size();
	if(i==n) throw "expr: out of range";
	int x; tie(x,i)=term(s,i);
	while(i<n && strchr("+-",s[i])){
		char op=s[i++];
		int y; tie(y,i)=term(s,i);
		if(op=='+') x+=y;
		else        x-=y;
		if(x<0 || 1024<=x) throw "expr: overflow";
	}
	return mp(x,i);
}

int main()
{
	for(string s;cin>>s && s!="#";){
		vi ds;
		rep(i,s.size()) if(s[i]=='.') ds.push_back(i);
		
		int pat=1;
		rep(i,ds.size()) pat*=7;
		
		int res=-1;
		rep(i,pat){
			for(int j=0,k=i;j<ds.size();j++,k/=7)
				s[ds[j]]="01+-*()"[k%7];
			try{
				int x,i; tie(x,i)=expr(s,0);
				if(i==s.size()){
					res=max(res,x);
					//cout<<s<<": "<<x<<endl;
				}
			}
			catch(const char* msg){
				//dump(msg);
				//cout<<s<<": "<<msg<<endl;
			}
		}
		cout<<res<<endl;
	}
}

Measured memory_bytes: 1272
n=int(input())
zoro=0
flg=0
for i in range(n):
  a,b=map(int,input().split())
  if a==b:
    zoro+=1
  else:
    zoro=0
  if zoro==3:
    flg=1
if flg==1:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9176
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

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


int main()
{
    int n;
    long long k;
    long long ans;
    vector<long long> a;
    
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> k;
        a.push_back(k);
    }
    
    sort(a.begin(),a.end());
       
    ans = a[0];
    for (int i = 0;i < a.size();i++){
        ans = gcd(a[i],ans);
    }
    cout << ans << endl;
}


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


void solve(long long N){
    float s=N;
    if(N%2==0) cout<<0.5<<endl;
    else cout<<(float) ((s+1)/s/2)<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::cout<<std::fixed<<std::setprecision(10);//誤差小数10桁まで
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
// Problem: B - Magic 2
// Contest: AtCoder - M-SOLUTIONS Programming Contest 2020
// URL: https://atcoder.jp/contests/m-solutions2020/tasks/m_solutions2020_b
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*
 *   ﷽
 * In the name of Allah, the Most Gracious, the Most Merciful
 */

#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <climits>

using namespace std;

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	int k;
	cin>>k;
	while( a >= b){
		k--;
		b = 2*b;
	}
	while(b >= c)
	{
		k--;
		c = 2*c;
	}
	if(k >= 0) cout <<"Yes";
	else cout <<"No";

	return 0;
}

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

#define point pair<int ,int>
#define x first
#define y second

int n;
vector <point> vs;

double ang(point p){
    if(p.x >= 0 && p.y >= 0 || p.x <= 0 && p.y >= 0)
        return acos(p.x/sqrt(1LL*p.x*p.x + 1LL*p.y*p.y));
    return 360-acos(p.x/sqrt(1LL*p.x*p.x + 1LL*p.y*p.y));
}
bool cmp(point p1 ,point p2){
    return ang(p1) < ang(p2);
}

int main()
{
    scanf("%d",&n);
    for(int a,b,i=0; i<n; i++){
        scanf("%d%d",&a,&b);
        if(a||b)
            vs.push_back({a ,b});
    }

    n = vs.size();
    sort(vs.begin() ,vs.end() ,cmp);
    vs.insert(vs.end() ,vs.begin() ,vs.end());

    long long ans = 0LL;
    for(int i=0; i<n; i++){
        long long sx = 0LL ,sy = 0LL;
        for(int j=i; j<i+n; j++){
            sx += vs[j].x ,sy += vs[j].y;
            ans = max(ans ,1LL*sx*sx + 1LL*sy*sy);
        }
    }

    printf("%.10f\n",sqrt(ans));
}


Measured memory_bytes: 384
#include <stdio.h>
int main(){
  int N,A[100],i=0,j,tmp,flag=1,count=0;

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  while(flag==1){
    flag=0;
    for(j=N-1;j>=1;j--){
      if(A[j]<A[j-1]){
	tmp=A[j];
	A[j]=A[j-1];
	A[j-1]=tmp;
	flag=1;
	count++;
      }
    }
  }
  for(i=0;i<N-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[i]);
  printf("%d\n",count);
   
  return 0;
}

Measured memory_bytes: 600
a,b,c = gets.split('').map(&:to_i)
if a==1 && b==1 && c==1
  puts 3
elsif (a==0 && b==1 && c==1) ||  (a==1 && b==0 && c==1) ||  (a==1 && b==1 && c==0) 
  puts 2
elsif (a==0 && b==0 && c==1) ||  (a==0 && b==1 && c==0) ||  (a==1 && b==0 && c==0) 
  puts 1
else
  puts 0
end

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

template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}

signed main(){
  int h,w;cin>>h>>w;
  vector<string> s(h);
  for(int i=0;i<h;i++)cin>>s[i];
  int nowy=0,nowx=0;
  while(nowy!=h-1||nowx!=w-1){
    if(nowy<h-1&&s[nowy+1][nowx]=='#')s[nowy++][nowx]='A';
    else if(nowx<w-1&&s[nowy][nowx+1]=='#')s[nowy][nowx++]='A';
    else fin("Impossible");
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if((i<h-1||j<w-1)&&s[i][j]=='#')fin("Impossible");
    }
  }
  fin("Possible");
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

//Stopping Problem
public class Main{

	boolean[][][][] u;
	int r, c;
	int[][] move = {{-1,0},{0,1},{1,0},{0,-1}};

	int ni(int i, int d){
		return (i+move[d][0]+r)%r;
	}
	int nj(int j, int d){
		return (j+move[d][1]+c)%c;
	}
	
	
	void add(int i, int j, int m, int d, List<int[]> l){
		if(!u[i][j][m][d]){
			u[i][j][m][d] = true;
			l.add(new int[]{i,j,m,d});
		}
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		r = sc.nextInt();
		c = sc.nextInt();
		char[][] m = new char[r][c];
		for(int i=0;i<r;i++)m[i]=sc.next().toCharArray();
		u = new boolean[r][c][16][4];
		boolean g = false;
		List<int[]> l = new ArrayList<int[]>();
		l.add(new int[]{0,0,0,1});
		u[0][0][0][1] = true;
		while(!g&&!l.isEmpty()){
			List<int[]> next = new ArrayList<int[]>();
			for(int a[]:l){
				int i = a[0];
				int j = a[1];
				int mem = a[2];
				int dir = a[3];
				char ch = m[i][j];
				if(ch=='<'){
					add(ni(i,3),nj(j,3),mem,3,next);
				}
				else if(ch=='>'){
					add(ni(i,1),nj(j,1),mem,1,next);
				}
				else if(ch=='^'){
					add(ni(i,0),nj(j,0),mem,0,next);
				}
				else if(ch=='v'){
					add(ni(i,2),nj(j,2),mem,2,next);
				}
				else if(ch=='_'){
					if(mem==0)add(ni(i,1),nj(j,1),mem,1,next);
					else add(ni(i,3),nj(j,3),mem,3,next);
				}
				else if(ch=='|'){
					if(mem==0)add(ni(i,2),nj(j,2),mem,2,next);
					else add(ni(i,0),nj(j,0),mem,0,next);
				}
				else if(ch=='?'){
					add(ni(i,3),nj(j,3),mem,3,next);
					add(ni(i,1),nj(j,1),mem,1,next);
					add(ni(i,0),nj(j,0),mem,0,next);
					add(ni(i,2),nj(j,2),mem,2,next);
				}
				else if(ch=='@'){
					g = true;
					break;
				}
				else if(ch=='+'){
					add(ni(i,dir),nj(j,dir),(mem+1)%16,dir,next);
				}
				else if(ch=='-'){
					add(ni(i,dir),nj(j,dir),(mem+15)%16,dir,next);
				}
				else if(Character.isDigit(ch)){
					add(ni(i,dir),nj(j,dir),ch-'0',dir,next);
				}
				else {
					add(ni(i,dir),nj(j,dir),mem,dir,next);
				}
			}
			l = next;
		}
		System.out.println(g?"YES":"NO");
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>
#include <cstdint>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef unsigned long long		SQWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	string s;
	int k;
	cin >> s >> k;

	vector<string> subStrList;
	REP(i, s.size()) {
		REP(j, 5) {
			subStrList.emplace_back(s.substr(i, j + 1));
		}
	}
	sort(subStrList.begin(), subStrList.end());
	subStrList.erase(unique(subStrList.begin(), subStrList.end()), subStrList.end());
	cout << subStrList[k - 1] << endl;
	return 0;
}



Measured memory_bytes: 1660
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int N, M;
  cin >> N >> M;
  if (N == M) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3052
//PLUS ULTRA

#include<bits/stdc++.h>
using namespace std;
     
     
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back 
#define mp make_pair
#define forn(i,st,n) for(int i = st; i < n ; i++)
#define nfor(i,st,n) for(int i = st; i >= n ; i--)

typedef long long ll;
typedef pair <int , int> pii;

const int N = 1e5 + 10 , mod =  1000000007;



int main(){
    SPEED;

    ll x; cin >> x;

    ll ans = 0;

    ll a;

    ans = x / 500;
    a = (ll)ans * 1000;
    x = x - (ans * 500);

    ans = x/5;

    a += ans * 5;


    cout << a << endl;
    
    return 0;
}
      
       


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

int main() {
    int n;
    cin >> n;
    ll md = 1e9 + 7;
    ll power = 1;
    for (int i = 1; i <= n; i++) {
        power = i * power % md;
    }
    printf("%lld\n", power);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;


int main(){
    
    int N; cin>>N;
    vector<int> k(N*2);
    REP(i,N*2)cin>>k[i];
    sort(k.begin(),k.end());
    
    ll ans=0;
    REP(i,N){
        ans+=min(k[2*i],k[2*i+1]);
    }
    
    cout<<ans<<endl;
    
    return 0;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>

using namespace std;

class Cube{
    public:
    Cube(){}
    int f[6];
    
    void roll_x(){
        roll(0, 1, 5, 4);
    }
    void roll_y(){
        roll(0, 2, 5, 3);
    }
    void roll_z(){
        roll(1, 2, 4, 3);
    }
    
    void roll(int i, int j, int k, int l){
        int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
    }
};

int getRight(Cube c1, int f1, int f2){
    for(int i = 0; i < 6; i++){
        for(int j = 0; j < 4; j++){
            if(c1.f[0] == f1 && c1.f[1] == f2) return c1.f[2];
            c1.roll_z();
        }
        if(i % 2 == 0) c1.roll_y();
        else c1.roll_x();
    }
    return -1;
}

int main(){
    Cube c;
    int f1, f2;
    
    for(int i = 0; i < 6; i++){
        cin >> c.f[i];
    }
    int q;
    cin >> q;
    
    for(int i = 0; i < q; i++){
        cin >> f1 >> f2;
        cout << getRight(c, f1, f2) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;
const int MAX = 210000;

long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

lint nsum(lint n) {
    return n * (n+1) / 2;
}

int main() {
    lint n, k;
    cin >> n >> k;

    lint res = 0;

    for (int a = k; a <= n; a++) {
        lint c = nsum(n) - nsum(n-a);
        lint f = nsum(a-1);

        lint t = (c - f) + 1;
        t = ((t % MOD) + MOD) % MOD;

        res += t;
        res %= MOD;
    }
    res++;
    res %= MOD;

    cout << res << endl;
    return 0;
}

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

const int64_t MOD = 1000000007;
typedef int64_t ll;
typedef uint64_t ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

/* 
  //エラトステネスのふるい
  int maxNum = 100000;
  char isNotPrime[maxNum+1] = {};
  isNotPrime[0]=isNotPrime[1]=1;
  for(int i=2;i<maxNum;i++){
    if(isNotPrime[i]==1) continue;
    int num = i+i;
    while(num<=maxNum){
      isNotPrime[num]=1;
      num += i;
    }
  }
*/
// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

// 降順ソート vector<int> v;
// sort(v.begin(),v.end(),greater<int>());

// keyが降順ソートされるmap
// map<int, int, std::greater<int>> edges;

signed main() {
  int n;
  cin >> n;
  
  map<int, int, std::greater<int>> edges;

  int e;
  for(int i=0;i<n;i++){
    cin >> e;
    edges[e]++;
  }
  
  queue<ll> rect;
  for(auto ed:edges){
    if(ed.second>=4){
      rect.push(ed.first);
      if(rect.size()==1){
        rect.push(ed.first);
      }
    }
    else if(ed.second>=2){
      rect.push(ed.first);
    }
    if(rect.size()>=2) break;
  }
  
  if(rect.size()<2){
    cout << "0" << endl;
  }
  else{
    ll area = 1;
    while(!rect.empty()){
      area = area * rect.front();
      rect.pop();
    }
    cout << area << endl;
  }
  
  return 0;
}
  

Measured memory_bytes: 8164
#include<stdio.h>
#define NIL -1

int FindDepth(int);

int FindHeight(int);
int FindSib(int);
typedef struct{
  int parent;
  int left;
  int right;
}vertex;
void output(int);
vertex V[25];
int ver[25],D[25];
int n;
int FHd=0;
main()
{
  int i,childleft,childright;
  scanf("%d",&n);

  for(i=0;i<n;i++)
    {
      V[i].parent = V[i].left = V[i].right = NIL;
    }

  for(i=0;i<n;i++)
    {
      scanf("%d",&ver[i]);/*ver[i]????????????????????\???*/
      if(i == 0){
	V[ver[i]].parent=NIL;/*root?????´???*/
      }
     
      scanf("%d",&V[ver[i]].left);/*root???parent??\???????????§???-1?????\??£??????*/
      scanf("%d",&V[ver[i]].right);

      childleft = V[ver[i]].left;
      childright = V[ver[i]].right;
      V[childleft].parent = V[childright].parent = ver[i];

    }/*??\?????????*/

  for(i=0;i<n;i++){
    D[i]=FindDepth(i);
  }
  for(i=0;i<n;i++){
   
      output(i);
      
  }
  return 0;

}

int FindDepth(int i)
{
  int d = 0,u = 0;
  while(1){

    if(V[i].parent == NIL)break;
    d++;
    i = V[i].parent;
  }
  return d;
}

int FindHeight(int i)
{
  int RightHeight=0,LeftHeight=0;
  
 
  if( V[i].left == NIL && V[i].right == NIL )return 0;
    if(V[i].left!=NIL)LeftHeight = FindHeight(V[i].left)+1; 
    if(V[i].right!=NIL)RightHeight = FindHeight(V[i].right)+1;
   
    if(RightHeight>LeftHeight)return RightHeight;
    else return LeftHeight;
  
}

int FindSib(int i){
  int k;
  k = V[i].parent;
  if(k==-1)return NIL;
  if(i==V[k].left)return V[k].right;
  else if(i==V[k].right)return V[k].left;
  else if(V[k].right==NIL && V[k].left==NIL)return NIL;
}

void output(int p)
{
  
  printf("node %d: parent = %d, sibling = %d, degree = ",p,V[p].parent,FindSib(p));
  if(V[p].left ==NIL && V[p].right ==NIL)printf("0, ");
  else if(V[p].left == NIL || V[p].right == NIL)printf("1, ");
  else printf("2, ");

  printf("depth = %d, height = %d, ",D[p],FindHeight(p));

  if(V[p].left == NIL && V[p].right == NIL && V[p].parent!=NIL)printf("leaf\n");
  else if(V[p].parent == NIL)printf("root\n");
  else printf("internal node\n");
}

Measured memory_bytes: 612
#include <iostream>
#include<iomanip>
#include<math.h>
using namespace std;
int main() {
  while(1){
    int n;
    cin>>n;
    if(n==0)break;
    int s[n];
    double sum=0;
    for(int i=0;i<n;i++){
      cin>>s[i];
      sum+=s[i];
    }
    double a=0;
    sum/=n;
    for(int i=0;i<n;i++)a+=(s[i]-sum)*(s[i]-sum)/n;
    cout<<setprecision(10);
    cout<<sqrt(a)<<endl;
  }//pow(s[i]-m,2)
  return 0;
}/*
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main(){
    int n;
    while(1){
        cin >> n;
        if(n==0) break;
        int a[n];
        for(int i=0;i<n;i++) cin >> a[i];
        double m = 0;
        for(int i=0;i<n;i++) m += a[i];
        m /= n;
        double b = 0;
        for(int i=0;i<n;i++) b += (a[i]-m)*(a[i]-m)/n;
        cout << setprecision(10);
        cout << sqrt(b) << endl;
    }
}*/

Measured memory_bytes: 1236
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  string s; cin >> s;
  rep(i, s.size() - 1) {
    if(s[i] == s[i + 1]) {
      cout << i + 1 << " " << i + 2 << "\n";
      return 0;
    }
    if(i + 2 <= s.size() - 1) {
        if(s[i] == s[i + 2]) {
        cout << i + 1 << " " << i + 3 << "\n";
        return 0;
        }
    }
  }
  cout << -1 << " " << -1 << "\n";
  return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int N;
main()
{
	int ans=0,pre=0;
	cin>>N;
	for(int i=0;i<N;i++)
	{
		int a,b;cin>>a>>b;
		if(pre<a)
		{
			pre=a;
			ans=a+b;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <deque>

using namespace std;

typedef long long ll;

int N, A, B;
int main() {
	scanf("%d %d %d", &N, &A, &B);
	int diff = abs(A - B);
	if (diff % 2 == 0) {
		printf("Alice\n");
	} else {
		printf("Borys\n");
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string.h>
#define ll long long
using namespace std;
int A[5];
int main(){
	scanf("%d%d%d",&A[1],&A[2],&A[3]);
	int anss=0;
	sort(A+1,A+4);
	for(int i=2;i<=3;++i){
		anss+=abs(A[i]-A[i-1]);
	}
	printf("%d",anss);
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn top_sort(point: usize, adjs: &Vec<Vec<usize>>, visited: &mut Vec<bool>, sorted: &mut Vec<usize>) {
  if visited[point] {
    return;
  }
  visited[point] = true;
  for &next in adjs[point].iter() {
    top_sort(next, adjs, visited, sorted);
  }
  sorted.push(point);
}

fn main() {
  input! {
    n: usize,
    m: usize,
    edges: [(usize1, usize1); m]
  }
  let mut adjs = vec![vec![]; n];
  for &(src, dst) in edges.iter() {
    adjs[src].push(dst);
  }
  let mut visited = vec![false; n];
  let mut sorted = Vec::new();
  for point in 0..n {
    top_sort(point, &adjs, &mut visited, &mut sorted);
  }
  let mut path_len = vec![0; n];
  for &point in sorted.iter() {
    for &next in adjs[point].iter() {
      path_len[point] = cmp::max(path_len[point], path_len[next] + 1);
    }
  }
  let ans = path_len.iter().fold(0, |current, val| cmp::max(current, *val));
  println!("{}", ans);
}


Measured memory_bytes: 19324
from sys import stdin
input = stdin.readline

# map(int, input().rstrip().split())

def VI(N, init=0):
  return [init for _ in range(N)]
def VVI(N, M, init=0):
  return [[init for _ in range(M)] for _ in range(N)]

def VD(N, init=0.0):
  return [init for _ in range(N)]
def VVD(N, M, init=0.0):
  return [[init for _ in range(M)] for _ in range(N)]

A, B = map(int, input().rstrip().split())
print((A+B)%24)


Measured memory_bytes: 38256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! { a:usize, b:usize, }
    println!("{} {}", a * b, 2 * (a + b));
}



Measured memory_bytes: 5032
n,m = map(int, input().split())
wa = [0]*n
ac = [0]*n
for i in range(m):
    p,s = input().split()
    p = int(p)
    if ac[p-1]==1 :
        continue
    else:
        if s == 'AC':
           ac[p-1]+=1
        else :
            wa[p-1]+=1            
 
for i in range(n):
    if ac[i]==0:
        wa[i] = 0
 
print(sum(ac), sum(wa))

Measured memory_bytes: 4596
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i = 0; i < n; i++)
int a[3][2];
long long n, m, ans;
vector<pair<int,int>> atob;
vector<pair<int,int>> btoa;
inline long long cal(long long i, pair<int, int> pr){return i/pr.first*pr.second+i%pr.first;}

int main(){
    scanf("%lld%d%d%d%d%d%d", &n, a[0], a[1], a[2], a[0]+1, a[1]+1, a[2]+1);
    for(int i = 0; i < 3; i++){
        if(a[i][0] < a[i][1]) atob.push_back(make_pair(a[i][0], a[i][1]));
        else btoa.push_back(make_pair(a[i][1], a[i][0]));
    }
    if(atob.size() == 3){
        for(int i = 0; i <= n; i++){
            for(int j = 0; j <= n-i; j++){
                ans = max(ans, cal(i,atob[0]) + cal(j,atob[1]) + cal(n-i-j, atob[2]));
            }
        }
    }else if(atob.size() == 2){
        for(int i = 0; i <= n; i++) m = max(m, cal(i,atob[0]) + cal(n-i,atob[1]));
        ans = cal(m, btoa[0]);
    }else if(atob.size() == 1){
        m = cal(n, atob[0]);
        for(int i = 0; i <= m; i++) ans = max(ans, cal(i,btoa[0]) + cal(m-i,btoa[1]));
    }else{
        for(int i = 0; i <= n; i++){
            for(int j = 0; j <= n-i; j++){
                ans = max(ans, cal(i,btoa[0]) + cal(j,btoa[1]) + cal(n-i-j, btoa[2]));
            }
        }
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 256
N, K = map(int, input().split())
h_list = [int(input()) for i in range(N)]
#select k trees.

#昇順ソート
sorted_h = sorted(h_list)

best_score = 1000000000000
for idx, h in enumerate(sorted_h[:-K+1]):
    highest_idx = idx + K - 1
    score = sorted_h[highest_idx] - h
    
    if score < best_score:
        best_score = score
print(best_score)

Measured memory_bytes: 8652
#[allow(unused)]
use std::{io, str, vec};

#[allow(unused)]
fn read<T: str::FromStr>() -> T {
    let mut s = String::new();
    io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(unused)]
fn read_vec<T: str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

#[allow(unused)]
fn read_vec2<T: str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let v: Vec<usize> = read_vec();
    
    let mut count = 0;
    for i in (1..v[1]+1).rev() {
        if v[0]%i == 0 {
            if v[1]%i == 0 {
                count += 1;
                if count == v[2] {
                    println!("{:?}", i);
                    break;
                    }
            }
        }
    }
}

Measured memory_bytes: 4352
import bisect
import sys
input = sys.stdin.readline

A, B, Q = map(int, input().split())
s = []
for i in range(A):
    s.append(int(input()))
t = []
for i in range(B):
    t.append(int(input()))
for i in range(Q):
    x = int(input())
    j = bisect.bisect(s, x)
    ans = 2 * 10 ** 10
    if j > 0:
        k = bisect.bisect(t, s[j - 1])
        if k > 0:
            ans = min(ans,abs(x-s[j-1])+abs(s[j-1]-t[k-1]))
        if k < B:
            ans = min(ans, abs(x-s[j-1])+abs(s[j-1]-t[k]))
    if j < A:
        k = bisect.bisect(t, s[j])
        if k > 0:
            ans = min(ans, abs(x-s[j])+abs(s[j]-t[k-1]))
        if k < B:
            ans = min(ans, abs(x-s[j])+abs(s[j]-t[k]))
    j = bisect.bisect(t, x)
    if j > 0:
        k = bisect.bisect(s, t[j - 1])
        if k > 0:
            ans = min(ans,abs(x-t[j-1])+abs(t[j-1]-s[k-1]))
        if k < A:
            ans = min(ans, abs(x-t[j-1])+abs(t[j-1]-s[k]))
    if j < B:
        k = bisect.bisect(s, t[j])
        if k > 0:
            ans = min(ans, abs(x-t[j])+abs(t[j]-s[k-1]))
        if k < A:
            ans = min(ans, abs(x-t[j])+abs(t[j]-s[k]))
    print(ans)


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

int main()
{
    int N, K, tmp;
    cin >> N;
    cin >> K;
    tmp = 1;
    for (int i = 0; i < N; i++)
    {
        int ta, tb;
        ta = tmp * 2;
        tb = tmp + K;
        tmp = min(ta, tb);
    }
    cout << tmp << endl;
}


Measured memory_bytes: 256
import sys

#+++++
		
def main():
	s = input()
	ww=['dream','dreamer','erase','eraser']
	
	s=s[::-1]
	wwr=[w[::-1] for w in ww]
	#print(wwrs)
	while len(s)>0:
		#pa(s)
		is_ok=False
		for w in wwr:
			ll=len(w)
			ss=s[:ll]
			#pa((2,ss,w))
			if ss == w:
				is_ok=True
				#pa((1,ss,ll))
				s=s[ll:]
		if not is_ok:
			print('NO')
			return 
		
	print('YES')
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3236
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        s: Chars,
    }

    let zero = '0' as i32;
    let mut min = std::i32::MAX;
    for i in 0..(s.len() - 2) {
        let n = (s[i] as i32 - zero) * 100 + (s[i + 1] as i32 - zero) * 10 + s[i + 2] as i32 - zero;
        min = min.min((n - 753).abs());
    }
    println!("{}", min);
}


Measured memory_bytes: 2084
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
using namespace std;

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

    int a, b;
    cin >> a >> b;

    if (a <= b)
        cout << a << endl;
    else
        cout << a - 1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int gcd(int a, int b){
	if((0 == a) || ( 0 == b)) return 0;
	
	while( a != b){
		if( a > b) a = a - b;
		else       b = b - a;
	}
	return a;
}

int lcm(int a, int b){
	if((0 == a) || ( 0 == b)) return 0;
	
	return ((a / gcd(a,b)) * b);
}

int main(){
	int a, b;
	
	while(cin >> a >> b){
		cout << gcd(a, b) << " " << lcm(a, b) << endl;
	}
		
	return 0;
}

Measured memory_bytes: 3056
N,X = map(int,input().split())

"""
　　レベルnの層数：a_0 = 1 , a_n = 2*a_(n-1)+3
レベルnのパティ数：b_0 = 1 , b_n = 2*b_(n-1)+1
"""

def thickness(n):
    if n == 0:
        return 1
    else:
        return 2 * thickness(n-1) + 3

def patty(n):
    if n == 0:
        return 1
    else:
        return 2 * patty(n-1) + 1

def ans(n,x):
    if n == 0:
        return 1
    else:
        if x == 1:
            return 0
        if 1 < x <= thickness(n-1)+1:
            return ans(n-1,x-1)
        if x == thickness(n-1) + 2:
            return patty(n-1) + 1
        if thickness(n-1) + 2 < x <= 2 * thickness(n-1) + 2:
            return patty(n-1) + 1 + ans(n-1,x-2-thickness(n-1))
        if x == 2 * thickness(n-1) + 3:
            return 2 * patty(n-1) + 1

print(ans(N,X))


Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
	int n;
	while (scanf("%d", &n) != EOF) {
		int i;
		int a, cnt;
		cnt = 0;
		for (i = 1; i <= n; i ++) {
			scanf("%d", &a);
			if (a % 2 != 0 && i % 2 != 0) {
				cnt ++;
			}
		}
		printf("%d\n", cnt);
	}
	return (0);
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1E9 + 7;
const int INF = 1 << 29;

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  vector<int> ans(n, 0);
  int l;
  for (int i = 1; i < n; i++) {
    for (int j = i + 1; j <= n; j++) {
      l = min(abs(j - i), abs(x - i) + abs(j - y) + 1);
      ans[l]++;
    }
  }
  for (int i = 1; i < n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 256