akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		for(int i=0;i<N;i++) A[i] -= K;
		long[] sum = new long[N+1];
		for(int i=0;i<N;i++) sum[i+1] = sum[i] + A[i];
		long Inf = (long) 1e18;
		
		HashSet<long> H = new HashSet<long>();
		H.Add(-Inf);
		H.Add(Inf);
		H.Add(0);
		foreach(var v in sum) H.Add(v);
		var L = H.ToList();
		L.Sort();
		var dic = new Dictionary<long,int>();
		for(int i=0;i<L.Count;i++) dic.Add(L[i], i);
		
		int NN = N * 2;
		var BT = new BIT(NN);
		for(int i=1;i<=N;i++) BT.Add(dic[sum[i]] + 1,1);
		
		long ans = 0;
		ans += N - BT.Sum(dic[L[dic[0]]]);
		BT.Add(dic[sum[1]] + 1, -1);
		BT.Add(dic[-Inf] + 1, 1);
		for(int i=1;i<N;i++){
			ans += N - BT.Sum(dic[L[dic[sum[i]]]]);
			BT.Add(dic[sum[i+1]] + 1, -1);
			BT.Add(dic[-Inf] + 1, 1);
		}
		
		Console.WriteLine(ans);
	}
	
	int N;
	long K;
	long[] A;
	public Sol(){
		var d = ria();
		N = d[0]; K = d[1];
		A = new long[N];
		for(int i=0;i<N;i++) A[i] = rl();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}

class BIT{
	int MM;
	int n;
	long[] bit;
	public BIT(int n_){
		n = n_;
		MM = 1;
		while(MM < n * 2) MM <<= 1;
		bit = new long[MM + 1];
	}
	//1-origin!!
	public void Add(int i,long x){
		while(i <= n){
			bit[i] += x;
			i += (i&-i);
		}
	}
	
	// i=>sum(a_1,...,a_i)
	// i=0 -> return 0;
	public long Sum(int i){
		long s = 0;
		while(i > 0){
			s += bit[i];
			i -= (i&-i);
		}
		return s;
	}
}




Measured memory_bytes: 49888
#include<iostream>
using namespace std;
int main(){
  string s;
  int ans = 0;
  while(cin >>s){
    s+='.';
    for(int i=0,t=0; i<s.size(); i++){
      if(s[i]>='0' && s[i]<='9') t = t*10+s[i]-'0';
      else if(t!=0){ans+=t;t = 0;}
    }
  }
  cout <<ans<<endl;
  return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;

int main() {
    int N;
    cin >> N;
    vi A(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    map<int, ll> a;
    for (int x : A) {
       a[x]++;
    }
    ll sum = 0;
    for(int i = 0; i < N + 1; i++) {
        sum += (a[i] * (a[i] - 1)) / 2;
    }

    for(int k = 0; k < N; k++) {
        ll b = 0;
        b = (a[A[k]] - 1);
        cout << sum - b << endl;
    }
    return 0;
}

Measured memory_bytes: 15872
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#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() {
  int A, B;
  cin >> A >> B;
  cout << max({A-B, A+B, A*B}) << endl;
  return 0;
}

Measured memory_bytes: 3160
from __future__ import division
import sys

def can_place(pos, idx, col):
    for i in range(8):
        if pos[i] is not None and pos[i] == col: return False
    for i in range(8):
        if pos[i] is not None and abs(pos[i] - col) == abs(i - idx): return False
    return True

def dfs(pos, depth):
    if 8 == depth:
        for idx, p in enumerate(pos):
            print('.' * p + 'Q' + '.' * (7 - p))
        return True
    else:
        if pos[depth] is None:
            for i in range(8):
                if can_place(pos, depth, i):
                    pos[depth] = i
                    if dfs(pos, depth + 1):
                        return True
                    pos[depth] = None
            return False
        else:
            return dfs(pos, depth + 1)

if __name__ == '__main__':
    n = int(sys.stdin.readline())
    pos = [None] * 8
    for _ in range(n):
        row, col = map(int, sys.stdin.readline().strip().split())
        pos[row] = col
    dfs(pos, 0)

Measured memory_bytes: 6492
h,w=map(int,input().split())
s=[]
for i in range(h):
    s.append(input())
    
dij=[-1,0,1,0,-1]
def update(i,j,x,d,q):
    if(d[i][j]!=-1):return
    d[i][j]=x
    q.append((i,j))

m=-1
for i in range(h):
    for j in range(w):
        if(s[i][j]=="#"):continue
        d=[[-1 for ii in range(w)] for jj in range(h)]
        q=[]
        update(i,j,0,d,q)
        while q:
            xy=q.pop(0)
            xx=xy[0]
            yy=xy[1]
            for k in range(4):
                ni=xx+dij[k]
                nj=yy+dij[k+1]
                if(ni<0 or ni>=h or nj<0 or nj>=w):continue
                if(s[ni][nj]=="#"):continue
                update(ni,nj,d[xx][yy]+1,d,q)
        for ii in range(h):
            for jj in range(w):
                m=max(d[ii][jj],m)
print(m)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N; cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; i++){
        int d; cin >> d;
        d -= (i+1);
        a[i] = d;
    }

    sort(a.begin(), a.end());

    int b = a[(N-1)/2];

    ll ans = 0;
    for(int i=0; i<N; i++) ans += abs(b - a[i]);

    cout << ans << endl;
}

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

int main(){
  string s, t;
  cin >> s >> t;
  t.pop_back();
  cout << (s == t? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 3532
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int n, k; cin >> n >> k;
	vector<bool> f(n,1);
	REP(i,k){
		int d; cin >> d;
		REP(j,d){
			int a; cin >> a;
			f[a-1]=0;
		}
	}
	int ans=0;
	REP(i,n){
		if(f[i])
			ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
using namespace std;
using ll=long long;
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll lcm(ll a,ll b)
{
    ll g=gcd(a,b);
    return a/g*b;
}
int main(void)
{
    int n;
    cin>>n;
    ll ans=1ll;
    for(int i=0;i<n;i++)
    {
        ll T;
        cin>>T;
        ans=lcm(ans,T);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
using namespace std;

int main(){
    map<char,int> plus, minus;
    plus['('] = 0;  minus[')'] = 0;
    plus['{'] = 1;  minus['}'] = 1;
    plus['['] = 2;  minus[']'] = 2;

    int p, q;
    while(cin >> p >> q, p+q){
        vector<vector<double>> v;
        v.push_back(vector<double>(4, 0));
        for(int i = 0; i < p; i++){
            string s;   cin >> s;
            s += "@";   // sentinel
            int pos = 0;
            while(s[pos] == '.')    pos++;
            v[i][3] = pos;
            vector<double> now = v.back();
            while(pos < s.length()){
                if(plus.count(s[pos]))  now[plus[s[pos]]]++;
                if(minus.count(s[pos]))  now[minus[s[pos]]]--;
                pos++;
            }
            if(i != p-1)    v.push_back(now);
        }

        vector<int> x, y, z;
        for(int i = 1; i <= 20; i++){
            for(int j = 1; j <= 20; j++){
                for(int k = 1; k <= 20; k++){
                    bool valid = true;
                    for(int l = 0; l < p; l++){
                        valid &= i*v[l][0]+j*v[l][1]+k*v[l][2]==v[l][3];
                    }
                    if(!valid)  continue;
                    x.push_back(i);
                    y.push_back(j);
                    z.push_back(k);
                }
            }
        }

        vector<int> target(3,0);
        while(q-- > 0){
            string s;   cin >> s;
            set<int> num;
            for(int i = 0; i < x.size(); i++){
                num.insert(x[i]*target[0]+y[i]*target[1]+z[i]*target[2]);
            }
            cout << (num.size()!=1 ? -1 : *(num.begin())) << " \n"[q==0];
            for(char c : s){
                if(plus.count(c))  target[plus[c]]++;
                if(minus.count(c))  target[minus[c]]--;
            }
        }

    }
    return 0;
}


Measured memory_bytes: 3292
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const int N=2e5+5;
ll a[N],dp[N],n,k;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;++i)
		cin>>a[i];
	dp[1]=0;
    dp[0]=0;
    for(int i=2;i<=n;++i)
    	dp[i]=inf;
    for(int i=2;i<=n;++i)
     for(int j = 1;j<=k;++j)
        {
            if(i-j<1) break;
            dp[i] = min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
        }
		cout<<dp[n];
	return 0;
} 

Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

template<class T> ostream& operator << ( ostream& os, vector<T> v ) {
    for ( typename vector<T>::iterator it_i = v.begin(); it_i != v.end(); ++it_i ) {
        os << *it_i << ", ";
    }
    return os;
}


void solve( string s0, string s1, string s2 ) {
    int A0 = 0, A1 = 0, A2 = 0;
    int B0 = 0, B1 = 0, B2 = 0;
    int n0 = s0.size(), n1 = s1.size(), n2 = s2.size();
    for ( int i = 1; i < n0; ++ i ) {
        if ( s0[i] == 'A' ) A0 ++;
        else B0 ++;
    }
    for ( int i = 1; i < n1; ++ i ) {
        if ( s1[i] == 'A' ) A1 ++;
        else B1 ++;
    }
    for ( int i = 1; i < n2; ++ i ) {
        if ( s2[i] == 'A' ) A2 ++;
        else B2 ++;
    }
    if ( s1[0] == 'A' ) A0 ++;
    else B0 ++;
    if ( s2[0] == 'A' ) A1 ++;
    else B1 ++;
    if ( A2 >= 10 && B2 >= 10 ) {
        if ( A2 > B2 ) A2 ++;
        else B2 ++;
    } else if ( A2 > B2 ) {
        A2 ++;
    } else {
        B2 ++;
    }

    cout << A0 << " " << B0 << endl;
    cout << A1 << " " << B1 << endl;
    cout << A2 << " " << B2 << endl;
}

int main() {
    string s0, s1, s2;
    while ( cin >> s0 ) {
        if ( s0 == "0" ) break;
        cin >> s1 >> s2;
        solve( s0, s1, s2 );
    }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N;
    cin >> N;
    ll Res = 0;
    for (int n = 1; n <= N; ++n) {
        if (n % 3 != 0 && n % 5 != 0) {
            Res += n;
        }
    }
    cout << Res << endl;

    return 0;
}


Measured memory_bytes: 3648
const lineList = require('fs').readFileSync('/dev/stdin','utf8').trim().split('\n')

const s = lineList[0]
const k = parseInt(lineList[1])

var blockList = s.match(/(.)\1*/g)

var total = 0
var head = blockList[0]
var tail = blockList[blockList.length-1]

if(blockList.length === 1) {
  total = Math.floor(blockList[0].length * k  / 2)
} else if(head[0] === tail[0]) {
  blockList.pop()
  blockList.shift()
  total = blockList.reduce((acc, e, i) => Math.floor(acc + e.length / 2), 0) * k
  total += Math.floor(head.length / 2)
  total += Math.floor(tail.length / 2)
  total += Math.floor((head.length + tail.length) / 2) * (k - 1)
} else {
  total = blockList.reduce((acc, e, i) => Math.floor(acc + e.length / 2), 0) * k
}

console.log(total)


Measured memory_bytes: 7500
import os
import heapq
import sys
import math
import operator
from collections import defaultdict
from io import BytesIO, IOBase


"""def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)"""

"""def pw(a,b):
    result=1
    while(b>0):
        if(b%2==1): result*=a
        a*=a
        b//=2
    return result"""



def inpt():
    return [int(k) for k in input().split()]


def main():
    n=int(input())
    d={}
    seven=7
    q=0
    ok=True
    while(True):
        r=seven%n
        q+=1
        if(r==0):
            break
        if(r in d):
            ok=False
            break
        d[r]=True
        seven=r*10+7
    if(not ok):
        print(-1)
    else:
        print(q)

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()


Measured memory_bytes: 158600
A = raw_input().split()
B = []
def add(x, y):
    return x + y
def sub(x, y):
    return x - y
def mul(x, y):
    return x * y
operation = {'+':add, '-':sub, '*':mul}
for item in A:
    if item.isdigit():
        B.append(int(item))
    else:
        num2 = B.pop() 
        num1 = B.pop()
        ans = operation[item](num1, num2)
        B.append(ans)
print ans

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

#define LL long long
#define LD long double
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(a,n) memset(a,n,si 2)

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))


int main()
{
    LL int i,j,n,m,a,b,c,d,ans=0;
    cin>>a>>b>>c>>d;
    ans=min(b,d)-max(a,c);
    if(ans>=0)
        cout<<ans;
    else
        cout<<0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int,int,int,int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };
int ddx[]={2,2,-2,-2,1,1,-1,-1},ddy[]={1,-1,1,-1,2,-2,2,-2};

ll n;
ll d[1000001];
int main(){
	scanf("%lld",&n);
	d[0]=1,d[1]=n,d[2]=n*n;
	ll s=(n*n+n+1)%MOD;
	fup(i,3,n,1)
	{
		d[i]=(s-d[i-2]+n*n-n+2-i)%MOD;
		s=(s+d[i])%MOD;
	}
	printf("%lld",(d[n]+MOD)%MOD);
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll INF=1e18;
struct UnionFind {
  vector<int> d;
  UnionFind(int n): d(n,-1) {}//-1で初期化
  int root(int x) {
    if (d[x] < 0) return x;//rootを負にする（構成node数x(-1))
    //root以外は親の番号
    return d[x] = root(d[x]);
    //return(root(d[x]))とするとメモできないが上の書き方だとメモができる
  }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    //swapすることで小さい方を大きい方につけられ計算量減らせる
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return root(x) == root(y);}
  //同じグループ化
  int size(int x) { return -d[root(x)];}
  //グループのnode数
    int group_num(int n){
        set<int> s;
        for(int i = 0; i < n; ++i){
            s.insert(root(i));
        }
        return int(s.size());}
};


int main() {
  int n,q;
  cin>>n>>q;
  UnionFind uf(n);

  rep(i,q){
    int t1,u1,v1;

    cin>>t1>>u1>>v1;
  
    if(t1==0){
      uf.unite(u1,v1);
    }
    if(t1==1){
      if (uf.same(u1,v1)==1) cout<<1<<endl;
      else cout<<0<<endl;
    }
  }
}


Measured memory_bytes: 3964
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	
		while(true){
			int n=sc.nextInt();
			if(n==0) break;
			int data[] = new int[n];
			double ave=0;
			for(int i=0;i<n;++i) {
				data[i]=sc.nextInt();
				ave+=data[i];
			}
			
			ave/=n;
			
			int count=0;
			for(int i=0;i<n;++i) {
				if(data[i]<=ave) count++;
			}
			
			System.out.println(count);
		}
	
	}

}



Measured memory_bytes: 59144
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#define LL long long

using namespace std;

int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        int a[100001];
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
        }
        int sum=0;
        for(int i=1;i<=n;i++)
        {
            if(a[i]==i)
            {
                swap(a[i],a[i+1]);
                sum++;
            }
        }
        printf("%d\n",sum);
    }
    return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    int N;
    cin >> N;
    set<string> s;
    rep(i, N)
    {
        string st;
        cin >> st;
        s.insert(st);
    }
    int ans = s.size();
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 19120
sss = input()
while not sss == '0 0':
	ss = sss.split(' ')
	H = int(ss[0])
	W = int(ss[1])
	for i in range(H):
		sh = ''
		for j in range(W):
			sh += '#'
		print(sh)
	print('')
	sss = input()


Measured memory_bytes: 7648
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String NN =String.valueOf(N);
		String ans = "No";
		if(NN.charAt(0) == '7'|| NN.charAt(1) == '7'|| NN.charAt(2) == '7'){
			ans = "Yes";
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 35736
import math

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,k=map(int,input().split())
mod=10**9+7


for i in range(1,k+1):
    if n-k+1-i<0:
        print(0)
    else:
        print(comb(n-k+1,i)*comb(k-1,i-1)%mod)

Measured memory_bytes: 3316
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        
        int tkh = sc.nextInt();
        int aok = sc.nextInt();
        int k = sc.nextInt();
        
        for(int i = 1; i <= k; i++){
            if(i % 2 == 1){ //全体の奇数回は高橋の番
                if(tkh % 2 == 1){
                    tkh--;
                    aok += tkh / 2;
                    tkh /= 2;
                    
                }else{
                    aok += tkh / 2;
                    tkh /= 2;
                }
                //System.out.println(tkh + " " + aok);
               
            }else{
                if(aok % 2 == 1){
                    aok--;
                    tkh += aok / 2;
                    aok /= 2;
                }else{
                    tkh += aok / 2;
                    aok /= 2;
                }
                //System.out.println(tkh + " " + aok);
            }

        }
         
         System.out.println(tkh + " " + aok);
        
    }
}



Measured memory_bytes: 23124
#include <iostream>
#include <algorithm>
using namespace std;
enum{LOGOUT,LOGIN};
const int MAX_T=1260+1-540;
int tomin(int d){
     return d-540;
}
bool table[10000+1][MAX_T];
int login[1000+1];

int main(){
     int N,M;
     while(cin>>N>>M,N||M){
	  int r;
	  cin>>r;
	  for(int i=0;i<M+1;i++){
	       for(int j=0;j<MAX_T;j++){
		    table[i][j]=false;
	       }
	  }
	  for(int i=0;i<r;i++){
	       int t,n,m,s;
	       cin>>t>>n>>m>>s;
	       t=tomin(t);
	       switch(s){
	       case LOGIN:
		    login[n]=t;
		    break;
	       case LOGOUT:
		    fill(&table[m][login[n]],&table[m][t],true);
		    break;
	       }
	  }
	  int q;
	  cin>>q;
	  for(int i=0;i<q;i++){
	       int ts,te,m;
	       cin>>ts>>te>>m;
	       ts=tomin(ts);te=tomin(te);
	       cout<<count(&table[m][ts],&table[m][te],true)<<endl;
	  }
     }
}

Measured memory_bytes: 7692
#include <bits/stdc++.h>
 using namespace std;
 #define rep(i,N) for(int i=0;i<int(N);++i)
 using ll = long long;
 using v_i = vector<int>;
 using v_s = vector<string>;
 const int INF = 2147483647;

 int main(){
     int n;
     cin >> n;
     v_s s(n);
     v_i t(n);
     int sum =0;
     rep(i,n){
         cin >> s[i];
         cin >> t[i];
         sum+=t[i];
     }    
     string x;
     cin >> x;
     int num;
     rep(i,n){
         if(x==s[i])
            num = i;
     }
     int sum2 =0;
      for(int i=0;i<=num;i++){
          sum2+=t[i];
      }
      cout << sum-sum2 << endl;
     return 0;
 }

     //int nin = *max_element(a.begin(),p.end());
    //int nax = *max_element(a.begin(),p.end())-p.begin();
    //int min_index = min_element(p.begin(),p.end())-p.begin();
     //sort(l.begin(),l.end(),greater<int>());
     //stringは",charは'
     //ちょっとあやしかったら立ち止まって考える
     //例外処理はreturn忘れずに
     //文字列連結 文字+="aa" でできる

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

using namespace std;
using namespace __gnu_cxx;

#define all(v)   v.begin(), v.end()
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define THINK_TWICE_CODE_ONCE cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define isOdd(n)    (n&1)
#define LLMAX LLONG_MAX
#define LLMIN LLONG_MIN
#define IMN INT_MIN
#define IMX INT_MAX
#define pow(n, m) power((ll)n, (ll)m)
#define numOfDigits(n)  ((n)? (ll)(log10(n)+1) : 1)
#define mem(x, val)    memset(x, val, sizeof(x))
#define MOD 1000000007

typedef long long ll;
typedef long double ld;
typedef double dd;
typedef string str;
typedef pair<int, int> pii;



int main()
{
    THINK_TWICE_CODE_ONCE
    //freopen("test cases\\.txt", "r", stdin) ;
    ll n, k, x, y; cin>>n>>k>>x>>y;
    ll first = min(k, n), rest = n - first;
    cout<<first * x + rest * y;
	return 0;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)      x.begin(), x.end()
#define SIZE(x)     static_cast<i64>(x.size())
#define rep(i,n)    for (i64 i = 0, i ## _limit = (n); i < i ## _limit; ++i)
#define reps(i,s,t) for (i64 i = (s), i ## _limit = (t); i <= i ## _limit; ++i)
#define repr(i,s,t) for (i64 i = (s), i ## _limit = (t); i >= i ## _limit; --i)

#ifdef DBG
#define trace(...) _trace(#__VA_ARGS__, __VA_ARGS__);
#else
#define trace(...)
#endif

using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template<class T, class U>inline bool chmax(T &a, const U &b){return b>a && (a=b, true);}
template<class T, class U>inline bool chmin(T &a, const U &b){return b<a && (a=b, true);}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template<class T>
ostream& operator<< (ostream &os, const vector<T> &vec) {
    rep(i, vec.size()) os << vec[i] << (i+1 == vec.size() ? "" : " ");
    return os;
}

template<class T, class U>
ostream& operator<< (ostream &os, const pair<T, U> &p) {
    return os << p.first << ' ' << p.second;
}

template<class Itr>
ostream& printContainer(Itr begin, Itr end, const string &separator = " ", ostream &os = cout) {
    const auto rbegin = std::prev(end);
    for (; begin != rbegin; ++begin) os << *begin << separator;
    os << *rbegin;
    return os;
}

ostream& operator<< (ostream &os, ostream&) {
    return os;
}

template <class T>
void _trace(const char *s, T&& x) {
    clog << '{';
    while(*s != '\0') clog << *(s++);
    clog << ":" << setw(3) << x << '}' << endl;
}

template <class Head, class... Tail>
void _trace(const char *s, Head&& head, Tail&&... tail) {
    clog << '{';
    while(*s != ',') clog << *(s++);
    clog << ":" << setw(3) << head << "}, ";
    for (++s; !isgraph(*s); ++s);
    _trace(s, std::forward<Tail>(tail)...);
}
// }}} End Header

struct UnionFind { // {{{
    vector<int> u;
    explicit UnionFind(int n): u(n+5, -1) {}
    int  size(int x)        { return -u[root(x)]; }
    int  root(int x)        { return (u[x] < 0)? x : (u[x] = root(u[x])); }
    bool same(int x, int y) { return (root(x) == root(y)); }
    bool unite(int x, int y){ return (x=root(x)) == (y=root(y))? false : (u[x]+=u[y], u[y]=x, true); }
}; // }}}

signed main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N, K, L;
    cin >> N >> K >> L;

    UnionFind G(N);
    UnionFind H(N);

    rep(i, K) {
        int a, b;
        cin >> a >> b;
        G.unite(a, b);
    }
    rep(i, L) {
        int a, b;
        cin >> a >> b;
        H.unite(a, b);
    }

    unordered_map<int, int> cnt[200010];

    reps(u, 1, N) {
        cnt[G.root(u)][H.root(u)] += 1;
    }

    reps(u, 1, N) {
        cout << cnt[G.root(u)][H.root(u)] << " \n"[u == N];
    }


    return 0;
}


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

int main() {
    int N;
    cin >> N;
    ll A, B, C;
    cin >> A >> B >> C;
    vector<string> S(N+1);
    for (int i = 0; i < N; i++) cin >> S[i];
    S[N] == "--";
    
    vector<char> ans(N);
    for (int i = 0; i < N; i++) {
        if (S[i] == "AB") {
            if (A == 0 && B == 0) {
                cout << "No" << endl;
                return 0;
            }
            if (A == 0) {
                ans[i] = 'A';
                A++;
                B--;
            }else if (B == 0) {
                ans[i] = 'B';
                A--;
                B++;
            }else if (A == 1 && C == 0 && S[i+1] == "AC") {
                ans[i] = 'A';
                A++;
                B--;
            }else if (B == 1 && C == 0 && S[i+1] == "BC") {
                ans[i] = 'B';
                B++;
                A--;
            }else if (A < B) {
                ans[i] = 'A';
                A++;
                B--;
            }else {
                ans[i] = 'B';
                B++;
                A--;
            }
        }
        if (S[i] == "AC") {
            if (A == 0 && C == 0) {
                cout << "No" << endl;
                return 0;
            }
            if (A == 0) {
                ans[i] = 'A';
                A++;
                C--;
            }else if (C == 0) {
                ans[i] = 'C';
                C++;
                A--;
            }else if (A == 1 && B == 0 && S[i+1] == "AB") {
                ans[i] = 'A';
                A++;
                C--;
            }else if (C == 1 && B == 0 && S[i+1] == "BC") {
                ans[i] = 'C';
                C++;
                A--;
            }else if (A < C) {
                ans[i] = 'A';
                A++;
                C--;
            }else {
                ans[i] = 'C';
                C++;
                A--;
            }
        }
        if (S[i] == "BC") {
            if (B == 0 && C == 0) {
                cout << "No" << endl;
                return 0;
            }
            if (B == 0) {
                ans[i] = 'B';
                B++;
                C--;
            }else if (C == 0) {
                ans[i] = 'C';
                C++;
                B--;
            }else if (B == 1 && A == 0 && S[i+1] == "AB") {
                ans[i] = 'B';
                B++;
                C--;
            }else if (C == 1 && A == 0 && S[i+1] == "AC") {
                ans[i] = 'C';
                C++;
                B--;
            }else if (B < C) {
                ans[i] = 'B';
                B++;
                C--;
            }else {
                ans[i] = 'C';
                C++;
                B--;
            }
        }
    }
    cout << "Yes\n";
    for (int i = 0; i < N; i++) cout << ans[i] << "\n";
    return 0;
}

Measured memory_bytes: 6428
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<ctime>
#include<set>
#include<vector>
#include<map>
#include<queue>
 
#define N 300005
#define M 8000005
 
#define ls (t<<1)
#define rs ((t<<1)|1)
#define mid ((l+r)>>1)
 
#define mk make_pair
#define pb push_back
#define fi first
#define se second
 
using namespace std;
 
int i,j,m,n,p,k,Q,H,S,D;
 
int main()
{
		scanf("%d%d%d%d%d",&Q,&H,&S,&D,&n); 
		H=min(H,2*Q);
		S=min(S,2*H);
		D=min(D,2*S);
		cout<<1ll*(n/2)*D+(n%2)*S<<endl;
}

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

#define ll long long
#define pb push_back
#define INF 1e9+7
#define cases int t;cin>>t;while(t--)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define per(i,a,b) for(ll i=a;i>=b;i--)
#define ff first
#define ss second

#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;

int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	ll a,b;
	cin>>a>>b;
	ll c=max(a,b)+max(max(a,b)-1,min(a,b));
	cout<<c;
	
	
	
	return 0;
}

Measured memory_bytes: 3580
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
	int A, B, H, M;
	scanf("%d%d%d%d", &A, &B, &H, &M);
	double ans, angle, k;
	const double pi = acos(-1.0);
	angle=(pi/6)*H-(pi/30)*M+(pi/360)*M;
	if(angle<0) angle=-angle;
	else
	{
		if(angle>pi) angle=2*pi-angle;
	}
	k=A*A+B*B-2*A*B*cos(angle);
	ans=sqrt(k);
	printf("%.20lf", ans);
	return 0;
}

Measured memory_bytes: 2604
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
#include <bitset>
#include <string>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)


ll modpow(ll x, ll n) {
    if (n == 0) {
        return 1;
    } else if (n % 2 == 0) {
        ll h = modpow(x, n / 2);
        return h * h % MOD;
    } else {
        return x * modpow(x, n - 1) % MOD;
    }
}

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

int main() {
    vector<int> A(3);
    rep(i,3)  cin >> A[i];
    sort(A.begin(), A.end());
    int ans = 0;

    ans = A[0] + A[1] + A[2]*10;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int i, A, B, C, K;
	scanf("%d %d %d", &A, &B, &C);
	scanf("%d", &K);
	if (A >= B && A >= C) for (i = 1; i <= K; i++) A *= 2;
	else if (B >= A && B >= C) for (i = 1; i <= K; i++) B *= 2;
	else for (i = 1; i <= K; i++) C *= 2;
	printf("%d\n", A + B + C);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1732
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace XXFESTIVAL
{
    class Program
    {
        static void Main(string[] args)
        {
            string strS = Console.ReadLine();

            int intMaxLen = strS.Length;

            int intLen = intMaxLen - 8;

            Console.WriteLine(strS.Substring(0,intLen));

            // for debug
            return;

        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h> 
using namespace std;
int main(){
	int x;
	cin>>x;
	if(x>=400&&x<=599) cout<<8;
	if(x>=600&&x<=799) cout<<7;
	if(x>=800&&x<=999) cout<<6;
	if(x>=1000&&x<=1199) cout<<5;
	if(x>=1200&&x<=1399) cout<<4;
	if(x>=1400&&x<=1599) cout<<3;
	if(x>=1600&&x<=1799) cout<<2;
	if(x>=1800&&x<=1999) cout<<1;
	return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<climits>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)
#define P pair<int, int>
const int INF = INT_MAX / 2;

int n;

vector<P> makeVecP(vector<int> v){
    vector<P> ret;
    int i = 0, j = 0;
    while(i < n){
        while(j < n && v[i] == v[j]) j++;
        ret.push_back( P(v[i], j - i) );
        i = j;
    }
    return ret;
}

int cntBall(vector<P> v, int left, int right){
    int cnt = 0;
    while(left >= 0 && right < v.size() && v[left].first == v[right].first && v[left].second + v[right].second >= 4){
        cnt += ((left == right)? v[left].second : (v[left].second + v[right].second));
        left--; right++;
        if(v[left].second == 0) left--;
        if(v[right].second == 0) right++;
    }
    return n - cnt;
}

int main(){
    while(cin >>n && n){
        vector<int> tmp(n); REP(i, n) cin >>tmp[i];
        vector<P> v = makeVecP(tmp);

        int ans = n;
        REP(i, v.size()){
            if(v[i].second >= 3){
                v[i].second++;
                if(i - 1 >= 0){
                    v[i - 1].second--;
                    ans = min(ans, cntBall(v, i, i));
                    v[i - 1].second++;
                }
                if(i + 1 < v.size()){
                    v[i + 1].second--;
                    ans = min(ans, cntBall(v, i, i));
                    v[i + 1].second++;
                }
                v[i].second--;
            }
            else if(i - 1 >= 0 && i + 1 < v.size() && v[i - 1].first == v[i + 1].first && v[i - 1].second + v[i + 1].second >= 3){
                v[i].second--;
                v[i - 1].second++;
                ans = min(ans, cntBall(v, i - 1, i + 1));
                v[i - 1].second--;
                v[i].second++;
            }
        }
        cout <<ans <<endl;
    }
    return 0;
}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int N, A, B; cin >> N >> A >> B;
    int pass = 0;
    int foreign_rank = 1;
    string S; cin >> S;
    rep(i, N){
        if(S[i] == 'a'){
            if(pass < A+B){
                cout << "Yes" << endl;
                pass++;
            }
            else cout << "No" << endl;
        }
        else if(S[i] == 'b'){
            if(pass < A+B && foreign_rank <= B){
                cout << "Yes" << endl;
                pass++;
                foreign_rank++;
            }
            else cout << "No" << endl;
        }
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

vector<vector<pair<int, int>>>dat;

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

	int A, B, C;
	cin >> A >> B >> C;
	if (A + B + C >= 22)puts("bust");
	else puts("win");

	return 0;
}

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

int main() {
char x;
cin >> x;
if(isupper(x)){
    cout << 'A' << endl;
}
else{
    cout << 'a' << endl;
}

return 0; 
}

Measured memory_bytes: 3588
#include "bits/stdc++.h"
using namespace std;

int main() {
	int n,q;
	cin >> n >> q;
	vector<priority_queue<int> > v(n);

	for (int i = 0; i < q; i++) {
		int c; cin >> c;
		if (c == 0) {
			int x,t;
			cin >> t >> x;
			v[t].push(x);
		}
		else if (c == 1) {
			int t;
			cin >> t;
			if(!v[t].empty()) cout << v[t].top() << endl;
		}
		else {
			int t; cin >> t;
			if (!v[t].empty()) v[t].pop();
		}
	}
}
	



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

int main() {
    long long price;
    vector<double> vec;
    cin >> price;

    for (int i = 1; i <= 50000; i++) {
        vec.push_back(static_cast<long long>(i * 1.08));
    }

    for (int i = 0; i < 50000; i++) {
        if (vec[i] == price) {
            cout << i + 1 << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
}

Measured memory_bytes: 3900
#include<iostream>
#include<algorithm>
using namespace std;

int main() {
  int N; cin >> N;
  int A[N], B[N], C[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++) cin >> C[i];
  sort(A, A+N);
  sort(B, B+N);
  sort(C, C+N);
  long dp1[N+1], dp2[N+1]; dp1[N] = dp2[N] = 0;
  for (int i = N-1; i >= 0; i--) {
    int j = lower_bound(C, C+N, B[i]+1) - C;
    dp1[i] = dp1[i+1] + N - j;
  }
  for (int i = N-1; i >= 0; i--) {
    int j = lower_bound(B, B+N, A[i]+1) - B;
    dp2[i] = dp2[i+1] + dp1[j];
  }
  cout << dp2[0] << endl;
}

Measured memory_bytes: 6324
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mod ((ll)1e9+7)
#define N ((ll)2e6+10)
#define pb push_back
#define in insert
#define F first
#define S second
#define speed ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x); x=(x*x); y/=2; } return res;}
int sv[1000000]={0};
//ll factorialNumInverse[N + 1];
//ll naturalNumInverse[N + 1];
//ll fact[N + 1];
//void InverseofNumber(ll p){naturalNumInverse[0] = naturalNumInverse[1] = 1;for (ll i = 2; i <= N; i++)naturalNumInverse[i]=naturalNumInverse[p % i] * (mod - mod / i) % mod;}
//void InverseofFactorial(ll p){factorialNumInverse[0] = factorialNumInverse[1] = 1;for (ll i = 2; i <= N; i++)factorialNumInverse[i] = (naturalNumInverse[i] * factorialNumInverse[i - 1]) % mod;}
//void factorial(ll p){fact[0] = 1;for (ll i = 1; i <= N; i++) {fact[i] = (fact[i - 1] * i) % mod;}}
//ll Binomial(ll n, ll R){ll ans = ((fact[n] * factorialNumInverse[R])%mod * (factorialNumInverse[n - R])%mod)% mod;return ans;}
///*TOIENT FUNCTION*/ll phi(ll n){ll ans=n;for(ll i=2;i*i<=n;i++){if(n%i==0){while(n%i==0) n/=i;ans-=ans/i;}}if(n>1) ans-=ans/n;return ans;}
ll mini=1000000000;

using namespace std;

int main(){
    speed
//    InverseofNumber(mod);
//    InverseofFactorial(mod);
//    factorial(mod);
    ll a,b,c,d,e,n;
    string s1,s2;
    cin>>s1>>s2;
    bool f=0;
    for(ll i=0;i<s1.length();i++){
        if(s1[i]==s2[i]){
            
        }
        else f=1;
    }
    if(f)
        cout<<"No";
    else cout<<"Yes";
    
}


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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}

int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int n,m;
  cin>>n>>m;
  vector<int> v(2*m),w(n);
  rep(i,2*m) cin>>v[i];
  rep(i,n) w[i]=0;
  rep(i,2*m) w[v[i]-1]++;
  rep(i,n) cout<<w[i]<<endl;
  
  
}
///////////////////////////

Measured memory_bytes: 256
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(void){
  int h,w;
  cin >> h >> w;
  string board[50];
  
  for(int i = 0; i < h; i++) cin >> board[i];
  
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(board[i][j] == '.') continue;
      
      int num=0;
      bool can = false;
      for(int d = 0; d < 4; d++){
      	const int ni = i + dx[d];
        const int nj = j + dy[d];
        
        if(ni < 0 or h <= ni) continue;
        if(nj < 0 or w <= nj) continue;
        if(board[ni][nj] == '#') can = true;
      }
      if(!can){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
/*
  Vivek Rathi
  CSE 2nd Year
  MNNIT
*/
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 1e17
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
ll a[101],n,k;
int main()
{
	boost
	cin>>n;
	cin>>k;
	for(ll i=0;i<n;i++) 
	{
		cin>>a[i];
	}
	ll dp[k+1][2];
	memset(dp,-1,sizeof(dp));
	dp[0][1]=0;
	dp[0][0]=1;
	for(ll i=1;i<=k;i++)
	{
		for(ll j=0;j<2;j++)
		{
			for(ll l=0;l<n;l++)
			{
				if(i-a[l]>=0)
				{
					if(dp[i][j]==(j+1)%2||dp[i][j]==-1)dp[i][j]=dp[i-a[l]][(j+1)%2];
				}
				else dp[i][j]=(j+1)%2;
				if(dp[i][j]==j) break;
				//debug3(i,j,dp[i][j]);
			}
		}
	}
	if(dp[k][0]==0) cout<<"First"<<endl;
	else cout<<"Second"<<endl;
 	return 0;
}

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

namespace AltCoder
{
    public sealed class G_LongestPath
    {
        public static void Main()
        {
            int[] NM = Console.ReadLine().Split(new char[] { ' ' }).Select(x => Convert.ToInt32(x)).ToArray();
            int N = NM[0];
            int M = NM[1];

            Dictionary<int, List<int>> edges = new Dictionary<int, List<int>>(N);
            for (int i = 0; i < N; i++)
            {
                edges.Add(i, new List<int>());
            }

            for (int i = 0; i < M; i++)
            {
                int[] XY = Console.ReadLine().Split(new char[] { ' ' }).Select(x => Convert.ToInt32(x)).ToArray();
                edges[XY[0] - 1].Add(XY[1] - 1);
            }
            
            bool[] visited = new bool[N];
            int[] d = new int[N];

            foreach (var node in edges.Keys)
            {
                if (edges[node].Count > 0 && !visited[node])
                {                    
                    DFS(node, edges, d, visited);                    
                }
            }

            int result = d.Max();
            Console.WriteLine(result);
        }

        private static void DFS(int node, Dictionary<int, List<int>> edges, int[] d, bool[] visited)
        {
            visited[node] = true;

            foreach (var neighbour in edges[node])
            {
                if (!visited[neighbour])
                {
                    DFS(neighbour, edges, d, visited);
                }

                d[node] = Math.Max(d[node], 1 + d[neighbour]);  
            }            
        }
    }
}


Measured memory_bytes: 32376
import java.util.Scanner;

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

      while(true){

        int h = sc.nextInt();
        int w = sc.nextInt();

        if(h==0&&w==0){
          break;
        }

        for(int i = 0; i<w; i++){
            System.out.print("#");
        }
        System.out.println("");


        for(int j=0;j<h-2;j++){

          System.out.print("#");
          for(int i =0;i<w-2;i++){
              System.out.print(".");
          }
          System.out.println("#");

        }

        for(int i = 0; i<w; i++){
            System.out.print("#");
        }
        System.out.println("");

        System.out.println("");

      }

    } 
}


Measured memory_bytes: 36552