akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<string.h>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#include <iomanip>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
#define MAX 100000


ll a, b,c;


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

	cin >> a >> b >> c;
	ll  K=c-a-b;
	if (K >= 0 && K*K > a*b*4) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	
	return 0;
}


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

int main() {
  vector<int> a(3);
  cin >> a.at(0) >> a.at(1) >> a.at(2);
  sort(a.begin(), a.end(), greater<int>());
  cout << a.at(0)*10 + a.at(1) + a.at(2) << endl;
}

Measured memory_bytes: 256
import bisect
import collections
import functools
import heapq
import math
import sys
from collections import deque
from collections import defaultdict
input = sys.stdin.readline
MOD = 10**9+7

H,W = map(int,(input().split()))
S = [[] for _ in range(H)]
for i in range(H):
    S[i] = list(input())

c = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == ".":
            c += 1

dx = [1,-1,0,0]
dy = [0,0,1,-1]

def distance(i,j):
    not_visit = [[-1]*W for i in range(H)]
    not_visit[i][j] = 0
    stack = [(i,j)]

    while stack != []:
        y,x = stack.pop(0)
        for i in range(4):
            if 0<= x+dx[i] <W and 0<= y+dy[i] <H and S[y+dy[i]][x+dx[i]] != "#" and not_visit[y+dy[i]][x+dx[i]] == -1:
                not_visit[y+dy[i]][x+dx[i]] =  not_visit[y][x] + 1
                stack.append((y+dy[i],x+dx[i]))
                if x+dx[i] == W-1 and y+dy[i] ==H-1:
                    break

    return not_visit[H-1][W-1]+1

if distance(0,0) != 0:
    print(c - distance(0,0))
else:
    print(-1)

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

using namespace std;

typedef long long ll;

const int K_MAX = 100002;

const int MOD = 1e9+7;

int pwr (int a, int b)
{
    if(b == 0)
        return 1;
    if(b & 1)
        return 1LL * a * pwr(a, (b ^ 1)) % MOD;
    int aux = pwr(a, (b >> 1));
    return 1LL * aux * aux % MOD;
}

int n, k;

int dp[K_MAX];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    int ans = 0;
    for(int i = k; i >= 1; i--)
    {
        dp[i] = pwr(k / i, n);
        for(int j = i * 2; j <= k; j += i)
        {
            dp[i] -= dp[j];
            if(dp[i] < 0)
                dp[i] += MOD;
        }
        ans = (ans + 1LL * dp[i] * i) % MOD;
    }
    cout << ans << "\n";
    return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  int num = 0;
  
  for (int i = A; i < B + 1; i++) {
    int m, th, t, o;
    m = i / 10000;
    th = (i % 10000) / 1000;
    t = (i % 100) / 10;
    o = i % 10;
    if (m == o && th == t) {
      num++;
    }  
  }
  cout << num << endl;
}

Measured memory_bytes: 256
import numpy as np
x, y, a, b, c = map(int,input().split())
p = np.array(input().split(),dtype=int)
q = np.array(input().split(),dtype=int)
r = np.array(input().split(),dtype=int)
p = np.sort(p)[::-1]
q = np.sort(q)[::-1]
ans = 0
kouho = []

for i in range(x):
    kouho.append(p[i])
for i in range(y):
    kouho.append(q[i])
for i in range(c):
    kouho.append(r[i])
kouho = sorted(kouho)[::-1]

for i in range(x+y):
    ans += kouho[i]

print(ans)


Measured memory_bytes: 30856
n = int(raw_input())
  
d = [0 for i in range(n)]
f = [0 for i in range(n)]
G = [0 for i in range(n)]
v = [[0 for i in range(n)] for j in range(n)]
st = [0 for i in range(n)]
tm = [0]
  
def DFS_visit(s):
  st[s] = 1
  tm[0] += 1
  d[s] = tm[0]
  for e in range(n):
    if v[s][e] == 1 and st[e] == 0:
      DFS_visit(e)
  st[s] == 2
  tm[0] += 1
  f[s] = tm[0]
  
def DFS():
  for s in range(n):
    if st[s] == 0:
      DFS_visit(s)
  for s in range(n):
     print'{0} {1} {2}'.format(s+1, d[s], f[s])
      
for i in range(n):
  G = map(int, raw_input().split())
  for j in range(G[1]):
    v[G[0]-1][G[2+j]-1] = 1
  
DFS()

Measured memory_bytes: 6508
#include "bits/stdc++.h"
#include "sstream"
#define EPS 1e-9
using namespace std;
const int N=1e5,OO=0x3f3f3f3f;
typedef long long ll;
int arr[N],dp[N],n,k;
int solve(int idx){
    if(idx==n-1)
        return 0;
    int &ret=dp[idx];
    if(~ret)
        return ret;
    ret=OO;
   for(int i=1;idx+i<n&&i<=k;i++)
       ret=min(ret,solve(i+idx)+abs(arr[idx]-arr[i+idx]));

    return ret;
}
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>arr[i];
    memset(dp,-1, sizeof(dp));
    cout<<solve(0);
}


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

# In[2]:


import collections


# In[11]:


N = int(input())
S = input()


# In[13]:


ans = 1
for tmp in collections.Counter(S).items():
    x = tmp[1]+1
    ans *= x
print((ans-1)%(10**9+7))


# In[ ]:






Measured memory_bytes: 9464
#include <stdio.h>

int main(void){
	int h[2],m[2],s[2],t,g,i,j;
	for(t=0;t<3;t++){
		i=0;j=0;
		scanf("%d %d %d %d %d %d",&h[0],&m[0],&s[0],&h[1],&m[1],&s[1]);
		g=3600*(h[1]-h[0])+60*(m[1]-m[0])+s[1]-s[0];
		while(g>=3600){
			g-=3600;
			i++;
		}
		while(g>=60){
			g-=60;
			j++;
		}
		printf("%d %d %d\n",i,j,g);
	}
	return 0;
}

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


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

    if(b-a+1 > 2*k){
        for (int i = 0; i < k; i++){
            cout << a+i << endl;
        }
        for (int i = k-1; i >= 0; i--){
            cout << b-i << endl;
        }
    }else{
        for (int i = a; i < b+1; i++){
            cout << i << endl;
        }
    }


    return 0;
}


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

using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<int> w(n);
  for(int i=0;i<n;i++){
    cin >> w[i];
  }
  
  int ans=1e9;
  for(int i=0;i<n-1;i++){
    int s1=0,s2=0;
    for(int j=0;j<n;j++){
      if(j<=i) s1+=w[j];
      else s2+=w[j];
    }
    ans = min(ans,abs(s1-s2));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
program sequence_sum
  implicit none
  integer(8) :: n, num, tmp, a(0:100000) = 0
  integer :: x, m, b(0:100000) = 0, period, offset, rem, i
  read(*,*) n, x, m
  tmp = m
  if (n <= 200000_8) then
    num = x
    rem = int(n)
    do i = 2, rem
      x = mod(int(x, 8) * x, tmp)
      if (x == 0) exit
      num = num + x
    end do
    write(*,'(i0)') num
    stop
  end if
  a(1) = x
  b(x) = 1
  do i = 2, m + 1
    x = int(mod(int(x, 8) * x, tmp))
    a(i) = a(i - 1) + x
    if (b(x) > 0) then
      offset = b(x) - 1
      period = i - offset - 1
      exit
    end if
    b(x) = i
  end do
  num = (n - offset) / period
  rem = int(n - offset - num * period)
  write(*,'(i0)') (a(offset + period) - a(offset)) * num + a(offset + rem)
end program sequence_sum

Measured memory_bytes: 3400
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  int n;
  string w[40];
  int lengths[] = {5, 7, 5, 7, 7};
 
  while(cin >> n, n) {
    for(int i = 0; i < n; i++) {
      cin >> w[i];
    }
    for(int i = 4; i < n; i++) {
      int beforreadidx = 4, len = 0;
      for(int j = i; j >= 0; j--) {
        len += w[j].length();
        if(lengths[beforreadidx] == len) {
          len = 0;
          beforreadidx--;
          if(beforreadidx == -1) {
            cout << j + 1 << endl;
            break;
          }
        }
      }
      if(beforreadidx == -1) break;
    }
  }
  return(0);
 
}

Measured memory_bytes: 3116
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	S := ReadString()
	cnt := 0
	for i, c := range S {
		if i%2 == 0 {
			if c == '1' {
				cnt++
			}
		} else {
			if c == '0' {
				cnt++
			}
		}
	}
	cnt2 := len(S) - cnt
	if cnt < cnt2 {
		fmt.Println(cnt)
	} else {
		fmt.Println(cnt2)
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};


int tab[1007][1007];
int h, w, a, b;

bool check(int r, int c){
	for(int i = 1; i <= h; i++ ){
		int num1 = 0, num0 = 0;
		for(int j = 1; j <= w; j++){
			if(tab[i][j] == 1) num1++;
			else num0++;
		}
		if(min(num1,num0) != r)
			return false;
	}
	
	
	for(int i = 1; i <= w; i++ ){
		int num1 = 0, num0 = 0;
		for(int j = 1; j <= h; j++){
			if(tab[j][i] == 1) num1++;
			else num0++;
		}
		if(min(num1,num0) != c)
			return false;
	}
	
	return true;
}

int main(){
	clr(tab,0);
	
	cin>> h >> w >> a >> b;
	for(int i = 1; i <= b; i++ ){
		for(int j = 1; j <= a; j++){
			tab[i][j] = 1;
		}
	}
	

	
	for(int i = b+1; i <= h; i++ ){
		for(int j = a+1; j <= w; j++){
			tab[i][j] = 1;
		}
	}
	
	if(check(a,b)){
		for(int i = 1; i <= h; i++ ){
			for(int j = 1; j <= w; j++){
				cout<<tab[i][j];
			}
			cout<<endl;
		}
	}
	else
		cout<<-1;
	return 0;
}


Measured memory_bytes: 5248
#include<stdio.h>

int main(){
int i=0;
char s[100001];
scanf("%s",s);
int a[30]={0};
while(s[i]!=0){
a[s[i]-'a']++;
i++;
}
for(i=0;i<26;i++){
if(a[i]==0){
printf("%c\n",'a'+i);
return 0;
}
}
if(i==26)puts("None");
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
string S;
bool n, s, e, w;
int main() {
	cin >> S;
	for (char c : S) {
		if (c == 'N')n = true;
		if (c == 'S')s = true;
		if (c == 'E')e = true;
		if (c == 'W')w = true;
	}
	if (n == s && e == w)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string s;
  cin >> n >> s;
  int ans = n;
  for(int i = 0;i<n-1;i++){
    if(s[i]==s[i+1]) ans--;
  }
  cout << ans;
  return 0;

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	cout << 1000 * (n / 500) + 5 * ((n % 500) / 5) << endl;
}

Measured memory_bytes: 256
def resolve():
  A, B, C, K = map(int, input().split(" "))

  if A >= K:
    print(K)
    return True

  result = 0
  K = K - A
  result = A

  if B >= K:
    print(result)
    return True

  K = K - B

  print(result - K)

if __name__ == "__main__":
    resolve()

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

using namespace std;


int main(void)
{
	int n,t;
	bool flag = true;
	cin >> n;
	vector<int> h(n);
	for(int i=0;i<n;i++){
		cin >> h[i];
	} 
	for(int i = n-1; i > 0; i--) {
		t = h[i-1]-h[i];
		if(t <= 0) continue;
		else if(t == 1) h[i-1]--;	
       		else flag = false;
 	}


	if(flag) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

bool p(string s) {
    string s2 = s;
    reverse(s2.begin(), s2.end());
    return s == s2;
}

int main() {
    cin.sync_with_stdio(0); cin.tie(0);

    string s;
    cin >> s;

    int n = s.length();
    string s1 = s.substr(0, n / 2);
    string s2 = s.substr(n / 2 + 1);

    if (p(s) && p(s1) && p(s2)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import bisect

n = int(input())
l = list(map(int,input().split()))
l.sort()
ans = 0

for i in range(n-2):
    for j in range(i+1,n-1):
        ind = bisect.bisect_left(l,l[i]+l[j])
        ans += ind-j-1

print(ans)

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for(int i =1; ; i++) {
            int x = sc.nextInt();
             if(x != 0)
                 System.out.printf("Case %d: %d\n", i, x);
             else
                 break;
        }
    }
}


Measured memory_bytes: 65468
#include<bits/stdc++.h>
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 ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

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

int main() {
    int n;cin >> n;
    vi a(n);
    rep(i,n)cin >> a[i];

    rep(i,n){
        if(a[i] % 2 == 0){
            if(a[i] % 3 == 0 || a[i] % 5 == 0){

            }else{
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}


Measured memory_bytes: 256
import std.algorithm,
       std.string,
       std.array,
       std.range,
       std.stdio,
       std.conv;

void main() {
  int[] nm = readln.chomp.split.to!(int[]);
  int n = nm[0],
      m = nm[1];
  int[][] routes;
  routes.length = n + 1;

  foreach (i; m.iota) {
    int[] ab = readln.chomp.split.to!(int[]);
    int ta = ab[0],
        tb = ab[1];

    routes[tb] ~= ta;
  }

  bool flag;


  foreach (route1; routes[n]) {
    foreach (route; routes[route1]) {
      if (route == 1) {
        flag = true;
        break;
      }
    }
    if (flag) break;
  }

  writeln(flag ? "POSSIBLE" : "IMPOSSIBLE");
}


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

using namespace std;

typedef long long ll;

int n, ma, mb;
int dp[512][512];

int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);

  memset(dp, -1, sizeof dp);

  cin >> n >> ma >> mb;

  for(int i = 0; i < n; ++i) {
    int a, b, c;
    cin >> a >> b >> c;

    for(int x = 400-a; x >= 0; --x)
      for(int y = 400-b; y >= 0; --y)
        if(dp[x][y] != -1) {
          if(dp[x+a][y+b] == -1)
            dp[x+a][y+b] = dp[x][y]+c;
          else
            dp[x+a][y+b] = min(dp[x+a][y+b], dp[x][y]+c);
        }

    if(dp[a][b] == -1)
      dp[a][b] = c;
    else
      dp[a][b] = min(c, dp[a][b]);
  }

  int a = ma;
  int b = mb;
  int inf = 1000 * 1000 * 1000;
  int ans = inf;
  while(ma <= 400 && 400 >= mb) {
    ans = dp[ma][mb] != -1 ? min(ans, dp[ma][mb]) : ans;
    ma += a;
    mb += b;
  }

  cout << (ans == inf ? -1 : ans);
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
// #define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FORE(x,c) for(auto &x:c)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define REP(v,n) FOR(v,0,n)
#define RREP(v,n) for(int v=((int)(n)-1);v>=0;v--)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
const int DX[9]={0,1,0,-1,1,1,-1,-1,0}, DY[9]={-1,0,1,0,-1,1,1,-1,0};
const int INF=1e9; const long long INFLL=1e18;
template<class T> ostream& operator << (ostream &os, const vector<T> &v) {
    ITR(i,v) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is, vector<T> &v) {
    ITR(i,v) is>>*i; return is; }
//------------------------------------------------------------------------------

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
    void unite(int x, int y) {
	    x = root(x); y = root(y);
        if(x != y) {
            if(data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
	}
	bool same(int x, int y) {
	    return root(x) == root(y);
    }
	int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};
signed main() {
    int n,q;
    cin>>n>>q;
    UnionFind uf(n);
    REP(i,q) {
        int com,x,y;
        cin>>com>>x>>y;
        if(com==0) uf.unite(x,y);
        else {
            cout<<uf.same(x,y)<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3152
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

ll dp[3010][3010];

void solve() {
  string s, t;
  cin >> s >> t;

  rep (i, 3010) rep (j, 3010) dp[i][j] = 0;

  rep (i, s.size()) rep (j, t.size()) {
    dp[i+1][j+1] = max(dp[i+1][j],  dp[i][j+1]);
    if (s[i] == t[j]) dp[i+1][j+1] = max(dp[i+1][j+1],  dp[i][j]+1);
  }

  ll i = s.size();
  ll j = t.size();

  vector<char> ans;

  while (i != 0 and j != 0) {
    if (dp[i][j] ==  dp[i-1][j]) i--;
    else if (dp[i][j] ==  dp[i][j-1]) j--;
    else {
      i--;
      j--;
      ans.push_back(s[i]);
    }
  }

  reverse(ans.begin(), ans.end());
  for (auto it: ans) cout << it;
  cout << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}


Measured memory_bytes: 71168
#include <stdio.h>
#include <string.h> // strcmp(s1, s2) -> membandingkan apakah s1 sama dengan s2

// subgoals
// 1. scan semua input
// 2. cari jumlah AC, WA, TLE, RE

int main() {
  int N, AC = 0, WA = 0, TLE = 0, RE = 0;
  scanf("%d", &N);

  for(int i = 0; i < N; i++) {
    char str[10];
    scanf("%s", str);

    if(strcmp(str, "AC") == 0) { // "AC" - "AC" = 0
      AC++;
    } else if(strcmp(str, "WA") == 0) { // apakah str itu WA
      WA++;
    } else if(strcmp(str, "TLE") == 0) { // apakah str itu TLE 
      TLE++;
    } else if(strcmp(str, "RE") == 0) { // apakah str itu RE
      RE++;
    }
  }

  printf("AC x %d\n", AC);
  printf("WA x %d\n", WA);
  printf("TLE x %d\n", TLE);
  printf("RE x %d\n", RE);

  return 0;
}

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

int main() {
  long long j;
  string S;
  j=-1;
  cin >>S;
  vector<char>a(10);
  for(int i=0;i<10;i++){
    a[i]='a';
  }
  for(int i=0;i<S.size();i++){
   if(S[i]=='B'){
     if(j==-1){
       continue;
     }
     else{
       a[j]='a';
       j--;
      }
   }
      else if(S[i]=='1'){
        a[j+1]='1';
        j++;
      }
      else{
        a[j+1]='0';
        j++;
      }
  }
    for(int i=0;i<10;i++){
    if(a[i]=='a'){
      break;
    }
      else{
        cout<<a[i];
  }
    }
  cout<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int X;
	cin >> X;
	vector<bool>V(X+1);
	V[1] = true;
	for (int i = 2; i <= X; ++i) {
		int b= i * i;
		while (b <= X) {
			V[b] = true;
			b *= i;
		}
	}
	for (int i = X; i >= 1; i--) {
		if (V[i]) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CBugged solver = new CBugged();
        solver.solve(1, in, out);
        out.close();
    }

    static class CBugged {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] s = new int[n];
            for (int i = 0; i < n; i++) {
                s[i] = in.nextInt();
            }

            BigInteger possible = BigInteger.ONE;
            for (int x : s) {
                possible = possible.or(possible.shiftLeft(x));
            }

            for (int i = possible.bitLength(); i >= 0; i--) {
                if (i % 10 != 0 && possible.testBit(i)) {
                    out.println(i);
                    return;
                }
            }

            out.println(0);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 23380
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;

typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18
// cout << fixed << setprecision(10);

int main() {
    int N; cin >> N;
    ullong B = 1;
    double D = 1.0 / 1e18;
    bool over = false;

    for (int i=0; i<N; i++) {
        ullong A; cin >> A;
        if (A == 0) {
            cout << 0 << endl;
            return 0;
        }

        D *= A;
        // > 1.0だと間違えてフラグが立つケースが生じるので > 1.1として粗く判定.
        // 1.0は1e18  1.1は1.1e18
        //if (D > 1.1) over = true;
        if (D > 2.0) over = true;

        // 浮動少数の結果が2e18を超えていないなら計算.
        // e20とかならB*Aが正しく計算できないからまずはe18オーダーに収まっているかを浮動少数で確認
        if (!over) B *= A;
        if (B > static_cast<ullong>(1e18)) over = true;
    }
    if (over) cout << -1 << endl;
    else cout << B << endl;
}

Measured memory_bytes: 3596
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int comb(int n, int m) {
  for (int i = 0; i < 20; ++i) {
    int u = (n >> i) & 1;
    int v = (m >> i) & 1;
    if (v > u) return 0;
  }
  return 1;
}

int solve(const vector<int>& a) {
  int n = a.size();
  int ret = 0;
  for (int i = 0; i < n; ++i) {
    if (comb(n - 1, i)) ret = (ret + a[i]) % 2;
  }
  return ret;
}

const int N = 1e6 + 10;
char s[N];

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  bool found = false;
  scanf("%s", s);
  for (int i = 0; i < n; ++i) {
    a[i] = s[i] - '0';
    if (a[i] % 2 == 0) found = true;
  }
  if (!found) {
    for (int i = 0; i < n; ++i) a[i] = (a[i] + 1) / 2;
    int ret = solve(a);
    printf("%d\n", ret * 2);
  } else {
    int ret = solve(a);
    printf("%d\n", ret);
  }
  return 0;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  int r = 0,l = 0;
  for(int i = 0;i<S.size();i++){
    if(S.at(i) == 'R' && S.at(i+1) == 'R'){
      cout << 0 << " ";
      r++;
    }
    else if(S.at(i) == 'R' && S.at(i+1) == 'L'){
      r++;
      while( i<S.size()-1 && S.at(i+1) == 'L'){
        l++;
        i++;
      }
      cout << l/2+r-r/2 << " " << r/2+l-l/2 << " ";
      for(int k = 0;k<l-1;k++){
        cout << 0 << " ";
      }
      r = 0;
      l = 0;
    }
  }
  return 0;
}


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())

signed main(){

	lli n;
	cin>>n;

	lli data[100010];
	vector<lli> a(n);
	REP(i,0,n){
		cin>>data[i];
		a[i] = data[i];
	}
	sort(data,data+n);

	lli cnt=0;

	REP(i,0,n){
		lli num = a[i];
		lli index = abs((lli)(lower_bound(data,data+n,num)-data) - i);
		if(abs(index)%2==1)cnt++;
	}
	cout<<cnt/2<<endl;

	return 0;
}

Measured memory_bytes: 1792
import math

K= int(input())

gcd = [[0 for j in range(K+1)]for i in range(K+1)]

for i in range(K+1):
    for j in range(K+1):
        gcd[i][j] = math.gcd(i,j) 

ans = 0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            ans += gcd[gcd[a][b]][c]
print(ans)

Measured memory_bytes: 9476
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define ll long long
using namespace std;
const int inf=1e9;
const int mod=1e9+7;
const int maxn=1e5+10;
int n,x;
int l[110];
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>n>>x;
	int k=0,ans=0;
	for(int i=1;i<=n;i++){
		if(k<=x) ans++;
		cin>>l[i];
		k+=l[i];
	}
	if(k<=x) ans++;
	cout<<ans;
	return 0;
}

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

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define mp make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define MOD 1000000007


ll a[6];
int main(){
  ll n;
  cin >> n;
  for(int i = 0; i < 5; i++){
    cin >> a[i];
  }
  sort(a,a+5);
  ll p = n/a[0];
  if(p == 0){
    cout << 5 <<endl;
    return 0;
  }
  else if(p*a[0]<n){
    p+=1;
  }
  cout << p + 4 <<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59

ll n,k;
ll M;
vector<ll> a;

bool ok(ll s){
    ll i;
    vector<ll> b(n);
    for(i=0;i<n;i++){
        b[i]=a[i]%s;
    }
    sort(b.begin(),b.end());
    reverse(b.begin(),b.end());
    ll t=0;
    for(i=0;i<n;i++) t+=b[i];
    ll sum=t;
    sum/=s;
    for(i=0;i<sum;i++){
        t-=b[i];
        t+=s-b[i];
    }
    if(t/2<=k) return 1;
    else return 0;

}

int main(){
   ll i,j;
   cin>>n>>k;
   a=vector<ll>(n);
   for(i=0;i<n;i++) cin>>a[i];

   M=0;
   for(i=0;i<n;i++) M+=a[i];

   ll ans=1;
   for(i=1;i*i<=M;i++){
       if(M%i==0){
           if(ok(i)) ans=max(ans,i);
           if(ok(M/i)) ans=max(ans,M/i);
       }
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll asd[50][4];
ll n,m,q;
ll ans = 0;
void dfs(vector<ll> v)
{
	if(v.size()==n)
	{
		ll A = 0;
		for(ll i = 0;i<q;i++)
		{
			if(v[asd[i][1]]-v[asd[i][0]]==asd[i][2])
			{
				A+=asd[i][3];
			}
		}
		ans = max(ans,A);
		return;
	}
	for(ll i = v.back();i<=m;i++)
	{
		auto nex = v;
		nex.push_back(i);
		dfs(nex);
	}
}


int main()
{
	cin >> n >> m >> q;
	for(ll i = 0;i<q;i++)
	{
		cin >> asd[i][0] >> asd[i][1] 
		>> asd[i][2] >> asd[i][3];
		asd[i][0]--;
		asd[i][1]--;
		//cout<<i<<endl;
	}
	for(ll i = 1;i<=m;i++)
	{
		vector<ll> a ={i};
		dfs(a);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N;
  cin >> N;
  vector<string> s(N);
  for (int i=0; i<N; i++) cin >> s[i];
  int AB_num = 0, c1 = 0, c2 = 0, c3 = 0;
  for (int i=0; i<N; i++) {
    for (int j=0; j<s[i].size()-1; j++) {
      if (s[i][j]=='A'&&s[i][j+1]=='B') AB_num++;
    }
    if (s[i][0]=='B'&&s[i][s[i].size()-1]=='A') c1++;
    else if (s[i][0]=='B') c2++;
    else if (s[i][s[i].size()-1]=='A') c3++;
  }
  int ans = AB_num;
  if (c1==0) ans += min(c2, c3);
  else if (c2+c3>0) ans += c1+min(c2, c3);
  else if (c2+c3==0) ans += c1-1;
  cout << ans << endl;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define ll long long
#define fin(x) scanf("%lld",&x)
#define fout(x) printf("%lld\n",x)
#define pll pair<ll,ll>
#define mp(x,y) make_pair(x,y)
#define cases int t;  scanf("%d",&t);   while(t--)
#define MOD 1000000007
#define MAXN 123456
#define read() freopen("lele.txt","r",stdin)
#define write() freopen("dede.txt","w",stdout)

using namespace std;

int main()
{
    ll n, mx = -1, mn = MOD;
    fin(n);
    ll ar[n];
    for(ll i = 0; i < n; i++)
    {
        fin(ar[i]);
        mx = max(mx, ar[i]);
        mn = min(mn, ar[i]);
    }
    ll mnk = 0, mxk = 0;
    ll ans = (mx - mn);
    fout(ans);
    return 0;
}


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

int main(void) {
  string S;
  cin >> S;
  int n = S.length();
  long long ans = 0;
  for (int i = 0; i < (1 << (n - 1)); i++) {
    long long tmp = S[0] - '0';
    for (int j = 1; j < n; j++) {
      if (i & (1 << (j - 1))) {
        ans += tmp;
        tmp = S[j] - '0';
      } else {
        tmp *= 10;
        tmp += S[j] - '0';
      }
    }
    ans += tmp;
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int a = n /1000;
		if( n % 1000 == 0) {
			a--;
		}
		System.out.println((a+1)*1000 - n);
	}
}


Measured memory_bytes: 27016
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {

    ll H, W;
    cin >> H >> W;
    vector<vector<ll>> c(10, vector<ll>(10));
    REP(i, 10)REP(j, 10) cin >> c[i][j];
    vector<vector<ll>> A(H, vector<ll>(W));
    REP(i, H) REP(j, W) cin >> A[i][j];
    REP(i, 10) REP(j, 10) REP(k, 10) c[j][k] = min(c[j][k], c[j][i] + c[i][k]);

    ll ans = 0;
    REP(i, H) REP(j, W) ans += A[i][j] == -1 ? 0 : c[A[i][j]][1];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=input()
c=0
for i in range(len(n)):
    c+=int(n[i])
if c%9==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 73284
object Main extends App {
  import scala.io.StdIn._

  val n = readInt
  val str = readLine.trim
  val q = readInt
  for (k ← readLine.trim.split(' ').map(_.toInt)){
    println(count(str, k))
  }
  def count(str: String, k: Int): Long = {
    def sub(current: Int, d: Long = 0, dm: Long = 0, m: Long = 0, result: Long = 0): Long = {
      if (current == str.length) result
      else{
        if (current < k) {
          if (str(current) == 'D') sub(current + 1, d + 1, dm, m, result)
          else if (str(current) == 'M') sub(current + 1, d, dm + d, m + 1, result)
          else if (str(current) == 'C') sub(current + 1, d, dm, m, result + dm)
          else sub(current + 1, d, dm, m, result)
        }else {
          val (nd, ndm, nm) = if (str(current - k) == 'D') (d - 1, dm - m, m) else if (str(current - k) == 'M') (d, dm, m - 1) else (d, dm, m)
          if (str(current) == 'D') sub(current + 1, nd + 1, ndm, nm, result)
          else if (str(current) == 'M') sub(current + 1, nd, ndm + nd, nm + 1, result)
          else if (str(current) == 'C') sub(current + 1, nd, ndm, nm, result + ndm)
          else sub(current + 1, nd, ndm, nm, result)
        }
      }
    }
    sub(0)
  }
  implicit class Scope[T](val value: T) extends AnyVal {
    @inline
    def also(@inline func: T ⇒ Unit): T = {
      func(value)
      value
    }
    @inline
    def let[A](@inline func: T ⇒ A): A = func(value)
  }
}

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

vector<char> Front;
vector<char> Back;

int main(){
    int Q;
    string S;
    cin >> S >> Q;
    for(int i = 0; i < S.length(); i++){
        Back.push_back(S[i]);
    }

    bool rev = false;
    for(int i = 0; i < Q; i++){
        int T;
        cin >> T;
        if (T == 1){
            if (rev) rev = false;
            else rev = true;
        }
        if (T == 2){
            int F;
            char c;
            cin >> F >> c;
            if ((!rev && F == 1) || (rev && F == 2)){
                Front.push_back(c);
            }
            else Back.push_back(c);
        }
    }
    if (!rev){
        for(int i = Front.size()-1; i >= 0; i--)cout << Front[i];
        for(int i = 0; i < Back.size(); i++)cout << Back[i];
    }
    else{
        for(int i = Back.size()-1; i >= 0; i--)cout << Back[i];
        for(int i = 0; i < Front.size(); i++)cout << Front[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1148
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <iomanip>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))
#define INF 1000000000
typedef long long ll;

int G[55];
vector<pair<int,int>> edge;

int u_root( int a, int u_array[]) {
    if (u_array[a] == a) return a;
    u_array[a] = u_root(u_array[a], u_array);
    return u_array[a];
}

void u_connect( int a, int b, int u_array[]){
    int pa = u_root(a, u_array);  // 第一引数aの親
    int pb = u_root(b, u_array);  // 第二引数bの親
    
    if (pa==pb) return;         // 親が同じであれば何もしない
    else u_array[pb] = pa;      // 親が異なっていればaの親に統一する
}

bool u_same( int a, int b, int u_array[]) {
    return u_root(a, u_array)==u_root(b, u_array);
}

int main() {
    int N, M;
    cin >> N >> M;
    
    rep(i,M){
        int u, v;
        cin >> u >> v;
        edge.push_back({u,v});
    }
    
    int cnt=0;
    rep(i,M){
        rep1(j,N) G[j] = j;
        rep(j,M){
            if(i==j) continue;
            u_connect(edge[j].first, edge[j].second, G);
        }
        rep1(i,N){
            if(!u_same(1,i,G)){
                cnt++;
                break;
            }
        }
    }
    cout1(cnt);
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Rev(a) reverse(a.begin(), a.end())
typedef long long ll;
const ll MOD = 1e9+7;

/*ll gcd(ll a, ll b){
  if(b==0) return a;
  return gcd(b, a%b);
}*/
/*ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}*/

/*ll lcm(ll a, ll b){
  ll g = gcd(a, b);
  b /= g;
  a *= b;
  return a;
}*/

/*int dfs(vector<int> &T, vector<int> &C, int i, int sum, int g, int count){
   
}*/

int main(){
  double r;
  cin >> r;
  const double PI=3.14159265358979323846;
  printf("%lf\n", 2*r*PI);


}



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

#define ll long long int
#define pb push_back
#define endl "\n"
ll input;
int main() {
    int t=1;
    // cin>>t;
    while(t--)
    {
        ll x,n;
        cin>>x>>n;
        set<ll> s;
        for(int i=0;i<n;i++)
        {
            cin>>input;
            s.insert(x-input);
        }
        // for(auto it:s)
        // cout<<it<<" ";
        for(int i=0;i<=50;i++)
        {
            if(s.find(i)==s.end())
            {
                cout<<x-i<<endl;
                break;
            }
            else if(s.find(-i)==s.end())
            {
                cout<<x+i<<endl;
                break;
            }
        }
        // cout<<"No\n";
    }
}


Measured memory_bytes: 3608
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] line = sc.nextLine().split(" ", 0);

		BigDecimal a = new BigDecimal(line[0]);
		BigDecimal b = new BigDecimal(line[1]).multiply(BigDecimal.valueOf(100));
		BigDecimal ans = a.multiply(b).divide(BigDecimal.valueOf(100));

		System.out.println(ans.setScale(0, RoundingMode.DOWN));
	}
}

Measured memory_bytes: 36104
def main():
    n = int(input())
    t = []
    x = []
    y = []

    for _ in range(n):
        ti, xi, yi = map(int, input().split())
        t.append(ti)
        x.append(xi)
        y.append(yi)
    
    if solve(n, t, x, y):
        print('Yes')
    else:
        print('No')

def solve(n, t, x, y):
    cur_t, cur_x, cur_y = 0, 0, 0

    for i in range(n):
        if t[i] % 2 != (x[i] + y[i]) % 2:
            return False
        
        if abs(x[i] - cur_x) + abs(y[i] - cur_y) > t[i] - cur_t:
            return False

    return True
        
main()


Measured memory_bytes: 11824
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;



struct UnionFind {
	vector<int> par;
	vector<int> rank;

	UnionFind(int n) : par(n), rank(n) { 
		for(int i = 1; i <= n; i++) {par[i] = i; rank[i] = 0;}
	}

	int find(int x) {if (par[x]==x) return x; else return par[x] = find(par[x]);}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x==y) return;

		if (rank[x]>rank[y]) par[y] = x;
		else {par[x] = y; if (rank[x]==rank[y]) rank[y]++;}
	}
	bool same(int x, int y) {return find(x)==find(y);}
};

int ans, N, M;
int p[100005];

int main(void) {
    scanf("%d %d", &N, &M);
    for (int i=1; i<=N; i++) scanf("%d", &p[i]);
    
    UnionFind uf(100005);
    
    for (int i=0; i<M; i++) {
        int x, y;
        scanf("%d %d", &x, &y);
        uf.unite(x, y);
    }

    for(int i=1; i<=N; i++) if (uf.same(i, p[i])) ans++;
    
   
    printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 1408
from collections import defaultdict
N, M = map(int, input().split())
city_road_nums = defaultdict(int)

for _ in range(M):
    a, b = map(int, input().split())
    city_road_nums[a] += 1
    city_road_nums[b] += 1

for i in range(1, N+1):
    print(city_road_nums[i])


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

int main(){
	ll n;
	cin >> n;
	ll left = 1, right = n;
	for(ll i=1;i*i<=n;i++) {
		if(n%i==0) {
			left = i;
			right = n/i;
		}
	}
	cout << left+right-2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <algorithm>
#include <string>
#include <iomanip>

using namespace std;

#define pi 3.141592653589
#define repeat(i,n) for(int i=0;i<n;i++)

int main()
{
	int i = 0, j;
	char ch[1200];

	while (1){

		scanf("%c", &ch[i]);

		if (ch[i] == '\n') break;

		if (isupper(ch[i])) ch[i] = tolower(ch[i]);
		else if (islower(ch[i])) ch[i] = toupper(ch[i]);
		else;
		i++;
	}

	for (j = 0; j < i; j++){

		cout << ch[j];
	}
	cout << "\n";
	return 0;
}

Measured memory_bytes: 1116
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int D=sc.nextInt();
		int N=sc.nextInt();
		int answer=0;
		if( N!=100) {
			answer=N*(int)Math.pow(100,D);
		}else {
			answer=101*(int)Math.pow(100, D);
		}
		System.out.println(""+answer);
	}
}

Measured memory_bytes: 22100
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("5");
            WillReturn.Add("1 4 3 5 2");
            //2
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("2");
            WillReturn.Add("1 2");
            //1
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("2");
            WillReturn.Add("2 1");
            //0
        }
        else if (InputPattern == "Input4") {
            WillReturn.Add("9");
            WillReturn.Add("1 2 4 9 5 8 7 3 6");
            //3
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] PArr = InputList[1].Split(' ').Select(X => int.Parse(X)).ToArray();

        int Answer = 0;
        for (int I = 0; I <= PArr.GetUpperBound(0); ) {
            if (PArr[I] != I + 1) {
                I++;
                continue;
            }

            Answer++;
            I += 2;
        }
        Console.WriteLine(Answer);
    }
}


Measured memory_bytes: 20064