akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int maxn =2e5+10;
const int mod=1e9+7;
char s[1005][1005];
int h,w;
int sx,sy,ex,ey;
int xx[5]={58,0,0,1,-1};
int yy[5]={58,1,-1,0,0};
int min1=1e9;

struct ac
{
    int x,y,step;
};


void bfs()
{
    deque<ac>q;
    q.push_front({sx,sy,0});
    s[sx][sy]='#';
    while(!q.empty())
    {
        ac u=q.front();
        q.pop_front();
        int x=u.x,y=u.y;
        if(x==ex&&y==ey)
        {
            min1=u.step;
            return;
        }
        s[x][y]='#';
        for(int i=1;i<=4;i++)
        {
            int tx=x+xx[i];
            int ty=y+yy[i];
            if(tx<1||ty<1||tx>h||ty>w||s[tx][ty]=='#')
                continue;
            q.push_front({tx,ty,u.step});
        }
        for(int i=x-2;i<=x+2;i++)
        {
            for(int j=y-2;j<=y+2;j++)
            {
                if(i<1||j<1||i>h||j>w||s[i][j]=='#')
                    continue;
                q.push_back({i,j,u.step+1});
            }
        }
    }
}


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>h>>w;
    cin>>sx>>sy>>ex>>ey;
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            cin>>s[i][j];
        }
    }
    bfs();
    if(min1==1e9)
        cout<<-1<<'\n';
    else
        cout<<min1<<'\n';



}

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

#define int long long

signed main(){
  int n,w;
  cin>>n>>w;
  int a[n+1],b[n+1];
  for(int i=0;i<n;++i)cin>>a[i]>>b[i];
  int dp[n+1][w+1];
  for(int i=0;i<=n;++i)for(int j=0;j<=w;++j)dp[i][j]=0;

  for(int i=0;i<n;++i){
    for(int j=0;j<=w;++j){
      if(j>=a[i])dp[i+1][j]=max( dp[i+1][j],dp[i][j-a[i]]+b[i] );
      dp[i+1][j]=max( dp[i][j],dp[i+1][j] );
    }
  }

  cout<<dp[n][w]<<endl;
  return 0;
}

Measured memory_bytes: 79104
// G++ MACRO.CPP -STD=C++17
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision; // cpp_int
 
#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>
 
#define pb(a) push_back(a)
#define mp make_pair

int main(){
  CIN(a,b);
  int cou = a-1;
  cou+=(a<=b);
  COUT(cou);

  return 0;
}

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

typedef long long ll;
typedef long long LL;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#ifdef DEBUG
    #define cek(x) cout<<x
#else
    #define cek(x) if(false){}
#endif // DEBUG

#define fi first
#define se second
#define INF 1000000000
#define INFLL 1000000000000000000LL
#define EPS 1e-9
#define PI acos(-1.0)
#define pb push_back
#define TC() while(tc--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORN(i,n) for(int i=0;i<=n;i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define REPN(i,a,b) for(int i=a;i<=b;i++)
#define reset(a,b) memset(a,b,sizeof(a))
#define sc(x) scanf("%d",&x)

int main(void){
    #ifdef ccsnoopy
        freopen("D:/Code/in.txt","r",stdin);
    #endif

    int n;
    sc(n);
    string res;
    deque<char> atas,bawah;
    char iatas[] = {'.','.','#','#'};
    char ibawah[] = {'.','#','.','#'};
    bool gausah = false;
    while(true){
        bool valid = false;
        if(!gausah)FOR(i,4){
            FOR(j,atas.size()){
                printf("%c", atas[j]);
            }
            printf("%c\n", iatas[i]);
            FOR(j,bawah.size()){
                printf("%c", bawah[j]);
            }
            printf("%c\n", ibawah[i]);
            fflush(stdout);
            cin>>res;
            if(res == "T"){
                atas.push_back(iatas[i]);
                bawah.push_back(ibawah[i]);
                valid = true;
                break;
            }else if(res == "end"){
                return 0;
            }
        }

        if(valid)continue;
        gausah = true;
        FOR(i,4){
            printf("%c", iatas[i]);
            FOR(j,atas.size()){
                printf("%c", atas[j]);
            }
            printf("\n%c", ibawah[i]);
            FOR(j,bawah.size()){
                printf("%c", bawah[j]);
            }
            printf("\n");
            fflush(stdout);
            cin >> res;
            if(res == "T"){
                atas.push_front(iatas[i]);
                bawah.push_front(ibawah[i]);
                break;
            }else if(res == "end"){
                return 0;
            }
        }

    }


    return 0;
}





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

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n,m;
	string s;
	cin>>n>>m>>s;
	int squ[n+1],num[m];
	vector <int> v;
	for (int i=0;i<m;i++) num[i]=i+1;
	for (int i=0;i<n+1;i++) squ[i]=0;
	for (int i=0;i<n+1;i++){
		if (s[i]=='1') squ[i]=1;
	}
	
	int big=0,count=0;
	for (int i=0;i<n;i++){
		if (squ[i+1]==1) count++;
		else {
			big=max(big,count);
			count=0;
		}
	}
	if (big>=m) cout<<-1<<endl;
	else {
		int now=n;
		while (now>0){
			for (int i=m-1;i>=0;i--){
				if (now==0) break;
				if (squ[now-num[i]]==0 && now-num[i]>=0){
					now=now-num[i];
					v.push_back(num[i]);
					break;
				}
			}
		}
		for (int i=v.size()-1;i>=0;i--) cout<<v[i]<<" ";
	}
	
	return 0;
}

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

int main(){
    long long N, K;
    cin >> N >> K;
    long long ans;
    if(K%2 == 1){
        long long M = N/K;
        ans = M*M*M;
    }
    else{
        long long M = N/K;
        long long L = (N + K/2)/K;
        ans = M*M*M + L*L*L;
    }
    cout << ans << endl;
}

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

int main(){
  bool minus = false;
  uint64_t X;
  uint64_t numA,numB;
  uint64_t ansA,ansB;
  cin >> X;
  for(uint64_t i=0; i<=7131; i++){
    for(uint64_t j=0; j<=7131; j++){
      numA = i*i*i*i*i;
      numB = j*j*j*j*j;
      if(numA-numB==X){
        ansA = i;
        ansB = j;
      }
      if(numA+numB==X){
        ansA = i;
        ansB = j;
        minus = true;
      }
    }
  }
  if(minus && ansB!=0) cout << ansA << " " << "-" << ansB << endl;
  else cout << ansA << " " << ansB << endl;
  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	double t, a;
	cin >> n >> t >> a;
	
	int ans = 0;
	double diff = (double)(1e9);
	for(int i = 0; i < n; ++i) {
		double h;
		cin >> h;
		
		double aveT = t - h * 6.0 / 1000.0;
		
		if( diff > abs(a - aveT) ) {
			diff = abs(a - aveT);
			ans = i + 1;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stack>
#include <math.h>

using namespace std;

int n;

bool rangeCheck(int row,int col){
	if(row >= 0 && row <= n-1 && col >= 0 && col <= n-1)return true;
	else{
		return false;
	}
}

int main(){

	int d,row,col,move;
	char current,table[100][101];
	bool FLG,First = true;

	scanf("%d",&d);

	for(int loop=0; loop < d; loop++){
		scanf("%d",&n);


		if(!First)printf("\n");

		for(int i=0; i < n; i++){
			for(int k=0; k < n; k++)table[i][k] = ' ';
		}

		row = n-1,col = 0;
		current = 'U';

		FLG = true;

		while(FLG){
			move = 0;

			switch(current){
			case 'U':

				for(;row >= 0; row--){
					if((rangeCheck(row-1,col) == true && table[row-1][col] == '#')||
					   (rangeCheck(row,col-1) == true && table[row][col-1] == '#')||
					   (rangeCheck(row,col+1) == true && table[row][col+1] == '#'))break;

					table[row][col] = '#';
					move++;
				}
				if(move == 0){
					FLG = false;
				}else{
					row += 1;
					col += 1;
					current = 'R';
				}
				break;
			case 'R':

				for(;col <= n-1; col++){
					if((rangeCheck(row-1,col) == true && table[row-1][col] == '#')||
					   (rangeCheck(row+1,col) == true && table[row+1][col] == '#')||
					   (rangeCheck(row,col+1) == true && table[row][col+1] == '#'))break;

					table[row][col] = '#';
					move++;
				}
				if(move == 0){
					FLG =false;
				}else{
					col -= 1;
					row += 1;
					current = 'D';
				}
				break;
			case 'D':

				for(; row <= n-1; row++){
					if((rangeCheck(row,col-1) == true && table[row][col-1] == '#')||
					   (rangeCheck(row+1,col) == true && table[row+1][col] == '#')||
					   (rangeCheck(row,col+1) == true && table[row][col+1] == '#'))break;

					table[row][col] = '#';
					move++;
				}
				if(move == 0){
					FLG = false;
				}else{
					row -= 1;
					col -= 1;
					current = 'L';
				}
				break;
			case 'L':

				for(; col >= 0; col--){
					if((rangeCheck(row-1,col) == true && table[row-1][col] == '#')||
					   (rangeCheck(row+1,col) == true && table[row+1][col] == '#')||
					   (rangeCheck(row,col-1) == true && table[row][col-1] == '#'))break;

					table[row][col] = '#';
					move++;
				}
				if(move == 0){
					FLG = false;
				}else{
					col += 1;
					row -= 1;
					current = 'U';
				}
				break;
			}
		}

		for(int i=0; i < n; i++){
			for(int k=0; k < n; k++)printf("%c",table[i][k]);
			printf("\n");
		}

		if(First)First = false;

	}


    return 0;
}

Measured memory_bytes: 2600
import numpy as np
from numba import njit, i8


@njit(i8(i8, i8, i8[:, :]), cache=True)
def solve(H, N, magics):
    dp = np.full((H + 1), 1 << 31, dtype=np.int64)
    dp[0] = 0
    for i in range(N):
        A, B = magics[i]
        for h in range(H):
            dp[min(h + A, H)] = min(dp[min(h + A, H)], dp[h] + B)
    return dp[-1]


H, N, *AB = map(int, open(0).read().split())
magics = np.array([(A, B) for A, B in zip(*[iter(AB)] * 2)], dtype=np.int64)
print(solve(H, N, magics))


Measured memory_bytes: 106656
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    N = II()
    B = LI()
    for i, b in enumerate(B, 1):
        if b > i:
            print(-1)
            return -1
    ans = [0] * N
    nofill = list(range(N))
    for b in B[::-1]:
        ans[nofill[b - 1]] = b
        del nofill[b - 1]
    for a in ans:
        print(a)

    return 0

main()

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int h = in.nextInt();
		int w = in.nextInt(); in.nextLine();
		
		int[][] powAry = new int[10][10];
		for ( int i = 0; i < 10; i++ ) {
			for ( int j = 0; j < 10; j++ ) {
				powAry[i][j] = in.nextInt();
			} in.nextLine();
		}

		int[][] turnAry = new int[h][w];
		for ( int i = 0; i < h; i++ ) {
			for ( int j = 0; j < w; j++ ) {
				turnAry[i][j] = in.nextInt();
			} in.nextLine();
		}
		
		// Floyd-Warshall algo
		for ( int k = 0; k < 10; k++ ) {
			for ( int i = 0; i < 10; i++ ) {
				for ( int j = 0; j < 10; j++ ) {
					powAry[i][j] = Math.min(powAry[i][j], powAry[i][k]+powAry[k][j]);
				}
			}
		}

		int total = 0;
		for ( int i = 0; i < h; i++ ) {
			for ( int j = 0; j < w; j++ ) {
				if ( turnAry[i][j] != -1 && turnAry[i][j] != 1) {
					// total += powAry[turnAry[i][j]][i];
					total += powAry[turnAry[i][j]][1];
				}
			}
		}
		
		System.out.println(total);
		
	}
}

Measured memory_bytes: 48312
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define mod 1000000007
#define inf 999999999999999ll
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    vi a(n);
    for(ll i=0;i<n;i++)
        cin>>a[i];
    sort(a.begin(),a.end());
    ll ans=0;
    for(ll i=0;i<n;i++)
    {
        for(ll j=i+1;j<n;j++)
        {
            ll l1=a[i];
            ll l2=a[j];
            ll in=lower_bound(a.begin(),a.end(),l1+l2)-a.begin();
            ans+=in-1-(j+1)+1;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <cstdio>
#include <deque>
#include <iostream>

using namespace std;

int main(void)
{
	int q, i, com, d, x;
	deque<int> D;
	scanf("%d", &q);
	for (i = 0; i < q; i++)
	{
		scanf("%d", &com);
		switch (com)
		{
			case 0:
				scanf("%d %d", &d, &x);
				if (d == 0)
					D.push_front(x);
				else
					D.push_back(x);
				break;
			case 1:
				scanf("%d", &x);
				printf("%d\n", D[x]);
				break;
			case 2:
				scanf("%d", &d);
				if (d == 0)
					D.pop_front();
				else
					D.pop_back();
		}
	}
}


Measured memory_bytes: 4680
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int p[50001],a[20];
int main(){
int n,m,i,j;
cin>>n>>m;
for(i=0;i<m;i++)cin>>a[i];
for(i=1;i<=n;i++)p[i]=50000;
p[0]=0;
for(i=0;i<n;i++){
for(j=0;j<m;j++){
if(n>=i+a[j])p[i+a[j]]=min(p[i+a[j]],p[i]+1);
}
}
cout<<p[n]<<endl;
return 0;
}

Measured memory_bytes: 3288
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,i,j;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++)
    cin>>a[i];
  int s=0;
  for(i=0;i<n-1;i++)
  {
    for(j=i+1;j<n;j++)
      s+=a[i]*a[j];
  }
  cout<<s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define _GLIBCXX_DEBUG
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
const ll INF = 9223372036854775807;

int main() {
    ll N, Y;cin >> N >> Y;
    bool TF = true;
    bool TFs = false;
    rep(i,N+1) {
        rep(j,N+1) {
            if(N-i-j < 0) continue;
            if(10000*i+5000*j+1000*(N-i-j) == Y) {
                cout << i << " " << j << " " << N-i-j << endl;
                TF = false;
                TFs = true;
                break;
            }
        }
        if(TFs) break;
    }
    if(TF) cout << -1 << " " << -1 << " " << -1 << endl;
}

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

string getNumStr(int i){
    if(i == 0){
        return "0";
    }

    string ans = "";

    stack<char> c;

    while(i > 0){
        c.push((i % 10) + '0');
        i /= 10;
    }

    while(!c.empty()){
        ans.push_back(c.top());
        c.pop();
    }

    return ans;
}

string fizz(int i){
    if(i % 3 == 0 && i % 5 == 0){
        return "FizzBuzz";
    }

    if(i % 3 == 0){
        return "Fizz";
    }

    if(i % 5 == 0){
        return "Buzz";
    }

    return getNumStr(i);
}

int main(){
    int n, m;

    while(cin >> m >> n, m > 0 && n > 0){
        int now = 0;
        int ydk = m;

        int life[1010] = {};

        string s;

        string t[10010];
        for(int i = 0;i < n;i++){
            cin >> t[i];
        }

        for(int i = 0;i < n;i++){
            s = t[i];
            while(life[now] == 1) now = (now+1)%m;
            if(s != fizz(i+1)){
                life[now] = 1;
                ydk--;
                if(ydk == 1){
                    break;
                }
            }
            now = (now+1) % m;
        }

        queue<int> ans;

        for(int i = 0;i < m;i++){
            if(life[i] == 0){
                ans.push(i+1);
            }
        }

        while(!ans.empty()){
            cout << ans.front();
            ans.pop();
            if(ans.empty()){
                cout << endl;
            }else{
                cout << " ";
            }
        }
    }
    return 0;
}








Measured memory_bytes: 3772
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
const int64_t MOD = 1e9 + 7;

int n;
vector<int> v;

int partition(int p, int r) {

	//for (int i = 0; i < v.size(); i++) {
	//	if (i) cout << ' ';
	//	cout << v.at(i);
	//}
	//cout << endl;

	int x, i, j, t;
	x = v.at(r);
	i = p - 1;

	for (int j = p; j < r; j++) {
		if (v.at(j) <= x) {
			i++;
			t = v.at(i);
			v.at(i) = v.at(j);
			v.at(j) = t;
		}
	}

	t = v.at(i + 1);
	v.at(i + 1) = v.at(r);
	v.at(r) = t;

	return i + 1;
}

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

	for (int i = 0; i < n; i++) {
		int num;
		cin >> num;
		v.push_back(num);
	}

	q = partition(0, n - 1);

	for (int i = 0; i < n; i++) {
		if (i) cout << ' ';
		if (i == q) {
			cout << "[" << v.at(i) << "]";
		}
		else {
			cout << v.at(i);
		}
	}
	cout << endl;
}


Measured memory_bytes: 3428
#include <iostream>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main() {
    int n;
    string s;
    cin>>n;
    s=to_string(n);
    if (s[0]=='7'||s[1]=='7'||s[2]=='7') {
        cout<<"Yes"<<endl;
    } else {
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3692
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/
#define INF 100000000
int main()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);

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

	int a[M+1], b[M+1],c[M+1];
	int dist[N][N];

	for (int i = 0; i < M; i++)
	{
		cin >> a[i] >> b[i] >> c[i];
		a[i]--;
		b[i]--;
	}

	for (int i = 0; i < N; i++)
	{
		rep(j,N)
		{
			if (i==j)
			{
				dist[i][j] = 0;
			}
			else
			{
				dist[i][j] = INF;
			}
		}
	}

	rep(i, M)
	{
		dist[a[i]][b[i]] = min(dist[a[i]][b[i]], c[i]);
		dist[b[i]][a[i]] = min(dist[b[i]][a[i]], c[i]);
	}
	/*
	rep(i, N)
	{
		rep(j,N)
		{
			rep(k,N)
			{
				if (dist[i][j] > dist[i][k] + dist[k][j])
				{
					dist[i][j] = dist[i][k] + dist[k][j];
				}
			}
		}
	}
	*/
	rep(k, N)
	{
		rep(i,N)
		{
			rep(j,N)
			{
				if (dist[i][j] > dist[i][k] + dist[k][j])
				{
					dist[i][j] = dist[i][k] + dist[k][j];
				}
			}
		}
	}

	int ans = M;

	rep(i, M)
	{
		bool shortest = false;
		rep(j,N)
		{
			if (dist[j][a[i]] + c[i] == dist[j][b[i]])
			{
				shortest = true;
			}
		}

		if (shortest)
		{
			ans--;
		}
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 5100;
const int MOD = 998244353;

ll dp[2][MAX];
// 和について何通りの選び方があるのか保存しとく

int main(){
  ll N , S; cin >> N >> S;
  vector<ll> a(N); rep(i,N) cin >> a[i];
  ll ans = 1;
  dp[0][0] = 1;
  rep(i,N){
    // 選ばない場合
    rep(j,S + 1){
      dp[1][j] = 2 * dp[0][j];
      dp[1][j] %= MOD;
    }
     // 選ぶ場合
     rep(j,S + 1){
       if(j + a[i] > S) continue;
       else{
         dp[1][j + a[i]] += dp[0][j];
         dp[1][j + a[i]] %= MOD;
       }
     }
     // 入れ替え
     rep(j , S + 1){
       dp[0][j] = dp[1][j];
     }
  }
  // rep(i,S) cout << i << " " << dp[0][i] << endl;
  cout << dp[0][S] << endl;
}


Measured memory_bytes: 3692
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
typedef long long LL;
int _min(int x, int y) {return x < y ? x : y;}
int _max(int x, int y) {return x > y ? x : y;}
int read() {
	int s = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
	return s * f;
}

char ss[110000];

int main() {
	scanf("%s", ss + 1);
	int n = strlen(ss + 1);
	if(ss[n] == '1') {puts("-1"); return 0;}
	if(ss[1] == '0') {puts("-1"); return 0;}
	for(int i = 1; i < n; i++) {
		if(ss[i] != ss[n - i]) {puts("-1"); return 0;}
	} int id = 1, now = 1, o = n - 1;
	for(int i = n / 2; i >= 1; i--) {
		if(ss[i] == '1') {
			for(int j = 1; j <= o - i + 1; j++) {
				printf("%d %d\n", now, ++id);
			} o = i - 1; now = id;
		}
	}
	return 0;
}


Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int x = scanner.nextInt();
			int a = scanner.nextInt(), b = scanner.nextInt();
			System.out.println((Math.abs(a - x) > Math.abs(b - x)) ? "B" : "A");
		}
	}
}


Measured memory_bytes: 21332
#include <stdio.h>

int main(int argc, char const *argv[]) {
 int N;
 int A[200000];
 int m=0;
 int m1;
 int m2;

 scanf("%d\n",&N );
 for (int i = 0; i < N; i++) {
   scanf("%d\n",&A[i] );
 }


 for (int i = 0; i < N; i++) {
   if(m<A[i]){
     m=A[i];
     m1=i;
   }
 }
 m=0;

 for (int i = 0; i < N; i++) {
   if(i!=m1){
     if(m<A[i]){
       m=A[i];
       m2=i;
     }
   }
 }

 for (int i = 0; i < N; i++) {
   if(i!=m1){
     printf("%d\n",A[m1] );
   }else{
     printf("%d\n",A[m2] );
   }
 }
  return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <iomanip>
#include <type_traits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//constexpr long long MOD = 1e9 + 7;
//constexpr long long MAX = 1000000;

//long long MOD = 998244353;
constexpr ll INF = 1e17;
constexpr double PI = 3.141592653589793;
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 h, w;
vector<ll> dx = { -1, 0, 1, 0 };
vector<ll> dy = { 0, -1, 0, 1 };


bool isInField(ll x, ll y) {
    bool f = x >= 0 && x < w && y >= 0 && y < h;
    return f;
}

bool compare_first(pair<ll, ll> x, pair<ll, ll> y)
{
    if (x.first != y.first) {
        return x.first < y.first;
    }
    else {
        return x.second < y.second;
    }
}

bool compare_second(pair<ll, ll> x, pair<ll, ll> y)
{
    if (x.second != y.second) {
        return x.second < y.second;
    }
    else {
        return x.first < y.first;
    }
}

struct {
    bool operator()(pair<string, int> x, pair<string, int> y) const
    {
        return x.second <= y.second && x.first < y.first;
    }
} compare_map;

const ll MAX = 500000000;
const ll MOD = 1000000007;


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

    //int a, b, c, l, m, n, h, w;
    //cin >> h >> w;

    int n, m;
    cin >> n >> m;

    int ans = m * (m - 1) / 2 + n * (n - 1) / 2;
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int h, w;
char s[2001][2001];
int result[2001][2001][4] = {};

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

int getresult(int i, int j, int k)
{
	if(i < 0 || j < 0 || i >= h || j >= w) return 0;
	if(result[i][j][k] >= 0) return result[i][j][k];
	if(s[i][j] == '#') return result[i][j][k] = 0;
	return result[i][j][k] = getresult(i + dx[k], j + dy[k], k) + 1;
}

int main()
{
	cin >> h >> w;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cin >> s[i][j];
			for(int k = 0; k < 4; k++){
				result[i][j][k] = -1;
			}
		}
	}
	int ans = 0;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(s[i][j] == '#') continue;
			int nowresult = 0;
			for(int k = 0; k < 4; k++){
				nowresult += getresult(i + dx[k], j + dy[k], k);
			}
			nowresult++;
			ans = max(ans, nowresult);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 66688
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    ll n,m;
    cin >> n >> m;
    if(n==1 && m==1){
        cout << 1 << endl;
    }
    else if(n==1){
        cout << m-2 << endl;
    }
    else if(m==1){
        cout << n-2 << endl;
    }
    else{
        cout << n*m - n*2 - m * 2 + 4 << endl;
    }
}

Measured memory_bytes: 256
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n=int(readline())
    a=list(map(int,readline().split()))

    d=dict()
    for i in range(n):
        if a[i] not in d:
            d[a[i]]=1
        else:
            d[a[i]]+=1

    cnt=0
    for x in range(1,10**5+1):
        if x-1 in d: s=d[x-1]
        else: s=0

        if x in d: t=d[x]
        else: t=0

        if x+1 in d: u=d[x+1]
        else: u=0

        cnt=max(cnt,s+t+u)

    print(cnt)

if __name__=="__main__":
    main()

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

int main() {
  string S;
  cin >> S;

  bool ans1;
  if (S.at(0) == '0') {
    if (S.at(1) != '0') {
      ans1 = true;
    }
    else {
      ans1 = false;
    }
  }
  else if (S.at(0) == '1') {
    if (S.at(1) == '0' || S.at(1) == '1' || S.at(1) == '2') {
      ans1 = true;
    }
    else {
      ans1 = false;
    }
  }
  else {
    ans1 = false;
  }

  bool ans2;
  if (S.at(2) == '0') {
    if (S.at(3) != '0') {
      ans2 = true;
    }
    else {
      ans2 = false;
    }
  }
  else if (S.at(2) == '1') {
    if (S.at(3) == '0' || S.at(3) == '1' || S.at(3) == '2') {
      ans2 = true;
    }
    else {
      ans2 = false;
    }
  }
  else {
    ans2 = false;
  }

  if (ans1) {
    if (ans2) {
      cout << "AMBIGUOUS" << endl;
    }
    else {
      cout << "MMYY" << endl;
    }
  }
  else {
    if (ans2) {
      cout << "YYMM" << endl;
    }
    else {
      cout << "NA" << endl;
    }
  }
}


Measured memory_bytes: 256
from heapq import heappush, heappop

INF = float('inf')

def dijkstra(n, G, s):
    dist = [INF] * n
    dist[s] = 0
    h = []
    heappush(h, (0, s))

    while h:
        # 使っていない頂点のうち、現時点で最も距離の近いものを選びvとする
        d, v = heappop(h)
        if dist[v] < d:
            continue
        # vから到達可能な頂点について、距離が短くなれば更新
        for b, cost in G[v]:
            if dist[b] > dist[v] + cost:
                dist[b] = dist[v] + cost
                heappush(h, (dist[b], b))
    return dist

n, x, y = map(int, input().split())

g = [[] for i in range(n)]

for i in range(n-1):
    g[i].append((i+1, 1))
    g[i+1].append((i, 1))

g[x-1].append((y-1, 1))
g[y-1].append((x-1, 1))

ans = [0] * n

for i in range(n):
    for d in dijkstra(n, g, i):
        ans[d] += 1

for item in ans[1:]:
    print(item // 2)



Measured memory_bytes: 120924
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  if (s < t) {
  	cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

const int NN=200;

int main()
{
    char str[5];
    scanf("%s",&str);
    int a1=str[0]-'0';
    a1=a1*10+str[1]-'0';
    int a2=str[2]-'0';
    a2=a2*10+str[3]-'0';
        if(a1<=12&&a2>12&&a1>0){
            printf("MMYY\n");
        }
        else if(a1>12&&a2<=12&&a2>0){
            printf("YYMM\n");
        }
        else if(a1<=12&&a2<=12&&a1>0&&a2>0){
            printf("AMBIGUOUS\n");
        }
        else if(a1==0&&a2<=12&&a2>0){
            printf("YYMM\n");
        }
        else if(a2==0&&a1<=12&&a1>0){
            printf("MMYY\n");
        }
        else{
            printf("NA\n");
        }

}


Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

import math

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def dist(a, b):
    d = 0
    for a1, b1 in zip(a, b):
        d += (a1-b1)**2
    d = math.sqrt(d)
    return (d-int(d)) < 0.00001

def main():
    n, d = rli()
    lp = []
    for _ in range(n):
        lx = rli()
        lp.append(lx)
    ans = 0
    for i in range(n):
        for j in range(i+1, n):
            if dist(lp[i], lp[j]):
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = a; i >= (b); --i)
#define trav(a, x) for(auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;



int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  int t; cin >> t;
  int res = 1 ^ t;
  cout << res;
}

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

int main(){
  int n;
  double s = 0.0;
  cin >> n;
  for (int i = 0; i < n; i++){
    double x;
    string u;
    cin >> x >> u;
    if (u == "JPY") s += x;
    else s += 380000.0*x;
  }
  cout << s << endl;
}


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

using vector = std::vector<int>;

int main(void) {
    int n;
    std::cin >> n;

    vector vec_a{};
    for (int i = 0; i < n; ++i) {
        int a;
        std::cin >> a;
        vec_a.push_back(a);
    }

    int m;
    std::cin >> m;

    vector vec_b{};
    for (int i = 0; i < m; ++i) {
        int b;
        std::cin >> b;
        vec_b.push_back(b);
    }

    vector intersection{};

    std::set_intersection(vec_a.begin(), vec_a.end(), vec_b.begin(),
                          vec_b.end(), std::back_inserter(intersection));

    for (auto iter = intersection.begin(); iter != intersection.end(); ++iter) {
        std::cout << *iter << std::endl;
    }
}


Measured memory_bytes: 5152
/*
 *  * main.cpp
 *   *
 *    */

#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<set>
#include<cstring>
#include<string>
#include<cassert>
using namespace std;

int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}
int main() {

    long long A, B;
    scanf("%lld %lld", &A, &B);
    printf("%lld\n", A * B / gcd(A, B));



    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define ONE 1
#define NINE 9
int main()
{
	int i = 0, j = 0;
	for(i = ONE; i <= NINE; i++)
	{
		for(j = ONE; j <= NINE; j++)
		{
			printf("%dx%d=%d\n", i, j, i * j);
		}
	}
	return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define M 1000000007
#define sz(a) (ll)a.size()
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    string s;
    cin>>n>>s;
    map<char,ll>m;
    for(auto i:s)
    	m[i]++;
    ll ans=1;
    for(auto i:m)
    {
    	ans=(ans*(i.S+1))%M;
    }
    ans=(ans-1+M)%M;
    cout<<ans;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	int a, b;
	cin >> a >> b;
	if (a == b) cout << "Draw" << endl;
	else if(a == 1) cout << "Alice" << endl;
	else if (b == 1) cout << "Bob" << endl;
	else if (a > b) cout << "Alice" << endl;
	else if (a < b) cout << "Bob" << endl;
}

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

#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)
#define iter(it,c) for(auto it=c.begin(); it!=c.end(); it++)
typedef vector<int> vi;
typedef vector<vi> vvi;

int main(){
    int n, m;
    string s;
    while (cin >> n >> m >> s && n){
        vi c(m);
        rep(i, m){
            if (s[i] == 'I'){
                if (i != 0 && s[i - 1] == 'O'){
                    c[i] = c[i - 1] + 1;
                }
                else{
                    c[i] = 1;
                }
            }
            else{
                if (i != 0 && s[i - 1] == 'I'){
                    c[i] = c[i - 1] + 1;
                }
            }
        }
        int ans = 0;
        int l = 2 * n + 1;
        rep(i, m){
            if (s[i]=='I' && c[i] >= l) ans++;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 5996
#include <bits/stdc++.h>
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrepi(i,a,b) for(int i=((int)(b)-1);i>=(a);--i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) rrepi(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define ZERO(x) memset(x,0,sizeof(x))
#define MINUS(x) memset(x,-1,sizeof(x))
#define UNIQUE(x) (x).erase(unique(ALL(x)), (x).end())
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void viewarr(T arr[], int n) { for(int i = 0; i < n; ++i) std::cout << arr[i] << " "; std::cout << std::endl; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    bool ans = false;
    if(a == b && a != c) ans = true;
    else if(b == c && c != a) ans = true;
    else if(c == a && a != b) ans = true;
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include<iomanip>
#include<functional>
using namespace std;
typedef long long ll;




// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

int main() {
    int n;
    cin >> n;
    vector<int> A(n);
    ll sum = 0;
    vector<ll> backet(1e7,0);
    for (int i = 0; i < n; i++) {
        cin >> A[i];
        backet[A[i]]++;
        sum += A[i];
    }
    int q; cin >> q;
    for (int i = 0; i < q; i++) {
        ll b, c;
        cin >> b >> c;
         sum -= backet[b] * b;
         sum += backet[b] * c;
         backet[c] += backet[b];
         backet[b] = 0;
        cout << sum << endl;
    }
}


Measured memory_bytes: 81644
s=input().strip()
c=0
for i in s:
    c+=1
    if c%2:
        if i not in ['R', 'U', 'D']:
            print('No')
            exit(0)
    else:
        if i not in ['L', 'U', 'D']:
            print('No')
            exit(0)
print('Yes')

Measured memory_bytes: 3060
//
//  main.cpp
//  tarea
//
//  Created by AdÃ¡n LÃ³pez Alatorre on 3/31/17.
//  Copyright Â© 2017 AdÃ¡n LÃ³pez Alatorre. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <string.h>
#include <bitset>
#include <set>
#include <cstdio>
#include <cmath>
#include <vector>
#include <iomanip>
#include <stack>
#include <map>
#include <queue>
#include <climits>
#define se second
#define fi first

using namespace std;

typedef  long long ll;
typedef vector<int> vi;
typedef pair<ll, ll> ii;

const int MOD = 998244353, maxN = 1e2 + 6, maxV = 4e6 + 6;



int main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    
    int d, n;
    cin >> d >> n;
    
    int cn = 1;
    while(d--){
        cn *= 100;
    }if(n == 100) n++;
    
    cout << n * cn << '\n';
    
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    String s = sc.next();
    char[] c = new char[n];

    for(int i = 0;i < n;i++) {
      c[i] = s.charAt(i);
    }

    if(c[k-1] == 'A') c[k-1] = 'a';
    if(c[k-1] == 'B') c[k-1] = 'b';
    if(c[k-1] == 'C') c[k-1] = 'c';

    for(int i = 0;i < n;i++)
    System.out.print(c[i]);

  }

}


Measured memory_bytes: 21844
import java.util.*;
 
class Main{
	
	public static void main(String args[]){
 
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		int B[] = new int[N];
		int C[] = new int[N];
		long sum_A = 0;
		long sum_B = 0;
 
		for(int n=0;n<N;n++){
			A[n] = sc.nextInt();
			sum_A += A[n];	
		}
		for(int n=0;n<N;n++){
			B[n] = sc.nextInt();
			sum_B += B[n];
			C[n] = A[n] - B[n];
		}
		Arrays.sort(C);
		if(sum_A < sum_B){
			System.out.println(-1);
			return;
		}
		int arg=0;
		long sum_minus=0;
		for(int c : C){
			if(c<0){
				sum_minus += Math.abs(c);
				arg++;
			}else{
				break;
			}
		}
		if(sum_minus == 0){
			System.out.println(0);
			return;
		}
		int tmp = 0;
		for(int n=C.length-1;n>0;n--){
			
			sum_minus -= C[n];
			tmp++;
			if(sum_minus<=0){
				break;
			}
		}
		System.out.println(tmp+arg);
 
 
	}
}

Measured memory_bytes: 80160
#include <stdio.h>
#include <stdlib.h>

int n,m;
int *x,*y;
int ans=0;

int asc(const void *a, const void *b){
  return *(int *)a - *(int *)b;
}

int main(){
    int i;
    scanf("%d%d",&n,&m);
    x=(int*)malloc(sizeof(int)*m);
    y=(int*)malloc(sizeof(int)*(m-1));
    for(i=0;i<m;i++)scanf("%d",&x[i]);
    qsort(x,m,sizeof(*x),asc);
    for(i=0;i<m-1;i++)y[i]=x[i+1]-x[i];
    qsort(y,m-1,sizeof(*y),asc);
    for(i=0;i<m-n;i++)ans+=y[i];
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1396
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split();
            var a = line[0];
            var b = line[1];

            Console.WriteLine(b + a);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 11092
A = int(input())
B = int(input())

if(A == 1):
  if(B == 2):
    print("3")
  else:
    print("2")
elif(A == 2):
  if(B == 1):
    print("3")
  else:
    print("1")
else:
  if(B == 1):
    print("2")
  else:
    print("1")



Measured memory_bytes: 3060
n = int(input())
evidences = [[] for _ in range(n)]
for i in range(n):
    a = int(input())
    for j in range(a):
        x, y = map(int, input().split())
        evidences[i].append((x-1, y))

ans = 0
for i in range(2**n):
    consistent = True
    for j in range(n):
        if (i>>j) & 1 == 0:
            continue
        for x, y in evidences[j]:
            if (i>>x) & 1 != y:
                consistent = False
                break
    if consistent:
        ans = max(ans, bin(i)[2:].count('1'))

print(ans)

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

bool pattern1(int from, int to, vector<bool> field)
{
    while (from < to)
    {
        if (from + 1 == to || from + 2 == to)
        {
            break;
        }
        if (field[from + 2])
        {
            from += 2;
        }
        else if (field[from + 1])
        {
            from += 1;
        }
        else
        {
            return false;
        }
    }
    return true;
}

int main()
{
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;

    string S;
    cin >> S;
    vector<bool> field(N);
    bool can_jump = false;
    int count = 0;
    for (int i = 0; i < N; i++)
    {
        field[i] = S[i] == '.';
        if (field[i])
        {
            count++;
        }
        else
        {
            count = 0;
        }
        if (count >= 3)
        {
            int third = i + 1;
            int second = i;
            int first = i - 1;
            if (B <= second && second <= D && third <= C)
            {
                can_jump = true;
            }
        }
    }

    if (C < D)
    {
        // AB->AB
        if (!pattern1(B, D, field))
        {
            cout << "No" << endl;
            return 0;
        }
        if (!pattern1(A, C, field))
        {
            cout << "No" << endl;
            return 0;
        }
        cout << "Yes" << endl;
    }
    else
    {
        // AB->BA
        if (!pattern1(B, D, field))
        {
            cout << "No" << endl;
            return 0;
        }
        if (!pattern1(A, C, field))
        {
            cout << "No" << endl;
            return 0;
        }
        if (!can_jump)
        {
            cout << "No" << endl;
            return 0;
        }
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 640
# include <bits/stdc++.h>
# pragma GCC optimize("Ofast")
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define forn(i, n) for (int i = 0; i < int(n); i++)
# define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define fore(i, l, r) for (int i = int(l); i < int(r); i++)
# define fors(i, s) for (int i = 0; s[i]; i++)
# define in freopen("input.txt", "r", stdin)
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
 
using namespace std;
 
const ll INF = 1e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 7;

string a, b; 
 
int main()
{
	speed;
	cin >> a >> b;
	cout << b << a;
	time;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try(Scanner scn = new Scanner(System.in)) {
            int n;
            while((n = scn.nextInt()) > 0) {
                for(int i = 0; i < 9; i++) {
                    n -= scn.nextInt();
                }
                System.out.println(n);
            }
        }
    }
}

Measured memory_bytes: 26412
#include<bits/stdc++.h>
using namespace std;
typedef struct
{
	vector<int> contact;
	int father;
	int value;
}son;
map<int,son> mp;
void dfs(int a)
{
	mp[a].value+=mp[mp[a].father].value;
	for(int i=0;i<mp[a].contact.size();i++)
	{
		if(mp[a].contact[i]!=mp[a].father)
		{
			mp[mp[a].contact[i]].father=a;
			dfs(mp[a].contact[i]);
		}
	}
	return;
}
int main()
{
	int a,b,n,q;
	map<int,son> ::iterator iter;
	cin>>n>>q;
	for(int i=0;i<n-1;i++)
	{
		cin>>a>>b;
		if(a==1)
		{
			mp[a].father=0;
		}
		mp[a].contact.push_back(b);
		mp[b].contact.push_back(a);
	}
	for(int i=0;i<q;i++)
	{
		cin>>a>>b;
		mp[a].value+=b;
	}
	dfs(1);
	for(iter=mp.begin();iter!=mp.end();iter++)
	{
		if(iter!=mp.begin())
		cout<<(*iter).second.value<<" ";
	}
	return 0;
}

Measured memory_bytes: 43008