akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int a,b,x;cin >> a >> b >> x;
    int ans = b/x - (a-1)/x;
    if( a == 0)ans = b/x +1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n=97
p=print
r=range
def a(i,j,k,l=0):p("+<"[l],i,j,k)
def b(i):a(i,i,i+1)
def d(x,i,j):
	for t in r(30):
		b(j+t-1);a(j+t,n,j+t)
		for s in r(j+t,j+29):b(s)
		a(j+29,x,i+t,1);b(j+t-1);a(j+t,i+t,j+t)
p(3933)
a(0,1,n)
a(2,n,n,1)
a(0,n,3)
a(1,n,4)
d(3,5,36)
d(4,36,67)
for t in r(59):
	a(2,2,2)
	for s in r(t+1):
		if t-30<s<30:a(5+t-s,36+s,98);a(n,98,99,1);a(2,99,2)

Measured memory_bytes: 9212
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include <functional>
#include <queue>

using namespace std;

constexpr int MOD = 1000000007;
constexpr int INF = 1050000000;

int main() {

	long long x, y; cin >> x >> y;
	long long ans = 0;
	while (x <= y) {
		x *= 2;
		ans++;
	}

	cout << ans << endl;







}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for(ll i = 0;i < n;i++)
int x4[4] = {1, -1, 0, 0}, y4[4] = {0, 0, 1, -1};


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

  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i, h) cin >> s[i];

  vector<pii> graph[400][400];

  rep(i, h) rep(j, w) rep(k, 4) {
    int ni = i+x4[k];
    int nj = j+y4[k];
    if (0 <= ni && ni < h && 0 <= nj && nj < w && s[i][j] != s[ni][nj]) {
      graph[i][j].push_back(pii(ni, nj));
    }
  }

  vector<vector<bool>> reached(400, vector<bool>(400));
  ll ans = 0;

  rep(i, h) rep(j, w) {
    if (reached[i][j]) continue;

    ll black = 0;
    ll white = 0;

    queue<pii> que;
    que.push(pii(i, j));
    reached[i][j] = true;

    while (que.size()) {
      pii p = que.front(); que.pop();

      if (s[p.first][p.second] == '#') {
        black++;
      } else {
        white++;
      }

      for (auto&& k : graph[p.first][p.second]) {
        if (reached[k.first][k.second] == false) {

          reached[k.first][k.second] = true;
          que.push(pii(k.first, k.second));
        }
      }
    }

    ans += white*black;
  }

  cout << ans << endl;
}


Measured memory_bytes: 11776
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <math.h>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
const int maxn=2e5+10;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
int n,a[maxn],k;
bool judge(int m)
{
    int cnt=0;
    for(int i=0;i<n;++i)
    {
        cnt+=(a[i]-1)/m;
    }
    return cnt<=k;
}
int main()
{
    cin>>n>>k;
    for(int i=0;i<n;++i)
        cin>>a[i];
    int l=1,r=1e9+10;
    while(l<=r)
    {
        int mid=l+r>>1;
        if(judge(mid))
            r=mid-1;
        else l=mid+1;
    }
    cout<<l<<endl;
    return 0;
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <math.h>
#define N 100

int main(){
    int n, a[N+2]={}, b[N+2]={};
    int i;
    int count=0;
    int tmp=0,dice=0;

    scanf("%d",&n);

    for(i=1;i<=n;i++){
        scanf("%d",&a[i]);
        if(a[i]==0){
            count++;
            b[count]=i;
        }
    }
    b[count+1]=n+1;
    
    for(i=0;i<=count;i++){
        tmp = b[i+1] - b[i];
        if(tmp>dice){
            dice = tmp;
        }
    }

    printf("%d\n",dice);
    return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < int(n); ++i)
#define REPE(i, a, b) for (int i = (a); i <= int(b); ++i)
#define SZ(x) ((int)(x).size())
#define ALL(x) x.begin(), x.end()
#define PB push_back
#define EB emplace_back
using LL = long long;
using PII = pair<int, int>;
#define F first
#define S second

int main() {
  int n;
  string s;
  cin >> n >> s;
  char l = 0;
  int ans = 0;
  for (char c : s) {
    if (l == 'x' && c == 'x') break;
    ans++;
    l = c;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3320
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[] s = sc.next().toCharArray();
        int ans = 1;
        for (int i = 1; i < n; i++) {
            if(s[i-1] != s[i])ans++;
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 25940
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#define lowbit(a) ((a)&(-(a)))
using namespace std;

void file(bool opt)
{
	if (opt&&fopen("in.txt", "r"))
	{
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	}
}

const long long mod = 1e9 + 7;
long long  inv[200000+5];
long long  fac[200000 + 5];


long long  C(int n, int m) {
	return fac[n] * inv[m] % mod*inv[n - m] % mod;
}


void init() {
	inv[0] = fac[0] = 1;
	inv[1] = 1;
	for (int i = 1; i<=200000; i++) {
		fac[i] = fac[i - 1] * i%mod;
	}
	inv[1] = 1;
	for (int i = 2; i<=200000; i++) {
		inv[i] = (long long )(mod - mod / i)*inv[mod%i] % mod;
	}
	inv[0] = 1;
	for (int i = 1; i<=200000; i++) {
		inv[i] = inv[i - 1] * inv[i] % mod;
	}
}

long long n, m,k;
long long ans = 0;

int main()
{
	init();
	cin >> n >> m>>k;
	for (long long i = 1; i <= n - 1; i++)
		ans = (ans + i*(n - i) % mod*m%mod*m%mod) % mod;
	for (long long i = 1; i <= m - 1; i++)
		ans = (ans + i*(m - i) % mod*n%mod*n%mod) % mod;

	//cout << C(n*m - 2, k - 2) % mod << endl;
	ans = ans * C(n*m - 2, k - 2)%mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
 
int main(){
   int k;
   cin>>k;
   if(k%2==0 || k%5==0){
    cout<<-1<<endl;
       return 0;
   }
   int p=7%k,ans=1;
   while(p){
       p=p*10+7;
       p=p%k;
       ans++;
   }
   cout<<ans<<endl;
}

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

template <class T>
using lim = numeric_limits<T>;

struct sushi{
	int t, d;
	sushi(){t=d=0;}
	sushi(int a, int b){
		t = a;
		d = b;
	}
	
	void show(){
		cout << t << ": " << d << endl; 
	}
};


const int maxn = 1e5;
vector<sushi> leftOvers;
sushi arr[maxn];
int counters[maxn+1];
bool seen[maxn+1];

bool compare(const sushi &a, const sushi &b){
	return a.d > b.d;
}
int main() {
	ios_base::sync_with_stdio(false) ;
	cin.tie(0);
	
	memset(counters, 0, sizeof counters);
	
	int n, k;
	cin >> n >> k;
	
	for (int i = 0; i < n; i++){
		int t,d;
		cin >> t >> d;
		arr[i] = sushi(t,d);
	}
	
	sort(arr, arr+n, compare);
	
	ll total = 0;
	ll unique = 0;
	for (int i = 0; i < k; i++){
		total += arr[i].d;
		if (counters[arr[i].t] == 0) unique++;
		counters[arr[i].t]++;
		seen[arr[i].t] = true;
	}
	
	for (int i = k; i < n; i++){
		if (!seen[arr[i].t]) {
			seen[arr[i].t] = true;
			leftOvers.push_back(arr[i]);
		}
	}
	
	ll ans = total + unique*unique;
	
	int x = 0;
	for (int i = k-1; i >= 0; i--){
		if (x == (int) leftOvers.size()) break;
		if (counters[arr[i].t] == 1) continue;
		
		total -= arr[i].d;
		total += leftOvers[x].d;
		
		counters[arr[i].t]--;
		unique++;
		x++;
		
		ans = max(ans, total+unique*unique);
	}
	

	cout << ans << endl;
}



Measured memory_bytes: 2172
// Problem : C - Vacation
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;

#define ff first
#define fs second
#define lb lower_bound
#define ub upper_bound

#define int long long
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector< vi >
#define vpii vector< pii >
#define vb vector<bool>
#define si set<int>
#define mii map<int, int>
#define mci map<char, int>
#define md 1000000007
#define pb push_back
#define eb emplace_back
#define fio ios_base::sync_with_stdio (false); cin.tie (NULL);  cout.tie (NULL);
#define qw1(x) cerr<<#x<<": "<<x<<" "<<endl
#define qw2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define qw3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define qw4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl


#define f(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define rl(i,a,b) for(int i=(int)a;i>=(int)b;i--)
#define all(x) x.begin(),x.end()
#define endl '\n'
void printv(vector<int>  v){ for(int i=0;i<v.size();i++) cout<<v[i]<<' '; cout<<endl;   }
int bem(int m , int n, int mod) { int res=1; while(n){
	     			        if(n%2!=0) { res*=m; res%=mod; }
	    			        m*=m;   m%=mod;   n/=2;
			                          }
				return res;	}
int be(int a, int b) { int res=1; 	while(b){
				if(b%2!=0) res*=a;
				a*=a; b/=2;
				}
			return res;	}
void sieve(int n, vb &prime){
    prime[0]=false;     prime[1]=false;
    for(int i=2;i*i<=n;i++){
         if(prime[i]==true){
              for(int j=i*i;j<=n;j+=i)    prime[j]=false;
             	  }
    	 }
	}
struct tr{
	int a, b, c;
};
void solve()
  {
int n; cin>>n;
vector< tr > v(n);
f(i, 0, n-1) { int x, y, z; cin>>x>>y>>z; v[i]={x, y, z};}
vector< vector< int > >dp(n, vi (3));
dp[0][0]=v[0].a;
dp[0][1]=v[0].b;
dp[0][2]=v[0].c;
for( int i=1; i<=n-1; i++)
{
	for( int j=0; j<=2; j++)
	{
		if(j==0)
		dp[i][j]=max(dp[i-1][1], dp[i-1][2])+v[i].a;
		if(j==1)
		dp[i][j]=max(dp[i-1][0], dp[i-1][2])+v[i].b;
		if(j==2)
		dp[i][j]=max(dp[i-1][1], dp[i-1][0])+v[i].c;		
		
	}
}
cout<<*max_element(dp[n-1].begin(), dp[n-1].end())<<endl;
  }

int32_t main ()
{
//fio
int t=1; 
//cin>>t; 
while(t--){
	solve();
}
 
}








Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    vi a(n+1, 0);
    rep(i, n) cin >> a[i];
    ll m = 1000, s = 0;
    // keepがtrueなら安値で買って持ってる状態
    bool keep = false;
    for(ll i=0; i<n; i++){
        // 株価が下がる場合
        if(a[i] > a[i+1]){
            // 株を持ってる状態
            if(keep){
                m += s*a[i];
                s = 0;
                keep = false;
            }
            // 違うなら
            else{
                continue;
            }
        }
        // 株価が上がる場合
        else if(a[i] < a[i+1]){
            if(keep){
                continue;
            }
            else{
                s = m/a[i];
                m = m%a[i];
                keep = true;
            }
        }
    }
    cout << m << endl;
}

Measured memory_bytes: 3656
#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)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int a, b, c; cin >> a >> b >> c;
    if (c >= a && c <= b) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
from functools import lru_cache

@lru_cache()
def GCD(a,b):
    if min(a,b)==0:
        return max(a,b)
    else:
        return GCD(min(a,b),max(a,b)%min(a,b))

def extendedEuler(a,b):
    if b==GCD(a,b):
        return (0,1)
    elif a==GCD(a,b):
        return (1,0)

    if a<b:
        X,Y=extendedEuler(a,b%a)
        return (X-(b//a)*Y,Y)
    else:
        X,Y=extendedEuler(a%b,b)
        return (X,Y-(a//b)*X)

a,b=[int(i) for i in input().split(" ")]
x0,y0=extendedEuler(a,b)
print(x0,y0)



Measured memory_bytes: 6292
#include <iostream>
#include <vector>
#include <numeric>//accumulate(v.begin(), v.end(), 0);
#include <algorithm>//sort(v.begin(),v.end());
#include <string>//
#include <cmath>
#include <iomanip> //setprecision(2)
#include <stack>

using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
  string s;
  cin >> s;
  stack<char> res;
  for (auto e : s) {
    if (!res.empty() && e != res.top()) {
      res.pop();
    } else {
      res.push(e);
    }
  }
  cout << s.size() - res.size() << endl;
}


Measured memory_bytes: 512
//
// Created by PIIMUU on 8/29/2020.
//
#include <bits/stdc++.h>
using namespace std;
vector<int> E[200010];
int cnt;
bool vis[200010];
void dfs(int u) {
    vis[u] = true;
    cnt++;
    for (int v : E[u]) {
        if (vis[v] == false) {
            dfs(v);
        }
    }
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        int u, v;
        cin >> u >> v;
        E[u].push_back(v);
        E[v].push_back(u);
    }
    int answer = 0;
    for (int i = 1; i <= n; i++) {
        if (vis[i] == false) {
            cnt = 0;
            dfs(i);
            answer = max(answer, cnt);
        }
    }
    cout << answer;
}



Measured memory_bytes: 20840
#include <math.h>
#include <stdio.h>

int ispower(int n) {
	int a, b;

	for (a = 1; a < 50; a++)
		for (b = 2; b < 50; b++)
			if (pow(a, b) == n)
				return 1;
	return 0;
}

int main() {
	int x, n, max;

	scanf("%d", &x);
	max = 0;
	for (n = 1; n <= x; n++)
		if (ispower(n) && max < n)
			max = n;
	printf("%d\n", max);
	return 0;
}


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

ans = 0
num = [0] * K
for i in range(1, N + 1):
        num[i % K] += 1
for a in range(K):
        b = (K - a) % K
        c = (K - a) % K
        if (b + c) % K != 0:
                continue
        ans += num[a] * num[b] * num[c]
print(ans)

Measured memory_bytes: 40560
K = int(input())
print([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][K - 1])


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    while(scanf("%d",&N),N) {
        int ans=0;
        for(int i=1;i<N;i++) {
            int sum=i;
            for(int j=i+1;sum<N;j++) sum+=j;
            if(sum==N) ans++;
        }
        printf("%d\n",ans);
    }
}

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

int n, W, V_MAX = 1000;
ll w[110], v[110], INF = 1000000000000;
ll dp[110][100100];

int main()
{
	cin >> n >> W;
	for (int i = 0; i < n; i++)
	{
		cin >> w[i] >> v[i];
	}
	for (int i = 0; i <= n * V_MAX; i++)
		dp[0][i] = INF;
	dp[0][0] = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j <= n * V_MAX; j++)
		{
			if (j < v[i])
				dp[i + 1][j] = dp[i][j];
			else
				dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
		}
	}
	ll ans = 0;
	for (int i = 0; i <= n * V_MAX; i++)
		if (dp[n][i] <= W)
			ans = i;
	cout << ans << endl;
}


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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	ll n, k;
	cin>>n>>k;
  	ll i, h[n+1], cost[n+1] = {}, min = 0, t, j;
    cost[0] = 10000;
    for(i=1; i<=n; i++){
        cin>>h[i];
    }
    if(1+k<=n){
        for(i = 2; i<=1+k; i++){
            cost[i] = abs(h[i] - h[1]);
        }
        for(i=k+2; i<=n; i++){
            min = abs(h[i] - h[i-1]) + cost[i-1];
            for(j = i - 2; j>=i-k; j--){
                if(abs(h[i] - h[j]) + cost[j] < min) {
                    min = abs(h[i] - h[j]) + cost[j];
                    t = j;
                }
            }
            cost[i] = min;
        }
    }
    else{
        cost[n] = h[n] - h[1];
    }
  	cout<<cost[n];
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(ll)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll n,m;cin>>n>>m;
    vector<pair<ll,ll>> p(m);
    vector<vector<ll>> x(n+10);
    rep(i,m){
        ll a,b;
        scanf("%lld %lld",&a,&b);
        p[i]={a,b};
        x[a-1].push_back(b);
    }
    rep(i,n) sort(x[i].begin(),x[i].end());
    rep(i,m){
        ll a=p[i].first,b=p[i].second;
        string P=to_string(a);
        while(P.size()<6) P="0"+P;
        auto itr= lower_bound(x[a-1].begin(),x[a-1].end(),b);
        ll k=itr-x[a-1].begin();
        k++;
        string Y=to_string(k);
        while(Y.size()<6) Y="0"+Y;
        cout<<P<<Y<<endl;
    }
}


Measured memory_bytes: 8576
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int N=1e3+5;

char s[N],t[N];
int ans=1e9;
int main()
{
    ios::sync_with_stdio(false);
    scanf("%s%s",s,t);
    int ls= strlen(s);
    int lt= strlen(t);
    
    for(int i=0;i<=ls-lt;i++){
        int diff=0;
        for(int j=0;j<lt;j++)
        {
            if(s[i+j]!=t[j])
                diff++;
        }
        ans=min(ans,diff);
    }
    cout<<ans<<endl;
    
}

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

int n,m,S,T;
vector<vector<int>>graph(333333);
vector<int>dist(333333,-1);

void BFS()
{
	queue<int> que;
	dist[3*S]=0;
	que.push(3*S);
	while(!que.empty())
	{
		int f=que.front();
		que.pop();
		for(auto t:graph[f])
		{
			if(dist[t]==-1)
			{
				dist[t]=dist[f]+1;
				que.push(t);
			}
		}
	}
}

int main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int u,v;
		cin>>u>>v;
		u--;
		v--;
		for(int k=0;k<3;k++)
			graph[3*u+k].push_back(3*v+((k+1)%3));
	}
	cin>>S>>T;
	S--;
	T--;
	BFS();
	if(dist[3*T]==-1)cout << "-1" << endl;
	else cout << dist[3*T]/3 << endl;
	return 0;
}


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

namespace ABC138A
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();

            if(a >= 3200)
            {
                Console.WriteLine(s);
            }
            else
            {
                Console.WriteLine("red");
            }
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 100000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n ; cin >> n ;
	vector<pll> a(n) ;
	for(int i=0;i<n;i++){
		cin >> a.at(i).first ;
		a.at(i).second = i ;
	}
	sort(all(a)) ;
	reverse(all(a)) ;
	vvll dp(n+1,vll(n+1,0)) ;
	for(int i=0;i<n;i++){
		for(int j=0;j<n-i;j++){
			dp.at(i+1).at(j) = max(dp.at(i+1).at(j),dp.at(i).at(j)+a.at(i+j).first*(a.at(i+j).second-i)) ;
			dp.at(i).at(j+1) = max(dp.at(i).at(j+1),dp.at(i).at(j)+a.at(i+j).first*((n-1-j)-a.at(i+j).second)) ;
		}
	}
	ll ans = 0 ;
	for(int i=0;i<n+1;i++) ans = max(ans,dp.at(i).at(n-i)) ;
	cout << ans << endl ;
}


Measured memory_bytes: 34676
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int comparator(const void* n1, const void* n2) {
    long long data1 = *(long long*)n1;
    long long data2 = *(long long*)n2;

    if (data1 > data2) {
        return 1;
    } else if (data1 < data2) {
        return -1;
    } else {
        return 0;
    }
}

int main(void) {
    int N, M;
    scanf("%d %d", &N, &M);

    long long scores[8][N];
    for (int i=0; i<N; i++) {
        long long x;
        long long y;
        long long z;

        scanf("%lld %lld %lld", &x, &y, &z);

        for (int pattern=0x0; pattern<=0x7; pattern++) {
            // calc +++, ++-, +-+, +--, -++, -+-, --+, ---
            long long nx = x;
            long long ny = y;
            long long nz = z;
            if ((pattern & 0x4) > 0) {
                nx *= -1;
            }
            if ((pattern & 0x2) > 0) {
                ny *= -1;
            }
            if ((pattern & 0x1) > 0) {
                nz *= -1;
            }
            scores[pattern][i] = nx + ny + nz;
        }
    }
    long long max = 0;
    for (int pattern=0x0; pattern<=0x7; pattern++) {
        qsort(scores[pattern], N, sizeof(long long), comparator);

        long long total = 0;
        for (int i=0; i<M; i++) {
            total += scores[pattern][N-1-i];
        }
        if (max < total) {
            max = total;
        }
    }

    printf("%lld\n", max);

    return 0;
}



Measured memory_bytes: 256
def f(x)
    return {} if x == 0
    k = 0
    k += 1 until (x - 3 ** k).abs <= (3 ** k - 1) / 2
    if x >= 3 ** k
        return f(x - 3 ** k).merge({ k => ?+ })
    else
        h = f(3 ** k - x)
        h.each {|k, v| h[k] = (v == ?+ ? ?- : ?+)}
        return h.merge({ k => ?+ })
    end
end
x = gets.to_i
h = f(x)
puts (0..h.keys.max).map {|k| h[k] || ?0}.reverse * ''


Measured memory_bytes: 6876
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);
        String s = sc.next();
        char[] cl = s.toCharArray();
        int len = cl.length;
        for(int i = 0; i < len/2; i++){
            if(cl[i] != cl[len-1-i]){
                System.out.println("No");
                return;
            }
        }
        char[] cl2 = s.substring(0,s.length()/2).toCharArray();
        len = cl2.length;
        for(int i = 0; i < len/2; i++){
            if(cl2[i] != cl2[len-1-i]){
                System.out.println("No");
                return;
            }
        }
        char[] cl3 = s.substring((s.length()+2)/2,s.length()).toCharArray();
        len = cl3.length;
        for(int i = 0; i < len/2; i++){
            if(cl3[i] != cl3[len-1-i]){
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }

}

Measured memory_bytes: 23764
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const [n, m] = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)

const [, ..._lr] = stdin.trim().split('\n')
const lr = _lr.map(e => e.split(' ').map(Number))

const ans = _ => {
  let lMax = lr[0][0]
  let rMin = lr[0][1]

  for (let i = 0; i < lr.length; i++) {
    const [l, r] = lr[i]

    if (l > lMax) {
      lMax = l
    }

    if (r < rMin) {
      rMin = r
    }
  }

  if (rMin >= lMax) {
    return rMin - lMax + 1
  } else {
    return 0
  }
}

console.log(ans())


Measured memory_bytes: 53176
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
import sys,bisect,string,math,time,functools,random
def Golf():*a,=map(int,open(0))
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[];g=[[] for i in range(n)]
    for i in range(E):
        inp=LI();org_inp.append(inp)
        if index==0:inp[0]-=1;inp[1]-=1
        if len(inp)==2:
            a,b=inp;g[a].append(b)
            if not Directed:g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp;aa=(inp[0],inp[2]);bb=(inp[1],inp[2]);g[a].append(bb)
            if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,boundary=1,search=[],replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,boundary=1,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[boundary]*(w+2);found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
    mp+=[boundary]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def bit_combination(k,n=2):return [[tb//(n**bt)%n for bt in range(k)] for tb in range(n**k)]
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)
def show2d(g,h,w):
    for i in range(h):show(g[i*w:i*w+w])

YN=['YES','NO'];Yn=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=0
n,x,y=LI()
d=[0]*n

for i in range(1,n+1):
    for j in range(i+1,n+1):
        t=j-i
        t=min(t,abs(i-x)+1+abs(j-y),abs(i-y)+1+abs(j-x))
        d[t]+=1
    

for i in range(1,n):
    print(d[i])



Measured memory_bytes: 49496
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000


ll gcm(ll a,ll b);
ll lcm(ll a,ll b);
ll fac(ll a);

int main(){
  ll h,w;
  cin >> h >> w;
  if(h == 1 || w == 1){
    cout << 1 << endl;
  }
  else if(h % 2 == 0){
    cout << h/2*w << endl;
  }
  else if(w % 2 == 0){
    cout << w/2*h << endl;
  }
  else{
    cout << (w*h/2)+1 << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 100
using namespace std;
char Map[MAXN+5][MAXN+5];
int n,m,ex,ey;
int sumr[MAXN+5][MAXN+5],sumc[MAXN+5][MAXN+5];
int dp[MAXN+5][MAXN+5][MAXN+5];
void Init()
{
	memset(dp,-1,sizeof(dp));
}
int main()
{
	Init();
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",Map[i]+1);
		for(int j=1;j<=m;j++)
		{
			sumr[i][j]=sumr[i][j-1];
			sumc[i][j]=sumc[i-1][j];
			if(Map[i][j]=='E')
				ex=i,ey=j;
			else if(Map[i][j]=='o')
			{
				sumr[i][j]++;
				sumc[i][j]++;
			}
		}
	}
	int L,R,U,D,ans=0;
	L=ey-1;
	R=m-ey;
	U=ex-1;
	D=n-ex;
	dp[0][0][0]=0;
	for(int l=0;l<=L;l++)
		for(int r=0;r<=R;r++)
			for(int u=0;u<=U;u++)
				for(int d=0;d<=D;d++)
				{
					if(dp[r][u][d]==-1)
						continue;
					ans=max(dp[r][u][d],ans);
					int up=max(ex-u,d+1);
					int down=min(ex+d,n-u);
					int left=max(ey-l,r+1);
					int right=min(ey+r,m-l);
					if(up>down||left>right)
						continue;
					int add;
					if(u+d<U)
					{
						add=sumr[ex-u-1][right]-sumr[ex-u-1][left-1];
						dp[r][u+1][d]=max(dp[r][u+1][d],dp[r][u][d]+add);
					}
					if(u+d<D)
					{
						add=sumr[ex+d+1][right]-sumr[ex+d+1][left-1];
						dp[r][u][d+1]=max(dp[r][u][d+1],dp[r][u][d]+add);
					}
					if(l+r<R)
					{
						add=sumc[down][ey+r+1]-sumc[up-1][ey+r+1];
						dp[r+1][u][d]=max(dp[r+1][u][d],dp[r][u][d]+add);
					}
					if(l+r<L)
					{
						add=sumc[down][ey-l-1]-sumc[up-1][ey-l-1];
						dp[r][u][d]=max(dp[r][u][d],dp[r][u][d]+add);
					}
				}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4736
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int m, d;
    cin >> m >> d;

    int res = 0;

    for (int i = 1; i <= m; i++)
    {
        for (int j = 1; j <= d; j++)
        {
            int one = j % 10;
            int ten = (j - one) / 10;

            if (one < 2 || ten < 2)
                continue;

            res += one * ten == i;
        }
    }

    cout << res << endl;

    return 0;
}

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

int main()
{
  	int n;
  	string s;
  	cin>>n>>s;
  	int x = 0, res = 0;
  	for(int i = 0; i < s.length(); i++)
    {
    	if(s[i] == 'I')
          x++;
      	else
          x--;
      	res = max(res, x);
    }
  	cout<<res<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    string t;
    cin >> t;
    int sl = s.length();
    int tl = t.length();
    vector<int>smoji(26,0);
    vector<int>tmoji(26,0);
    for(int i=0;i<max(sl,tl);i++){
        if(i<sl)smoji[(int)(s[i]-'a')]++;
        if(i<tl)tmoji[(int)(t[i]-'a')]++;
    }
    string ss = "";
    string tt = "";
    for(int i=0;i<26;i++){
        for(int j=0;j<smoji[i];j++){
            ss += (char)(i+'a');
        }

        for(int j=0;j<tmoji[25-i];j++){
            tt += (char)('z'-i);
        }
    }
    if(ss<tt)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int high, wide;
    int x, y;
    
    while(1){
      scanf("%d %d", &high, &wide);
      if (high == 0 && wide == 0)
          break;
      for(x = 1; x <= high; x++){
        for(y = 1; y <= wide; y++){
            if(x % 2 == 1 && y % 2 == 1)
                printf("#");
            else if(x % 2 == 0 && y % 2 == 1)
                printf(".");
            else if(x % 2 == 0 && y % 2 == 0)
                printf("#");
            else if(x % 2 == 1 && y % 2 == 0)
                printf(".");
        }
        printf("\n");
      }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2140
n = int(input())
a_l = list(map(int, input().split()))
ans = 1
is_plus = None
sub = []
for i in a_l:
    if len(sub) == 0:
        sub.append(i)
        continue
    if i == sub[-1]:
        sub.append(i)
        continue

    if is_plus is None:
        if sub[-1] > i:
            is_plus = False
        else:
            is_plus = True
        sub.append(i)

    elif is_plus is True:
        if sub[-1] > i:
            sub = [i]
            ans += 1
            is_plus = None
        else:
            sub.append(i)
    else:
        if sub[-1] < i:
            sub = [i]
            ans += 1
            is_plus = None
        else:
            sub.append(i)
print(ans) 

Measured memory_bytes: 20104
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
	int n;
	int num[11][11];
		
		while(cin >> n,n){
			for(int i=0;i<=n;i++){
				for(int j=0;j<=n;j++){
					num[i][j]=0;
				}
			}
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					cin >> num[i][j];
					num[i][n] += num[i][j];
					num[n][j] += num[i][j];
					num[n][n] += num[i][j];
				}
			}
			for(int i=0;i<=n;i++){
				for(int j=0;j<=n;j++){
					printf("%5d",num[i][j]);
				}
				cout << endl;
			}
	}
	return 0;
}

Measured memory_bytes: 0
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n:u32,
        a:u32,
    };
    println!("{}", if n % 500 <= a {"Yes"} else {"No"});
}


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

using namespace std;

int main(int argc, char *argv[]) {
	string O, E;
	cin >> O >> E;

	string pass;
	int len = O.size() + E.size();
	for (int i = 0; i < E.size(); i++) {
		pass += O[i];
		pass += E[i];
	}

	if (O.size() > E.size()) {
		pass += O[O.size() - 1];
	}

	cout << pass << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*
import kotlin.collections.HashMap

fun main(args: Array<String>) {
    val scan = Scanner(System.`in`)
    var (n,k) = scan.nextLine().split(" ").map{ it.trim().toInt() }.toTypedArray()
    var map = HashMap<Int,Int>()
    for(i in 1..n)
    {
        map.put(i,0)
    }

    for(i in 1..k)
    {
        var x = scan.nextLine().toInt()
        var arr = scan.nextLine().split(" ").map{ it.trim().toInt() }.toTypedArray()
        for(z in arr)
        {
            map.put(z, map.get(z)!! +1)
        }
    }

    var c = map.count {
        it.value==0
    }
    println(c)
}


Measured memory_bytes: 40620
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,k,num[200100];
bool che(int ip){
	int res=0;
	for(int i=1;i<=n;i++){
		if(num[i]==0)res+=(n-1)*(ip>=0);
		if(num[i]>0){
			if(num[i]*num[i]<=ip)res--;
			if(num[i]*num[1]>ip)continue;
			int l=1,r=n;
			while(l<r){
				int mid=(l+r+1)>>1;
				if(num[i]*num[mid]<=ip)l=mid;
				else r=mid-1;
			}
//			printf("%lld:>:%lld\n",i,l);
			res+=l;
		}
		if(num[i]<0){
			if(num[i]*num[i]<=ip)res--;
			if(num[i]*num[n]>ip)continue;
			int l=1,r=n;
			while(l<r){
				int mid=(l+r)>>1;
				if(num[i]*num[mid]<=ip)r=mid;
				else l=mid+1;
			}
//			printf("%lld:<:%lld\n",i,r);
			res+=n-r+1;
		}
	}
//	printf("%lld:%lld\n",ip,res);
	res>>=1;
	return res>=k;
}
signed main(){
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;i++)scanf("%lld",&num[i]);
	int l=-1e18,r=1e18;
	sort(num+1,num+n+1);
	while(l<r){
		int mid=(l+r)>>1;
		if(che(mid))r=mid;
		else l=mid+1;
	}
	printf("%lld\n",r);
	return 0;
}

Measured memory_bytes: 1792
H, W = map(int, input().split(" "))

area = [["." for _ in range(W+2)]]
for _ in range(H):
    line = [d for d in ("."+input()+".")]
    area.append(line)
area.append(["." for _ in range(W+2)])
    
def distinct(x,y):
    if area[y+1][x] == "#" or area[y-1][x] == "#" or \
        area[y][x+1] == "#" or area[y][x-1] == "#":
        return 0
    else:
        return 1
    
flg = 0
for y in range(1,H+1):
    for x in range(1,W+1):
        if area[y][x] == "#":
            if distinct(x,y) == 1:
                flg = 1
                break
    if flg == 1:
        break

if flg == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9080
#include <bits/stdc++.h>
using namespace std;
int main(){
int A, B, ans=0; cin >> A >> B;
if(A!=1&&B!=1){ ans=1; }
if(A!=2&&B!=2){ ans=2; }
if(A!=3&&B!=3){ ans=3; }
cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
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; }
using namespace std;

int h,w;
char grid[2010][2010];
int side[2010][2010],vert[2010][2010];

class UnionFindS{
private:
    vector<int> par;
public:
    UnionFindS(int n){
        par=vector<int>(n,-1);
    }
    int find(int x){
        if(par.at(x)<0) return x;
        else return par.at(x)=find(par.at(x));
    }
    int size(int x){
        return -par.at(find(x));
    }
    void unite(int x, int y){
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(size(x)<size(y)) swap(x,y);
        par.at(x)+=par.at(y);
        par.at(y)=x;
    }
    bool same(int x, int y){
        return find(x)==find(y);
    }
    void reset(int n){
        par=vector<int>(n,-1);
    }
};

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

    cin>>h>>w;
    rep(i,h)rep(j,w){
        cin>>grid[i][j];
    }

    UnionFindS uni(w);    
    rep(i,h){
        uni.reset(w);
        rep(j,w-1){
            if(grid[i][j]=='.' and grid[i][j+1]=='.'){
                uni.unite(j,j+1);
            }
        }
        rep(j,w){
            side[i][j]=uni.size(j);
        }
    }

    rep(i,w){
        uni.reset(h);
        rep(j,h-1){
            if(grid[j][i]=='.' and grid[j+1][i]=='.'){
                uni.unite(j,j+1);
            }
        }
        rep(j,h){
            vert[j][i]=uni.size(j);
        }
    }

    int ans=0;
    rep(i,h)rep(j,w){
        chmax(ans,side[i][j]+vert[i][j]-1);
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 67328
//Name: Maximum Sum Sequence II
//Level: 2
//Category: データ構造,累積和
//Note:

/**
 * 行列要素の累積和を求めておけば、任意の矩形に対して和をO(1)で計算できる。
 *
 * オーダーは O(N^4)。
 */
#include <iostream>
#include <vector>

using namespace std;

bool solve() {
    int N;
    if(!(cin >> N)) return false;
    if(!N) return false;

    vector<vector<long long>> v(N, vector<long long>(N));
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < N; ++j) {
            cin >> v[i][j];
        }
    }
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < N; ++j) {
            if(i > 0) v[i][j] += v[i-1][j];
            if(j > 0) v[i][j] += v[i][j-1];
            if(i > 0 && j > 0) v[i][j] -= v[i-1][j-1];
        }
    }
    long long ans = -100000;
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < N; ++j) {
            for(int k = i; k < N; ++k) {
                for(int l = j; l < N; ++l) {
                    long long sum = v[k][l];
                    if(i > 0) sum -= v[i-1][l];
                    if(j > 0) sum -= v[k][j-1];
                    if(i > 0 && j > 0) sum += v[i-1][j-1];
                    ans = max(ans, sum);
                }
            }
        }
    }
    cout << ans << endl;
    return true;

}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.setf(ios::fixed);
    cout.precision(10);

    while(solve()) ;
    return 0;
}

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

int main() {
    int x, y; cin >> x >> y;
    if (x == 1 && y == 1) cout << 1000000 << endl;
    else {
        cout << 100000 * (max(0, 4-x) + max(0, 4-y)) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

#define eps (1e-10)
struct Point{
    double x,y;
    Point(){}
    Point(double x,double y):x(x),y(y){}
    Point operator+(Point p) {return Point(x+p.x,y+p.y);}
    Point operator-(Point p) {return Point(x-p.x,y-p.y);}
    Point operator*(double k){return Point(x*k,y*k);}
    double norm(){return x*x+y*y;}
    double abs(){return sqrt(norm());}
    bool operator == (const Point &p) const{
    return fabs(x-p.x)<eps && fabs(y-p.y)<eps;
  }
  double dot(Point p){return x*p.x+y*p.y;}
  double det(Point p){return x*p.y-y*p.x;}
};

Point a[101];
int main(){
    int n,x,y;
    cin>>n;
    rep(i,n){
        cin>>x>>y;
        a[i]=Point(x,y);
    }
    double ans=0;
    rep(i,n){
        ans+=0.5*a[i].det(a[(i+1)%n]);
    }
    cout<<fixed<<setprecision(1)<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3300
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    map<string,int> vot;
    vector<string> sol;
    int max_num = -1;
    while(n--){
        string tmp;
        cin >> tmp;
        if(vot.count(tmp))vot[tmp]++;
        else vot[tmp] = 1;
        max_num = max(max_num,vot[tmp]);
    }
    for(auto x:vot){
        if(x.second == max_num)sol.emplace_back(x.first);
    }
    sort(sol.begin(),sol.end());
    for(auto x:sol)cout << x << endl;
}

Measured memory_bytes: 26868
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <map>

using namespace std;
typedef long long ll;
double N;
ll M;
string s;
vector<ll > input1;  
vector<vector <ll > > input2;

int main(){
    
    cin >> N;
    vector<pair<double, double > > aa;
    ll t = 0;
    for(int i = 0; i < 5; i++){
        cin >> t;
        aa.push_back(make_pair(t, i));
        
    } 
    sort(aa.begin(), aa.end());

    if(aa[0].first > N){
        cout << "5" << endl;
        return 0;
    }
    ll ans =  ceil(N / aa[0].first) + 4;
    
    cout << ans << endl;


} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;

vector<ll> ans;
ll V,E;
vector<ll> vec[10000];
vector<ll> che(10000,0);
vector<ll> path(10000,0);

void dfs(ll k){
  if(path[k] == 0){
    ans.push_back(k);
    for(auto itr:vec[k]){
      path[itr]--;
      dfs(itr);
    }
  }else{
    //path[k]--;
  }
}

int main(){
  cin >> V >> E;
  rep(i,E) {
    cin >> t1 >> t2;
    vec[t1].push_back(t2);
    che[t2]=1;
    path[t2]++;
  }
  rep(i,V){
    if(che[i] == 0){
      dfs(i);
    }
  }
  ull len = ans.size();
  rep(i,len){
    cout << ans[i] << endl;
  }
}


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

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

  if ((a != b && a != c && b != c) || (a == b && b == c && a == c))
    cout
        << "No";
  else
  {
    cout << "Yes";
  }
}


Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
long long n,a[100002],z,zs;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
      cin>>a[i];
    sort(a+1,a+n+1);
    z=1;
    for(int i=2;i<=n;i++)
    {
        if(a[i]==a[i-1])z=(z+1)%2;
        else zs+=z,z=1;
    }
    if(z%2)zs++;
    cout<<zs<<endl;
    return 0;
}

Measured memory_bytes: 1024