akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#include <fstream>
#include <functional>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 200001
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
using namespace std;
struct Point{int x; int y;};
struct PPoint{Point x; Point y;};
ll gcd(ll a, ll b) { if(a < b) swap(a, b); if(b <= 0) return a; return gcd(b, a % b); }

int H, W;
bool visited[101];
bool check(string str)
{
    for(int i = 0; i < (int)str.size(); i++)
        if(str[i] == '#')
            return true;
    return false;
}
int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    cin >> H >> W;
    vector<string> grid;
    for(int i = 0; i < H; i++)
    {
        string temp; cin >> temp;
        if(check(temp))
            grid.push_back(temp);
    }
    
    for(int i = 0; i < W; i++)
    {
        bool flag = false;
        for(int j = 0; j < (int)grid.size(); j++)
        {
            if(grid[j][i] == '#')
            {
                flag = true;
                break;
            }
        }
        if(flag == false)
            visited[i] = true;
    }
    
    for(int i = 0; i < grid.size(); i++)
    {
        for(int j = 0; j < grid[i].size(); j++)
        {
            if(visited[j]) continue;
            cout << grid[i][j];
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int i,j,num,count[26];
    char a[1200],ch;
     
    i = 0;
    while(scanf("%c", &ch)!=EOF){
        a[i]=ch;
        i++;
    }
  
    for(j=0;j<26;j++) count[j]=0;
    
  
    for(j=0;j<i;j++){
  
        if(a[j]>=65 && a[j]<=90) a[j]+=32;
        if('a'<=a[j] && a[j]<='z'){
            num= a[j]-'a';
            count[num]++;
        }
    }
  
    for(j=0;j<26;j++) printf("%c : %d\n",j+97,count[j]);
     
    return 0;
}



Measured memory_bytes: 2056
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

#include <cstdio>

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

int A[100000];

int main()
{
	int N;
	int Amin = 1000000000;
	ll ans = 0;
	bool zero = false;;

	cin >> N;
	rep(i, N) cin >> A[i];

	rep(i, N - 1) {
		if (A[i] < 0) {
			A[i] *= -1;
			A[i + 1] *= -1;
		}
		else if (A[i] == 0) zero = true;
	}

	rep(i, N) ans += (ll)abs(A[i]);

	if (A[N - 1] < 0 && !zero) {
		rep(i, N) Amin = min(Amin, abs(A[i]));
		ans -= (ll)Amin * 2;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
N = int(input())
D1 = []
D2 = []
for _ in range(N):
    d1, d2 = list(map(int, input().split()))
    D1.append(d1)
    D2.append(d2)

seq = 0
prev = False
for i in range(N):
    if D1[i] == D2[i]:
        if not prev:
            prev = True
            seq = 1
        else:
            seq += 1
        if seq >= 3:
            print("Yes")
            exit()
    else:
        prev = False
print("No")


Measured memory_bytes: 9192
#include <iostream>
#include <math.h>
#include <string>
using namespace std;

int main() {
    int price = 700;
    string s;
    cin >> s;

    if (s[0]=='o') price+=100;
    if (s[1]=='o') price+=100;
    if (s[2]=='o') price+=100;
    cout << price << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){

    LL int a,n,k;
    LL int ans;

    cin >> n >> k;

    a = n/k;
    ans = a*a*a;

    if(k%2 == 0){
        if(k/2 + k*a <= n)ans += (a+1)*(a+1)*(a+1);
        else ans *= 2;
    }

    cout <<ans;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main()
{string S; cin >> S; string T; cin >> T;
 int t = T.size(); int s = S.size();
 reverse(S.begin(),S.end()); reverse(T.begin(),T.end());
 //辞書式で調べたいので、両方とも反転させてから調べる
 
 
 bool Big_flag = false;
 if( s < t){cout << "UNRESTORABLE" << endl;}
 else{ //S>=Tの場合のelse
   for(int i = 0; i <= s - t; i++)// iは先頭ポインタ
      {int v = i;  bool flag = true;
     
     for(int j = v; j <= t + v - 1; j++)//jはループポインタ
       {if(S[j] != T[j - v] && S[j] != '?'){flag = false;}}
    //残るカッコは、elseとi-ループfor文の２つ
       if(flag == true){
         Big_flag = true;
         for(int k = v; k <= t + v - 1; k++)
           {S[k] = T[k - v];}
         for(int i = 0; i < s; i++)
           {if(S[i] == '?'){S[i] = 'a';}}
            
          reverse(S.begin(),S.end());
          for(int i = 0; i < s ; i++){cout << S[i];}
         
           return 0; } //ここで分岐ループ終了
               
           } //i-ループ閉じ
     
   if(!Big_flag){cout << "UNRESTORABLE";} } //elseとじ
 
  return 0;
 
} //mainとじ


Measured memory_bytes: 256
N = int(input())
X_list = list(map(int,input().split()))
sum_list = []
for P in range(min(X_list),max(X_list)+1):
  sum = 0
  for i in range(N):
    hp = (X_list[i]-P)**2
    sum += hp
  sum_list.append(sum)

print(min(sum_list))

Measured memory_bytes: 3060
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())[:-1]
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [list(input())[:-1] for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
import numpy as np
N,S = map(int,input().split())
MOD = 998244353
A = list(map(int,input().split()))
dp = np.zeros(S+1,dtype = np.int64)
dp[0] = 2
if A[0] <= S:
    dp[A[0]] = 1
for i in range(1,N):
    a = A[i]
    p = dp*2
    if a <= S:
        p[a:] += dp[:-a]
    p %= MOD
    dp = p
print(dp[-1])

    





Measured memory_bytes: 27432
#include <cstdio>
#include <string>
#include <math.h>

using namespace std;

int main()
{
    int a,b;
    while(~scanf("%d %d",&a,&b))
    {
        int x=b,c=1;
        while(x)
        {
            x=x/10;
            c=c*10;
        }
        x=a*c+b;
        if(sqrt(x)==(int)sqrt(x))
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
	string s;
	cin >> s;
	int n = s.size();
	int cnt1 = 0, cnt2 = 0;
	rep(i,n){
		if(i % 2 == 0){
			if(s[i] == '0') cnt1++;
		}else{
			if(s[i] == '1') cnt1++;
		}
	}
	rep(i,n){
		if(i % 2 == 0){
			if(s[i] == '1') cnt2++;
		}else{
			if(s[i] == '0') cnt2++;
		}
	}
	cout << min(cnt1, cnt2) << endl;
	return 0;
}

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

int main(){
	int v_taro=0,v_hanako=0;
	int i,n,result;
	char taro[100],hanako[100];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s %s",taro,hanako);
		result = strcmp(taro,hanako);
		if(result>0)v_taro+=3;
		else if(result<0)v_hanako+=3;
		else v_taro++,v_hanako++;
	}
	printf("%d %d\n",v_taro,v_hanako);
	return 0;
}

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

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

  ll H; cin >> H;
  ll N; cin >> N;
  vector<ll> A(N); for (ll i = 0; i < N; i++) cin >> A[i];

  ll sum = 0;
  for (int i = 0; i < N; i++) {
    sum += A[i];
  }

  string ans = "No";
  if (sum >= H) ans = "Yes";
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 1024
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
		 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
	    public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        int N = sc.nextInt();	
	        long X = sc.nextLong();
	        long[] lp = new long[N+1];
	        long[] lsum =new long[N+1];
	        lp[0]=1;lsum[0]=1;
	        for(int i=1;i<=N;i++) {
	        	lp[i]=2*lp[i-1]+1;
	        	lsum[i]=2*lsum[i-1]+3;
	        }
	        
	        boolean isEat=false;
	        int now =N;
	        long ans=0;
	        while(X>0) {
	        	if(now>=0&&X>=lsum[now]) {
	        		X=X-lsum[now];
	        		ans=ans+lp[now];
	        		if(X>0) {
	        			ans++;
	        			X--;
	        		}
	        	} else {
	        		X--;
	        		now--;
	        	}
	        }
	        System.out.println(ans);
	    }
	}


Measured memory_bytes: 21844
from fractions import Fraction

while True:
    s = input()
    if s == '#':
        break
    N = len(s)
    if s[-1] == 't':
        ans = Fraction(90)
        p = 4
    else:
        ans = Fraction(0)
        p = 5
    i = 1
    while p < N:
        if s[-1-p] == 't':
            ans += Fraction(90, 1 << i)
            p += 4
        else:
            ans -= Fraction(90, 1 << i)
            p += 5
        i += 1
    print(ans)

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

int main() {
    ll N, D, X;
    cin >> N >> D >> X;
    for (int i = 0; i < N; i++) {
        ld a;
        cin >> a;
        X += ceil(D / a);
    }
    cout << X << endl;
}


Measured memory_bytes: 256
# 自分の回答
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ptn = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if((500*i + 100*j + 50*k) == x):
                ptn += 1

print(ptn)

Measured memory_bytes: 3060
#include<stdio.h>
#include<iostream>
using namespace std;

int N;
int a,b,c;
int main (){
    cin >> N;
    for(int i=0; i<N; i++){
        int d;
        cin >> d;
        if( d % 2 == 1 ) a++;
        else if( d % 4 == 0 ) b++;
        else c++;
    }
    if( a > b + 1) cout << "No" << endl;
    else if( a >= b + 1 && c > 0) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int i;
    char ans[1001],s[1001];

    scanf("%s",s);

    for(i=0;s[i]!='\0';i++){
        ans[i]=s[i]-3;
        if(ans[i]<'A')ans[i]=ans[i]+'Z'-'A'+1;
    }
    ans[i]='\0';
    printf("%s\n",ans);
    return 0;
}

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

using namespace std;
typedef pair<int,int> pii;
typedef pair<int, long long> pil;
typedef long long ll;

int main(){
	int n,m;
	cin >> n >> m;
	vector<pii>students;
	while(n--){
		int a,b;
		cin >> a >> b;
		pii stud = {a,b};
		students.push_back(stud);
	}	
	vector<pii> checkpoints;
	while(m--){
		int c,d;
		cin >> c >> d;
		pii check = {c,d};
		checkpoints.push_back(check);
	}
	pii stud,check;
	pil min_manhattan = {-1,LONG_MAX};
	ll manhattan;
	for(int i=0;i<students.size();++i){
		stud = students[i];
		for(int j=0; j<checkpoints.size();++j){
			check = checkpoints[j];
			manhattan = abs(stud.first - check.first) + abs(stud.second - check.second);
			if(manhattan < min_manhattan.second) min_manhattan = {j+1,manhattan};
		}
		cout << min_manhattan.first << endl;
		min_manhattan = {-1,LONG_MAX};
	}

	return 0;
}

Measured memory_bytes: 256
//g++  7.4.0

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007 
#define MAXN 1000005
ll fac[MAXN];

ll power(ll x,ll y)  
{  
    ll res = 1;     // Initialize result  
  
    x = x % MOD; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) 
        return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1LL)  
            res = (res * x) % MOD;  
  
        // y must be even now  
        y = y>>1LL; // y = y/2  
        x = (x * x) % MOD;  
    }
    
    return res;
}  

void pre()
{
    fac[0] = 1;
    for(ll i=1;i<MAXN;++i)
        fac[i] = (fac[i - 1] * i) % MOD;
}

ll inv(ll x)
{
    return(power(x,MOD - 2));
}

ll ncr(ll N,ll R)
{
    ll one = fac[N];
    ll two = inv(fac[R]);
    two = (two * (inv(fac[N - R]))) % MOD;
    
    return((one * two) % MOD);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    pre();
    
    ll N; cin>>N;
    if(N == 1)
    {
        cout<<0<<endl;
        return(0);
    }
    
    ll ans = 0;
    for(ll i=2;i<=N;++i)
    {
        ll res = ncr(N,i);
        res = (res * ((power(2LL,i) - 2 + MOD) % MOD)) % MOD;
        res = (res * power(8LL,N - i)) % MOD;
        ans = (ans + res) % MOD;
    }
    
    cout<<ans<<endl;
}

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

numbers = list(map(int, input().split(" ")))

flag = 1

cnt = 0

while flag:
    flag = 0
    for j in range(n - 1, 0, -1):
        if numbers[j] < numbers[j - 1]:
            tmp = numbers[j]
            numbers[j] = numbers[j - 1]
            numbers[j - 1] = tmp
            # numbers[j], numbers[j - 1] = numbers[j - 1], numbers[j]
            flag = 1
            cnt += 1

numbers = map(str, numbers)
print(" ".join(numbers))

print(cnt)

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

int main(){
 	string s;
  	cin >> s;
  	int zero = 0;
  	int ichi = 0;
  	for(auto c:s){
    	if(c=='0')++zero;
      	else ++ichi;    
    }
  cout << min(zero,ichi)*2<<endl;
 
}

Measured memory_bytes: 512
import java.util.*;
public class Main
{
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
    long a=sc.nextLong();
    long b=sc.nextLong();
    long n=sc.nextLong();
    long d=0,c=n;
   c=Math.min(b-1,n);
    d=(a*c/b) - a*(c/b);
      System.out.println(d);
     
  }
}
    

Measured memory_bytes: 35760
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
static const int MAX = 100000;
static const int MAXN = 100001;

bool C(string s){
    int n = s.size();
    rep(i,n-1){
        if(fabs(s[i] - s[i+1]) > 1) return false;
    }
    return true;
}

ll change(ll x){
    string s = to_string(x);
    int n = s.size();
    rep(i,n-1){
        if(s[i] - s[i+1] > 1){
            for(int j = i+1; j < n; j++){
                if(s[j-1] - '0' != 0){
                    s[j] = s[j-1] - 1;
                }
                else{
                    s[j] = '0';
                }
            }
        }
        if(s[i] - s[i+1] < -1){
            s[i] = s[i] + 1;
            while( !C( s.substr(0,i+1) ) ){
                i--;
                s[i]++;
            }
            for(int j = i+1; j < n; j++){
                if(s[j-1] - '0' != 0){
                    s[j] = s[j-1] - 1;
                }
                else{
                    s[j] = '0';
                }
            }            
        }
    }
    return  atoll(s.c_str());
}

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

    int n=0;

    for(ll i = 1;; i++){
        if( C(to_string(i)) )n++;
        else{
            i = change(i);
            n++;
        }
        if(n == k){
            cout << i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int conv(int a){
    int n = 0;
    int p = a;
    while (p){
        n++;
        p /= 10;
    }
    VI c(n);
    p = a;
    REP(i,n){
        c[n-i-1] = p % 10;
        p /= 10;
    }
    int ma = 0;
    FOR(i,1,n-1){
        int x = 0, y = 0;
        REP(j,i){
            x *= 10;
            x += c[j];
        }
        FOR(j,i,n-1){
            y *= 10;
            y += c[j];
        }
        ma = max(ma, x*y);
    }
    return ma;
}

int main() {
    int q;
    cin >> q;
    while (q--){
        int a;
        cin >> a;
        int i = 0;
        while (a > 9){
            a = conv(a);
            i++;
        }
        cout << i << endl;
    }

    return 0;
}

Measured memory_bytes: 3108
n=int(input())
A=[]
A.append(list(map(int,input().split())))
A.append(list(map(int,input().split())))
total_list=[]

for i in range(n):
  total=0
  for j in range(1,i+1):
    total+=A[0][j]
  for k in range(i,n):
    total+=A[1][k]
  total_list.append(total)
print(max(total_list)+A[0][0])




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

using namespace std;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("avx")

#define name "name"
#define file(s) if(fopen(s".in", "r")) freopen(s".in","r",stdin), freopen(s".out","w",stdout);

typedef long long ll;

string s;

int res = -1e5, sum;

int main() {
    file(name);
    cin >> s;
    for (char i : s) {
        sum += i - '0';
    }
    --s[0];
    res = max(res, (s[0] - '0') + (9 * ((int)s.size() - 1)));
    cout << max(res, sum);
}


Measured memory_bytes: 256
N = 500
VAL_1 = 3
VAL_0 = 4
TEMP_1 = 5
TEMP_2 = 6
TEMP_3 = 7
TEMP_4 = 8
TEMP_5 = 9
TEMP_6 = 10
TEMP_7 = 11
TEMP_8 = 12

two_power_values = 200
A_binary_expression = 50
B_binary_expression = 100

M = 30

def emurate(ss, A, B):
    seq = [0 for _ in range(N)]
    seq[0]=A
    seq[1] =B
    for s in ss:
        c,i,j,k = s
        if c=="+":
            seq[k] = seq[i]+seq[j]
        elif c=="<":
            seq[k] = (1 if seq[i]<seq[j] else 0)
    return seq

out = []

def plus(i,j,k):
    out.append(("+",i,j,k))

def comp(i,j,k):
    out.append(("<",i,j,k))

def zero_clear(i):
    comp(i,i,i)
    
def move(i,j):
    plus(VAL_0, i, j)
    
def get_binary_expression(val, res):
    M = 30
    zero_clear(TEMP_1)
    for m in range(M,-1,-1):
        #move(VAL_1,TEMP_2)
        #for c in range(m):
        #    plus(TEMP_2,TEMP_2,TEMP_2)
        #plus(TEMP_2,TEMP_1,TEMP_3)
        plus(two_power_values+m, TEMP_1, TEMP_3)
        
        plus(VAL_1,val,TEMP_4)
        comp( TEMP_3, TEMP_4, res+m)
        
        move( res+m, TEMP_2)
        for c in range(m):
            plus(TEMP_2,TEMP_2,TEMP_2)
        plus(TEMP_1,TEMP_2,TEMP_1)
        
def main():
    plus(0,1,TEMP_1)
    comp(VAL_0,TEMP_1,VAL_1)

    for i in range(60):
        if i==0:
            move(VAL_1, two_power_values)
        else:
            plus(two_power_values+i-1,two_power_values+i-1,two_power_values+i)
    
    get_binary_expression(0,A_binary_expression)
    get_binary_expression(1,B_binary_expression)
    
    ans = 2
    for i in range(M):
        for j in range(M):
            plus(A_binary_expression+i,B_binary_expression+j,TEMP_1)
            comp(VAL_1,TEMP_1,TEMP_1)
            for c in range(i+j):
                plus(TEMP_1,TEMP_1,TEMP_1)
            plus(ans,TEMP_1,ans)
    
    print(len(out))
    for c,i,j,k in out:
        print(f'{c} {i} {j} {k}')

    if 0:
        print(len(out))
        A = 10**9
        B = 10**9
        res = emurate(out, A, B)
        print(res)
        print(res[A_binary_expression:])

main()
    

Measured memory_bytes: 11568
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n; cin >> n;
  int d=n%10; n/=10;
  int c=n%10; n/=10;
  int b=n%10; n/=10;
  int a=n%10; n/=10;
  for (int i=0; i<(1<<3) ; i++) {
    int sum =a;
    char first = a+'0';
    string ans=""; ans += first; 
    if ((i)&1) sum+=d;
    else sum-=d;
    if ((i>>1)&1) sum+=c;
    else sum-=c;
    if ((i>>2)&1) sum+=b;
    else sum-=b;
    if ((i>>2)&1) ans+='+';
    else ans+='-';
    ans += b+'0';
    if ((i>>1)&1) ans+='+';
    else ans+='-';
    ans += c+'0';
    if ((i)&1) ans += '+';
    else ans+='-';
    ans += d+'0'; 
    if (sum == 7) {
      cout << ans << "=7" << endl;
      return 0;
    }
    
  }
  return 0;
}

Measured memory_bytes: 256
#i文字目を見て，それより前のAの個数，ABの個数，ABCの個数を持っておく

S=input()
N=len(S)
dp=[0,0,0]

mod=10**9+7

p=[1]*(N+1)
for i in range(N):
    p[i+1]=(p[i]*3)%mod


count=0#?の数
for i in range(N):
    if S[i]=="A":
        dp[0]=(dp[0]+p[count]) %mod
    elif S[i]=="B":
        dp[1]=(dp[1]+dp[0])%mod
    elif S[i]=="C":
        dp[2]=(dp[2]+dp[1])%mod
    else:
        dp[2]=(dp[2]*3+dp[1])%mod
        dp[1]=(dp[1]*3+dp[0])%mod
        dp[0]=(dp[0]*3+p[count])%mod
        count+=1
        
print(dp[2]%mod)   







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

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

  vector<int> p(N);
  int sum = 0;

  for (int i = 0; i < N; i++)
  {
    cin >> p.at(i);
    sum += p.at(i);
  }

  int maxElement = *max_element(p.begin(), p.end());

  cout << sum - maxElement / 2 << endl;
}


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

#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define inf (long long int) 1e18
#define eps 0.000001
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define mod 1000000007
#define MAXN 100001
ll spf[MAXN]; 
ll gcd(ll a,ll b);
ll palindrome(string s);
ll modexp(ll a,ll b,ll m);
void sieve();
vl getFactorization(ll x);
void getZarr(string str, ll Z[]);


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    /*#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/

    string s;
    cin>>s;
    loop(i,0,3){
        if(s[i]=='1') s[i]='9';
        else if(s[i]=='9') s[i]='1';
    }
    cout<<s<<endl;
}

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

ll palindrome(string s){
    ll l = 0;
    ll h = s.length() - 1;
    while (h > l){
        if (s[l++] != s[h--]){
            return 0;
        }
    }
    return 1;
}

ll modexp(ll a, ll b, ll m){
    if (b==0)
        return 1;
    ll temp = modexp(a,b/2,m);
    temp = (temp*temp)%m;
    if (b&1)
        return (temp*(a%m))%m; // if b is odd a^b = a^(b/2)*a^(b/2)*a
    return temp;
}

void sieve() { 
    spf[1] = 1; 
    for (ll i=2; i<MAXN; i++) 
        spf[i] = i; 
    for (ll i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (ll i=3; i*i<MAXN; i++) { 
        if (spf[i] == i) { 
            for (ll j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 

vl getFactorization(ll x) 
{ 
    vl ret; 
    while (x != 1) 
    { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 

void getZarr(string str, ll Z[]){
    ll n = str.length();
    ll L, R, k;
    L = R = 0;
    for (ll i = 1; i < n; ++i){
        if (i > R){
            L = R = i;
            while (R<n && str[R-L] == str[R])
                R++;
            Z[i] = R-L;
            R--;
        } else {
            k = i-L;
            if (Z[k] < R-i+1)
                Z[i] = Z[k];
            else {
                L = i;
                while (R<n && str[R-L] == str[R])
                    R++;
                Z[i] = R-L;
                R--;
            }
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    REP(i,N) {
        cin >> A[i];
        if (i >= K) {
            ATYN(A[i] > A[i-K])
        }
    }

    return 0;
}

Measured memory_bytes: 3984
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;

vector<vector<ll>> field(3, vector<ll>(3, 0));
vector<ll> coord1 = {0, 4, 8};
vector<ll> coord2 = {2, 4, 6};
void Main(){
    ll n, K;
    cin >> n >> K;
    ll ans = 0;
    while(n>0){
        n /= K;
        ++ ans;
    }
    cout << ans <<endl;

}

int main(){
    Main();
}

Measured memory_bytes: 3132
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int N, A;
  cin >> N >> A;
  vector<int> X(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i];
    X[i] -= A;
  }

  map<int,ll> dp;
  dp[0] = 1;
  for (int i = 0; i < N; i++) {
    map<int,ll> newdp;
    for(auto d: dp) {
      newdp[d.first] += d.second;
      newdp[d.first + X[i]] += d.second;
    }
    dp = newdp;
  }
  cout << dp[0] - 1 << endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const ll mod = 1e9 + 7;
int n;
ll fac[N], inv[N];
ll power(ll a, ll x) {
	ll ans = 1;
	while (x) {
		if (x & 1) ans = (ans * a) % mod;
		a = (a * a) % mod;
		x >>= 1;
	}
	return ans;
}
void init() {
	fac[0] = 1;
	for (int i = 1; i < N; i++) {
		fac[i] = fac[i - 1] * i %mod;
	}
	inv[N - 1] = power(fac[N - 1], mod - 2);
	for (int i = N - 2; i >= 0; i--) {
		inv[i] = inv[i + 1] * (i + 1) % mod;
	}
}
ll C(ll n, ll k) {
	return fac[n] * inv[k] % mod*inv[n - k] % mod;
}
vector<int>G[N];
ll dp[N], ans[N], cnt[N];
void dfs1(int u, int _fa) {
	cnt[u] = dp[u] = 1;
	for (int v : G[u]) {
		if (v == _fa)continue;
		dfs1(v, u);
		cnt[u] += cnt[v];
		dp[u] = dp[u] * dp[v] % mod * C(cnt[u] - 1, cnt[v]) % mod;
	}
}
void dfs2(int u, int _fa) {
	for (int v : G[u]) {
		if (v == _fa)continue;
		ans[v] = ans[u] * power(dp[v] * C(n - 1, cnt[v])%mod, mod - 2) % mod;
		ans[v] = ans[v] * dp[v] % mod*C(n - 1, n - cnt[v])%mod;
		dfs2(v, u);
	}
}
int main() {
	init();
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs1(1, 0);
	ans[1] = dp[1];
	dfs2(1, 0);
	for (int i = 1; i <= n; i++)printf("%lld\n", ans[i]);
	return 0;
}

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

#define fio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define per(i,n) for (int i=(int)(n)-1;i>=0;i--)
#define For(i,n) for (int i=1;i<=(int)(n);i++)
#define Rep(i,n) for (int i=0;i<=(int)(n);i++)
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define all(x) (x).begin(),(x).end()
#define Max(a,b,c) max(a,max(b,c))
#define Min(a,b,c) min(a,min(b,c))
#define cmax(x,y) x=max(x,y)
#define cmin(x,y) x=min(x,y)
#define pii pair<int,int>
#define vi vector <int>
#define lb lower_bound
#define ub upper_bound
#define ll long long
#define pb push_back
#define re return
#define se second
#define fi first
const int INF=0x7fffffff;
const int MAXN=2e5+3;

int n,a[MAXN],b[MAXN];
ll tr[MAXN*4],ans;

#define lson l,mid,k<<1
#define rson mid+1,r,k<<1|1

void change(const int &p,const ll &v,const int &l,const int &r,const int &k){
	if (l==p && r==p){
		tr[k]=v;
		re;
	}
	int mid=(l+r)>>1;
	if (p<=mid) change(p,v,lson);
	if (p>mid) change(p,v,rson);
	tr[k]=max(tr[k<<1],tr[k<<1|1]);
}

ll query(const int &L,const int &R,const int &l,const int &r,const int &k){
	if (L>R) re 0;
	if (l>=L && r<=R) re tr[k];
	int mid=(l+r)>>1;
	ll ret=0;
	if (L<=mid) cmax(ret,query(L,R,lson));
	if (R>mid) cmax(ret,query(L,R,rson));
	re ret;
}

int main(){
	fio;
	cin>>n;
	For(i,n){
		cin>>a[i];
	}
	For(i,n){
		cin>>b[i];
	}
	For(i,n){
		ll x=query(1,a[i]-1,1,n,1);
		change(a[i],x+b[i],1,n,1);
		cmax(ans,x+b[i]);
	}
	cout<<ans<<endl;
	re 0;
}

Measured memory_bytes: 8064
#include<stdio.h>
#define MAX 100005
#define NIL -1

typedef struct{
  int r;
  int l;
  int p;
}node;

int n,D[MAX];
node T[MAX];

void print(int u);
int rec(int u,int p);

int main(){
  int i,j,d,v,c,l,r;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p=NIL;
    T[i].l=NIL;
    T[i].r=NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0) T[v].l=c;
      else T[l].r=c;
      l=c;
      T[c].p=v;
    }
  }
 
  for(i=0;i<n;i++){
    if(T[i].p==NIL) r=i;
  }
    
  rec(r,0);

  for(i=0;i<n;i++) print(i);
  




  return 0;
}

void print(int u){
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);

  if(T[u].p==NIL){
    printf("root, ");
  }
  else if(T[u].l==NIL){
    printf("leaf, ");
  }
  else printf("internal node, ");

  printf("[");
  for(i=0,c=T[u].l;c!=NIL;i++,c=T[c].r){
    if(i) printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

int rec(int u,int p){
  D[u]=p;
  if(T[u].r != NIL)    rec(T[u].r,p);
  if(T[u].l != NIL)    rec(T[u].l,p+1);

  return D[u];
}



Measured memory_bytes: 6464
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }

#define int long long
#define SIZE 100000

using namespace std;

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

  int num; // num
  num = 0; // count, result
  // num = numeric_limits<int>::min(); // max
  // num = numeric_limits<int>::max(); // min

  int n; cin >> n;
  vector<int> h(n);
  for (auto it = h.begin(); it < h.end(); ++it) cin >> *it;

  for (int i = 0; i <= 100; ++i) {

    bool is_watering = false;
    for (auto it = h.begin(); it < h.end(); ++it){
      if (is_watering) {
        if (*it <= i || it == h.end() - 1) {
          is_watering = false;
          ++num;
        }
      } else {
        if (*it > i) {
          if (it == h.end() - 1) {
            ++num;
          } else {
            is_watering = true;
          }
        }
      }
    }
    
  }
  
  // int num = 0;
  // int c; cin >> n;
  // vector<int> v(n);
  // for (auto it = v.begin(); it < v.end(); ++it) cin >> *it;
  // for (auto it = v.begin(); it < v.end(); ++it) num += *it;
  // cout << num << endl;
  
  cout << num << endl;
  return 0;
}


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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    unordered_map<int,int> mp(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }

    for(int i=0;i<N;i++){
        mp[A[i]-1] = i+1;
    }

    for(int i=0;i<N;i++){
        cout << mp[i];
        cout << " ";
    }
}

Measured memory_bytes: 5120
import java.util.Scanner;
import java.util.regex.Pattern;

public class Main {

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

    String mae = S.substring(0, 2);
    String ato = S.substring(2, 4);

    boolean maet = false;
    boolean atot = false;

    Pattern nump = Pattern.compile("[0-9]{2}");
    if (nump.matcher(mae).find() && nump.matcher(ato).find()) {
    	// YYMMorMMYYどちらか
    	if (mae.equals("01") || mae.equals("02") || mae.equals("03") || mae.equals("04") ||
    			mae.equals("05") || mae.equals("06") || mae.equals("07") || mae.equals("08") ||
    			mae.equals("09") || mae.equals("10") || mae.equals("11") || mae.equals("12")) {
    		maet = true;
    	}
    	if (ato.equals("01") || ato.equals("02") || ato.equals("03") || ato.equals("04") ||
    			ato.equals("05") || ato.equals("06") || ato.equals("07") || ato.equals("08") ||
    			ato.equals("09") || ato.equals("10") || ato.equals("11") || ato.equals("12")) {
    		atot = true;
    	}
    	if (maet && atot) {
    		System.out.println("AMBIGUOUS");
    	} else if (maet && !atot) {
    		System.out.println("MMYY");
    	} else if (!maet && atot) {
    		System.out.println("YYMM");
    	} else {
    		System.out.println("NA");
    	}
    } else {
    	// どちらでもない
    	System.out.println("NA");
    }

  }

}

Measured memory_bytes: 21844
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<list>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod = 1000000007;
const long long INF = 1LL << 55;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

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

	if (b%a == 0) {
		cout << a + b << endl;
	}
	else {
		cout << b - a << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

MOD = 10**9+7
fac = [1, 1]
f_inv = [1, 1]
inv = [0, 1]

def modcmb(n, r, mod):
    if n < 0 or r < 0 or r > n:
        return 0

    return fac[n] * f_inv[r] * f_inv[n-r] % mod


def main():
    H,W,A,B = map(int, readline().split())

    n = 2*10**5+10
    for i in range(2,n):
        fac.append((fac[-1] * i) % MOD)
        inv.append((-inv[MOD % i] * (MOD//i)) % MOD)
        f_inv.append((f_inv[-1] * inv[-1]) % MOD)

    ans = 0
    for i in range(H-A):
        ans += modcmb(B-1+i, B-1, MOD) * modcmb(H+W-B-2-i, W-1-B, MOD) % MOD
        ans %= MOD

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 27040
#include <iostream>
#include <set>

using namespace std;

int main(){
  int n;
  cin >> n;
  set<int> s;
  int t;
  for(auto i = 0; i < n; ++i){
    cin >> t;
    s.insert(t);
  }
  cout << s.size() << endl;
  return 0;
}


Measured memory_bytes: 256
nums = ['7','5','3']
N = input()
Max_digit = len(N)

def generator(n, nums):
    """
    return n-digit number in strings that are made out of numbers in nums and each one use precisely once
    """
    ans = [x for x in nums]
    
    for idx in range(1,n):
        new_ans = []
        for n1 in ans:
            for n2 in nums:
                new_ans.append(n1 + n2)
        ans = new_ans.copy()
    
    return [x for x in ans if all(num in x for num in nums)]

if Max_digit < 3:
    print(0)
if Max_digit == 3:
    ans = generator(3,nums)
    print(len([x for x in ans if int(x) <= int(N)]))
if Max_digit > 3:
    # count the number of eligible numbers which has less digits than N
    counter = 0
    for d in range(3, Max_digit):
        counter += len(generator(d,nums))
    # count the number of eligible numbers of the same digits as N and equal or less than N
    ans = generator(Max_digit, nums)
    counter += len([x for x in ans if int(x) <= int(N)])
    print(counter)

Measured memory_bytes: 5232
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int a,b,c;
    cin>>a>>b>>c;
    cout<<max(max(a*10+b+c,a+b*10+c),a+b+c*10)<<endl;

    return 0;
}


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

#define ll long long
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x << endl
#define N 200005

#define newLine	printf("\n");

#define sll(X) scanf("%lld", &X);
#define pll(X) printf("%lld", X);
#define printAll(X, n)	for(int i=0;i<n;i++)	printf("%lld ", X[i]); newLine;
#define scanAll(X, n)	for(int i=0;i<n;i++)	scanf("%lld", &X[i]);

ll n, m;
vector< string > s;
ll ans = 0;
bool flag = 0;
void poo(ll x, ll y) {
	if(x == n-1 && y == m-1) {
		if(s[x][y] == '#')
			ans ++;
		return ;
	}
	if(x+1 < n && y+1 < m && s[x+1][y] == '#' && s[x][y+1] == '#')	{
		flag = 1;
		return ;
	}
	bool here = 0;
	if(x+1 < n && s[x+1][y] == '#') {
		here = 1;
		poo(x+1, y);
	}
	if(y+1 < m && s[x][y+1] == '#') {
		here = 1;
		poo(x, y+1);
	}
	// if(here == 0)	flag = 1;
	return ;
}

int main() {
	sll(n); sll(m);
	ll ct = 0;
	for(int i=0;i<n;i++) {
		string temp;
		cin>>temp;
		for(int j=0;j<m;j++) {
			ct += (temp[j] == '#');
		}
		s.push_back(temp);
	}
	if(ct == n + m - 1 && s[n-1][m-1]=='#') {
		cout<<"Possible\n";
	} else {
		cout<<"Impossible\n";
	}
	// poo(0, 0);
	/*if(ans == 1 && !flag) {
		cout<<"Possible\n";
	} else {
		cout<<"Impossible\n";
	}*/
	return 0;
}

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

int main(){
  string s,t;
  cin >> s >> t;
  
  int count = 0;
  for(int i = 0;i < s.size();i ++){
    if(s[i] != t[i])count ++;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 3916
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
#include<bitset>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
/*O(log(n))??則x^n????賊????????????即????????\???*/
const ll mod = 1000000007;
ll mod_pow(ll x,ll n){
	ll res =1;
	while(n>0){
		if(n&1)res =res*x%mod;
		x= x*x%mod;
		n>>=1;
	}
	return res;
}

int main(){
	ll x,y;
	cin>>x>>y;
	cout <<mod_pow(x,y)<<endl;
	return 0;
}

Measured memory_bytes: 1160
def main():
    a, b, c = map(int, input().split())
    if a + b > c:
        print('No')
        return
    left = 4 * a * b
    right = (c - a - b) ** 2
    print('Yes' if left < right else 'No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <map>
#include <queue>
#include <string>
#include <iostream>
using namespace std;
int n; string a[10], b[10], s, t;
int main() {
	while (cin >> n, n) {
		for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
		cin >> s >> t;
		map<string, int> d; d[s] = 1;
		queue<string> que; que.push(s);
		while (!que.empty()) {
			string u = que.front(); que.pop();
			for (int i = 0; i < n; i++) {
				string v; int pos = 0;
				while (pos < u.size()) {
					if (u.substr(pos, a[i].size()) == a[i]) v += b[i], pos += a[i].size();
					else v += u[pos], pos++;
				}
				if (v.size() <= 10 && !d[v]) {
					d[v] = d[u] + 1;
					que.push(v);
				}
			}
		}
		cout << (d[t] ? d[t] - 1 : -1) << endl;
	}
}

Measured memory_bytes: 3248
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<functional>
#include<map>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<long long> A(N), B(N);
    REP(i, N){
        A[i] = (i+1) * (N+1);
        B[i] = (N-i) * (N+1);
    }
    REP(i, N){
        int d;
        cin >> d;
        A[d-1] += i;
    }
    REP(i, N){
        cout << A[i] << (i+1==N?"\n":" ");
    }
    REP(i, N){
        cout << B[i] << (i+1==N?"\n":" ");
    }
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b;
  string s;
  cin >> a >> b >> s;
  bool f=true;
  for (int i=0;i<a+b+1;i++){
    if(i==a){
      if(s[a]!='-'){
        f=false;
        break;
      }
    }
    else{
      if(s[i]<'0'||s[i]>'9'){
        f=false;
        break;
      }
    }
  }
  if(f){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
// AOJ 2808: Password
// 2017.10.11 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

#define MAX 400004
#define P4  531441		// 27^4

char s[MAX+10];
char f[P4+10];

int main()
{
	int n, i, a, a1, a2, a3, a4;
	char *p;

	fgets(s, 50, stdin); n = atoi(s);
	while (n-- > 0) {
		fgets(s, MAX, stdin); p = s;
		a1 = a2 = a3 = a4 = 0;
		while (*p >= 'a') {
			a = *p++ - 'a'+1;
			a4 = a3*27 + a, f[a4] = 1;
			a3 = a2*27 + a, f[a3] = 1;
			a2 = a1*27 + a, f[a2] = 1;
			a1 =         a, f[a1] = 1;
		}
	}

	for (i = 1; i < P4; i++) {
		if (i % 27 > 0 && f[i] == 0) {
			p = s+10; *p = 0;
			a = i; while (1) {
				if (!a) { puts(p); return 0; }
				*--p = a % 27 + 'a'-1;
				if (*p == 'a'-1) break;
				a /= 27;
			}
		}
	}
	// panic
	return 0;
}

Measured memory_bytes: 2544
import java.util.*;

public class Main {
    private static final char ABC[] = "ABC".toCharArray();
    private static final long MOD = 1_000_000_007L;

    public void main(Scanner sc) throws Exception {
        char s[] = sc.next().toCharArray();
        sc.close();

        int len = s.length;
        long data[][] = new long[len + 1][4];

        data[len][3] = 1;
        for (int i = len - 1; i >= 0; i--) {
            data[i][3] = (s[i] == '?' ? 3 : 1) * data[i + 1][3];
            data[i][3] %= MOD;
        }

        for (int i = len - 1; i >= 0; i--) {
            for (int j = 2; j >= 0; j--) {
                data[i][j] =
                    (s[i] == '?' ? 3 : 1) * data[i + 1][j]
                        + (s[i] == ABC[j] || s[i] == '?' ? 1 : 0) * data[i + 1][j + 1];
                data[i][j] %= MOD;
            }
        }

        System.out.println(data[0][0] % MOD);
    }

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


Measured memory_bytes: 31188
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, x, t;
    cin >> n >> x >> t;
    if(n % x)
    {
        cout << ((n / x) + 1 )* t << endl;
    }
    else{
        cout << (n / x) * t << endl;
    }

}


Measured memory_bytes: 3588
gets
$<.map(&:split).combination(2).map{|e|c,d=e
f=->a{a.map{|i|d[i]}.rotate.map.with_index{|v,i|d[a[i]]=v}}
(0..23).map{|i|f[[1,2,4,3]]
d==c&&(puts :No)^exit
i%4<1&&f[i%8<4?[0,4,5,1]:[0,2,5,3]]}}
puts:Yes

Measured memory_bytes: 11000
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    string S;
    cin>>S;
    long long ans=0;
    rep(i,S.size()){
        ans+=S[i]-'0';
    }
 
    if(ans%9==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3780