akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

char xy[10][10];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

void mapmv(int x,int y){
	int i,j;
	xy[x][y]='0';
	for(i=0;i<4;i++){
		for(j=1;j<=3;j++){
			if(!(x+dx[i]*j>7 || x+dx[i]*j<0 || y+dy[i]*j>7 || y+dy[i]*j<0)){
				if(xy[x+dx[i]*j][y+dy[i]*j]=='1'){
					mapmv(x+dx[i]*j,y+dy[i]*j);
				}
				xy[x+dx[i]*j][y+dy[i]*j]='0';
			}
			else break;
		}
	}
}

int main(void)
{
	int n,i,j,l;
	int x,y;
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		
		for(j=0;j<8;j++){
			scanf("%s",xy[j]);
		}
		
		scanf("%d %d",&x,&y);
		mapmv(y-1,x-1);
		printf("Data %d:\n",i+1);
		
		for(j=0;j<8;j++){
			printf("%s\n",xy[j]);
		}
	}

	return 0;
}

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

int n, a[2001], ans;

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	sort(a, a+n);
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < i; ++j)
			ans += upper_bound(a, a+n, a[i]+a[j]-1)-a-i-1;
	cout << ans;
}


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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> a(N), b(N, 0);
    rep(i, N) cin >> a[i];
    for (int i = N; i > 0; i--) {
        int s = 0;
        for (int j = i * 2; j <= N; j += i) {
            s += b[j - 1];
        }
        if (s % 2 != a[i - 1]) {
            b[i - 1] = 1;
        }
    }
    int M = 0;
    rep(i, N) M += b[i];
    cout << M << "\n";
    rep(i, N) {
        if (b[i]) {
            cout << i + 1 << " ";
        }
    }
    cout << "\n";
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
int main()
{
     long int a,b,k;
    cin>>a>>b>>k;
    if(a+b<=k)
        cout<<"0"<<" "<<"0"<<endl;
    else if(a+b>k)
    {
        if(k>=a)
            cout<<"0"<<" "<<abs(b-k+a)<<endl;
        else
            cout<<abs(a-k)<<" "<<b<<endl;
    }

}


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

#define ll long long
#define pb push_back
#define all(x) x.begin(), x.end()

int n, k;
int d[10];

bool check(string s) {
	for(int i = 0; i < s.size(); i++) {
		for(int j = 0; j < k; j++) {
			if(s[i] - '0' == d[j]) {
				return false;
			}
		}
	}
	return true;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> k;
	for(int i = 0; i < k; i++) {
		cin >> d[i];
	}
	string ans;
	for(;;) {
		string s = to_string(n);
		if(check(s)) {
			ans = s;
			break;
		} else {
			n++;
		}
	}
	cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  int sum = 0;
  cin >> N >> K;
  for ( int i = 0 ; i < N ; i++ ) {
    int x;
    cin >> x;
    if ( x <= K - x ) {
      sum += x;
    }
    else {
      sum += K -x;
    }
  }
  cout << 2*sum << endl;
}

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

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

        int N = scanner.nextInt();
        Integer[] nums = new Integer[N];

        for (int i = 0; i < N ; i++) {
            nums[i] = scanner.nextInt();
        }

        int diff = 0;
        boolean isEven = (N % 2) == 0;

        Arrays.sort(nums, Collections.reverseOrder());

        int pairLastIndex = isEven ? N-1: N-2;
        for (int i = 0; i < pairLastIndex ; i = i+2) {
            diff += nums[i] - nums[i+1];
        }

        if (!isEven) diff += nums[N-1];

        System.out.println(diff);

    }
}

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

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

  const double PI = 3.141592653589793;

  double degree = 30 * h + ((double)m / 2) - m * 6;
  double rad = degree * M_PI / 180;
  double ans = a * a + b * b - 2 * a * b * cos(rad);
  cout << fixed << setprecision(20) << sqrt(ans) << endl;
}


Measured memory_bytes: 4224
import java.util.*;

public class Main{
	static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		String answer = "No";

		for(int i=1; i<=3; i++){
			if(i*A*B%2 == 1){
				answer = "Yes";
			}
		}
				
					
		System.out.println(answer);
		

	}						
	
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_poizcy.hpp>
typedef long long  ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef long double lldb;
typedef pair<ll, ll>  ii;
typedef pair<lldb, lldb>  iidb;
typedef pair<ll, ii>  iii;
typedef vector<ll>     vi;
typedef vector<ll>      vll;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9+7;
const lldb PI = acos(-1);
#define initseg ll new_nodo=(pnodo*2),mid=(iz+der)/2;
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define tam 320000
#define offset 200
#define ptr nodo*
const ll MOD=1e9+7;

int main()
{
	string t1,t2;
	cin>>t1>>t2;
	int minn=INF;
	forr(i,0,t1.size())
	{
		int c=0;
		forr(j,0,t2.size())
		{
			if (i+j>=t1.size()){c=INF;break;}
			if (t1[i+j]!=t2[j])
				c++;

		}
		minn=min(minn,c);
	}
	cout<<minn<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e15;
typedef pair<int,int> ii;
typedef vector<int> vi;

ll W[110],V[110];
ll dp[110][(int)1e5+10];

int main(){
	ll n,w;
	cin>>n>>w;
	ll max_val=0;
	for(int i=1;i<=n;i++){
		cin>>W[i]>>V[i];
		max_val+=V[i];

	}
	for(int i=1;i<100010;i++){
			dp[0][i]=inf;
	}
	for(int i=1;i<=n;i++){
		for(int j=0;j<=max_val;j++){
			if(j>=V[i]){
				dp[i][j]=min(dp[i-1][j],dp[i-1][j-V[i]]+W[i]);
			}else{
				dp[i][j]=dp[i-1][j];
			}
			
		}
	}

	int ans=0;
	for(int v=max_val;v>=0 && !ans;v--){
		if(dp[n][v]<=w){
			ans=v;
		}
	}
	cout<<ans;
	

	return 0;
}

Measured memory_bytes: 80128
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;

const int maxn=3111;
const int mod=1e9+7;
int qpow(int x,int y)
{
	int ret=1;
	while(y)
	{
		if(y&1)ret=(LL)ret*x%mod;
		x=(LL)x*x%mod;
		y>>=1;
	}
	return ret;
}
inline void add(int&x,int y){x+=y;if(x>=mod)x-=mod;}
int n,q,a[maxn],w[maxn][maxn];

void do_swap(int u,int v)
{
	if(u>v)swap(u,v);
	
	int tmp=(LL)(w[u][v]+w[v][u])*(mod+1)/2%mod;
	w[u][v]=w[v][u]=tmp;
	
	for(int i=1;i<=n;i++)if(i!=u&&i!=v)
	{
		int tmp;
		tmp=(LL)(w[i][u]+w[i][v])*(mod+1)/2%mod;
		w[i][u]=w[i][v]=tmp;
		
		tmp=(LL)(w[u][i]+w[v][i])*(mod+1)/2%mod;
		w[u][i]=w[v][i]=tmp;
	}
}

int main()
{
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++)scanf("%d",a+i);
	
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)if(a[i]>a[j])w[i][j]=1;
	
	for(int i=1,x,y;i<=q;i++)
	{
		scanf("%d%d",&x,&y);
		do_swap(x,y);
	}
	
	int ans=0;
	for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++)add(ans,w[i][j]);
	ans=(LL)ans*qpow(2,q)%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 37120
n, w = map(int, input().split())
items = [list(map(int, input().split())) for _ in range(n)]

memo = [[0] + [-1] * w for _ in range(n+1)]

for i in range(n):
    for j in range(w+1):
        if memo[i][j] > -1 and j+items[i][1] <= w:
            memo[i+1][j+items[i][1]] = max(memo[i+1][j+items[i][1]], memo[i][j]+items[i][0])
        memo[i+1][j] = max(memo[i+1][j], memo[i][j])

print(max(memo[-1]))



Measured memory_bytes: 21960
#include "bits/stdc++.h"
using namespace std;

int main() {
    int n;
    cin >> n;
    vector< int> v(n);
    int cnt1 = 0, cnt2 = 0, cnt4 = 0;
    for (int &e : v) {
        cin >> e;
        if (e % 4 == 0) cnt4++;
        else if (e % 2 == 0) cnt2++;
        else cnt1++;
    }

    vector< int> chk(n);
    for (int i = 0; i < n; i += 2) {
        if (cnt1 > 0) {
            cnt1--;
            chk[i] = 1;
        }
    }

    for (int i = 1; i < n; i += 2) {
        if (cnt4 > 0) {
            cnt4--;
            chk[i] = 4;
        }
    }

    for (int i = 0; i < n; ++i) {
        if (chk[i] == 0) chk[i] = 2;
    }

    bool ok = true;
    for (int i = 0; i < n - 1; ++i) {
        int b = chk[i] * chk[i + 1];
        if (b % 4 != 0) ok = false;
    }
    puts(ok ? "Yes" : "No");
}

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


int main(){
  int a, b, c, d;
  
  cin >> a >> b >> c >> d;
	
  while (true){
   
    a -= d;
    c -= b;
    
    if (a<=0||c<=0){
     
      break;
      
    }
    
  }
  
  
  if (a == c){
  	cout << "Yes" << endl;
  }
  else if (c <= 0){
  
    cout << "Yes" << endl; 
  
  }
  else if (a <= 0){
  
  	cout << "No" << endl;
    
  }
  
  
  
  
}

Measured memory_bytes: 3620
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <complex>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VEC;
typedef vector<VEC> MAT;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second.first
#define T4 second.second.second

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EPS 1.0e-9

LL gcd(LL m, LL n){
	LL t;
	while(m){
		t = m;
		m = n % m;
		n = t;
	}
	return n;
}

LL lcm(LL m, LL n){	
	LL g = gcd(m, n);
	return m / g * n;
}

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

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

import static java.lang.System.in;

public class Main {
    ArrayList<Integer>[] graph;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        PriorityQueue<int[]> pq = new PriorityQueue<>(H+W,new myC());
        int[] p = new int[W], q = new int[H];
        for(int i=0;i<W;i++) pq.add(new int[]{sc.nextInt(),1});
        for(int i=0;i<H;i++) pq.add(new int[]{sc.nextInt(),2});
        long ans = 0;
        while(pq.size()>0){
            int[] cur = pq.poll();
            if(cur[1]==1){
                ans += ((long)cur[0])*((long)H+1);
                W--;
            } else{
                ans += ((long)cur[0])*((long)W+1);
                H--;
            }
        }
        System.out.println(ans);
    }
    static class myC implements Comparator<int[]>{
        // int[]{price,direction} direction: 1=hori, 2=vert
        public int compare(int[] a, int[] b){
            return a[0]-b[0];
        }
    }
}


Measured memory_bytes: 96304
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <math.h>
#include <set>
  
#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
typedef pair<int,int> P;
bool b[16][16][16][16];
int d[16][16];
int main(){
    int n,gx,gy,p;
    cin>>n;
    while(n--){
        for(int i=0;i<16;i++)for(int j=0;j<16;j++)for(int k=0;k<16;k++)for(int l=0;l<16;l++)b[i][j][k][l]=0;
        for(int i=0;i<16;i++)for(int j=0;j<16;j++)d[i][j]=0;
        cin>>gx>>gy;
        cin>>p;
        for(int i=0;i<p;i++){
            int x1,y1,x2,y2;
            cin>>x1>>y1>>x2>>y2;
            b[y1][x1][y2][x2]=true;
            b[y2][x2][y1][x1]=true;
        }
        d[0][0]=1;
        for(int i=0;i<=gx;i++){
            for(int j=0;j<=gy;j++){
                if(i!=0)if(!b[j][i][j][i-1])d[j][i]+=d[j][i-1];
                if(j!=0)if(!b[j][i][j-1][i])d[j][i]+=d[j-1][i];
            }
        }
        if(d[gy][gx]==0){
            cout<<"Miserable Hokusai!"<<endl;
        }else{
            cout<<d[gy][gx]<<endl;
        }
    }
}


Measured memory_bytes: 3144
//C++ おまじない
#include <bits/stdc++.h>
using namespace std;
int main()
{
    // input
    int n;
    cin >> n;
  	int a[1048576];
  	int p;
    for (int i=0; i<n; i++) {
      p = 0;
      cin >> p;
      a[p]++;
    }
    // output
    for (int i=1; i<=n; i++) {
		cout << a[i] <<endl;
    }
  	return 0;
}


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

int main(int, char **) {

  char b;

  std::cin >> b;
  switch (b) {
  case 'A':
    cout << 'T';
    break;
  case 'T':
    cout << 'A';
    break;
  case 'C':
    cout << 'G';
    break;
  case 'G':
    cout << 'C';
    break;
  }

  return 0;
}


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int n; cin >> n;
    vector<int> cnt(n);
    for (int i = 0; i < n - 1; i++) {
        int a; cin >> a; a--;
        cnt[a]++;
    }
    for (auto &e: cnt) cout << e << endl;
    return 0;
}


Measured memory_bytes: 3992
#include<stdio.h>
int main(void)
{
	int x, y, z;
	int i=0;
	
	while(1){
		scanf("%d %d", &x, &y);
		if(x==0 && y==0){
			break;
		}
		if(x>y){
			z=x;
			x=y;
			y=z;
		}
		printf("%d %d\n", x, y);
	}
	
	return 0;
}   

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()

const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x;
    cin>>x;
    int n=x/500;
    x-=500*n;
    int m=x/5;
    cout<<n*1000+m*5<<endl;
}

Measured memory_bytes: 256
#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

S = IS()
cnt = 0
max = 0
for i in range(len(S)//2):
    a = S[:i]
    b = S[i:2*i]
    if a == b and max < i:
        max = 2*i
print(max)

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

int main(int argc, char *argv[]) {
  int N, T;
  cin >> N >> T;
  int c[N];
  int t[N];
  for(int i = 0; i < N; i++) {
    cin >> c[i] >> t[i];
  }
  int min_cost = 10000;
  for(int i = 0; i < N; i++) {
    if(c[i] < min_cost) {
      if(t[i] > T) continue;
      min_cost = c[i];
    }
  }
  if(min_cost == 10000) {
    cout << "TLE" << endl;
  } else {
    cout << min_cost << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define vi vector<int>
#define vll vector<long long>
#define FOR(n) for(int i=0;i<n;i++)
#define till(n) for(int i=1;i<=n;i++)
#define mod 1000000007
using namespace std;

double p[3000];

double dp[3000][3000];

double getAns(int n, int val){
    if(n == 0) return 1.0;

    if(dp[n][val]!=-1)return dp[n][val];

    double x = 0, y = 0;

    //tail
    if(val > 0)
    x = getAns(n-1, val-1) * (1.0-p[n]);
    //head
    y = getAns(n-1, val) * (p[n]);
    //cout << x << " " << y << endl;
    return dp[n][val] = x + y;
}

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

    int n;cin>>n;

    for(int i=0;i<3000;i++){
        for(ll  j=0;j<3000;j++)
            dp[i][j] = -1;
    }

    for(int i=1;i<=n;i++) cin >> p[i];

    cout << setprecision(10) << getAns(n, n/2) << endl;

	return 0;
}


Measured memory_bytes: 70784
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
using namespace std;
typedef long long ll;
int main(){
  int kazu = 0;
  cin >> kazu;
  vector<vector<int>> count(kazu,vector<int>(26));
  for(int i = 0;i <= kazu - 1;i++){
    for(int j = 0;j <= 25;j++){
      count[i][j] = 0;
    }
  }
  //cout<<0<<endl;
  for(int i = 0;i <= kazu - 1;i++){
    string str;
    cin >> str;
    for(int j = 0;j <= str.size() - 1;j++){
      count[i][str[j] - 'a']++;
    }
  }
  //cout<<1<<endl;
  for(int i = 0;i <= 25;i++){
    int res = 0;
    res = INT_MAX;
    for(int j = 0;j <= kazu - 1;j++){
      res = min(res,count[j][i]);
    }
    for(int j = 0;j <= res - 1;j++){
      cout << (char)('a' + i);
    }
  }
  cout << endl;
  return 0;
}

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

int main() {
    int a, b, c, d;

    cin >> a >> b >> c >> d;

    string msg;
    if (a + b > c + d) {
        msg = "Left";
    }
    else if (a + b < c + d) {
        msg = "Right";
    }
    else {
        msg = "Balanced";
    }

    cout << msg << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)

using namespace std;

llint h, w, k;
char c[1005][15];
llint sum[15], nsum[15];
//llint sum[15][1005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> h >> w >> k;
	for(int y = 0; y < h; y++){
		for(int x = 1; x <= w; x++){
			cin >> c[x][y];
		}
	}
	
	/*for(int y = 1; y <= h; y++){
		for(int x = 1; x <= w; x++){
			sum[x][y] = sum[x-1][y] + sum[x][y-1] - sum[x-1][y-1] + (c[x][y]-'0');
		}
	}*/
	
	llint H = 1<<(h-1), ans = inf;
	for(int i = 0; i < H; i++){
		llint cnt = 0;
		for(int y = 0; y < h-1; y++){
			if(i & (1<<y)) cnt++;
		}
		for(int y = 0; y < h; y++) sum[y] = 0;
		for(int x = 1; x <= w; x++){
			llint p = 0;
			for(int y = 0; y < h; y++) nsum[y] = 0;
			for(int y = 0; y < h; y++){
				nsum[p] += c[x][y] - '0';
				if(i & (1<<y)) p = y+1;
			}
			bool flag = true;
			for(int y = 0; y < h; y++){
				if(nsum[y] > k) goto end;
				if(sum[y] + nsum[y] > k) flag = false;
			}
			if(flag){
				for(int y = 0; y < h; y++) sum[y] += nsum[y];
			}
			else{
				for(int y = 0; y < h; y++) sum[y] = nsum[y];
				cnt++;
			}
		}
		ans = min(ans, cnt);
		end:;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define debug(a) cout<<a<<endl
#define clr(a) memset(a,0,sizeof(a))
#define clrne(a) memset(a,-1,sizeof(a))
#define clrinf(a) memset(a,0x3f,sizeof(a))
#define clrneinf(a) memset(a,0xc0,sizeof(a))
#define pb(a) push_back(a)
#define maxn 10001
#define mod 1000000007
#define eps 1e-9
#define inf 0x7fffffff
struct e
{
    int next;
    int to;
};
e E[200010<<1];
int head[100010];
int vis[100010];
int cl[100010];
int tot;
void init()
{
    tot = 0;
    clrne(head);
    clr(vis);
}
void addedge(int u,int v)
{
    E[tot].to = v;
    E[tot].next = head[u];
    head[u] = tot++;
}
queue <int> q;
int main()
{
//  freopen("in.txt","r",stdin);
//  freopen("out.txt","w",stdout);
    int n,m;
    scanf("%d%d",&n,&m);
    init();
    for (int i = 0;i<m;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        addedge(u,v);
        addedge(v,u);
    }
    ll I,P,Q;
    I = P = Q = 0;
    for (int i = 1;i<=n;i++)
    {
        if (!vis[i])
        {
            if (head[i]==-1)
            {
                vis[i] = 1;
                I++;
                continue;
            }
            while (!q.empty()) q.pop();
            bool ok = 1;
            cl[i] = 0;
            vis[i] = 1;
            q.push(i);
            while (!q.empty())
            {
                int u = q.front();
                q.pop();
                for (int j = head[u];j!=-1;j = E[j].next)
                {
                    int v = E[j].to;
                    if (!vis[v])
                    {
                        vis[v] = 1;
                        q.push(v);
                        cl[v] = cl[u] +1;
                        cl[v]&=1;
                    }
                    else
                    {
                        if ((cl[u]^cl[v])!=1) ok = false;
                    }
                }
            }
//            cout<<cl[1]<<' '<<cl[2]<<endl;
//            if (!ok)cout<<i<<endl;
            if (ok) Q++;
            else P++;
        }
    }
//    cout<<I<<' '<<P<<' '<<Q<<endl;
//    Q = 1;
    ll ans = 2*I*n - I*I +P*P + 2*P*Q + 2*Q*Q;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
int n,m,x,y,type=-1,cnt=0;
char arr[15][15];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%s",arr[i-1]);
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(arr[i-1][j-1]=='#'){
				++cnt;
			}
		}
	}
	x=0;
	y=0;
	while(1){
		if((arr[x][y+1]=='#'&&arr[x+1][y]=='#')||(arr[x][y+1]=='.'&&arr[x+1][y]=='.')){
			type=0;
//			printf("%d %d\n",x,y);
			break;
		}else{
			if(arr[x][y+1]=='#'){
				++y;
			}else ++x;
			//if(x<=15&&y<=15)
			//printf("%d %d\n",x,y);
		}
		if(x==n-1&&y==m-1){
			break;
		}
	}
	if(type==-1&&cnt==n+m-1){
		printf("Possible");
	}else printf("Impossible");
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>

#define REP(i,n) for(i=0; i < (n); i++)
#define REPONE(i, n) for(i=1; i <= (n); i++)
#define LOOP(n) for(int loopCount=1; loopCount <= (n); loopCount++)
#define ITER(c) __typeof((c).begin())
#define EACH(c,it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define SZ(c) ((int) (c).size())
#define ALL(c) c.begin(), c.end()
#define SUM(c) accumulate(ALL(c), 0)
#define EXIST(c,v) (find(ALL(c), (v)) != (c).end())
#define PB push_back
#define MP make_pair

using namespace std;
static const double EPS = 1e-9;
static const double PI = 3.141592653589793238462643383279;
typedef long long ll;

vector<int> ps;

void primeTable(int n){
    vector<int> table(n+1, 0);
    for(int i=2; i<=n; i++){
        if(!table[i]){
            ps.push_back(i);
        if(i <= sqrt(n)) table[i*i] = i;
        }
        else{
        int j = i, step = table[i];
            while(j+step<=n){
                if(!table[j+step]) {
                    table[j+step] = step;
                    break;
                }
                else {
                    int tmp = step;
                    step = table[j+step];
                    table[j+tmp] = tmp;
                    j += tmp;
                }
            }
        }
    }
}

int main(){
    primeTable(10001);
    int cnt, n, i, s = SZ(ps);
    vector<int> sums(s+1);
    sums[0] = 0;
    REP(i,s) sums[i+1] = sums[i] + ps[i];
    while(scanf("%d",&n)){
        if(!n) break;
        cnt = 0;
        REPONE(i,s)if(binary_search(ALL(sums),sums[i]-n))cnt++;
        printf("%d\n", cnt);
    }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>
#include <map>
#include <queue>
#include <set>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

int N;
pair<int, int> table[110][110];
bool used[110][110];
int memo[110][110];

int color;
int dfs(int y, int x)
{
    if(memo[y][x]) return memo[y][x];
    pair<int ,int> p = table[y][x];
    int res;
    if(used[p.first][p.second]) res = color++;
    else
    {
        used[p.first][p.second] = true;
        res = dfs(p.first, p.second);
        used[p.first][p.second] = false;
    }
    return memo[y][x] = res;
}
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> N, N)
    {
        memset(used, 0, sizeof(used));
        memset(memo, 0, sizeof(memo));
        memset(table, 0, sizeof(table));
        for(int i = 0; i < N; i++)
        {
            for(int j = 0; j < N; j++)
            {
                int x, y; cin >> x >> y;
                table[i][j] = make_pair(y, x);
            }
        }

        int ans = 0;
        color = 1;
        set<int> st;
        for(int i = 0; i < N; i++)
        {
            for(int j = 0; j < N; j++)
            {
                if(memo[i][j]) continue;
                used[i][j] = true;
                int res = dfs(i, j);
                if(st.count(res) == 0)
                {
                    st.insert(res);
                    ans++;
                }
                used[i][j] = false;
            }
        }
        cout << ans << endl;
    }
    return 0;
}




Measured memory_bytes: 3772
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    string s;
    cin >> s;
    int left, right;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == 'A')
        {
            left = i;
            break;
        }
    }
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == 'Z')
        {
            right = i;
        }
    }
    cout << right - left + 1 << endl;
    return 0;
}


Measured memory_bytes: 3724
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(ll)(n);++i)
#define _repe3(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(ll)(b)-1;i>=(ll)(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define _rrepe2(i,n) for(ll i=(ll)(n);i>=0;i--)
#define _rrepe3(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)
#define rrepe(...) _overload3(__VA_ARGS__,_rrepe3,_rrepe2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

ll K;

void solve();

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> K;
    solve();
}

// 1 <= K <= 10^6
// K は整数である。

// ll K
// 答えを整数として出力せよ。
void solve(){
    if(K%2==0||K%5==0){
        cout<<-1<<endl;
        return;
    }
    ll x=7;
    rep(i,1,K+5){
        if(x%K==0){
            cout<<i<<endl;
            return;
        }
        x=(x*10+7)%K;
    }
    cout<<-1<<endl;
}


Measured memory_bytes: 3668
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        int n = in.nextInt();
        int[][] a = new int[3][n + 1];
        for (int i = 1; i <= n; i++) {
            a[0][i] = in.nextInt();
            a[1][i] = in.nextInt();
            a[2][i] = in.nextInt();
        }

        int[][] dp = new int[3][n + 1];

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 3; k++) {
                    if (j == k) {
                        continue;
                    }

                    if (dp[j][i] + a[k][i + 1] > dp[k][i + 1]) {
                        dp[k][i + 1] = dp[j][i] + a[k][i + 1];
                    }
                }
            }
        }

        out.println(Math.max(dp[0][n], Math.max(dp[1][n], dp[2][n])));
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}

Measured memory_bytes: 46892
#include<iostream>
#include<sstream>
#include<fstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
using namespace std;

int main(){
	int n;
	while(scanf("%d",&n),n){
		int mat[n][n];
		int tim[n][n];
		for(int x=0;x<n;++x){
			for(int y=0;y<n;++y){
				int j;scanf("%d",&j);
				mat[x][y] = j;
				tim[x][y] = 0;
			}
		}
		for(int x=0;x<n;++x){
			int taller = 0,small = mat[x][0];
			for(int y=0;y<n;++y){
				if(small>mat[x][y]){
					small = mat[x][y];
				}
				if(taller<mat[y][x]){
					taller = mat[y][x];
				}
			}
			for(int y=0;y<n;++y){
				if(mat[x][y] == small){
					tim[x][y]++;
				}
				if(mat[y][x] == taller){
					tim[y][x]++;
				}
			}
		}
		int sol = 0;
		for(int x=0;x<n;++x){
			for(int y=0;y<n;++y){
				if(tim[x][y] == 2)sol = max(sol,mat[x][y]);
			}
		}
		cout<<sol<<endl;
	}
	return 0;
}

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

using namespace std;
void insertion_sort(int N, vector<int> &A){
  //sort開始
  for (int i = 1; i < N; i++){
    //一旦値をvにいれて、それより一個前をみる
    int v = A.at(i);
    int j = i - 1;

    //配列を一つずつ遡りながら自分より小さい値に至るまで配列を右にずらす
    while ((j >= 0) && (A.at(j) > v)){
      A.at(j+1) = A.at(j);
      j--;
    }
    //自分より小さい値を見つける、若しくは先頭に到達したら、そこに挿入
    A.at(j+1) = v;
  }
}

//エラトステネスの篩(N以下の数字)ブール表返すようにする
vector<bool> Eratosthenes(int N){
  //2~Nまでの真偽値表。trueで初期化。
  vector<bool> is_prime(N+1, true);
  int lim = (int)sqrt(N)+1;

  //以下ループ。2~Nについてエラトステネス適用
  for (int i = 2; i < lim; i++){
    if(is_prime.at(i)){
      for(int j = i*2; j < N+1; j += i){
        is_prime.at(j) = false;
      }
    }
  }
  /*
  //素数リスト
  vector<int> P;
  for(int i = 2; i < N+1; i++){
    if(is_prime.at(i)) P.emplace_back(i);
  }*/

  return is_prime;
}

int prime_count(int N,vector<int> &A){
  int M = A.at(N-1);
  int counter = 0;//カウンター
  vector<bool> is_prime = Eratosthenes(M);

  for (int a : A){
    if(is_prime.at(a)) counter++;
  }

  return counter;
}

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

  vector<int> A(N);

  for(int &a : A){
    cin >> a;
  }

  insertion_sort(N, A);

  cout << prime_count(N, A) << endl;

}



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

typedef long long ll;
typedef long double ld;

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

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}

int main(){

    ll A, B, C, D;

    cin >> A >> B >> C >> D;

    cout << (A * B > C * D ? A * B : C * D) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() 
{
	int x,n,ans=0;
	cin>>x>>n;
	for(int i=1;i<=n;i++)
	{
		int a;
		cin>>a;
		ans+=a;
	}
	if(ans>x)cout<<-1;
	else cout<<x-ans;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
const int N = 2001 , md = (int)1e9 + 7;

int c[N][N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    for(int i = 0 ; i < N; i++)
        for(int j = 0; j < N; j++)
        if(j == 0) c[i][j] = 1;
        else if(i==0)c[i][j] = 0;
        else{
            c[i][j] = (c[i - 1][j- 1] + c[i - 1][j]) % md;
        }

        int n , k;
        cin >> n >> k;
        for(int i = 1; i <=k; i++){
            ll a=(ll)c[n - k + 1][i] * c[k - 1][i - 1] % md;
          //  cerr<< "# :" << n - k + 1 << " : " << i << " : "<< c[n -k + 1][i] << '\n';
            cout << a << '\n';
        }


    return 0;
}












Measured memory_bytes: 15872
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

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



int main() {
  int x, a, b;
  cin >> x >> a >> b;
  cout << (x-a) % b << endl;

  return 0;
}

Measured memory_bytes: 256
from collections import Counter
N=int(input())
A=list(map(int,input().split()))
Ac=dict(Counter(A))
a=0
b=0
for i in Ac.keys():
    if Ac[i]>1:
        a+=Ac[i]-1
if a%2==0:
    print(N-a)
else:
    print(N-a-1)

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

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

using namespace std;

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

ll exp(ll a,ll b){
    if(b == 0) return 1;
    ll tans = exp(a*a,b/2);
    if(b % 2) tans *= a;
    return tans;
}

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

Measured memory_bytes: 256
# AOJ 2834 Dimension travel
# Python3 2018.7.12 bal4u

INF = 0x7fffffff
import heapq
def dijkstra(V, to, start, goal):
	dist = [INF]*V
	Q = []
	dist[start] = 0
	heapq.heappush(Q, (0, start))
	while Q:
		t, s = heapq.heappop(Q)
		if s == goal: break
		if dist[s] < t: continue
		for e in to[s]:
			nt = t
			if e > s: nt += d[e]
			if dist[e] > nt:
				dist[e] = nt
				heapq.heappush(Q, (nt, e))
	return t

import sys
N, M, s, t = map(int, input().split())
s, t = s-1, t-1
if s >= t: print(0); sys.exit(0)
d = list(map(int, input().split()))
to = [[i-1] if i > 0 else [] for i in range(N)]
for i in range(M):
	a, b = map(int, input().split())
	to[a-1].append(b-1)
print(dijkstra(N, to, s, t))



Measured memory_bytes: 34404
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int a, b;
	cin >> a >> b;
	cout << (a <= 9 && b <= 9 ? a * b : -1) << endl;
}

Measured memory_bytes: 256
import itertools
N,D=map(int,input().split())
list1=[]
ans=0
for i in range(N):
  list1+=[list(map(int,input().split()))]
list2=list(itertools.combinations(list1,2))
for k in range(len(list2)):
  LEN=0
  for t in range(D):
    LEN+=(list2[k][0][t]-list2[k][1][t])**2
  if (LEN**0.5//1)**2==LEN:
    ans+=1
print(ans)    

Measured memory_bytes: 3064
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            final String[] sl = s.split(" ");
            Double D = Double.parseDouble(sl[0]);
            int N = Integer.parseInt(sl[1]);

            if (N == 100) N += 1;

            System.out.println((int)(N * Math.pow(100d, D)));
        }
    }
}


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

int main(){
    string x;
    cin >> x;
    vector <char> a;

    for (auto c:x){
        // cout << c << endl;
        if (a.empty()){
            a.push_back(c);
            continue;
        }
        if (a.back() == 'S' and c == 'T'){
            a.pop_back();
        }
        else{
            a.push_back(c);
        }
    }

    cout << a.size() << endl;
    return 0;
}

Measured memory_bytes: 772
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	string s; cin >> s;
	int n=s.size();
	for(int i=0;i<n-1;i++){
		if(s[i]==s[i+1]){
			cout << i+1 << " " << i+2 << endl;
			return 0;
		}
		if(i<n-2&&s[i]==s[i+2]){
			cout << i+1 << " " << i+3 << endl;
			return 0;
		}
	}
	cout << -1 << " " << -1 << endl;
}

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

int main() {
	int n, m;
	cin >> n >> m;
	
	int from_n, from_m;
	if (n < 2) {
		from_n = 0;
	}
	else {
		from_n = n*(n - 1)/2;
	}
	if (m < 2) {
		from_m = 0;
	}
	else {
		from_m = m*(m - 1)/2;
	}
	cout << from_n + from_m << endl;
}


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

int A;
int B;
int H;
int M;

int L_old = 0;
int S_old = 0;
double L = 0;
double S = 0;

double cen_old = 0;
double cen = 0;

long double x = 0;//求めたい線分長



int main() {
/*
  vector<int> data(5);
  for (int i = 0; i < 5; i++) {
    cin >> data.at(i);
  }
*/
cin >> A >> B >> H >> M;

L_old = (H * 60 + M) / 720;//与えられた時間のうち720分がいくつできるか
S_old = (H * 60 + M) / 60;

L = ((H * 60 + M) - L_old * 720) * 360.0 / 720.0;
S = ((H * 60 + M) - S_old * 60) * 360.0 / 60.0;

if(L-S < 0) cen_old = S - L;
else cen_old = L - S;

if(cen_old > 180) cen = 360.0 - cen_old;
else cen = cen_old;

x = sqrt(A * A + B * B - 2.0 * A * B * cos(cen * M_PI / 180));

cout << setprecision(20) << x << endl;
  
}


Measured memory_bytes: 4228
#include<cstdio>
#include<vector>
#include<algorithm>

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

using namespace std;

const double EPS=1e-11;

int main(){
	for(int W,H,n;scanf("%d%d%d",&W,&H,&n),W;){
		n*=2;
		int x[200],y[200];
		rep(i,n) scanf("%d%d",x+i,y+i);

		vector<double> y1;
		y1.pb(0);
		y1.pb(H);
		rep(i,n){
			double y_tmp;

			if(x[i]<W){
				y_tmp=(double)(y[i]-0)/(x[i]-W)*(0-W)+0;
				if(0<=y_tmp && y_tmp<=H) y1.pb(y_tmp);

				y_tmp=(double)(y[i]-H)/(x[i]-W)*(0-W)+H;
				if(0<=y_tmp && y_tmp<=H) y1.pb(y_tmp);
			}

			rep(j,i) if(x[i]!=x[j]) {
				y_tmp=(double)(y[i]-y[j])/(x[i]-x[j])*(0-x[j])+y[j];
				if(0<=y_tmp && y_tmp<=H) y1.pb(y_tmp);
			}
		}

		sort(y1.begin(),y1.end());

		double ans=0,y2[202];
		rep(i,y1.size()-1) if(y1[i+1]-y1[i]>EPS) {
			double y_mid=(y1[i]+y1[i+1])/2;
			rep(j,n){
				y2[j]=(y_mid-y[j])/(0-(x[j]+EPS))*(W-x[j])+y[j];
				if(y2[j]<0) y2[j]=0;
				if(y2[j]>H) y2[j]=H;
			}
			y2[n]=0;
			y2[n+1]=H;
			sort(y2,y2+n+2);
			ans+=(y1[i+1]-y1[i])*(y2[(n+2)/2]-y2[(n+2)/2-1]);
		}
		ans/=H*H;
		printf("%.10f\n",ans);
	}

	return 0;
}

Measured memory_bytes: 1068
import java.util.*;
import java.lang.*;

class LimitedBag<T> extends PriorityQueue<T>{
    int maxItem;
    public LimitedBag(int max){
        super();
        this.maxItem = max;
    }

    @Override
    public boolean add(T t) {
        boolean ret = super.add(t);
        if(super.size()>maxItem) super.poll();
        return ret;
    }
}

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int Y = sc.nextInt();
        int Z = sc.nextInt();
        int K = sc.nextInt();
        long[] A = new long[X];
        for(int x=0; x<X; x++) A[x]=sc.nextLong();
        long[] B = new long[Y];
        for(int y=0; y<Y; y++) B[y]=sc.nextLong();
        long[] C = new long[Z];
        for(int z=0; z<Z; z++) C[z]=sc.nextLong();


        LimitedBag<Long> twoLayer = new LimitedBag<>(K);
        for(long a:A) for(long b:B) twoLayer.add(a+b);

        LimitedBag<Long> threeLayer = new LimitedBag<>(K);
        for(long t:twoLayer) for(long c:C) threeLayer.add(t+c);

        List<Long> answer = new ArrayList<>(threeLayer);
        Collections.sort(answer, Collections.reverseOrder());
        for(long a:answer) System.out.println(a);

    }
}


Measured memory_bytes: 62176
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <stdlib.h>
using namespace std;

int main(){
    int A,B;
    cin >> A >> B;
    if(A < 10 && B < 10){
        cout << A * B << endl;
    }else{
        cout << "-1" << endl;
    }
}

Measured memory_bytes: 256
x1, y1, x2, y2 = map(int, input().split())

dis_x = x1 - x2
dis_y = y1 - y2

x3 = x2 + dis_y
y3 = y2 - dis_x

x4 = x3 + dis_x
y4 = y3 + dis_y

print(x3, y3, x4, y4)


Measured memory_bytes: 2940
import itertools
N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))

n_list = []
for i in range(N):
  n_list.append(i+1)

Per = list(itertools.permutations(n_list))
for i in range(len(Per)):
 tmp = list(Per[i])
 judge1,judge2 = 1,1
 for j in range(len(tmp)):
  if(tmp[j] != P[j]):
    judge1 = 0
  if(tmp[j] != Q[j]):
    judge2 = 0
    
 if(judge1 == 1): a = i+1
 if(judge2 == 1): b = i+1
  
print(abs(a-b))

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

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

    vector<long long int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    cout << abs(a[0] - a[n-1]) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>

using namespace std;
int main(void){
    string str;
    int sum;
    sum=0;
    while(1){
        getline(cin,str);
        if('0'==str[0])break;
        
        for(int i=0;i<str.size();i++){
            sum+=(str[i]-'0');
        }
        cout<<sum<<endl;
        sum=0;
    }
    
    return 0;
}


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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	string ans ="No";
	if( a + b == c) {
		ans = "Yes";
	} else if ( a + c == b) {
		ans = "Yes";
	} else if ( b + c == a) {
		ans = "Yes";
	}
	cout << ans << endl;
	return 0;
}

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

#define	Rep0(i, n)	for (auto i=0; i<n; i++)
#define	Rep1(i, n)	for (auto i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	string S;
	cin >>S;
	int n=S.size();
	if (2==n)
		cout <<S <<endl;
	else {
		Rep1(i, n)
			cout <<S.at(n-i);
		cout <<endl;
	}
	return 0;
}



Measured memory_bytes: 256