akhauriyash/Code-Regression huggingface dataset:
#大きさがN*Mの庭がある. そこに雨が降り, 水溜りができた.
#水溜りは8近傍で隣接している場合に繋がっているとみなす.
#全部でいくつの水溜りがあるか.(8近傍とは, 次のWに対する*の部分を指す)
# ***
# *W*
# ***
#"W"は水溜りを, "."は水溜りでない所を表すとする
#1<=n,m<=100
n,m=map(int,input().split())
s = [list(input()) for i in range(n)]
def dfs(x,y):
    c=False
    s[x][y]='.'
    for i in range(0,2):
        for j in range(0,2):
            if i==1 and j==1:
                continue
            nx=i+x
            ny=j+y
            if 0<=nx<n and 0<=ny<m and s[nx][ny]=='#':
                #print(nx,ny)
                c=True
                dfs(nx,ny)
            if c:
                break
        if c:
            break
ans=0
for i in range(n):
    for j in range(m):
        if s[i][j]=='#':
            #print("------------")
            #print(i,j)
            dfs(i,j)
            ans+=1
            #print(s)
if ans<=1:
    print("Possible")
else:
    print("Impossible")

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
typedef long long ll;

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

	ll n;
	cin >> n;

	ll m = n + 1;
	for(int i = 0; i < 63; i++) {
		if((n >> i & 1) == 0) {
			m = 1LL << i;
			break;
		}
	}
	cout << m << endl;
}

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

int d[100], a[100];
map<vector<int>, int>id;
map<int, vector<int>>re;
int dp[100][5040];

int main() {
	int n; scanf("%d", &n);
	rep(i, n)scanf("%d", &d[i]);
	rep(i, n)scanf("%d", &a[i]);
	vector<int>v(7); iota(v.begin(), v.end(), 0);
	int p = 0;
	do {
		id[v] = p; re[p] = v;
		int cnt = 0, t = 0;
		for (int i : v) {
			rep(j, 7) {
				if ((t >> j & 1) && abs(j - i) <= d[j])cnt += a[j];
			}
			t |= 1 << i;
		}
		dp[0][p] = cnt;
		p++;
	} while (next_permutation(v.begin(), v.end()));
	int ans = 0;
	for (int i = 1; i + 6 < n; i++)rep(j, 5040) {
		vector<int>v = re[j];
		rep(k, 8) {
			vector<int>t = v;
			t.insert(t.begin() + k, 7);
			int cnt = 0, p = 0;
			for (int u : t) {
				if (u == 7) {
					rep(y, 8) {
						if ((p >> y & 1) && y + d[i - 1 + y] >= 7)
							cnt += a[i - 1 + y];
					}
				}
				if ((p >> 7 & 1) && 7 - d[i + 6] <= u)cnt += a[i + 6];
				p |= 1 << u;
			}
			vector<int>q(7); int o = 0;
			for (int c : t) {
				if (c)q[o++] = c - 1;
			}
			int v = id[q];
			dp[i][v] = max(dp[i][v], dp[i - 1][j] + cnt);
			ans = max(ans, dp[i][v]);
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 6396
class UnionFind:
    
    def __init__(self,n):
        self.par = [i for i in range(n)]
        self.size = [1] * n

    def unite(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.size[x] < self.size[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            
    
    def find(self,x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
        
    def same(self,x,y):
        return self.find(x) == self.find(y)

if __name__ == '__main__':
    N,M = map(int,input().split())
    e = []
    for i in range(M):
        A,B = map(int,input().split())
        A -= 1
        B -= 1
        e.append((A,B))
    uf = UnionFind(N)
    now = N*(N-1)//2
    ans = []
    ans.append(now)
    for i in range(M-1,0,-1):
        A = uf.find(e[i][0])
        B = uf.find(e[i][1])
        if A != B:
            now -= uf.size[A]*uf.size[B]
            uf.unite(A,B)
        ans.append(now)
    ans.reverse()
    for i in range(M):
        print(ans[i])
            


Measured memory_bytes: 23308
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,q;
    while( cin>>n>>q&&n&&q){
	int data[101]={};
        for(int i=1;i<=n;++i){
	    int n,x; cin>>n;
	    for(int j=1;j<=n;++j){
	        cin>>x;
	        data[x]++;
	    }
	}
	int ans=0,m=0;
	for(int i=1;i<=100;++i)
	    m=max(m,data[i]);
	if(q<=m)
	    for(int i=1;i<=100;++i)
		if(data[i]==m){
		    ans=i;
		    break;
		}
	cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 2988
def solve(incomes)
  avg = incomes.sum / incomes.size
  incomes.select {|n| n <= avg }.size
end

@line_count = 0
while (line = gets.chomp) != '0' do
  if @line_count % 2 == 1 then
    incomes = line.chomp.split(' ').map {|n| n.to_i }
    puts solve incomes
  end
  @line_count += 1
end


Measured memory_bytes: 7512
n = int(input())
s = input()
line = list(s)
x = 0
xmax = 0

for i in range(n):
    if line[i] == 'I':
        x += 1
        if xmax < x:
            xmax = x
    elif line[i] == 'D':
        x -= 1

print(xmax)


Measured memory_bytes: 2940
H, W, K = map(int, input().split())
S = [input() for _ in range(H)]
ans = 0
for h in range(2**H):
    h = bin(h)[2:].zfill(H)
    for w in range(2**W):
        w = bin(w)[2:].zfill(W)
        cnt = 0
        for i in range(H):
            if h[i] == '1': continue
            for j in range(W):
                if w[j] == '1': continue
                if S[i][j] == '#':
                    cnt += 1
        
        if cnt == K:
            ans += 1

print(ans)

Measured memory_bytes: 9048
#include <bits/stdc++.h>
using namespace std;
long long i,j,k,n,t;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>k;
    if(1+(k-1)*2 <=n)cout<<"YES\n";
    else
        cout<<"NO\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void drawFrame(int height, int width);

int main(void) {

    int height;
    int width;
    
    while(1) {
        scanf("%d %d", &height, &width);
        
        if(height == 0 && width == 0) {
            break;
        }
        
        drawFrame(height, width);

        printf("\n");
    }

    return 0;
}

void drawFrame(int height, int width) {

    int i;
    int j;

    for(i = 0; i < height; i++) {
        for(j = 0; j < width; j++) {
            if(i == 0 ||
               i == height - 1 ||
               j == 0 ||
               j == width - 1) {
                putchar('#');
            }
            else {
                putchar('.');
            }
        }
        printf("\n");
    }

    return;
}

Measured memory_bytes: 576
import sys
from collections import deque, defaultdict
import copy
import bisect
sys.setrecursionlimit(10 ** 9)
import math
import heapq
from itertools import product, permutations,combinations
import fractions

import sys
def input():
	return sys.stdin.readline().strip()

N, K = list(map(int, input().split()))
h = list(map(int, input().split()))

h.sort()

loc = bisect.bisect_left(h, K)

print(N - loc)

Measured memory_bytes: 76140
#include<stdio.h>
#define N 10000
#define M 500
main()
{
  int s[N],t[M],i,q,n,l=0,j;
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    
    scanf("%d",&s[i]);
    
  }
  scanf("%d",&q);
  
  for(i=0;i<q;i++){
    
    scanf("%d",&t[i]);
    for(j=0;j<n;j++){
      if(s[j]==t[i]){
	l++;
	break;
      }
  }
  }
 
  printf("%d\n",l);
  return 0;
}

Measured memory_bytes: 640
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   //setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  //sin, cos, tan

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

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

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

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

void Main()
{
  ll x; cin >> x; 
  ll ans = 0, rad = 0;
  while(1)
  {
    ans++;
    rad += x;
    if(rad % 360 == 0) fin(ans);
  }
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(4); //高精度少数表示
  Main();
  return 0;
}


Measured memory_bytes: 3528
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long int ll;

const int N=2e6+100;

struct p{
    int a,b;
    int id;
    int type;
}v[N];

bool comp(const p& A,const p& B){
    if(A.type!=B.type) return A.type<B.type;
    if(A.type==2){
        if(A.b!=B.b){
            return A.b<B.b;
        }else{
            return A.a>B.a;
        }
    }
    if(A.type==3){
        return A.a>B.a;
    }
    return A.type<B.type;
}

int main(){
    int n; cin >> n;
    vector<string> s(n);
    for(int i=0;i<n;i++){
        cin >> s[i];
        int a=0,b=0;
        for(char c:s[i]){
            if(c=='('){
                a++;
            }else{
                if(a>0)a--;
                else b++;
            }
        }
        v[i].id=i+1;
        v[i].a=a; v[i].b=b;
        if(a+b==0){
            v[i].type=0;
        }
        else if(a>0&&b==0){
            v[i].type=1;
        }
        else if(a>0&&b>0&&a-b>=0){
            v[i].type=2;
        }
        else if(a>0&&b>0){
            v[i].type=3;
        }
        else{
            v[i].type=4;
        }
    }
    sort(v,v+n,comp);
    int now=0;
    bool ok=1;
    for(int i=0;i<n;i++){
        if(now-v[i].b<0)ok=0;
        now-=v[i].b;
        now+=v[i].a;
    }
    if(now!=0)ok=0;
    if(!ok){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}



Measured memory_bytes: 3232
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define per(i, n, s) for (int i = (n-1); i >= (int)(s); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;
const double PI=acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	ll a; cin>>a;
	long double b; cin>>b;
	cout<<(ll)floor(a*b)<<endl;
}

Measured memory_bytes: 3732
import java.util.*;


public class Main {

    private static final int INF = Integer.MAX_VALUE;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long d = sc.nextLong();

        long lcm = lcm(c, d);
        
        long result = (b-a+1)-b/c+(a-1)/c-b/d+(a-1)/d+b/lcm-(a-1)/lcm;

        System.out.println(result);

    }

    //最大公約数
    private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }
    private static long lcm(long m, long n) {
        return m * n / gcd(m, n);
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n;
    cin>>n;
    if(__builtin_popcount(n)==1){
        puts("No");
        return 0;
    }
    cout<<"Yes"<<endl;
    cout<<3<<" "<<2<<endl;
    cout<<2<<" "<<1<<endl;
    cout<<1<<" "<<3+n<<endl;
    cout<<3+n<<" "<<2+n<<endl;
    cout<<2+n<<" "<<1+n<<endl;
    for(int i=4;i<n;i+=2){
        cout<<1<<" "<<i<<endl;
        cout<<i<<" "<<i+1<<endl;
        cout<<1<<" "<<n+i+1<<endl;
        cout<<n+i+1<<" "<<n+i<<endl;
    }
    if(n%2==0){
        int a,b;
        for(int i=30;i>=0;i--){
            if((n>>i)&1){
                a=(1<<i);
                b=n-a;
                break;
            }
        }
        cout<<a<<" "<<n<<endl;
        cout<<n+b+1<<" "<<n+n<<endl;
    }
    return 0;
}

Measured memory_bytes: 3652
import java.io.IOException;
import java.util.Scanner;

public class Main {

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

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int a = scanner.nextInt();
			if (a == 0)
				break;
			int[] map = new int[5];
			boolean[] b = new boolean[4];
			map[0] = a;
			b[a] = true;
			for (int i = 1; i < 5; i++) {
				map[i] = scanner.nextInt();
				b[map[i]] = true;
			}
			int sum = 0;
			for (int i = 1; i < 4; i++) {
				if (b[i])
					sum++;
			}
			if (sum == 3 || sum == 1)
				for (int i = 0; i < 5; i++)
					System.out.println(3);
			else if (!b[1]) {
				slove(map, 2);
			} else if (!b[2]) {
				slove(map, 3);
			} else {
				slove(map, 1);
			}
		}
	}

	private void slove(int[] map, int i) {
		for (int a : map)
			if (a == i)
				System.out.println(1);
			else
				System.out.println(2);
	}
}

Measured memory_bytes: 20788
#include<bits/stdc++.h>
using namespace std;
int main(){
 int x;
 cin >> x;
 int a, b, c;
 a = x / 3600;
 x -= 3600*a;
 b = x/60;
 c = x%60;
 cout << a << ':' << b << ':' << c << endl;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000


int main(){
	int x,y;
	cin>>x>>y;
	int a = abs(x),b=abs(y);
	
	int ans = 0;
	
	if(a>b){
		if(x>0){
			x*=-1;
			ans++;
		}
		ans += a-b;
		x+=a-b;
	}
	else if(a<b){
		if(x<0){
			x*=-1;
			ans++;
		}
		ans += b-a;
		x+=b-a;
	
	}
	
	if(x!=y)ans++;
	
	cout<<ans<<endl;
	
	
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vector<int>>
#define fin(ar,k,n) for(int i=k;i<n;i++) cin>>ar[i]
#define fout(ar,k,n) for(int i=k;i<n;i++) cout<<ar[i]<<' '
#define all(z) z.begin(),z.end()
#define mcc ((int)1e9+7)
#define mcf 998244353
#define mi map<int,int>
#define mem(a,n) memset(a,n,sizeof(a))
#define pii pair<int,int>
#define mp(a,b) make_pair(a,b)

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> fst;

const int N=3e3+4;
int dp[N][N];
string s,t;
stack<char> ans;

void solve()
{
    cin>>s;
	cin>>t;
	int n=s.length(),m=t.length();
	for(int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++)
		{
			if (s[i-1]==t[j-1]) dp[i][j]=1+dp[i-1][j-1];
			else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	int i=n,j=m;
	while (i!=0 && j!=0)
	{
		if (dp[i][j]==dp[i-1][j]) i--;
		else if (dp[i][j]==dp[i][j-1]) j--;
		else
		{
			ans.push(s[i-1]);
			i--; j--;
		}
	}
	while (!ans.empty())
	{
		cout<<ans.top();
		ans.pop();
	}
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast", "unroll-loops")
using namespace std;
#define ll long long
#define int ll
#define FOR(i,a,b) for (int i = (a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) for (int i=(n)-1; i>=0; i--)
#define f first
#define s second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define SQ(x) (x)*(x)
#define pii pair<int, int>
#define endl '\n'
//#define TOAD
#ifdef TOAD
#define bug(x) cerr<<__LINE__<<": "<<#x<<" is "<<x<<endl
#define IOS()
#else
#define bug(...)
#define IOS() ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#endif
const ll inf = 1ll<<60;
const int iinf=2147483647;
const ll mod = 1e9+7;
const ll maxn=5e3;
ll pw(ll x, ll p){
    ll ret=1;
    while (p>0){
        if (p&1){
            ret*=x;
            ret%=mod;
        }
        x*=x;
        x%=mod;
        p>>=1;
    }
    return ret;
}
ll inv(ll x){
    return pw(x, mod-2);
}
int vc[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
signed main(){
    IOS();
    int k; cin>>k;
    cout<<vc[k-1]<<endl;


}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
//Int mod = 998244353;
Int INF = 1e18;
double EPS = 0.00000001;

int main() {
    string s;
    Int k;
    cin >> s >> k;
    Int n = (Int)s.size();
    if (n == 1) {
        dump(k / 2);
        return 0;
    }
    Int res = 0;
    char a = s.front();
    Int b = 0;
    Int e = n - 1;
    if (s.front() == s.back()) {
        while (b < n && s[b] == a) b++;
        while (b >= 0 && s[e] == a) e--;
        if (b > e) {
            dump(n * k / 2);
            return 0;
        }
        // dump((k - 1) * ((b + (n - 1) - e) / 2));
        // dump(b / 2);
        // dump((n - 1 - e) / 2);
        res += (k - 1) * ((b + (n - 1 - e)) / 2) + (b / 2) + ((n - 1 - e) / 2);
        //dump(res);
    }  
    Int res2 = 0;
    Int cnt = 0;
    a = s[b];
    for (Int i = b; i <= e; i++) {
        if (a == s[i]) {
            cnt++;
            if (i == e) {
                res2 += cnt / 2;
            }
        }
        else {
            res2 += cnt / 2;
            cnt = 1;
            a = s[i];
        }
    }
    dump(res + res2 * k);
    return 0;
}


Measured memory_bytes: 256
import java.awt.*;
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int[][] arr = new int[h][w];
        Queue<Point> que = new ArrayDeque<>();

        for (int i = 0; i < h; i++) {
            String line = sc.next();
            for (int s = 0; s < w; s++) {
                if (line.charAt(s) == '#') {
                    que.add(new Point(s, i));
                    arr[i][s] = 1;
                }
            }
        }

        while (!que.isEmpty()) {
            Point p = que.poll();
            if (0 <= p.x - 1 && arr[p.y][p.x - 1] == 0) {
                arr[p.y][p.x - 1] = arr[p.y][p.x] + 1;
                que.add(new Point(p.x - 1, p.y));
            }
            if (p.x + 1 < w && arr[p.y][p.x + 1] == 0) {
                arr[p.y][p.x + 1] = arr[p.y][p.x] + 1;
                que.add(new Point(p.x + 1, p.y));
            }

            if (0 <= p.y - 1 && arr[p.y - 1][p.x] == 0) {
                arr[p.y - 1][p.x] = arr[p.y][p.x] + 1;
                que.add(new Point(p.x, p.y - 1));
            }
            if (p.y + 1 < h && arr[p.y + 1][p.x] == 0) {
                arr[p.y + 1][p.x] = arr[p.y][p.x] + 1;
                que.add(new Point(p.x, p.y + 1));
            }
        }

        int ans = 0;
        for (int[] a : arr) {
            for (int b : a) {
                ans = Math.max(ans, b);
            }
        }
        System.out.println(ans-1);
    }
}

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

using namespace std;

int n;
int val, old;

int status = 0;
bool f (int v, int o) {
    if (status == 0) {
        if (o < v)
            status = 1;
        else if (o > v)
            status = -1;
    }
    else if (status > 0) {
        if (o > v) {
            status = 0;
            return true;
        }
    }
    else {
        if (o < v) {
            status = 0;
            return true;
        }
    }
    return false;
}

int main () {
    cin >> n;
    int result = 1;
    for (int i = 0; i < n; ++i) {
        cin >> val;
        if (i == 0)
            old = val;

        if ( f (val, old) ) {
            result++;
        }

        old = val;
    }
    std::cout << result << std::endl;
}

Measured memory_bytes: 256
until (n = gets.to_i).zero?
  n.times.map {gets.split.map(&:to_i)}.each do |m, e, j|
    math_eng_av = (m + e) / 2.0
    three_av = (m + e + j) / 3.0
  
    klass = case
            when [m, e, j].include?(100) then :A
            when math_eng_av >= 90 then :A
            when three_av >= 80 then :A
            when three_av >= 70 then :B
            when three_av >= 50 && [m, e].max >= 80 then :B
            else :C
            end
    puts klass
  end
end


Measured memory_bytes: 6892
// 2012/12/10 Tazoe

#include <iostream>
using namespace std;

int main()
{
while(true){
	int T;
	cin >> T;

if(T==0)
break;

	int P[10];
	for(int i=0; i<9; i++){
		cin >> P[i];
	}

	P[9] = T;
	for(int i=0; i<9; i++){
		P[9] -= P[i];
	}

	cout << P[9] << '\n';
}

	return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

/**
 * Created by dezhonger on 2019/4/13
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        String s = scanner.next();
        int zero = 0;
        int left = 0;
        int res = 0;
        for (int right = 0; right < n; ++right) {
            if (s.charAt(right) == '0') {
                zero++;
                for (int j = right + 1; j < n && s.charAt(j) == '0'; j++) {
                    right = j;
                }
                while (zero > k) {
                    if (s.charAt(left) == '0') {
                        --zero;
                        for (int j = left; j < n && s.charAt(j) == '0'; j++) {
                            left = j;
                        }
                    }
                    left++;
                }

            }
            res = Math.max(res, right - left + 1);
        }
        System.out.println(res);
    }

}


Measured memory_bytes: 25940
def check_double_block(start, end, S):
    for i in range(start, end):
        if S[i] == "#" and S[i+1] == "#":
            return False
    return True

def main():
    N, A, B, C, D = list(map(int, input().split()))
    S = input()

    S = "#" + S + "#"

    if C < D:
        if not check_double_block(A, C, S) or not check_double_block(B, D, S):
            print("No")
        else:
            print("Yes")
    else:
        for i in range(B, D+1):
            if S[i-1] == "." and S[i] == "." and S[i+1] == ".":
                print("Yes")
                exit()
        print("No")


if __name__ == '__main__':
    main()

Measured memory_bytes: 3636
s = input()
n = len(s)
s = s + ' '
k = int(input())
l = []
for i in range(1, k+1):
    for j in range(n - i + 1):
        l.append(s[j:j + i])
ans = sorted(list(set(l)))[k - 1]
print(ans)


Measured memory_bytes: 5068
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll INF=1e18;
int main(){
  ll a;
  long double b;
  cin >>a>>b;
  
  cout<<ll(a*b)<<endl;
 
  
 

}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define print(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}

ll solve(ll N){
    ll ans = 0;
    return ans;
}

int main(){
    ll N,M; cin >> N >> M;
    map<ll,ll> ans;
    ll R = 0 , P = 0;
    rep(i,M){
        ll p; string S; cin >> p >> S;
        if(S == "AC" && ans[p] != -1) R++, P += ans[p], ans[p] = -1;
        if(S == "WA" && ans[p] != -1) ans[p]++;
    }
    cout << R << " " << P;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=1e9+7;
const ll inf=LONG_LONG_MAX;
const ll ms=(2e5)+5;




int main()
{
    idfc;
     ll n;
     cin>>n;
     map<ll,ll> mm;
     ll i,j,e;
     ll ans=0;
     for(i=1;i<=n;i++)
     {
         cin>>e;
         mm[e]+=1;
         ans+=e;
     }

     ll q;
     cin>>q;
     ll a,b;
     while(q--)
     {
         cin>>a>>b;
         e=mm[a];
         ans=(ans-(e*a));
         ans=(ans+(e*b));

         if(e)
         {
             mm.erase(a);
             mm[b]+=e;
         }
         cout<<ans<<"\n";
     }

    return 0;
}


Measured memory_bytes: 7780
N = input()
for i in range(2 ** (len(N) - 1)):
    s = ''
    for n in N:
        s += n
        if len(s) != len(N) + 3:
            if i % 2 != 0:
                s += '+'
            else:
                s += '-'
        else:
            break
        i //= 2
    if eval(s) == 7:
        print(s + '=7')
        break

Measured memory_bytes: 3060
# ABC132 E
from collections import deque

f=lambda:map(int,input().split())
N,M=f()
G=[[] for _ in [0]*(N+1)]

for _ in [0]*M:
    a,b=f()
    G[a].append(b)
S,T=f()
S=(S,0)
T=(T,0)

q=deque()
q.append(S)
F=set()
res=-1
while q:
    node,r=q.popleft()
    if (node,r%3) in F:
        continue
    if (node,r%3) == T:
        res=r//3
        break
    F.add((node,r%3))
    for next_node in G[node]:
        if (next_node,(r+1)%3) in F:
            continue
        q.append((next_node,r+1))
print(res)

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

int main(){
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  if(k <= a){
    cout << k << endl;
  }
  else if(k <= a + b){
    cout << a << endl;
  }
  else{
    cout << 2 * a + b - k << endl;
  }
}

Measured memory_bytes: 3636
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`


		`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	s := next()

	a := []int{}
	for i := 0; i < len(s)+1; i++ {
		a = append(a, -1)
	}

	// 最初
	if s[0] == '<' {
		a[0] = 0
		a[1] = 1
		for i := 1; i < len(s); i++ {
			if s[i] == '<' {
				a[i+1] = i + 1
			} else {
				break
			}
		}
	}
	// 最後
	if s[len(s)-1] == '>' {
		a[len(a)-1] = 0
		a[len(a)-2] = 1
		for i := 1; i < len(s); i++ {
			if s[len(s)-i-1] == '>' {
				a[len(s)-i-1] = i + 1
			} else {
				break
			}
		}
	}

	//途中
	for i := 0; i < len(s)-1; i++ {
		if s[i:i+2] == "><" {
			a[i+1] = 0
			//<-
			for j := 1; i-j+1 >= 0; j++ {
				if s[i-j+1] == '>' {
					if a[i-j+1] < j {
						a[i-j+1] = j
					}
				} else {
					break
				}
			}
			//->
			for j := 1; i+j < len(s); j++ {
				if s[i+j] == '<' {
					if a[i+j+1] < j {
						a[i+j+1] = j
					}
				} else {
					break
				}
			}
		}
	}

	ans := 0

	for i := 0; i < len(a); i++ {
		ans += a[i]
	}

	//fmt.Fprintln(out, "[DEBUG]", a)
	fmt.Fprintln(out, ans)
}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}


Measured memory_bytes: 16896
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a;


    cin>>a;

    if(a==1||a==2||a==3||a==4||a==5||a==6||a==7||a==8||a==9||a==10||a==12||a==14||a==15||a==16||a==18||a==20||a==21||
       a==24||a==25||a==27||a==28||a==32||a==34||a==36||a==40||a==42||a==35||a==45||a==48||a==54||a==56||a==63||a==64||a==72||a==81||a==49)
        cout<<"Yes";
    else
        cout<<"No";




//47-025
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
        #define int long long int
        #define pb push_back
        #define mk make_pair
        #define ft first
        #define sc second
        #define ppb pop_back
        #define sz size
        #define forn(i,a,n) for(i=a;i<n;i++)
        #define M 998244353 
        #define inf 2e18

        bool compare(pair<int,int> a,pair<int,int> b){
            if(a.first==b.first)
                return a.second<b.second;
            return a.first<b.first;
        }

        signed main() {
 
 
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        
        int x;
        cin>>x;
        map<int,int> mp;
        mp[0]=0;
        for(int i=1;i<=1e5+5;i++){

            int p = pow(i,5);
            if(mp.count(-p+x)){
                cout<<mp[-p+x]<<" "<<-i<<"\n";
                // cout<<-p+x<<" "<<p<<"\n";
                break;
            }
            if(mp.count(p-x)){
                cout<<i<<" "<<mp[p-x]<<"\n";
                break;
            }
            mp[p]=i;
        }


        return 0;
    }

Measured memory_bytes: 4092
import math
a, b, x = map(int,input().split())
ans = math.atan(2*b/a-2/a/a/a*x) * 180 / math.pi
ans2 = math.atan(a*b*b/x/2) * 180 / math.pi
if a*a*b < 2*x:
    print(ans)
else:
    print(ans2)

Measured memory_bytes: 62296
import java.util.Scanner;

public class Main {

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

		int arraySize = scan.nextInt();

		int inputArray[] = new int[arraySize+1];
		
		for(int i =1;i<=arraySize;i++) {
			inputArray[i] = scan.nextInt();
		}
		System.out.println(findMinCost(inputArray));
	}
	
	public static int findMinCost(int[]inputArray) {
		int size = inputArray.length;
		int dp[] = new int[size];
		dp[1] = 0; //if frog is at index 0th stone
		for(int i = 2;i<size;i++) {
			int option1 = Math.abs(inputArray[i]-inputArray[i-1])+dp[i-1];
			int option2 = (i==2) ? Integer.MAX_VALUE : Math.abs(inputArray[i]-inputArray[i-2])+dp[i-2];
			dp[i] = Math.min(option1,option2); 
		}
//		for(int i =0;i<size;i++) {
//			System.out.print(dp[i]+"  ");
//		}
		return dp[size-1];
	}
	
}

Measured memory_bytes: 49452
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    rep(i, n) cin >> a[i], a[i]--;

    vector<int> ql(q), qr(q), qi(q);
    rep(i, q) cin >> ql[i] >> qr[i], ql[i]--;
    iota(qi.begin(), qi.end(), 0);

    int width = sqrt(n);
    sort(qi.begin(), qi.end(), [&](int i, int j) {
        if (ql[i] / width != ql[j] / width) return ql[i] < ql[j];
        return qr[i] < qr[j];
    });

    vector<int> cnt(n), ans(q);
    int sum = 0;
    int l = 0, r = 0;

    auto add = [&](int i) { if (cnt[a[i]]++ == 0) sum++;};
    auto del = [&](int i) { if (--cnt[a[i]] == 0) --sum;};
    
    for (int i : qi) {
        while (ql[i] < l) add(--l);
        while (r < qr[i]) add(r++);
        while (l < ql[i]) del(l++);
        while (qr[i] < r) del(--r);
        ans[i] = sum;
    }
    
    rep(i, q) cout << ans[i] << endl;
}


Measured memory_bytes: 15480
import scala.annotation.tailrec
import scala.collection.mutable
import scala.io.StdIn._
object Main extends App {
  val Array(n, x) = readLine.trim.split(' ').map(_.toInt)
  val ls = readLine.trim.split(' ').map(_.toInt)
  println(
    ls.scan(0){(d, l) ⇒ d + l}.count(_ <= x)
  )
  implicit class Scope[T](val receiver: T) extends AnyVal {
    def let[A](@inline func: T ⇒ A): A = func(receiver)
    def tap(@inline func: T ⇒ Unit): T = {
      func(receiver)
      receiver
    }
  }
}


Measured memory_bytes: 25396
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  int S, W; std::cin >> S >> W;
  if(W >= S) fin("unsafe");
  fin("safe");
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>

using namespace std;

typedef long long lint;

int A[200010];

int main(int argc, char **argv)
{
    int N, T = 0;
    cin >> N;

    for (int i = 0;i < N; i++) {
        cin >> A[i];
        T ^= A[i];
    }

    for (int i = 0;i < N; i++)
        cout << (T ^ A[i]) << " ";
    cout << endl;

    return 0;
};


Measured memory_bytes: 4336
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val N = nextInt()
    val S = next()
    var ans = 0
    var x = 0
    for (c in S) {
        x += if (c == 'I') 1 else -1
        ans = Math.max(ans, x)
    }
    println(ans)
}

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

int main()
{
  int N, K; cin >> N >> K;
  int L[N]; rep(i,N) cin >> L[i];
  
  sort(L, L+N, greater<int>());
  
  int ans = 0;
  rep(i,K) ans += L[i];
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

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

int main() {
    ll N;   cin >> N;
    ll *T = new ll[N];
    for (ll i = 0; i < N; i++)
        cin >> T[i];

    ll ans = 1;
    for (ll i = 0; i < N; i++) {
        ll g = gcd(T[i], ans);
        ans = T[i] / g * ans;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int h,w,n;
vi x,y;

int dist(int a,int b,int c,int d)
{
    return abs(a-c)+abs(b-d);
}

template<typename T> class Dijkstra {
public:
	vector<T> d;
	int V;
	using pti = pair<T,int>;
	Dijkstra(int node_size){
		V = node_size;
	    d.resize(V,numeric_limits<T>::max());
	}
	void solve(){
		priority_queue<pti,vector<pti>,greater<pti> > que;
		rep(i,n){
            int dir = dist(x[i],y[i],0,0);
            d[i*1001+dir] = dir;
            // cout << i << " " << dir << " " << dir << "\n";
            que.push(pti(dir,i*1001+dir));
        }
		while(!que.empty()){
			pti p = que.top();
			que.pop();
			if(d[p.second] < p.first) continue;
            int v = p.second / 1001,cs = p.second % 1001;
			rep(i,n){
                int val = max(dist(x[v],y[v],x[i],y[i])-(cs+1),0);
                if(i != v && d[i*1001+val] > val+p.first){
                    d[i*1001+val] = val+p.first;
                    que.push(pti(d[i*1001+val],i*1001+val));
                }
            }
		}
	}
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> w >> h >> n;
    x.resize(n),y.resize(n);
    rep(i,n){
        cin >> x[i] >> y[i];
        --x[i],--y[i];
    }
    Dijkstra<int> dj(n*1001);
    dj.solve();
    int ans = INT_MAX;
    rep(i,n){
        rep(j,1001){
            if(dj.d[i*1001+j] != INT_MAX){
                cmn(ans,dj.d[i*1001+j]+max(dist(x[i],y[i],w-1,h-1)-j,0));
            }
        }
    }
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 3900
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
now = 100
res = 0
while True:
    res += 1
    now *= 1.01
    now = int(now)
    if now >= n:
        print(res)
        break

Measured memory_bytes: 10468
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define nl '\n'
#define print(vec,l,r) for(int i = (l); i < (r); i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (b)-1; i >= (a); i--)
#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];
#define debug(x) cerr << #x << " = " << (x) << endl;

using namespace std;

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

const ll MOD = 1e9 + 7;

void solve()
{
	int n;
	cin>>n;
	ll a[n];
	for(int i=0; i<n; i++)
		cin>>a[i];
	ll sum = 0;
	for(int i=0; i<n; i++)
		sum += a[i];
	ll sq = 0;
	for(int i=0; i<n; i++)
		sq += (a[i]*a[i])%MOD;
	sum %= MOD;
	sq %= MOD;
	ll answer = (sum*sum)%MOD - sq;
	if(answer < 0) answer += MOD;
	if(answer%2 == 1) answer += MOD;
	answer /= 2;
	cout<<answer%MOD<<nl;
}

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


Measured memory_bytes: 5200
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#include<functional>
#define int long long
#define mod(int)(1000000007)
using namespace std;
signed main() {
    int n, ans = 0; string s, t; cin >> s >> t;
    vector<vector<int>>test(26);
    for (int h = 0; h < s.size(); h++) {
        test[(int)(s[h]) - 97].push_back(h + 1);
    }
    int ima = 0;
    for (int h = 0; h < t.size(); h++) {
        int a = (int)(t[h]) - 97; 
        if (test[a].empty()) { cout << -1 << endl; return 0; }
        if (test[a][test[a].size() - 1] <= ima) { ans++; ima = 0; }
        int b = lower_bound(test[a].begin(), test[a].end(), ima + 1) - test[a].begin();
        ima = test[a][b];
    }
    cout << ans * s.size() + ima << endl;
	return 0;
}

Measured memory_bytes: 1724
#include<bits/stdc++.h>
using namespace std;
long long int INF=1e18;
int main(){
	long long int n,w,sum,ans;
  	cin>>n>>w;
  	sum=0;
  	ans=0;
  	long long int a[n],b[n];
  	for(long long int i=0;i<n;i++){
      	cin>>a[i]>>b[i];
      	sum+=b[i];
    }
  	long long int dp[n+1][sum+1];
  	for(long long int i=0;i<=n;i++){
      	for(long long int j=0;j<=sum;j++){
        	if(i==0 || j==0)
              	dp[i][j]=INF;
         	else if(b[i-1]>j)
              	dp[i][j]=dp[i-1][j];
         	else if(b[i-1]==j)
              	dp[i][j]=min(a[i-1],dp[i-1][j]);
          	else
              	dp[i][j]=min(a[i-1]+dp[i-1][j-b[i-1]],dp[i-1][j]);
         	if(dp[i][j]<=w)
              	ans=max(ans,j);
        }
    }
	cout<<ans;
}


Measured memory_bytes: 79104
#include<stdio.h>
#define SIZE 10000
int main(){
  int n,a[SIZE],i,sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    sum=sum+a[i]-1;
  }
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {

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

		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if((n|m)==0)break;
			int[] a = new int[m];
			int[] b = new int[m];
			int[] c = new int[n+1];
			int[] d = new int[n+1];
			for(int i=0;i<m;i++){
				a[i] = sc.nextInt();
				b[i] = sc.nextInt();
			}
			for(int i=0;i<m;i++){
				if(a[i]==1)c[b[i]]++;
				if(b[i]==1)c[a[i]]++;
			}
			
			for(int i=0;i<n+1;i++){
				if(c[i]>0){
					for(int j=0;j<m;j++){
						if(a[j]==i)d[b[j]]++;
						if(b[j]==i)d[a[j]]++;
					}
				}
			}

			int count=0;
			for(int i=0;i<n+1;i++){
				if(i!=1 && (c[i]>0 || d[i]>0))count++;
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 46620
h,w = map(int, input().split())
list_prob = []
list_prob.append((list("."*(w+2))))
for i in range(0,h):
    list_prob.append(list("." + str(input()) + "."))
list_prob.append(list("."*(w+2)))
def decis_num(i,j):
    decis_str = \
    list_prob[i-1][j-1] + list_prob[i-1][j] + list_prob[i-1][j+1] + \
    list_prob[i][j-1] + list_prob[i][j+1] + \
    list_prob[i+1][j-1] + list_prob[i+1][j] + list_prob[i+1][j+1]
    return decis_str.count("#")

for i in range(1,h+1):
    for j in range(1,w+1):
        if list_prob[i][j] == "#":
            continue
        else:
            list_prob[i][j] = str(decis_num(i,j))
list_ans = []
for row in list_prob:
    list_ans.append(row[1:w+1])
del list_ans[0]
del list_ans[-1]
for row in list_ans:
    print("".join(row))


Measured memory_bytes: 3188
import java.util.*;
public class Main
{
	public static void main(String[] args)
	{
	  Scanner s=new Scanner(System.in);
	  int n=s.nextInt();
	  int ac=0;
	  int wa=0;
	  int tle=0;
	  int re=0;
	  for(int i=0;i<n;i++)
	  {
	    String k=s.next();
	    if(k.equals("AC"))
	     ac++;
	    else if(k.equals("WA"))
		wa++;
	    else if(k.equals("TLE"))
		tle++;
	    else
		re++;
	  }
	  
		System.out.println("AC x "+ac);
		System.out.println("WA x "+wa);
		System.out.println("TLE x "+tle);
		System.out.println("RE x "+re);
	  
	
	}
}

Measured memory_bytes: 58312
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        int len = s.length;
        int Ccnt = 0;
        if(s[0] != 'A'){
            System.out.println("WA");
            return;
        }
        for(int i = 1; i < len; i++){
            if(i == 1 || i == len-1){
                if(s[i] == 'C'){
                    System.out.println("WA");
                    return;
                }
            }
            if(s[i] == 'C'){
                Ccnt++;    
            } else {
                String s1 = String.valueOf(s[i]);
                String s2 = String.valueOf(s[i]).toLowerCase();
                if(!s1.equals(s2)){
                    System.out.println("WA");
                    return;
                }
            }
        }
        if(Ccnt == 1){
            System.out.println("AC");
        }else{
            System.out.println("WA");
        }
        
    }
}

Measured memory_bytes: 23764
#include <inttypes.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    intmax_t R;
    long double ans = 0;

    scanf("%jd", &R);

    ans = 2 * R * 3.14159;

    printf("%Lf\n", ans);

    return 0;
}


Measured memory_bytes: 2212
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string a;
	cin >> a;
	int cnt = 0, cnt1 = 0;
	for (int i = 0; i < a.length(); i++)
	{
		if (a[i] == '-')
			cnt++;
		else
			cnt1++;
	}
	printf("%d\n", cnt1 - cnt);
}

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

using namespace std;

#define rep(i , n) for(int i=0 ; i<n ; i++)
#define rep1(i , n) for(int i=1 ; i<=n ; i++)

typedef long long int ll;


int main()
{
	ios_base :: sync_with_stdio(false);
	cin.tie(NULL);

	int k,x;

	cin >> k >> x;

	for(int i=x-(k-1) ; i<=x ; i++)
		cout << i << " ";
	for(int i=x+1 ; i<=x+(k-1) ; i++)
		cout << i << " ";
	return 0;
}

Measured memory_bytes: 256