akhauriyash/Code-Regression huggingface dataset:
// start: 2013/07/11 3:12
// end: 2013/07/12 12:50
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <queue>

#define REP(i, n) for ( int i = 0; i < n; i++ )
#define INF INT_MAX

using namespace std;

class Rec {
public:
    int x;
    int y;
    int d;
    int cost;

    Rec( int xx, int yy, int dd, int s): x(xx), y(yy), d(dd), cost(s){}
};

bool operator< (const Rec& rec1, const Rec &rec2) {
    return rec1.cost > rec2.cost;
}
bool operator> (const Rec& rec1, const Rec &rec2) {
    return rec1.cost < rec2.cost;
}

int mx[4][4] = {{1, 0, -1, 0},
                {0, -1, 0, 1},
                {-1, 0, 1, 0},
                {0, 1, 0, -1}};
int my[4][4] = {{0, 1, 0, -1},
                {1, 0, -1, 0},
                {0, -1, 0, 1},
                {-1, 0, 1, 0}};

int main() {
    int w, h;

    while(cin >> w >> h, w||h) {
        // cout << w << " " << h << endl;
        priority_queue< Rec, vector<Rec>, less<vector<Rec>::value_type> > pq;

        vector< vector<int> > f(h, vector<int>(w));
        int closed[h][w][4];
        int COST[4];

        REP(y, h) REP(x, w) REP(i, 4) closed[y][x][i] = INF;

        REP(y, h) REP(x, w) cin >> f[y][x];
        REP(i, 4) cin >> COST[i];

        // dump(f);

        pq.push( Rec(0, 0, 0, 0));

        closed[0][0][0] = 0;

        while(!pq.empty()) {

            Rec tmp = pq.top(); pq.pop();
            int x = tmp.x,
                y = tmp.y,
                d = tmp.d,
                cost = tmp.cost,
                o = f[y][x];

            // printf("n:%d %d %d: %d\n", x, y, d, (0 <= x && x < w && 0 <= y && y < h));

            // ゴール
            if ( x == w-1 && y == h-1 ) {
                cout << cost << endl;
                break;
            }

            int nx = x + mx[d][o],
                ny = y + my[d][o],
                nd = (d+o) % 4;

            // マス目移動
            if ( o != 4 && 0 <= nx && nx < w && 0 <= ny && ny < h && cost < closed[ny][nx][nd] ) pq.push( Rec(nx, ny, nd, cost) );

            // 命令出す
            REP(i, 4) {
                if ( i == o ) continue; // マス目の命令と同じ

                int nx = x + mx[d][i],
                    ny = y + my[d][i],
                    nd = (d+i)%4;

                if ( 0 <= nx && nx < w && 0 <= ny && ny < h && cost+COST[i] < closed[ny][nx][nd] ) {
                    pq.push( Rec(nx, ny, nd, cost+COST[i]) );
                    closed[ny][nx][nd] = cost+COST[i];
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1356
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;

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


ll power(ll a, ll b, ll m){
    ll ret = 1;
    while(b){
        if(b & 1) ret = (ret * a) % m;
        a = (a * a) % m;
        b /= 2;
    }
    return ret;
}


ll power(int a, ll b) {
    return power(a, b, MOD);
}

int main(){
    int n, m; cin >> n >> m;
    cout << power(n, m) << endl;
    return 0;
}



Measured memory_bytes: 3116
import java.util.*;

public class Main {
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);


        int n = sc.nextInt();
        int m = sc.nextInt();

        List<Integer> num1 = new ArrayList<>();
        List<Integer> num2 = new ArrayList<>();


        for (int i = 0; i < m; i++){

            num1.add(sc.nextInt());
            num2.add(sc.nextInt());
        }
        int max_num = Collections.max(num1);
        int min_num = Collections.min(num2);

        if (max_num <= min_num){
            System.out.println(min_num - max_num + 1);
        }else{
            System.out.println(0);
        }

    }
}


Measured memory_bytes: 82156
#include<bits/stdc++.h>
using namespace std;
int n, m, ans;
const int M = 6001;
int dp[6005][12005];
int inc(int x, int y){
    return x + y >= m ? x + y - m : x + y;
}
int main(){
    cin >> n >> m; n = n * 3;
    dp[0][M] = 1;
    for(int i = 0; i <= n; i++)
        for(int j = -i; j <= i; j++){
            dp[i + 1][j + 1 + M] = inc(dp[i + 1][j + M + 1], dp[i][j + M]);
            dp[i + 2][j - 1 + M] = inc(dp[i + 2][j + M - 1], 1ll * dp[i][j + M] * (i + 1) % m);
            dp[i + 3][j + M] = inc(dp[i + 3][j + M], 1ll * dp[i][j + M] * (i + 1) % m * (i + 2) % m); 
        } 
   //cout << dp[3][0 + M] << endl;
   for(int i = 0; i <= n ; i++){
        ans = inc(ans, dp[n][i + M]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 279936
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;

#define M 1046527
long long T[M];

class Hash
{
	long long key;
	void getKey(char *p);
	int h1() { return key % M; }
	int h2() { return 1 + (key % (M - 1)); }
	int h(int i) { return (h1() + i*h2()) % M; }
public:
	void insert(char *str);
	bool find(char *str);
};

void Hash::getKey(char *p)
{
	key = 0;
	for (int i = (strlen(p) - 1); i >= 0; i--) {
		int x = p[i] % 9;
		key += x * pow(10, i);
	}
}

void Hash::insert(char *str)
{
	getKey(str);
	int i = 0;
	while (1) {
		int j = h(i);
		if (!T[j]) {
			T[j] = key;
			return;
		}
		else if (T[j] == key) return;
		else i++;
	}
}

bool Hash::find(char *str)
{
	getKey(str);
	int i = 0;
	while (1) {
		int j = h(i);
		if (T[j] == key) return 1;
		else if (!T[j]) return 0;
		else i++;
	}
}



int main()
{
	Hash H;
	int n;
	char order[10], word[15];
	scanf("%d", &n);

	for (int i = 0; i < n; i++) {
		scanf("%s %s", order, word);
		switch (order[0])
		{
		case 'i':
			H.insert(word); 
			break;
		case 'f':
			if (H.find(word)) printf("yes\n");
			else printf("no\n");
			break;
		default:
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 9396
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#define int long long
using namespace std;

int a[100000], b[100000], c[100000];
signed main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < n; i++) {
		c[i] = a[i] - b[i];
	}
	int sum = 0, ans = 0;
	for (int i = 0; i < n; i++) {
		if (c[i] < 0) {
			sum += -(c[i]);
			ans++;
		}
	}
	sort(c, c + n);
	reverse(c, c + n);
	for (int i = 0; i < n; i++) {
		if (sum <= 0)break;
		if (c[i] <= 0)break;
		ans++;
		sum -= c[i];
	}
	if (sum <= 0)cout << ans << endl;
	else puts("-1");
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define ll long long 
#define rep(i,a,b) for(ll i=a; i<b; ++i)
#define BOOST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(v) v.begin(),v.end()
#define sl(a) a.size()
#define mod 1000000007 
#define lcm(a,b) (a*b)/__gcd(a,b)
#define MAX 10000003
using namespace std;
ll count(ll arr[], ll n, ll i, ll k, vector<ll> &dp)
{
    if(i>=n-1) return 0;
    if(dp[i]!=-1) return dp[i];
    if(i<n-k and n>=k) 
    {
        ll m=INT_MAX;
        rep(j,1,k+1)
        {
            m=min(m,abs(arr[i+j]-arr[i])+count(arr,n,i+j,k,dp));
        }return dp[i]=m;
    }
    return dp[i]=abs(arr[n-1]-arr[i]);
}
void solve()
{
    ll n,k;  cin>>n>>k;
    ll arr[n];
    vector<ll> dp(n+1,-1);
    rep(i,0,n)  cin>>arr[i];
    cout<<count(arr,n,0,k,dp);
}
int main()
{
    BOOST
    int T=1;  //cin>>T;
    while(T--) solve();
    return 0;
}

Measured memory_bytes: 14248
from collections import deque

N = int(input())
adj = [[] for i in range(N)]
for _ in range(N-1):
    u, v, w = map(int, input().split())
    adj[u-1].append((v-1,w))
    adj[v-1].append((u-1,w))

color = [0]*N
visited = [0]*N
visited[0] = 1
q = deque()
q.append((0,0))

while q:
    v, l = q.pop()
    visited[v] = 1
    if l % 2 == 1:
        color[v] = 1
    for u, w in adj[v]:
        if not visited[u]:
            q.append((u, l+w))

for i in range(N):
    print(color[i])


Measured memory_bytes: 72608
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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; }



int main() {
  int n, k;
  cin >> n >> k;
  cout << n - k + 1 << endl;


  
  return 0;
}

Measured memory_bytes: 256
x,y = map(int,input().split())	

ansli=[]
for i in range (x * 2 - 1):
    ans = y - x + i + 1
    if (ans <= 1000000 and ans >= -1000000):
        ansli.append(ans)

for i in range(len(ansli)):
    print(ansli[i], end = "")
    if i != len(ansli) -1:
        print(" ", end="")
print("")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;
int v[100100];
int ev[100100]={};
int ov[100100]={};

int main(){
	cin>>n;
	REP(i,n)
		cin>>v[i];
	
	for(int i=0;i<n;i+=2){
		ev[v[i]]++;
	}
	for(int i=1;i<n;i+=2){
		ov[v[i]]++;
	}
	
	int me1=ev[0]>ev[1]?0:1,me2=ev[0]>ev[1]?1:0;
	int mo1=ov[0]>ov[1]?0:1,mo2=ov[0]>ov[1]?1:0;
	
	for(int i=2;i<100100;i++){
		if(ev[me1]<=ev[i]){
			me2=me1;
			me1=i;
		}else if(ev[me2]<=ev[i]){
			me2=i;
		}
	}
	//cout<<ov[mo1]<<" "<<mo2<<endl;
	for(int i=2;i<100100;i++){
		
		if(ov[mo1]<=ov[i]){
			mo2=mo1;
			mo1=i;
		}else if(ov[mo2]<=ov[i]){
			mo2=i;
		}
	}
	
	if(me1!=mo1){
		cout<<n-ev[me1]-ov[mo1]<<endl;
		//cout<<me1<<" "<<mo1<<endl;
	}else{
		int t=min(n-ev[me1]-ov[mo2],n-ev[me2]-ov[mo1]);
		cout<<t<<endl;
	}
	return 0;
}

Measured memory_bytes: 1408
import collections
N,P = map(int,input().split())


def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n //= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table
  
if __name__ == '__main__':

    lst = prime_decomposition(P)
    cout = collections.Counter(lst)
    ans = 1
    for p in cout.items():
        if p[1]>= N:
            ans = ans * (p[0] ** (p[1] // N))
    print(ans)

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

  int n,max=0;

  cin>>n;

  string str;


  cin>>str;

  for(int i=0;i<str.length();i++){
    int cnt=0;
    int ans[26]={ };
    int ans1[26]={ };
    for(int j=0;j<i;j++){
      ans[str[j]-'a']=1;
    }
    for(int j=i;j<str.length();j++){
      ans1[str[j]-'a']=1;
    }

    for(int j=0;j<26;j++){
      if(ans[j]==1&&ans1[j]==1){
	cnt++;
      }
    }

    if(cnt>max){
      max=cnt;
    }
  }

  cout<<max<<endl;

  return 0;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>

using namespace std;
#define N 501

int main(){
    int n;
    double p[N],q[N];
    double pSum[N][N],qSum[N][N];
    double d[N][N];
    double t;
    
    cin >> n;
    
    for(int i = 0;i < n;++i){
        cin >> p[i];
    }
    
    for(int i = 0;i < n + 1;++i){
        cin >> q[i];
        d[i][i] = q[i];
    }
    
     // p
    for(int i = 0;i < n;++i){
        pSum[i][i] = p[i];
        for(int j = i + 1;j < n;++j){
            pSum[i][j] = pSum[i][j - 1] + p[j];
        }
    }
    
    // q
    for(int i = 0;i < n + 1;++i){
        qSum[i][i] = q[i];
        for(int j = i + 1;j < n + 1;++j){
            qSum[i][j] = qSum[i][j - 1] + q[j];
        }
    }
    
    for(int i = 1;i < n + 1;++i){
        for(int j = 0;j < (n + 1) - i;++j){
            d[j][j + i] = __DBL_MAX__;
            for(int k = 0;k < i;++k){
                t = d[j][j + k] + d[j + k + 1][j + i] + pSum[j][j + i - 1] + qSum[j][j + i];
                d[j][j + i] = min(d[j][j + i], t);
            }
        }
    }
    
    printf("%.8lf \n",d[0][n]);
    
    return 0;
}




Measured memory_bytes: 9088
n = int(input())
lst = [[0 for j in range(10)] for i in range(10)]

for i in range(1, n+1):
    num = str(i)
    lst[int(num[0])][int(num[-1])] += 1

cnt = 0
for i in range(10):
    for j in range(i, 10):
        if i == j:
            cnt += lst[i][j] * lst[j][i]
        else:
            cnt += lst[i][j] * lst[j][i] * 2
print(cnt)

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

int main(void)
{
    ll W, H, x, y;
    cin >> W >> H >> x >> y;

    double area = W * H;
    double centX = W * 0.5;
    double centY = H * 0.5;

    if(W%2 == 0 && H % 2== 0 && x == W/2 && y == H/2){
        cout <<fixed << setprecision(10) << area * 0.5 << ' ' << 1 << endl;
    } else {
         cout <<fixed << setprecision(10)<< area * 0.5 << ' ' << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n;
  R n;
  string s[n];
  rep(i,n) R s[i];
  string t;
  R t;
  int x,y;
  {
    vector<string> v;
    rep(i,n) {
      string r=s[i];
      rep(j,r.size()) if(r[j]=='?') r[j]='z';
      v.pb(r);
    }
    sort(all(v));
    x=lower_bound(all(v),t)-v.begin();
  }
  {
    vector<string> v;
    rep(i,n) {
      string r=s[i];
      rep(j,r.size()) if(r[j]=='?') r[j]='a';
      v.pb(r);
    }
    sort(all(v));
    y=upper_bound(all(v),t)-v.begin();
  }
  REP(i,x,y+1) {
    if(i!=x) cout << " ";
    cout << i+1;
  }
  ln;
}

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


Measured memory_bytes: 1460
import sys
input = sys.stdin.readline

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
  
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
  
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

def print_bit(B):
    n = B.size
    ANS = []
    for i in range(n):
        ANS.append(B.sum(i+1) - B.sum(i))
    print(*ANS)


l = 10000
ll = 100
q = int(input())
Q = [list(map(int,input().split())) for i in range(q)]

from random import randint
# q = 20
# Q = []
# for i in range(q//2):
#     Q.append([1, randint(-ll,ll), randint(-ll,ll)])
#     Q.append([2])
# Q = [[1, 6, -10], [2], [1, -7, -3], [2], [1, 1, 6], [2], [1, 6, 10], [2], [1, -6, 9], [2]]
# print(Q)

A = []
for i in range(q):
    if Q[i][0] == 1:
        A.append((Q[i][1], i))
A.sort()
D = {}
for i in range(len(A)):
    D[A[i]] = i+1

B = Bit(len(D) + 2)
# print(D)
# print("A",A)

asum = 0
bsum = Q[0][2]
m_ind = D[(Q[0][1], 0)]
B.add(D[(Q[0][1], 0)], 1)
ok_a = 1
for i in range(1, q):
    if Q[i][0] == 2:
        # print("m_ind",m_ind)
        print(A[m_ind-1][0], asum+bsum)
    else:
        bsum += Q[i][2]
        B.add(D[(Q[i][1], i)], 1)
        # print_bit(B)
        if ok_a % 2 == 0 and D[(Q[i][1], i)] > m_ind:
            ng = 0
            ok = len(D)+2
            m = (ok+ng) // 2
            while abs(ok-ng) > 1:
                if B.sum(m) >= ok_a//2 + 1:
                    ok = m
                else:
                    ng = m
                m = (ok+ng) // 2
            m_ind = ok
        elif ok_a % 2 == 1 and D[(Q[i][1], i)] < m_ind:
            ng = 0
            # print("ok_a", ok_a)
            
            ok = len(D)+2
            m = (ok+ng) // 2
            while abs(ok-ng) > 1:
                if B.sum(m) >= ok_a//2 + 1:
                    ok = m
                else:
                    ng = m
                m = (ok+ng) // 2
            # print(ok,m_ind)
            asum += abs(A[ok-1][0]-A[m_ind-1][0])
            m_ind = ok
            
        asum += abs(Q[i][1]-A[m_ind-1][0])
        ok_a += 1


# A1 = []
# b1 = 0
# for i in range(q):
#     if Q[i][0] == 1:
#         A1.append(Q[i][1])
#         b1 += Q[i][2]
#     else:
#         ans = float("inf")
#         ansind = 0
#         for i in range(-l, l+1):
#             ans0 = b1
#             for j in range(len(A1)):
#                 ans0 += abs(A1[j]-i)
#             if ans0 < ans:
#                 ansind = i
#                 ans = ans0
#         print(ansind, ans)


Measured memory_bytes: 171056
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }


int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a == c)cout << b << endl;
  else if(a == b)cout << c << endl;
  else if(b == c)cout << a << endl;
}


Measured memory_bytes: 256
H,W=map(int, input().split()) 
S=[[0 for _ in range(W+2)] for _ in range(H+2)]
for i in range(H):
  S[i+1]= ["#"] + list(input()) + ["#"]
for j in range(W+2):
  S[0][j]="#"
  S[-1][j]="#"
  
t=[[-1 for _ in range(W)] for _ in range(H)]
y=[[-1 for _ in range(W)] for _ in range(H)]

for i in range(H):
  for j in range(W):
    if S[i+1][j+1]==".":
      if t[i][j]==-1:
        k=1
        while True:
          if S[i+k+1][j+1]==".":
            k +=1
          else:
            break
        for l in range(k):
          t[i+l][j]=k       
      if y[i][j]==-1:
        m=1
        while True:
          if S[i+1][j+1+m]==".":
            m +=1
          else:
            break
        for n in range(m):
          y[i][j+n]=m       

maxi=0          
for i in range(H):
  for j in range(W):
    maxi=max(maxi, t[i][j]+y[i][j])
print(maxi-1)

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

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

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)



int main() {
	ll N;
	cin >> N;
	ll A[N];
	rep(i,0,N) cin >> A[i];

	ll dp[100000] = {};
	ll cur[3] = {};
	rep(i,0,N) {
		bool used = false;
		rep(j,0,3) {
			if (cur[j] == A[i]) {
				dp[i]++;
				if (!used) {
					cur[j]++;
					used = true;
				}
			}
		}
	}
	ll ans = 1;
	rep(i,0,N) {
		// cout << dp[i] << " ";
		ans = (ans * dp[i]) % mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
a, b, c = [int(i) for i in input().split(" ")]
 
ab = a == b
bc = b == c
ca = c == a
 
cnt = 0
for r in [ab, bc, ca]:
  if r:
    cnt += 1

if cnt == 1:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9108
import java.io.*;
import java.util.*;
public class Main{
	public static void main(String args[]) throws IOException{
               BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));	
		String[] lo = reader.readLine().split(" ");
		int X = Integer.parseInt(lo[0]);		
		int Y = Integer.parseInt(lo[1]);
		if((Y-2*X)%2==0 && (Y-2*X)>=0 && (Y-2*X)/2 <= X){
			System.out.println("Yes");
		}
		else System.out.println("No");	
	}
}


Measured memory_bytes: 32852
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <numeric>
#include <limits>
#include <type_traits>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main () {
	int n;
	cin >> n;
	vector <char> s(n);
	vector <char> a;
	rep(i,n) {cin >> s[i];}
	a.push_back(s[0]);
	for(int i =1; i<n;i++) {
		if (s[i] != s[i-1]) {
			a.push_back(s[i]);
		}
	}
	cout << a.size() << endl;
}

Measured memory_bytes: 888
n=int(input())
c=list(range(1,1+2*n))
for _ in[0]*int(input()):
    k=int(input())
    if k:c=c[k:]+c[:k]
    else:
        for a,b in zip(c[:n],c[n:]):
            c+=[a,b]
        c=c[2*n:]
for x in c:print(x)


Measured memory_bytes: 5624
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();
        boolean isShiritoriA = false;
        boolean isShiritoriB = false;
        isShiritoriA = a.substring(a.length() - 1).equals( b.substring(0, 1) ) ? true : false;
        isShiritoriB = b.substring(b.length() - 1).equals( c.substring(0, 1) ) ? true : false;
        if (isShiritoriA && isShiritoriB) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 21844
N = int(input())

# 各Kに対する約数の個数を出す

l = [0]*(N+1)

for i in range(1,N+1):
    for j in range(i, N+1, i):
        l[j] += 1
ans = 0
for i in range(1,N+1):
    ans += i * l[i]
print(ans)

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

using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n],dp[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for(int i=2;i<n;i++){
		dp[i]=min(dp[i-2]+abs(a[i-2]-a[i]),dp[i-1]+abs(a[i-1]-a[i]));
	}
	cout<<dp[n-1]<<endl;
	
}


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

using namespace std;

typedef long long ll;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

const int N = 87;

int a[N][N], b[N][N];
int dp[N][N][3 * N * N];

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> b[i][j];
        }
    }
    dp[0][0][a[0][0] - b[0][0] + N * N] = true;
    dp[0][0][b[0][0] - a[0][0] + N * N] = true;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (i == 0 && j == 0) {
                continue;
            }
            for (int v = 0; v < 3 * N * N; v++) {
                int tx = a[i][j] - b[i][j];
                int ty = b[i][j] - a[i][j];
                int upd_x = v - tx;
                int upd_y = v - ty;
                if (upd_x >= 0 && upd_x < 3 * N * N) {
                    if (i > 0) {
                        dp[i][j][v] |= dp[i - 1][j][upd_x];
                    }
                    if (j > 0) {
                        dp[i][j][v] |= dp[i][j - 1][upd_x];
                    }
                }
                if (upd_y >= 0 && upd_y < 3 * N * N) {
                    if (i > 0) {
                        dp[i][j][v] |= dp[i - 1][j][upd_y];
                    }
                    if (j > 0) {
                        dp[i][j][v] |= dp[i][j - 1][upd_y];
                    }
                }
            }
        }
    }
    int ans = N * N * N;
    for (int v = 0; v < 3 * N * N; v++) {
        if (dp[n - 1][m - 1][v]) {
            ans = min(ans, abs(v - N * N));
        }
    }
    if (ans > 80) {
        assert(0);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 618752
#include<stdio.h>
int main()
{
	int A,B,C;
	scanf("%d %d %d",&A,&B,&C);
	if(A == 5&&B == 5&&C == 7)
	{
		printf("YES");
	}
	else if(A == 5&&B == 7&&C == 5)
	{
		printf("YES");
	}
	else if(A == 7&&B == 5&&C == 5)
	{
		printf("YES");
	}
	else printf("NO");
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
using namespace std;
#define INF 0x3f3f3f
const int maxn = 205;
int a[maxn];
int main()
{
    int n, l;
    cin >> n >> l;
    int sum = 0;
    for(int i = 0; i < n; i++){
        a[i] = l + i;
        sum += a[i];
    }
    if(l >= 0){
        cout << sum - a[0] << endl;
    }
    else if(l < 0 && l + n - 1 >= 0){
        cout << sum << endl;
    }
    else{
        cout << sum - a[n-1] << endl;
    }
    return 0;
}



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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;


int main() {
    string s; cin >> s;
    int n = (int)s.size();
    if(s[n - 1] == 's') {
        cout << s + "es" << endl;
    }else{
        cout << s + 's' << endl;
    }

    return 0;
}


Measured memory_bytes: 3628
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

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")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let n:usize = read();
    let m:usize = read();
    let mut map = HashMap::new();
    for _ in 0..n {
        let k:usize = read();
        let a:Vec<u32> = (0..k).map(|_| read()).collect();
        for i in 0..k {
            let cnt = map.entry(a[i]).or_insert(0);
            *cnt+=1;
        }
    }

    println!("{}",
        map.iter().filter(|&(_k,v)| *v as u32==n as u32).count()
    );

}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb push_back
#define REP(i, a, b)  for(int i = (a), i##end = (b); i < i##end; ++i)
#define DREP(i, a, b) for(int i=(a-1), i##end = (b); i >=i##end; --i)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int N = 100000;
const int oo = 0x3f3f3f3f;
 
template<typename T> T read() {
    T n(0), f(1);
    char ch = getchar();
    for( ;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for( ; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48; 
    return n * f;
}
 
LL fpm(LL a, LL b, LL mod) {
    LL res = 1;
    for(; b > 0; b >>= 1) {
        if(b & 1)
            res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}
 
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
 
LL exgcd(int a, int b, LL& x, LL& y) {
    if(!b) {
        x = 1;
        y = 0;
        return a;
    }
 
    LL g = exgcd(b, a % b, y, x);
    y -= (a / b) * x;
 
    return g;
}
 
int phi(int n) {
    int res = n;
    for(int i = 2; i * i <= n; ++i) if(n % i == 0) {
        res = res / i * (i - 1);
        while(n % i == 0) n /= i;
    }
    if(n > 1) res = res / n * (n - 1);
    return res;
}
 
LL solve(int a, int m) {
    if(m <= 500) {
        int x = a;
        for(int i = 1; ; i++) {
            if(x == i % m) return i;
            x = 1LL * x * a % m;
        }
    }
    
    int p = phi(m);
    int r = gcd(m, p);
    LL t = solve(a, r), a_t = fpm(a, t, m), x, y, l = p / r;
 
    exgcd(m / r, p / r, x, y);
 
    x *= (((t - a_t) % p + p) % p) / r;
    x = (x % l + l) % l + l;
    LL res = x * m + a_t;

    return res;
}
 
void write(LL x) {
    if(x) { 
        write(x / 10);
        putchar(x % 10 + '0');
    }
}
 
int main() {
#ifdef Wearry
    freopen("data.txt", "r", stdin);
    freopen("ans.txt", "w", stdout);
#endif
 
    for(int T = read<int>(); T--; ) {
        static int a, m;
        a = read<int>();
        m = read<int>();
        LL k = solve(a, m);
        write(k); putchar(10);
    }
 
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a,b[100],c=0;
	cin>>a;
	for(int i=1;i<=a;i++){
		cin>>b[i];
		if(b[i]!=i)
			c++;
	}
	if(c==2||c==0)
		cout<<"YES";
	else
		cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
while True:
     (H, W) = [int(x) for x in input().split()]
     if H == W == 0:
         break
    
     for hc in range(H):
            for wc in range(W):
                  if (hc + wc) % 2 == 0:
                       print('#', end='')
                  else:
                       print('.',end='')
            print()
     print()

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

ll f(ll b, ll n) {
	if (n < b) {
		return n;
	}
	else {
		return f(b, n / b) + n%b;
	}
}

int main() {
	ll n, s, i, j;
	cin >> n >> s;
	if (s == n) {
		cout << n + 1 << endl;
		return 0;
	}
	for (i = 2; i <= sqrt(n)+1; i++) {
		if (f(i, n) == s) {
			cout << i << endl;
			return 0;
		}
	}
	if (n - s <= 0) {
		cout << -1 << endl;
		return 0;
	}
	for (i = sqrt(n)+1; i >= 1; i--) {
		if ((n - s) % i) {
			continue;
		}
		ll b = (n - s) / i + 1;
		if (b >= 2) {
			if (f(b, n) == s) {
				cout << b << endl;
				return 0;
			}
		}
	}
	cout << -1 << endl;
	return 0;
	
}

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

int main() {
  set<int> S;
  for (int i = 0; i < 3; i++) {
    int N;
    cin >> N;
    S.insert(N);
  }
  cout << ((S.size() == 2) ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 256
n=int(input())
ans=0
D=[]
A=[]
for i in range(n):
  a,b=map(int, input().split())
  D.append([a,b])


for i in range(len(D)):
  if D[i][0]==D[i][1]:
    ans +=1
  else:
    if ans>0:
      ans = 0
  A.append(ans)
  
if max(A) >= 3:
  print("Yes")
  
else:
  print("No")

Measured memory_bytes: 9224
#include <cstdio>
#include <iostream>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

typedef long long ll;
int main(void) {
  int n, h, w;
  cin >> n >> h >> w;
  int res = 0;
  REP(i, n) {
    int a, b;
    cin >> a >> b;
    if(a >= h && b >= w) {
      ++res;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>
#include <cctype>
#include <climits>

#define MAX_SIZE 100000000
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

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

  ull X,Y; cin>>X>>Y;
  ull now = X;
  ull next = X;
  ull cnt = 0;
  while(next <= Y) {
    cnt++;
    now = next;
    next *= 2;
  }

  cout << cnt << endl;
}


Measured memory_bytes: 256
// 中間試験、期末試験のいずれかを欠席した場合成績は F。
// 中間試験と期末試験の合計点数が 80 以上ならば成績は A 。
// 中間試験と期末試験の合計点数が 65 以上 80 未満ならば成績は B。
// 中間試験と期末試験の合計点数が 50 以上 65 未満ならば成績は C。
// 中間試験と期末試験の合計点数が 30 以上 50 未満ならば成績は D。 ただし、再試験の点数が 50 以上ならば成績は C。
// 中間試験と期末試験の合計点数が 30 未満ならば成績は F。

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            while(true) {
                String[] arr = br.readLine().split(" ");
                int m = Integer.parseInt(arr[0]), f = Integer.parseInt(arr[1]), r = Integer.parseInt(arr[2]);
                if(m==-1 && f==-1 && r==-1){
                    break;
                }
                int total = m+f;
                if ((m==-1 || f==-1) || total<30) {
                    System.out.println("F");
                } else if (total>=80) {
                    System.out.println("A");
                } else if (total>=65 && total<80) {
                    System.out.println("B");
                } else if (total>=50 && total<65) {
                    System.out.println("C");
                } else if (total>=30 && total<50) {
                    if(r>=50) {
                        System.out.println("C");
                    } else {
                        System.out.println("D");
                    }
                }
            }
        } catch(IOException e) {
            e.printStackTrace();
        }
    }
}



Measured memory_bytes: 24140
use std::io::*;//Not mine.
use std::str::FromStr;
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:i64 = read();
    println!("{}",a + a * a + a * a * a);
}

Measured memory_bytes: 2116
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] rate = new int[9];
        for (int i = 0; i < n; i++) {
            int r = sc.nextInt();
            for (int j = 8; j >= 0; j--) {
                if(r >= 400 * j){
                    rate[j]++;
                    break;
                }
            }
        }
        int var = 0;
        for (int i = 0; i < 8; i++) {
            if(rate[i] > 0) var++;
        }

        System.out.print(Math.max(var, 1) + " ");
        System.out.println(var + rate[8]);
        sc.close();
    }

}


Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

#define all(x) begin(x),end(x)

using namespace std;
using ll = long long;

int main()
{
	vector<int> A(5);
	for (int i = 0; i < 5; ++i)
		cin >> A[i];
	int last = 9;
	int index = 0;
	int ll = 0;
	for (int i = 0; i < 5; ++i) {
		if (A[i] % 10 != 0 && A[i] % 10 < last) {
			last = A[i] % 10;
			index = i;
			ll = A[i];
		}
	}
	if (ll == 0) {
		index = 4;
		ll = A[4];
	}

	int time = 0;
	for (int i = 0; i < 5; ++i) {
		if (index == i)
			continue;
		int tmp = A[i];
		if (tmp % 10 != 0) {
			int t = tmp % 10;
			int s = 10 - t;
			A[i] += s;
		}
		time += A[i];
	}
	time += ll;
	cout << time << endl;
}



Measured memory_bytes: 256
/*
      author  : nishi5451
      created : 14.08.2020 20:03:48
*/

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


int main(){
    int h,w;
    cin >> h >> w;
    vector<bool> y(h,true),x(w,true);
    vector<string> a(h);
    rep(i,h) cin >> a[i];
    rep(i,h){
        rep(j,w){
            if(a[i][j]!='.') y[i]=false;
        }
    }
    rep(i,w){
        rep(j,h){
            if(a[j][i]!='.') x[i]=false;
        }
    }
    rep(i,h){
        rep(j,w){
            if(y[i] || x[j]) continue;
            cout << a[i][j];
        }
        if(!y[i])
            cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3652
W, H, N = map(int, input().split())

b = 0
t = H
l = 0
r = W

for i in range(N):
  x, y, a = map(int, input().split())
  if a==1:
    l = max(l, x)
  elif a==2:
    r = min(r, x)
  elif a==3:
    b = max(b, y)
  else:
    assert a==4
    t = min(t, y)
print( max(t-b, 0) * max(r-l, 0) )

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

const int N = 15;

char str[N];

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	
	cin >> str;
	
	int len = strlen(str);
	char tmp = 'h';
	bool flag = true, ok = true;
	
	if (len & 1) ok = false;
	
	for (int i = 0; i < len && ok; ++i)
	{
		if (flag && str[i] == tmp)
		{
			flag = false;
			tmp = 'i';
		}
		else if (!flag && str[i] == tmp)
		{
			flag = true;
			tmp = 'h';
		}
		else ok = false;
	}

	if (ok) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}


Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):                                          # 根を見つける関数を定義（同時にxを直接根にくっつける操作も行う）
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])        # 右辺で再帰的に根を探索。根に到達すると一つ目のif判定に引っかかるので、
                                                                # 最終的にself.parents[根]が返ってくる。
                                                                # これを左辺に代入することで、根が親になるように変更する。（根までの距離が長いとO(N)になってしまうので）
            return self.parents[x]

    def union(self, x, y):                                      # 二つの木をくっつける（子を多く持つ方を根とした親子関係）。これは破壊的操作を行う。
        x = self.find(x)                                        # xをxの根に置き換える
        y = self.find(y)                                        # yをyの根に置き換える

        if x == y:                                              # 根が同じなら置き換える必要なし
            return

        if self.parents[x] > self.parents[y]:                   # 子がたくさんある方を x とする（出来るだけ浅い木にするため）
            x, y = y, x

        self.parents[x] += self.parents[y]                      # xの子の数を更新
        self.parents[y] = x                                     # yの親を更新

    def same(self, x, y):                                       # xとyが同じ根の子かを判定
        return self.find(x) == self.find(y)

    def size(self, x):                                          # xの根のparent（= 要素数）を返す
        return -self.parents[self.find(x)]

    def members(self, x):                                       # xが属するグループの要素をリストとして返す
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):                                            # 全ての根の要素をリストとして返す
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):                                      # グループの数を返す
        return len(self.roots())

    def all_group_members(self):                                # {根:[根の子のリスト],...}を辞書で返す
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):                                          # print(self) での返し方を定義
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


##############################################################################################################
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
U = UnionFind(N)
for _ in range(M):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    U.union(a, b)
print(-min(U.parents))

Measured memory_bytes: 77616
def main():
	N = int(input())
	a = list(map(int, input().split()))
	
	a_lst = [0] * (10 ** 5 + 1)
	for num in a:
		a_lst[num] += 1

	ans = 0
	for X in range(10 ** 5 + 1):
		cnt = 0

		if X == 0:
			cnt += a_lst[X]
			cnt += a_lst[X + 1]
		elif X == 10 ** 5:
			cnt += a_lst[X - 1]
			cnt += a_lst[X]
		else:
			cnt += a_lst[X - 1]
			cnt += a_lst[X]
			cnt += a_lst[X + 1]

		if cnt > ans:
			ans = cnt

	print(ans)



 
if __name__ == "__main__":
  	main()

Measured memory_bytes: 20872
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <vector>
#include <queue>
#include <unordered_map> 
#include <iomanip>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF (INT_MAX/3)
#define PSB push_back
#define PN 1000000007
typedef long long LL;
//#define int long long


//booooooooooooost
//#include <boost/multiprecision/cpp_int.hpp>
//#include <boost/multiprecision/cpp_dec_float.hpp>
//namespace mp = boost::multiprecision;	//多倍長整数(mp::cpp_int), 多倍長小数(mp::cpp_dec_float_100)



LL inv_mod(LL a, LL m)
{
	LL b, x, u, q, tmp;

	b = m; x = 1; u = 0;
	while (b > 0) {
		q = a / b;
		tmp = u; u = x - q * u; x = tmp;
		tmp = b; b = a - q * b; a = tmp;
	}

	return (x < 0) ? m + x : x;
}



signed main() {

	LL N;
	vector<LL> T, A, B;
	cin >> N;
	REP(i, N) {
		LL tmp;
		cin >> tmp;
		T.PSB(tmp);
	}
	REP(i, N) {
		LL tmp;
		cin >> tmp;
		A.PSB(tmp);
	}

	B.assign(N, 0);

	LL tmp = 0;
	REP(i, N) {
		if (tmp < T[i]) {
			tmp = T[i];
			B[i] = tmp;
		}
	}
	tmp = 0;
	for (LL i = N - 1; 0 <= i; --i) {
		if (tmp < A[i]) {
			if (B[i] == 0 || B[i] == A[i]) {
				tmp = A[i];
				B[i] = tmp;
			}
			else {
				cout << 0 << endl;
				return 0;
			}
		}
	}
	REP(i, N) {
		if (B[i] > T[i] || B[i] > A[i]) {
			cout << 0 << endl;
			return 0;
		}
	}

	LL ans = 1;

	tmp = 0;
	for(LL i = 1; i < N; ++i) {
		if (B[i] != 0) {
			LL diff = min(B[i], B[tmp]);
			LL p = i - tmp - 1;
			tmp = i;


			REP(j, p) {
				ans *= diff;
				ans %= PN;
			}
		}
	}

	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 2804
N, M = map(int, input().split())
res = 0
c_list = [-1 for i in range(N)]

for i in range(M):
  s, c = map(int, input().split())

  if c_list[s - 1] != -1 and c_list[s - 1] != c:
    res = -1
  elif N != 1 and s == 1 and c == 0:
    res = -1
  else:
    c_list[s - 1] = c

if res == -1:
  pass
else:
  res = ''
  for i in range(N):
    if c_list[i] == -1:
      res += '0'
    else:
      res += str(c_list[i])

  if N != 1 and res[0] == '0':
    res = '1' + res[1::]

print(int(res))

Measured memory_bytes: 38384
#include<stdio.h>

int main(){
  int W,H,x,y,r;
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
  if(x+r<=W && y+r<=H && x-r>=0 && y-r>=0) printf("Yes\n");
  else printf("No\n");
  return 0;

}

Measured memory_bytes: 584
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define mod 1000000007
#define PI 3.1415926535
#define all(x) x.begin(),x.end()
#define speedUp ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
void CyBerForCe()
{
	int n;
	cin>>n;
	vector <int> v;
	for(int i=0;i<n;i++)
	{
	    int a;
	    cin>>a;
	    v.push_back(a);
	}
	int ans=0;
	for(int i=0;i<n-2;i++)
	{
	    for(int j=i+1;j<n-1;j++)
	    {
	        for(int k=j+1;k<n;k++)
	        {
	            if(v[i]!=v[j] && v[j]!=v[k] && v[k]!=v[i])
	            {
	                if(v[i]+v[j]>v[k] && v[j]+v[k]>v[i] && v[k]+v[i]>v[j])
	                ans++;
	            }
	        }
	    }
	}
	cout<<ans<<"\n";
}
signed main()
{
    speedUp
    /*int t;
    cin>>t;
    while(t--)*/
    CyBerForCe();
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
    ll a,b,m;
    cin >> a >> b >> m;
    
    vector<ll> A(a),B(b);
    
    rep(i,a){
        cin >> A[i];
    }
    rep(i,b){
        cin >> B[i];
    }
    
    ll minAB;
    minAB = *min_element(A.begin(),A.end()) + *min_element(B.begin(),B.end());
    //cout << minAB;
    
    //割引
    vector<ll> AB(m);
    ll x,y,c;
    rep(i,m){
        cin >> x >> y >> c;
        AB[i] = A[x-1] + B[y-1] - c;
    }
    
    ll ans;
    ans =  *min_element(AB.begin(),AB.end()) ;
    if(ans > minAB) ans = minAB;
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 2560
import java.io.*;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine();
		int K = str.length();
		for(int a = K-1;a >= 0;a--){
			if(a==0){
				System.out.println(str.charAt(a));
			}else{
				System.out.print(str.charAt(a));
			}
		}
	}
}

Measured memory_bytes: 16860