akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int INF = 1000000007;

ll gcd(ll x, ll y){
	ll r=0;
	if(x < y) swap(x, y);
	while(y > 0){
		r = x % y;
		x = y;
		y = r;
	}

	return x;
}

ll lcm(ll x, ll y){
	ll res=0;
	res = x * (y / gcd(x, y));

	return res;
}

int main(){
	int n;
	cin>>n;
	ll t[110]={0};
	t[1] = 1;
	for(int i=0;i<n;i++) cin>>t[i];

	ll ans = lcm(t[0], t[1]);

	for(int i=2;i<n;i++){
		ans = lcm(ans, t[i]);
	}

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

Measured memory_bytes: 256
N, K = map(int, input().split())

if K == 0:
  print(N ** 2)
  exit()
  
ans = 0
for b in range(1, N+1):
  ans += int(N/b) * max(0, b-K)
  ans += max(0, N%b + (1-K))

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(ll i = (ll)j;i <= (ll)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define pb push_back

typedef long long ll;
typedef pair<ll,ll> pi;
const ll MAXN = (ll)2e5+7;
const ll INF = (ll)1e18+7;

ll n,d,dam;
pi mo[MAXN];
queue<pi> qu;

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

    cin >> n >> d >> dam;
    d = d*2+1;
    rep(i,1,n) {
        ll x,h;
        cin >> x >> h;
        mo[i] = make_pair(x,h);
    }
    sort(mo+1,mo+1+n);
    ll biao = 0,ci = 0;
    rep(i,1,n) {
        ll x = mo[i].first,h = mo[i].second;
        while (!qu.empty() && qu.front().first < x) {
            biao -= qu.front().second;
            qu.pop();
        }
        ll remi = h - biao;
        if (remi <= 0) continue;
        ll tmpci = (remi+dam-1)/dam;
        ci += tmpci;
        biao += tmpci*dam;
        qu.push(make_pair(x+d-1,tmpci*dam));
    }
    cout << ci << endl;
}




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

int main() {
    int N, X, m;
    cin >> N >> X;
    vector<int> ms(N, 0);
    for (int i = 0; i < N; i++) {
        cin >> m;
        ms.at(i) = m;
        X -= m;
    }
    sort(ms.begin(), ms.end());
    cout << N + X/ms[0] << endl;
}

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

int flags(int x){
    if(x==0) return 0;
    if(x==1) return 1;
    if(x%2==0) return flags(x/2);
    if(x%2==1) return 1+flags(x/2);
}
int main(){
    int n;
    cin >> n;
    int a[16];
    int x[16][16];
    int y[16][16];
    rp(i,n){
        cin >> a[i];
        rp(j,a[i]){
            cin >> x[i][j] >> y[i][j] ;
        }
    }
    int max=0;
    for(int i=0; i<(1<<n); i++){
        bool ok=true;
        rp(j,n){
            if((i>>(j-1))%2){
                for(int k=1; k<=a[j]; k++){
                    if((i>>(x[j][k]-1))%2!=y[j][k]){
                    ok=false;
                    break;
                    }
                }

            }
            if(!ok) break;
        }
        if(ok){
            if(max<flags(i)) max=flags(i);
        }
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
char c;
double xa,ya,xb,yb,xc,yc,xd,yd,ab,bc,cd,da,aa,bb,cc,dd;
while(cin>>xa){
cin>>c>>ya>>c>>xb>>c>>yb>>c>>xc>>c>>yc>>c>>xd>>c>>yd;
ab=(xb-xa)*(yc-ya)-(yb-ya)*(xc-xa);
bc=(xc-xb)*(yd-yb)-(yc-yb)*(xd-xb);
cd=(xd-xc)*(ya-yc)-(yd-yc)*(xa-xc);
da=(xa-xd)*(yb-yd)-(ya-yd)*(xb-xd);
if(ab*bc<0||bc*cd<0||cd*da<0||da*ab<0)cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}
return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <math.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = (ll)1 << 62;

bool B[100002] = {};
bool T[100002] = {};
int main() {
	ll n; cin >> n;
	string s; cin >> s;

	rep(i, 0, s.size()) {
		B[i] = (s[i] == 'o');
	}

	B[n] = B[0];
	B[n + 1] = B[1];

	rep(k, 0, 4) {
		if (k == 0) {
			T[0] = 1; T[1] = 1;
		}
		else if (k == 1) {
			T[0] = 1; T[1] = 0;
		}
		else if (k == 2) {
			T[0] = 0; T[1] = 1;
		}
		else if (k == 3) {
			T[0] = 0; T[1] = 0;
		}

		rep(i, 2, n + 2) {
			if (B[i - 1]) {
				if (T[i - 2] && T[i - 1]) T[i] = 1;
				else if (!T[i - 2] && T[i - 1]) T[i] = 0;
				else if (T[i - 2] && !T[i - 1]) T[i] = 0;
				else if (!T[i - 2] && !T[i - 1]) T[i] = 1;
			}
			else {
				if (T[i - 2] && T[i - 1]) T[i] = 0;
				else if (!T[i - 2] && T[i - 1]) T[i] = 1;
				else if (T[i - 2] && !T[i - 1]) T[i] = 1;
				else if (!T[i - 2] && !T[i - 1]) T[i] = 0;
			}
		}

		if (T[0] == T[n] && T[1] == T[n + 1]) {
			rep(i, 0, n) {
				cout << (T[i] ? 'S' : 'W');
			}
			cout << endl;
			return 0;
		}
	}

	cout << -1 << endl;
	return 0;
}

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

int main()
{
  int r, c;
  int sum = 0;
  int allsum = 0;
  int table[101][101];
  cin >> r >> c;
  for (int i = 0; i < 101; i++)
  {
    for (int k = 0; k < 101; k++)
    {
      table[i][k] = 0;
    }
  }
  for (int i = 0; i < r; i++)
  {
    for (int j = 0; j < c; j++)
    {
      cin >> table[i][j];
    }
  }
  for (int i = 0; i < r; i++)
  {
    for (int j = 0; j < c; j++)
    {
      sum += table[i][j];
      cout << table[i][j] << " ";
    }
    cout << sum;
    sum = 0;
    cout << endl;
  }
  for (int i = 0; i < c; i++)
  {
    for (int j = 0; j < r; j++)
    {
      sum += table[j][i];
    }
    cout << sum << " ";
    allsum += sum;
    sum = 0;
  }
  cout << allsum << endl;;
}


Measured memory_bytes: 3124
#include<stdio.h>
int main(void)
{
	int A,B,i;
	int k = 0,j = 0;
	//電源タップの口数(A)
	do{
		scanf("%d",&A);
	}while(A < 2||A > 20);
	//必要タップ数(B)
	do{
		scanf("%d",&B);
	}while(B < 1||B > 20);

	if(B==1)
		j = 0;
	else{
		for (i = 1; k < B; ++i)
		{
		k = (i*A) - (i-1);
		j++;
		}
	}
	printf("%d",j);

	return 0;
}

Measured memory_bytes: 128
x = []
for _ in range(5):
    x.append(int(input()))
t = 0
wt = []
for a in x:
    t += a
    m = a % 10
    if m > 0:
      wt.append(10-m)
if len(wt) > 1:
    wt.sort()
    wt.pop()
    for x in wt:
        t += x
print(t)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;
/*
const ll int nax = 1e18;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,k;
    for (int i = 0; i < 5; ++i)
    {
        cin>>a;
        if(a==0)k = i+1;
    }
    cout<<k;
    return 0;
}
*/
/*
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x,y;
    cin>>x>>y;
    if((2*x) < y && y < (4*x)){
        y = y - (2*x);
        if(y % 2 == 0){
            cout<<"Yes\n";
        }
        else{
            cout<<"No\n";
        }
    }
    else if(y == (2*x)){
        cout<<"Yes\n";
    }
    else if(y == (4*x)){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
    return 0;
}
*/


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x,n;
    cin>>x>>n;
    std::map<int, int> mp;
    int a;
    for (int i = 0; i < n; ++i)
    {
        cin>>a;
        mp[a]++;

    }
    int r = x , l = x;
    while (true)
    {
        if(mp[l] != 1){
            cout<<l;
            return 0;
        }
        else{
            l--;
        }
        if(mp[r] != 1){
            cout<<r;
            return 0;
        }
        else{
            r++;
        }
    }
    return 0;
}


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

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

    int n, idx;
    cin >> n;
    vector<int> x(n), y(n), h(n);
    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i] >> h[i];
        if(h[i] > 0) idx = i;
    }

    for(int cx = 0; cx <= 100; cx++){
        for(int cy = 0; cy <= 100; cy++){
            int H = h[idx] + abs(x[idx] - cx) + abs(y[idx] - cy);
            bool f = true;
            for(int i = 0; i < n; i++){
                int hi = max(H - abs(x[i] - cx) - abs(y[i] - cy), 0);
                if(hi == h[i]);
                else{f = false; break;}
            }
            if(f){
                cout << cx << ' ' << cy << ' ' << H << endl;
                return 0;
            }
        }
    }


    return 0;
}

Measured memory_bytes: 256
n = int(input())
S,H,C,D = [],[],[],[]
for i in range(n):
	a,b = input().split()
	if a == "S":
		S.append(int(b))
	elif a == "H":
		H.append(int(b))
	elif a == "C":
		C.append(int(b))
	else:
		D.append(int(b))
for s in range(13):
	if s+1 not in S:
		print("S",(s+1))
for h in range(13):
	if h+1 not in H:
		print("H",(h+1))
for c in range(13):
	if c+1 not in C:
		print("C",(c+1))
for d in range(13):
	if d+1 not in D:
		print("D",(d+1))


Measured memory_bytes: 5612
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: usize = read();
    let b: usize = read();
    let x: usize = read();

    if a <= x && x <= a + b {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<utility>
#include<cstring>
#include<string>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pll;
const int maxn=1e5+10;
const int mod =1e9+7;
const double EPS = 1e-6;
int a[maxn];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    for(int i=1;i<=n;i++)
        cin >> a[i];
        int flag=0;
    for(int i=1;i<=n;i++)
    {
        if(!(a[i]&1))
        {
            if(a[i]%3==0||a[i]%5==0)
                continue;
            else
            {
                flag=1;
                break;
            }
        }
    }
    if(!flag)
    {
        cout << "APPROVED" << endl;
    }
    else
        cout << "DENIED" << endl;
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define FS              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll              long long int
#define ld              long double
#define pb              push_back
#define bp              __builtin_popcount
#define sz              size()
#define ff              first
#define ss              second
#define vll             vector<ll>
#define vbool           vector<bool>
#define vpll            vector<pair<ll,ll>>
#define pll             pair<ll,ll>
#define vllv            vector<vector<ll>>
#define setpri(x)       cout<<setprecision(x)<<fixed;
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){return (n-1)/x+(n>0);}

ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

ll pow1(ll n,ll m ,ll mod=MOD );
ll pow2(ll n,ll k);

ll modinv(ll n,ll mod=MOD){  return pow1(n,mod-2,mod);}

bool func(pair<pair<string,ll>,ll> &a,pair<pair<string,ll>,ll> &b ){
        if(a.ff.ff != b.ff.ff)return a.ff.ff < b.ff.ff;
        return a.ff.ss > b.ff.ss;
}
ll const N=(ll)1e5+11;
ll const LG=(ll)log2(N)+1;


void solve(){
        ll i,j,k,l,n,m,x,y,z,r;
        
        cin>>n;
        vector<pair<pair<string,ll>,ll>> a(n);
        for(i=0;i<n;i++){
                cin>>a[i].ff.ff>>a[i].ff.ss;
                a[i].ss=i+1;
        }
        sort(all(a),func);
        for(i=0;i<n;i++){
                cout<<a[i].ss<<endl;
        }
        
        
        
        
        
}       
int main(){
        FS;
        
        ll i,j,k,n,m,x,y,z,q;
        q=1;
        // cin>>q;
        while(q--){
                solve();
        }
        return 0;
}


ll pow1(ll n,ll m,ll mod){
        if(m==0)return 1;
        
        if(m%2==0)return pow1((n*n)%mod,m/2,mod);
    	
    	return (pow1((n*n)%mod,m/2,mod)*n)%mod;
}

ll pow2(ll n,ll k){
        ll ans=1;
            while(k>0){
                if(k%2==1)ans=ans*n;
                n=n*n;
                k/=2;
            }
            return ans;
}

Measured memory_bytes: 3652
#include<iostream>
using namespace std;
int main(){
	int w,n,a,b,x[31][31];
	char ch;
	for(int i=0;i<31;i++){
		for(int j=0;j<31;j++){
		x[i][j]=j;
		}
	}
	cin>>w>>n;
	for(int i=1;i<=n;i++){
	cin>>a>>ch>>b;
	x[i][a]=b;
	x[i][b]=a;
	}
	for(int i=1;i<=w;i++){
		a=i;
		for(int j=n;j>=0;j--){
		a=x[j][a];
		}
		cout<<a<<endl;
	}

	return 0;
}


Measured memory_bytes: 3056
/*
                   _ooOoo_
                  o8888888o
                  88" . "88　AC!AC!
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rep3(var, min, max) for (ll (var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll (var) = (max) - 1; (var) + 1 > (min); --(var))
#define Mp(a,b) make_pair((a),(b))
#define F first
#define S second
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll MOD = 1e9 + 7;
int main(){
    ll s;cin>>s;
    ll v=1000000000;
    ll x=(v-s%v)%v;
	ll y=(s+x)/v;
	cout<<"0 0 1000000000 1 "<<x<<" "<<y<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(long long i = 0; i < n; i++)
#define REPR(i, n) for(long long i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(long long i = m; i <= n; i++)
#define FORR(i, m, n) for(long long i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
ll power(ll a,ll b){return b?power(a*a%2019,b/2)*(b%2?a:1)%2019:1;}


int main(){FIN


 
    string s; cin>>s;

    ll n=s.size();
    map<ll,ll> mp;
    ll count=0, dig=0;
    FORR(i,n-1,0){

        if(i==n-1) dig=s[i]-'0';
        else dig += power(10,count)*(s[i]-'0');

        mp[dig%2019]++;
        dig%=2019;
        count++;
    }

    mp[0]++;
    ll ans=0;
    for(auto p:mp){
        ll m = p.second;
        ans+=m*(m-1)/2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3744
# coding: utf-8
x, y = map(int, input().split())
if y < x < 0 or 0 < y < x:
    print(abs(x - y) + 2)
elif (y < x and x == 0) or (y == 0 and y < x):
    print(abs(x - y) + 1)
elif x <= y <= 0 or 0 <= x <= y:
    print(abs(x - y))
else:
    print(abs(abs(x) - abs(y)) + 1)

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

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 2e6+5;

int n;
int a[N];
int he,ta,tot;
int lst[N],nxt[N];
int pos[N],d[N];

bool check(int L){
	pos[tot=1]=a[1];
	ta=1;
	d[1]=0;
	pos[1]=lst[1]=nxt[1]=d[1]=0;
	fo(i,2,n){
		if (a[i]>a[i-1]){
			int x=++tot;
			pos[x]=lst[x]=nxt[x]=d[x]=0;
			d[x]=0;
			pos[x]=a[i];
			nxt[ta]=x;
			lst[x]=ta;
			ta=x;
		}
		else{
			while(ta&&pos[ta]>a[i])ta=lst[ta];
			nxt[ta]=0;
			if (pos[ta]!=a[i]){
				int x=++tot;
				pos[x]=lst[x]=nxt[x]=d[x]=0;
				d[x]=0;
				pos[x]=a[i];
				nxt[ta]=x;
				lst[x]=ta;
				ta=x;
			}
			int x=ta;
			d[x]++;
			for(;d[x]==L;){
				if (pos[x]==1)return 0;
				int y=lst[x];
				if (pos[y]!=pos[x]-1){
					int z=++tot;
					pos[z]=lst[z]=nxt[z]=d[z]=0;
					d[z]=0;
					pos[z]=pos[x]-1;
					lst[z]=y,nxt[z]=x;
					lst[x]=z,nxt[y]=z;
					y=z;
				}
				d[x]=0;
				d[y]++;
				x=y;
			}
		}
	}
	return 1;
}

int main(){
	n=get();
	fo(i,1,n)a[i]=get();
	bool pd=1;
	fo(i,2,n)pd&=(a[i]>a[i-1]);
	if (pd)return printf("1\n"),0;
	int l=2,r=n,ans=1;
	while(l<=r){
		int mid=(l+r)/2;
		if (check(mid))ans=mid,r=mid-1;
		else l=mid+1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 13440
#include<cstdio>

int main()
{
	int a, b, c, k;
	scanf("%d %d %d %d", &a, &b, &c, &k);
	
	while(b <= a and k--) b <<= 1;
	if(b <= a){
		printf("No\n");
		return 0;
	}
	while(c <= b and k--) c <<= 1;
	if(c <= b) printf("No\n");
	else printf("Yes\n");
}

Measured memory_bytes: 1664
/*
    Vishal Raj
    IIT Kharagpur
*/

#include <bits/stdc++.h>

using namespace std;

#define FOR(i,l,r) for( int (i) = (l); (i) < (r); (i)++ )
#define li long long int

int main() {
    li n, w; cin>>n>>w;
    li dp[2][w+5]; 
    memset(dp,0ll,sizeof(dp));
    FOR(i,0,n) {
        li u = i%2;
        li W, v; cin>>W>>v;
        FOR(j,0,w+1) {
            dp[u][j] = dp[1-u][j];
            if( j-W >= 0 ) dp[u][j] = max(dp[u][j],dp[1-u][j-W]+v);
        }
    }
    li ans = 0;
    FOR(j,0,w+1) ans = max(ans,dp[(n-1)%2][j]);
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
  int n,h,w; cin >> n >> h >> w;
  int ans = 0;
  for(int i = 0; i < n; ++i){
    int a,b; cin >> a >> b;
    ans += (a >= h && b >= w);
  }
  cout << ans << endl;
}

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

int main() {
  string s;
  cin >> s;
  if(s.at(0) == s.at(1) || s.at(0) == s.at(2) || s.at(1) == s.at(2)){
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

vector<vector<int>> to;
vector<int> dp;

int dfs(int v) {
    if (dp[v] != -1) return dp[v] + 1;
    dp[v] = 0;
    for (auto u : to[v]) chmax(dp[v], dfs(u));
    return dp[v] + 1;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, m;
    cin >> n >> m;
    to.resize(n);
    rep(i, m) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        to[x].pb(y);
    }
    dp.resize(n, -1);
    rep(i, n) if (dp[i] == -1) dfs(i);
    int ans = 0;
    rep(i, n) chmax(ans, dp[i]);
    cout << ans << endl;
}

Measured memory_bytes: 7552
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
int n,flag=1;string s;
int main(){
//	freopen("1.in","r",stdin);
//	freopen("1.out","w",stdout);
	in(n);cin>>s;if(n%2){
		printf("No\n");return 0;
	}
	for(int i=0;i<n/2;i++)
	if(s[i]!=s[i+n/2])flag=0;
	if(flag==0)printf("No\n");
	else printf("Yes\n");
	return 0;
}


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

using namespace std;


struct BinaryIndexedTree
{
  vector< int > data;

  BinaryIndexedTree(int sz)
  {
    data.assign(++sz, 0);
  }

  int sum(int k)
  {
    int ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, int x)
  {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};

int main()
{
  long long N, M, K, L;
  char buff[12];

  while(scanf("%lld %lld %lld %lld", &N, &M, &K, &L), N) {

    vector< pair< int, string > > data(N);
    vector< int > toint(N);
    vector< string > priority(N);
    unordered_map< string, int > vv;
    vector< bool > like(N, false);

    for(int i = 0; i < N; i++) {
      int x;
      scanf(" %s %d", buff, &x);
      data[i] = make_pair(-x, buff);
      priority[i] = data[i].second;
    }
    sort(begin(priority), end(priority));
    sort(begin(data), end(data));


    for(int i = 0; i < N; i++) {
      toint[i] = lower_bound(begin(priority), end(priority), data[i].second) - begin(priority);
      vv[data[i].second] = i;
      data[i].first *= -1;
    }

    for(int i = 0; i < M; i++) {
      scanf("%s", buff);
      like[vv[buff]] = true;
    }

    BinaryIndexedTree bit(N);

    long long right = K, bottom = 0, up = 0;
    long long sz = 0, ret = 0, pre = -1;

    for(int i = 0; i < K; i++) {
      ret += like[i];
    }

    for(int i = K - 1; i >= 0; i--) {
      if(!like[i]) {
        while(right < N && !like[right]) ++right;
        if(right == N) break;

        if(data[i].first == data[pre].first) {
//          cerr << "foo" << endl;
// ???????????¨???????????????????????????

        }
        L -= data[i].first - data[right].first;
        if(~pre) {
          L -= bottom * (data[i].first - data[pre].first);
          L -= up * (data[i].first - data[pre].first - 1);
        }
//        assert(bottom * (data[i].first - data[pre].first) >= 0);
//        assert(up * (data[i].first - data[pre].first - 1) >= 0);

        bit.add(toint[right], 1);

        bottom = bit.sum(toint[i]);
        up = bit.sum(N - 1) - bottom;
        pre = i;
        sz = 0;

        L -= up;


        if(L < 0) break;
        ++ret;
        ++right;
      } else {
        if(i == 0) break;
        bit.add(toint[i], 1);
        L -= ++sz * (data[i - 1].first - data[i].first);
      }
    }

    printf("%lld\n", ret);
  }

}

Measured memory_bytes: 16544
#include <bits/stdc++.h>
using namespace std;
typedef pair < char, int > Pci;
typedef pair < int , char > Pic;
struct BIT
{
    int data[200005];
    BIT() { memset(data, 0, sizeof(data)); }
    void add(int k, int x) { for(k++; k < 200005; k += (k & -k)) data[k] += x; }
    int query(int k) { int ans = 0; for(k++; k > 0; k -= (k & -k)) ans += data[k]; return (ans); }
};

int main()
{
    string S, ANS;
    int K, N;
    BIT tree;
    Pci data[200005]; 
    priority_queue < Pic , vector < Pic > , greater < Pic > > pq;

    cin >> S >> K;
    N = S.size();
    for(int i = 0; i < N; i++) {
        tree.add(i, 1);
        data[i] = Pci(S[i], i);
    }
    sort(data, data + N);
    int i = 0;
    while(!pq.empty() || i < N) {
        int val;
        if(!pq.empty() && (val = tree.query(pq.top().first) - 1) <= K) {
            K -= val;
            tree.add(pq.top().first, -1);
            ANS.push_back(pq.top().second);
            pq.pop();
        } else if((val = tree.query(data[i].second) - 1) <= K) {
            K -= val;
            tree.add(data[i].second, -1);
            ANS.push_back(data[i].first);
            i++;
        } else {
            pq.push(Pic(data[i].second, data[i].first));
            i++;
        }
    }
    cout << ANS << endl;
    return (0);
}
        

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

const int MAXN = 18;
const int MAXM = 1 << MAXN;
int N;
int M;

int A[MAXM];

int ans[MAXM];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N;
	M = 1 << N;
	for (int i = 0; i < M; i++) {
		cin >> A[i];
	}

	for (int m = 0; m < M; m++) {
		int v[2] = {};
		for (int s = m; true; s = (s-1) & m) {
			if (A[s] > v[0]) {
				v[1] = v[0];
				v[0] = A[s];
			} else if (A[s] > v[1]) {
				v[1] = A[s];
			}
			if (s == 0) break;
		}
		ans[m] = v[0] + v[1];
	}

	for (int m = 1; m < M; m++) {
		ans[m] = max(ans[m], ans[m-1]);
	}

	for (int m = 1; m < M; m++) {
		cout << ans[m] << '\n';
	}

	return 0;
}

Measured memory_bytes: 5120
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let s = get!(String);
    let k = s.len();
    let maru = s.chars().filter(|&c| c=='o').count();
    if maru + 15 - k >= 8 {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    int a,b,k;
    cin>>a>>b>>k;
    if((b-a+1)/k<2){
        for(int i=a;i<b+1;i++){
            cout<<i<<endl;
        }
    }else{
        for(int i=a;i<a+k;i++){
            cout<<i<<endl;
        }
        for(int i=b-k+1;i<b+1;i++){
            cout<<i<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
fn read() -> (i32, i32, i32) {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut vec: Vec<i32> = s
        .trim()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    vec.sort();
    (vec[0], vec[1], vec[2])
}

fn main() {
    let (a, b, c) = read();
    match (a, b, c) == (5, 5, 7) {
        true => println!("YES"),
        false => println!("NO"),
    };
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> Pii;

int N;

int main() {
    cin >> N;
    set<string> st;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        st.insert(s);
    }
    

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

Measured memory_bytes: 19252
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define msi map<string,int>
#define mii map<int,int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define po pop_back
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
//	#ifndef ONLINE_JUDGE
 //   	freopen("input.txt", "r", stdin);
 //   	freopen("output.txt", "w", stdout);
//	#endif
	string s,t;
	cin>>s>>t;
	int n = s(s);
	int m = s(t);
	int dp[n+1][m+1];
	rep(i,n+1){
		rep(j,m+1){
			dp[i][j] = 0;
		}
	}	
	repa(i,1,n+1){
		repa(j,1,m+1){
			if(s[i-1] == t[j-1]){
				dp[i][j] = dp[i-1][j-1] + 1;
			}
			else{
				dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	int i = n;
	int j = m;
	string ans;
	// rep(i,n+1){
	// 	rep(j,m+1){
	// 		cout<<dp[i][j];
	// 	}
	// 	cout<<"\n";
	// }
	// cout<<s[n-1];
	while(i > 0 && j > 0){
		if(dp[i][j-1] == dp[i][j]){
			j--;
		}
		else if(dp[i-1][j] == dp[i][j]){
			i--;
		}
		else if(dp[i-1][j-1] == dp[i][j]-1){
			// cout<<s[i-1]<<i<<" "<<j<<"\n";
			ans.pb(s[i-1]);
			i--;
			j--;
		}
		
	}
	// cout<<dp[n][m];
	// cout<<"a";
	repr(i,s(ans)){
		cout<<ans[i];
	}
	return 0;
}

Measured memory_bytes: 35456
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;

vector <ll> bit(ll x)
{
  vector<ll>bit(42, 0);
  ll power = 1;

  if( x == -1 )
    return bit;
  
  for(int i=0;i<42;i++)
    {
      if(i!=0)
	power *= 2;
      
      if( x<power )
	continue;
      
      ll l  = (x-power)/(power*2);
      ll v  = (x-power)%(power*2);
      if( v>=power )
	bit[i] = (l+1)*power;
      else
	bit[i] = l*power+(v+1);

    }
  return bit;
}

int main()
{
  ll A, B;

  cin >> A >> B;

  vector<ll> bA = bit(A-1);
  vector<ll> bB = bit(B);

  ll ans = 0;
  for( int i=0;i<42;i++)
    {
      if((bB[i]-bA[i])%2 == 1)
	ans += pow(2, i);
    }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        List<Integer> list = new ArrayList<>();
        for(int i = 0; i < N; i++) {
            list.add(scan.nextInt());
        }
        Collections.sort(list);
        
        System.out.println(list.get(list.size()-1)-list.get(0));
    }
}


Measured memory_bytes: 20564
#include <stdio.h>
#include <string.h>
int main(void){
	int ac = 0;
	int wa = 0;
	int tle = 0;
	int re = 0;
	int n;
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		char s[4] = { '\0' };
		scanf("%s", s);
		if(strcmp(s, "AC") == 0){
			ac++;
		}
		if(strcmp(s, "WA") == 0){
			wa++;
		}
		if(strcmp(s, "TLE") == 0){
			tle++;
		}
		if(strcmp(s, "RE") == 0){
			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
#!/usr/bin/env python3

import math

H, W = map(int, input().split())

# ポイント: コーナーケースを避けるため、制約の下限に注意する。
# 今回だと、H == 1 or W == 1のとき、必ず1になってしまう。

if H == 1 or W == 1:
    print(1)
elif H % 2 == 1 and W % 2 == 1:
    print(math.ceil(H * W / 2))
else:
    print(int(H * W / 2))


Measured memory_bytes: 38384
#関数リスト
import sys
import numpy as np
input = sys.stdin.readline

 
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

L, R, D = MI()
result = 0
for i in range(L,R+1):
    if i % D == 0:
        result += 1

print(result)

Measured memory_bytes: 27156
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >>n;
    vector<int>dp(n,0);
    for(int i=1;i<=n;i++){
        for(int j=1;i*j<=n;j++){
            if(i*j%2==1)dp[i*j-1]++;
        }
    }
    
    cout <<count(dp.begin(),dp.end(),8);
}


Measured memory_bytes: 3668
#include <cstdio>
#include <string.h>

using namespace std;

int main() {

  char a[100];
  char b[100];
  scanf("%s", a);
  scanf("%s", b);

  if (strlen(a) > strlen(b)) {
    printf("GREATER");
  } else if (strlen(a) < strlen(b)) {
    printf("LESS");
  } else {
    int i;
    for (i=0; i<strlen(a); i++) {
      if (a[i] > b[i]) {
        printf("GREATER");
        break;
      } else if (a[i] < b[i]) {
        printf("LESS");
        break;
      }
    }
    if (i == strlen(a)) {
      printf("EQUAL");
    }
  }
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int H=sc.nextInt();
		int W=sc.nextInt();
		int[][] kumo=new int[H][W];
		for(int i=0; i<H; i++) {
			String s=sc.next();
			for(int j=0; j<W; j++) {
				if(s.charAt(j)=='.') {
					kumo[i][j]=0;
				}
				else {
					kumo[i][j]=1;
				}
			}
		}
		for(int i=0; i<H; i++) {
			StringBuilder sb=new StringBuilder();
			for(int j=0; j<W; j++) {
				int tmp=-1;
				for(int k=0; k<=j; k++) {
					if(kumo[i][j-k]==1) {
						if(j==W-1) {
							sb.append(k);
						}
						else {
							sb.append(k);
							sb.append(" ");
						}
						break;
					}
					else if(kumo[i][j-k]==0 && j-k==0) {
						if(j==W-1) {
							sb.append(-1);
						}
						else {
							sb.append(-1);
							sb.append(" ");
						}
					}
				}
			}
			pl(sb.toString());
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}


Measured memory_bytes: 26844
// C++ Program for Floyd Warshall Algorithm 
#include <bits/stdc++.h> 
using namespace std; 

// Number of vertices in the graph 
int V;
int graph[401][401],dist[401][401];

/* Define Infinite as a large enough 
value.This value will be used for 
vertices not connected to each other */
const int INF = 1e7+7; 

// A function to print the solution matrix 
void printSolution(); 

// Solves the all-pairs shortest path 
// problem using Floyd Warshall algorithm 
void floydWarshall () 
{ 
	/* dist[][] will be the output matrix 
	that will finally have the shortest 
	distances between every pair of vertices */
	int  i, j, k; 

	/* Initialize the solution matrix same 
	as input graph matrix. Or we can say 
	the initial values of shortest distances 
	are based on shortest paths considering 
	no intermediate vertex. */
	for (i = 0; i < V; i++) 
		for (j = 0; j < V; j++) 
			dist[i][j] = graph[i][j]; 

	/* Add all vertices one by one to 
	the set of intermediate vertices. 
	---> Before start of an iteration, 
	we have shortest distances between all 
	pairs of vertices such that the 
	shortest distances consider only the 
	vertices in set {0, 1, 2, .. k-1} as 
	intermediate vertices. 
	----> After the end of an iteration, 
	vertex no. k is added to the set of 
	intermediate vertices and the set becomes {0, 1, 2, .. k} */
	for (k = 0; k < V; k++) 
	{ 
		// Pick all vertices as source one by one 
		for (i = 0; i < V; i++) 
		{ 
			// Pick all vertices as destination for the 
			// above picked source 
			for (j = 0; j < V; j++) 
			{ 
				// If vertex k is on the shortest path from 
				// i to j, then update the value of dist[i][j] 
				if (dist[i][k] + dist[k][j] < dist[i][j]) 
					dist[i][j] = dist[i][k] + dist[k][j]; 
			} 
		} 
	} 

	// Print the shortest distance matrix 
	printSolution(); 
} 

/* A utility function to print solution */
void printSolution() 
{ 
	int ans=0;
	for (int i = 0; i < V; i++) 
	{ 
		for (int j = 0; j < V; j++) 
		{ 
			// cout<<dist[i][j]<<" ";
			if (dist[i][j] == INF) 
				continue;
			else
				ans=max(ans,dist[i][j]);
		} 
		// cout<<endl;
	}
	cout<<ans<<endl;
	exit(0); 
} 
int a[21][21];
int n,m;
int id(int i,int j){
	return m*i+j;
}
void addEdge(int i1,int j1,int i2,int j2){
	// cout<<i1<<" "<<j1<<" "<<i2<<" "<<j2<<endl;
	int u=id(i1,j1);
	int vv=id(i2,j2);
	// cout<<u<<" "<<vv<<endl;
	graph[u][vv]=1;
	graph[vv][u]=1;
}
// Driver code 
int main() 
{ 
	cin>>n>>m;
	for (int i = 0; i < n; ++i)
	{
		string s;
		cin>>s;
		for (int j = 0; j < m; ++j)
		{
			if(s[j]=='#') a[i][j]=0;
			else a[i][j]=1;
		}
	}
	V = n*m;
	for (int i = 0; i < V; ++i)
	{
		for (int j = 0; j < V; ++j)
		{
			if(i!=j) graph[i][j]=INF;
		}
	}
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < m; ++j)
		{
			if(i+1<n and a[i][j] and a[i+1][j]) addEdge(i,j,i+1,j);
			if(j+1<m and a[i][j] and a[i][j+1]) addEdge(i,j,i,j+1);
		}
	}
	// for (int i = 0; i < V; ++i)
	// {
	// 	for (int j = 0; j < V; ++j)
	// 	{
	// 		cout<<graph[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
	// cout<<endl;
	// Print the solution 
	floydWarshall(); 
	return 0; 
} 


Measured memory_bytes: 1536
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <functional>

using namespace std;

template <class It> string join(It i1, It i2)
{
    ostringstream ss;
    for (auto it = i1; it != i2; ++it)
        ss << ((it == i1) ? "" : ", ") << (*it);
    return ss.str();
}

void Print() { cout << endl; }
template <class Head, class... Args> void Print(Head &&head, Args&&... args)
{
    cout << head;
    Print(args...);
}

#ifdef DEBUG
#define Dump(x) cerr << #x << " = " << x << endl;
#define Dumps(x) cerr << #x << " : { " << join(x.begin(), x.end()) << " }" << endl;
#else
#define Dump(x)
#define Dumps(x)
#endif


using city_t = int;
using train_t = int;


int main()
{
    city_t N;
    train_t M;
    int Q;
    cin >> N >> M >> Q;

    vector<vector<size_t>> T(N, vector<size_t>(N, 0));
    for (train_t i = 0; i < M; ++i)
    {
        city_t l, r;
        cin >> l >> r;
        ++T[l - 1][r - 1];
    }

    vector<vector<size_t>> S(N, vector<size_t>(N, 0));
    S[0][0] = T[0][0];
    for (city_t i = 1; i < N; ++i)
    {
        S[i][0] = S[i - 1][0] + T[i][0];
        S[0][i] = S[0][i - 1] + T[0][i];
    }
    for (city_t i = 1; i < N; ++i)
        for (city_t j = 1; j < N; ++j)
            S[i][j] = (S[i - 1][j] + S[i][j - 1] - S[i - 1][j - 1]) + T[i][j];

    // S[i][j]: T[0~i][0~j]
    
    for (int i = 0; i < Q; ++i)
    {
        int p, q;
        cin >> p >> q;
        --p, --q;

        int n = S[q][q];
        if (p > 0)
            n -= (S[p - 1][q] + S[q][p - 1] - S[p - 1][p - 1]);
        
        cout << n << endl;
    }
}


Measured memory_bytes: 4864
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		// 文字列の入力
		String s = sc.next();
		String[] S = s.split("");

		int count=0;
		int max=0;

		for(String str:S){
			if(str.equals("A")||str.equals("G")||str.equals("C")||str.equals("T")){
				count++;
			} else {
				if(count>max)max=count;
				count=0;
			}
		}
		if(count>max)max=count;

		// 出力
		System.out.println(max);
	}
}

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

const int MAX_N = (int)(3e5 + 5);

string s, t;

int info_s[MAX_N];
int info_t[MAX_N];

map<char, int> mp_s;
map<char, int> mp_t;

int main(void) {
  cin >> s;
  cin >> t;

  for (int i = 0; i < s.size(); ++i) {
    if (mp_s.find(s[i]) == mp_s.end()) {
      info_s[i] = mp_s.size();
      mp_s[s[i]] = info_s[i];
    }
    else {
      info_s[i] = mp_s[s[i]];
    }
  }

  for (int i = 0; i < t.size(); ++i) {
    if (mp_t.find(t[i]) == mp_t.end()) {
      info_t[i] = mp_t.size();
      mp_t[t[i]] = info_t[i];
    }
    else {
      info_t[i] = mp_t[t[i]];
    }
  }

  for (int i = 0; i < s.size(); ++i) {
    if (info_s[i] != info_t[i]) {
      printf("No\n");
      return 0;
    }
  }

  printf("Yes\n");

  return 0;
}


Measured memory_bytes: 2312
# include <iostream>
using namespace std;
 
int main(void){
  int S;
  int h, m, s;
 
  cin >> S;

  h = (S / 3600);
  m = (S - (h * 3600)) / 60;
  s = S - ((h * 3600) + (m * 60));

  cout << h;
  cout << ":";
  cout << m;
  cout << ":";
  cout << s;
  cout << endl;
 
  return 0;
}

Measured memory_bytes: 1164
#include<stdio.h>
int main(){

	int a=0,b=0,d,r;
	double f;

	scanf("%d %d",&a,&b);

	d=a/b;

	r=a%b;

	f=1.0*a/b;

	printf("%d %d %f",d,r,f);

	return 0;

}

Measured memory_bytes: 636
let scan_int () = Scanf.scanf " %d" (fun x -> x)
let print_float n = Printf.printf "%.12f\n" n

(* 辺の入力 *)
let input_edge edges m =
  for i = 0 to m-1 do
    let s = scan_int() and t = scan_int() in
    edges.(s-1) <- (t-1) :: edges.(s-1) 
  done

(* 頂点vからの期待値の計算 *)
let calc_expected_value n edges =
  let expected = Array.make n 0.0 in
  let prop expect p u v = expect.(u) <- expect.(u) +. (expect.(v) +. 1.0) *. p in
  let rec rev_calc curr edges ret =
    if curr < 0 then ret
    else
      let p = 1.0 /. (float (List.length edges.(curr))) in
      let _ = List.iter (prop ret p curr) edges.(curr) in
      rev_calc (curr-1) edges ret in
  rev_calc (n-1) edges expected

(* 頂点vを通る確率の計算 *)
let calc_probability n edges =
  let probability = Array.make n 0.0 in
  let _ = probability.(0) <- 1.0 in
  let prop prob p u v = prob.(v) <- prob.(v) +. prob.(u) *. p in
  let rec calc curr edges ret =
    if curr = n then ret
    else
      let p = 1.0 /. (float (List.length edges.(curr))) in
      let _ = List.iter (prop ret p curr) edges.(curr) in
      calc (curr+1) edges ret in
  calc 0 edges probability


let solve n edges expected probability =
  let ans = ref expected.(0) in
  let p = expected.(0) in
  let _ =
    for u = 0 to n-1 do
      let l = List.length edges.(u) in
      if l <= 1 then ()
      else
        let add_prob = 1.0 /. (float (l-1)) -. 1.0 /. (float l) in
        let fold_func p v = p +. add_prob *. expected.(v) *. probability.(u) in
        let ref_value = List.fold_left fold_func p edges.(u) in
        let sub_prob = 1.0 /. (float (l-1)) in
        let calc_func v =
          let result = ref_value -. sub_prob *. expected.(v) *. probability.(u) in
          ans := min !ans result in
        List.iter calc_func edges.(u)
    done in
  print_float !ans


let () =
  let n = scan_int() and m = scan_int() in
  let edges = Array.make n [] in
  let _ = input_edge edges m in
  let expected = calc_expected_value n edges in
  let probability = calc_probability n edges in
  solve n edges expected probability

Measured memory_bytes: 6912
#include<bits/stdc++.h>
typedef long long ll;
#define sz(x) int(x.size())
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
int main(){
    ll A,B,C; cin >> A >> B >> C;
    if(A%2 == 0 || B%2 == 0 || C%2 == 0) cout << 0 << endl;
    else cout << min(A*B,min(B*C,C*A)) << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long gcd(long long m, long long n){
    if(m < 0 || n < 0) return 0; // エラー
    if(m < n) swap(m, n);
    if(n == 0) return m;
    return gcd(n, m % n);
}

long long lcm(long long m, long long n){
    if(m < 0 || n < 0) return 0; // エラー
    return m * n / gcd(m, n);
}

int main(){
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << b - a + 1 - (b/c + b/d - b/lcm(c,d) - ((a-1)/c + (a-1)/d - (a-1)/lcm(c,d))) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<sstream>
#include<string>
#include<vector>
#include <cmath>
#include <limits>
#include <queue>
#include<algorithm>
#include<cstring>
#include <cstdlib>
#include <cstdio>
#include <set>
 
using namespace std;
 
#define rep(i,n) for (int (i)=0;(i)<(n);i++)


int main(void){
    int n;
    cin >> n;
    priority_queue<string, vector<string>, greater<string> > S;
    string s;
    rep(i,n){
        cin >> s;
        S.push(s);
    }
    string s0;
    s0 = S.top();
    S.pop();
    priority_queue<pair<int, string> , vector<pair<int,string> > > counter;
    pair<int, string> p;
    int num = 1;
    rep(i,n-1){
        s = S.top();
        if (s0 == s){
            num++;
        }
        else{
            p.second = s0;
            p.first = num;
            counter.push(p);
            s0 = s;
            num = 1;
        }
        S.pop();
    }
    p.second = s0;
    p.first = num;
    counter.push(p);
    int frag = 0;
    int n0;
    priority_queue<string,vector<string>, greater<string> > ans;
    while(true){
        n0 =  counter.top().first;
        ans.push(counter.top().second);
        counter.pop();
        if (n0 != counter.top().first) break;
        if (counter.empty()) break;
    }

    while(!ans.empty()){
        cout << ans.top() << endl;
        ans.pop();
    }
    

    
    

    return 0;
}

Measured memory_bytes: 21484
#include <stdio.h>

int main(){
  int N, Y, i, j;
  scanf("%d%d", &N, &Y);
  for(i=0; i<=N; i++){
    for(j=0; j<=N-i; j++){
        if(i*10000 + j*5000 + (N-i-j)*1000 == Y){
          printf("%d %d %d", i, j, N-i-j);
          return 0;
        }
    }
  }
  if(i==N+1) printf("-1 -1 -1");
  return 0;
}

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

int main(){
    int n,k,i;
    cin >> n >> k;
    for (i = 1;n >= pow(k,i) ;i++ );
    cout << i <<endl;
    return 0;
}

Measured memory_bytes: 256