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

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, m, s, t, x, y, a, b, ds[114514], dt[114514];
vpii es[114514], et[114514];


void dijkstra(int n, vpii e[], int d[], int s) {
	priority_queue<pii, vector<pii>, greater<pii> > que;
	fill(d, d+n, linf), d[s] = 0;
	que.push({0,s});
	while(!que.empty()) {
		pii p = que.top(); que.pop();
		int v = p.se, dis = p.fi;
		if (d[v] < dis) continue;
		for (int i = 0; i < e[v].size(); ++i) {
			pii q = e[v][i];
			int u = q.fi, cost = q.se;
			if (d[u] > d[v] + cost) {
				d[u] = d[v] + cost;
				que.push({d[u], u});
			}
		}
	}
}

signed main() {
	cin >> n >> m >> s >> t;
	s--, t--;
	rep(i,m) {
		cin >> x >> y >> a >> b;
		x--, y--;
		es[x].pb({y,a}), es[y].pb({x,a});
		et[x].pb({y,b}), et[y].pb({x,b});
	}
	dijkstra(n,es,ds,s), dijkstra(n,et,dt,t);
	vi res;
	int mx = 0;
	repr(i,n-1) {
		// iで両替する場合
		int t = 1e15 - (ds[i] + dt[i]);
		chmax(mx,t);
		res.pb(mx);
	}
	repr(i,n-1) cout << res[i] << ln;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  if (abs(x - a) < abs(x - b))
    cout << "A" << endl;
  else
    cout << "B" << endl;
}


Measured memory_bytes: 256
import math
import bisect
n= int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
A=0
B=0
for i in range(n-1):
    an=bisect.bisect_left(sorted(a[i:]),a[i])
    # print('an:',an)
    A+= an *math.factorial(n-i-1)
    # print(A)
    bn=bisect.bisect_left(sorted(b[i:]),b[i])

    B+= bn *math.factorial(n-i-1)
    # print(B)

print(abs(A-B))

Measured memory_bytes: 38256
#include <iostream>
#include <map>
#include <string>
#include <set>
using namespace std;

int main() {
  int n, m;
  cin >> n;
  set<string> dict;
  map<string,int> blue;
  map<string,int> red;
  for (int i = 0; i < n; ++i) {
    string tmp = "";
    cin >> tmp;
    dict.insert(tmp);
    if (blue.find(tmp) == blue.end()) {
      blue[tmp] = 1;
    } else {
      ++blue[tmp];
      //      cout << tmp << " " << blue[tmp] << endl;
    }
  }
  cin >> m;
  for (int i = 0; i < m; ++i) {
    string tmp = "";
    cin >> tmp;
    if (red.find(tmp) == red.end()) {
      red[tmp] = 1;
    } else {
      ++red[tmp];
    }
  }
  int M = 0;
  for (set<string>::iterator it = dict.begin(); it != dict.end(); ++it) {
    //    cout << dict.size() << endl;
    if (red.find(*it) == red.end()) {
      M = max(M, blue[*it]);
    } else {
      M = max(M, blue[*it] - red[*it]);
    }
  }
  cout << M << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MAX = 5100000;
ll gcd(ll a, ll b) {
    return (b==0) ? a : gcd(b, a%b);
}

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// 以下から
const int MAX_N = 100000;
struct Edge {
    int to;
    int id;
};

vector<vector<Edge>> g;
vector<int> ans;

void dfs(int v, int c=-1, int p=-1) {
    int k=1;
    rep(i,g[v].size()) {
        int u = g[v][i].to, ei = g[v][i].id;
        if (u==p) continue;
        if (k == c) ++k;
        ans[ei] = k; ++k;
        dfs(u,ans[ei],v);
    }
}
int main() {
    int n; cin >> n;
    vector<int> v(n, 0);
    v[0] = 3;
    ll ans = 1;
    rep (i,n) {
        int a; cin >> a;
        ans *= v[a];
        v[a]--;
        v[a+1]++;
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 768
dic = {}
for i in range(input()):
    dic[i+1] = []
for i in range(input()):
    x, y = map(int, raw_input().split())
    dic[y].append(x)
else:
    del dic[2]

ans  = []
while True:
    lis = sorted(dic.items(), key=lambda x: len(x[1]))
    k = lis[0][0]
    del dic[k]
    ans.append(k)
    if not dic: break
    for v in dic.values():
        if k in v:
            v.remove(k)

for v in ans:
    print v
else:
    print 2

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

int main(){
    int n, k;
    cin >> n >> k;

    int sum = 0;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;

        if(x > k - x){
            sum += ((k - x) * 2);
        }
        else{
            sum += (x * 2);
        }
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int n, T, good = 1000, che = 0;
    int c[1000], t[1000];
    scanf("%d%d", &n, &T);
    for (int i = 0; i < n; i++)
    {
        scanf("%d%d",&c[i],&t[i]);
        if (t[i] <= T && c[i] <= good)
        {
            good = c[i];
            che++;
        }
    }
    if (che)
        printf("%d", good);
    else
        printf("TLE");
    return 0;
}

Measured memory_bytes: 128
# AGC038A - 01 Matrix
def main():
    H, W, A, B = map(int, input().split())
    ans = []
    for i in range(H):
        if i < B:
            x = "0" * A + "1" * (W - A)
        else:
            x = "1" * A + "0" * (W - A)
        ans.append(x)
    print("\n".join(ans))


if __name__ == "__main__":
    main()

Measured memory_bytes: 7028
# coding: utf-8
# Your code here!

while True:
   n = int(input())
   if n == 0:
      break

   s = list(map(int, input().split()))
   
   m = sum(s) / n
   b = 0
   for i in range(n):
      b += (s[i] - m) ** 2
   
   ans = (b / n) ** 0.5
   print(ans)

   



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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

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

struct edge {
	int to,cost;
	edge(int t,ll c):to(t),cost(c) {}
};

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

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

//-----------------------------------------------------------------------------

int n;
string s;

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

	cin>>n>>s;
	s=s+s[0]+s[1];
	REP(i,4) {
		int prv=i/2,crt=i%2;
		int p[n+2];
		p[0]=prv,p[1]=crt;
		FOR(j,2,n+2) {
			if(s[j-1]=='o') {
				if(p[j-1]==0) p[j]=p[j-2];
				else p[j]=(p[j-2]^1);
			}
			else {
				if(p[j-1]==0) p[j]=(p[j-2]^1);
				else p[j]=p[j-2];
			}
		}
		if(p[0]==p[n]&&p[1]==p[n+1]) {
			REP(j,n) cout<<(p[j]?'W':'S');
			cout<<endl;
			return 0;
		}
	}

	cout<<-1<<endl;

	return 0;
}


Measured memory_bytes: 1004
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
2
ip cc
---+/

void main(string[] args) {
  const N = readln.chomp.to!long;
  string S, T;
  readf(" %s %s ", &S, &T);

  string ans;
  foreach (i; 0..N) ans ~= S[i] ~ T[i].to!string;
  ans.writeln;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
//================================================

int a = 0, b = 0, c, d, n, k = 0;
string s, t;



int main()
{
	char x;
	cin >> x;
	if (x == 'A')cout << 'T' << endl;
	else if (x == 'T')cout << 'A' << endl;
	else if (x == 'G')cout << 'C' << endl;
	else if (x == 'C')cout << 'G' << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define BUFMAX 10

int main(){
    char buf[BUFMAX];
    int a,b, area,perimeter;

    fgets(buf,BUFMAX,stdin);
    buf[BUFMAX-1] = '\0';
    sscanf(buf,"%d %d", &a, &b);
    area = a * b;
    perimeter = a * 2 + b * 2;
    printf("%d %d\n",area, perimeter);
    return 0;
}

Measured memory_bytes: 1672
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var n = cin.next();
            Console.WriteLine("ABC"+n);
            
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 13140
#include<iostream>
using namespace std;
int main(){
  int x;
  cin >> x;
  if(x>=1800){
  cout << 1 << endl;
  }else if(x>=1600){
  cout << 2 << endl;
  }else if (x>=1400){
  cout << 3 << endl;
  }else if(x>=1200){
  cout << 4 << endl;
  }else if(x>=1000){
  cout << 5 << endl;
  }else if(x>=800){
  cout << 6 <<endl;
  }else if(x>=600){
  cout << 7 << endl;
  }else{
  cout << 8 << endl;
  }
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"

using namespace std;
#define ll long long

#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

ll mod(ll a, ll m) { return (a + (abs(a) / m) * m + m) % m; }

//****************************don't use int!!!!!!!****************************//
//***************************code starts here!!!!!****************************//


int main() {
    IOS


    ll n;
    cin >> n;
    vector<ll> a(n);
    ll s = 0;
    for (int i = 0; i < n; ++i) {

        cin >> a[i];
        s += a[i];
    }
    ll prev = 0;
    ll cur = 0;
    ll mi = LL_INF;
    for (int i = 0; i < n; ++i) {
        cur = prev + a[i];

        if (cur * 2 >= s) {
            cout << min(mi, cur - (s - cur));
            return 0;
        } else {
            mi = min(mi, (s - cur) - cur);
        }

        prev = cur;

    }

    return 0;
}

Measured memory_bytes: 1792
(let* ((n (read))
       (a (make-array n :element-type 'integer
                        :adjustable t
                        :fill-pointer 0))
       (ch (make-array n :element-type 'integer
                         :adjustable t
                         :fill-pointer 0))
       (max-num 0)
       pointer
       (point-a 0)
       (point-b 0))
  (dotimes (i n)
    (setf (aref a i) (read))
    (setf (aref ch i) 0))
  (dotimes (i n)
    (setf max-num 0)
    (dotimes (j n)
      (if (and (< max-num (aref a j)) (= 0 (aref ch j))) (progn (setf pointer j)
                                                                (setf max-num (aref a j)))))
    (setf (aref ch pointer) 1)
    (if (= (mod i 2) 0) (setf point-a (+ point-a (aref a pointer))) (setf point-b (+ point-b (aref a pointer)))))
  (format t "~A~%" (- point-a point-b)))


Measured memory_bytes: 16744
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#define rep(i,n) for(int i = 0;i<(n);i++);
using namespace std;
using ll = long long;
const ll INF = 100100100100100;
ll algo[12][12];
int main() {
	ll N, M, X;
	cin >> N >> M >> X;//tate N yoko M
	vector<ll> C(N);
	for (int i = 0; i < N; i++) {
		cin >> C[i];
		for (int j = 0; j < M; j++) {
			cin >> algo[i][j];
		}
	}
	ll ans = INF;
	for (int i = 0; i < (1 << N); i++) {
	ll prise = 0;
	vector<ll> rikai(M);
	for (int j = 0; j < N; j++) {
		if (i >> j & 1) {
			prise += C[j];
			for (int k = 0; k < M; k++) {
				rikai[k] += algo[j][k];
				}
			}
		bool yes = true;
		for (int k = 0; k < M; k++) if (rikai[k] < X)yes = false;
		if (yes)ans = min(ans, prise);
		}
	}
	if (ans == INF)cout << "-1" << endl;
	else cout << ans << endl;
}



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

const int N=2e5+100;
const int mod=1e9+7;
typedef long long ll;


typedef pair<int,int> pa;

map<ll,int>mp;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    int n,m;cin>>n>>m;
    mp[0]=1;
    ll sum=0,ans=0;
    for(int i=1;i<=n;i++){
        ll x;cin>>x;
        sum=(sum+x)%m;
        ans+=mp[sum];
        mp[sum]++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 7520
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
#define ALL(x) (x).begin(), (x).end()
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された

    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }

    return true;
}
int ans;
int main(void){
    int n;
    cin >> n;
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        ans += b - a + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>

int main(){
  int N;
  scanf("%d", &N);
  std::vector<int > x(N), y(N), h(N);
  std::multimap<int, int, std::greater<int> > mp;
  for (int i=0; i<N; i++){
    scanf("%d", &x[i]);
    scanf("%d", &y[i]);
    scanf("%d", &h[i]);
    mp.insert(std::make_pair(h[i],i));
  }
  for (int Cx=0; Cx<=100; Cx++){
    for (int Cy=0; Cy<=100; Cy++){
      int Hcand = -1;
      bool ok = true;
      auto itr = mp.begin();
      for (int i=0; i<N; i++){
        int index = itr->second;
        int Htemp = h[index]+abs(x[index]-Cx)+abs(y[index]-Cy);
        if (Hcand==-1){
          if (h[index]!=0){
            Hcand = Htemp;
          }
        } else if (h[index]==0){
          if (Hcand>abs(x[index]-Cx)+abs(y[index]-Cy)){
            ok = false;
          }
        } else if (Htemp!=Hcand){
          ok = false;
          break;
        }
        itr++;
      }
      if (ok && Hcand>0){
        printf("%d %d %d\n",Cx,Cy,Hcand);
      }
    }
  }
  return 0;
}


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

int main() {
  int N,M,C;
  cin >> N >> M >> C;
  vector<int>B(M);
  vector<vector<int>>A(N,vector<int>(M));
  for(int i=0;i<M;i++){
    cin >> B[i];
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      cin >> A[i][j];
    }
  }
  vector<int>sum(N);
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
       sum[i]+=A[i][j]*B[j];
    }
  }
  int ans=0;
  for(int i=0;i<N;i++){
    if(sum[i]+C>0){
      ans++;
    }
  }
  cout << ans << endl;
}
    
      


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i < (n);i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define SCANF(i) int i;scanf("%d",&i)
typedef long long ll;
using namespace std;
using P = pair<int,int>;
const long long INF = 1LL << 60;
const int IINF=100000000;
const int MOD = (int)1e9 + 7;
//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    //sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
vector<int> dx={1,0,-1,0};vector<int> dy={0,-1,0,1};

signed main () {
    ll n,m,k;cin >> n >> m >> k;
    vector<ll> alist(n+1,0);
    vector<ll> blist(m+1,0);
    REP(i,n){
        ll tmp;cin >> tmp;
        alist[i+1]=alist[i]+tmp;
    }
    REP(i,m){
        ll tmp;cin >> tmp;
        blist[i+1]=blist[i]+tmp;
    }
    ll ans=0;
    REP(i,n+1){
        ll target=alist[i];
        if(k-target<0)continue;
        auto bitr=upper_bound(ALL(blist),k-target);
        ll cnt=bitr - blist.begin()-1;
        ans=max(ans,cnt+i);
    }
    REP(i,m+1){
        ll target=blist[i];
        if(k-target<0)continue;
        auto aitr=upper_bound(ALL(alist),k-target);
        ll cnt=aitr-alist.begin()-1;
        ans=max(ans,cnt+i);
    }
    cout << ans << endl;
}//https://atcoder.jp/contests/abc172/tasks/abc172_c

Measured memory_bytes: 6396
#include<stdio.h>
#include<algorithm>
using namespace std;
const int maxn=100005;
int n,m,map[10][maxn],ans;
void fun(int x)//翻?第x行
{
    for(int i=0;i<m;++i)
    {
        map[x][i]=!map[x][i];
    }
}
int num()//?算当前状?最多有多少个 1
{
    int cnt=0;
    for(int i=0;i<m;++i)
    {
        int tp=0;
        for(int j=0;j<n;++j)//?着??
        {
            if(map[j][i]==1)
            {
                ++tp;
            }
        }
        cnt+=max(tp,n-tp);
    }
    return cnt;
}
void dfs(int cnt,int r)//暴力遍?
{
    if(cnt==n)
    {
        ans=max(num(),ans);
        return;
    }
    dfs(cnt+1,r+1);
    fun(r);//翻?
    dfs(cnt+1,r+1);
    fun(r);//回溯
}
int main()
{
	//freopen("shuju.txt","r",stdin); 
	while(scanf("%d%d",&n,&m),n|m)
	{
		for(int i=0;i<n;++i)
        {
            for(int j=0;j<m;++j)
            {
                scanf("%d",&map[i][j]);
            }
        }
        ans=0;
        dfs(0,0);
        printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1452
N, x = map(int, raw_input().split())
a = map(int, raw_input().split())
ans = 0
for i in range(N-1):
  t = a[i]+a[i+1]-x
  if t>0:
    a[i] -= max(0, t-a[i+1])
    a[i+1] -= min(a[i+1], t)
    ans += t
print ans


Measured memory_bytes: 11316
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define mp make_pair
int n;
const int maxn=2e5+100;
int dist[maxn];
priority_queue < pair < int,int > > q;
bool used[maxn];
void solve(){
	cin >> n;
	memset(dist,10,sizeof(dist));
	q.push(mp(0,0));
	dist[0]=0;
	while (!q.empty()){
		int u=-q.top().fi;
		int v=q.top().se;
//		cout << u << ' '<< v << endl;
		q.pop();
		if (dist[v]!=u) continue;
		used[v]=true;
		int tmp[2];tmp[1]=(v+1-1)%n+1;
		tmp[0]=(v*10-1)%n+1;
		for (int i=0;i<=1;i++){
			if (!used[tmp[i]] && dist[tmp[i]]>u+i){
				dist[tmp[i]]=u+i;
				q.push(mp(-dist[tmp[i]],tmp[i]));
			}
		}
	}
	cout << dist[n] << endl;
}
signed main(){
	solve();
	return 0;
}

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7

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

int N;
char field[1010][1010];
int dp[1010][1010];

int main() {
	while(scanf("%d", &N), N) {
		rep(i, N) scanf("%s", &field[i]);
		memset(dp, 0, sizeof(dp));
		int ans = 0;
		rep(i, N) rep(j, N) {
			if(field[i][j] == '*') dp[i][j] = 0;
			else {
				if(i == 0 || j == 0) dp[i][j] = 1;
				else {
					int mini = min(dp[i - 1][j], dp[i][j - 1]);
					dp[i][j] = min(mini, dp[i - 1][j - 1]) + 1;
				}
			}
			ans = max(ans, dp[i][j]);
		}
		printf("%d\n", ans);
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;

const ll mod = 1000000007;

struct mat{
    vvi d;
    int sz;
    mat(int n){
        sz = n;
        d.resize(sz, vi(sz));
    }
    mat operator * (const mat &o){
        mat ans(sz);
        for(int i = 0; i < sz; i++)
            for(int j = 0; j < sz; j++)
                for(int k = 0; k < sz; k++)
                    ans.d[i][j] = (ans.d[i][j] + d[i][k] * o.d[k][j] % mod) % mod;
        return ans;
    }
};

mat fast_exp(mat a, ll k){
    mat r(a.sz);
    for(int i = 0; i < a.sz; i++) r.d[i][i] = 1;
    while(k){
        if(k & 1) r = r * a;
        a = a * a;
        k >>= 1;
    }
    return r;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, k;
    cin >> n >> k;
    mat a(n);
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            cin >> a.d[i][j];
    a = fast_exp(a, k);
    ll ans = 0;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            ans = (ans + a.d[i][j]) % mod;
    cout << ans << endl;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-

n = int(input())
t_l = list(map(int, input().split()))
m = int(input())
result = []

for i in range(m):
    t_l_i = list(t_l)
    p, x = map(int, input().split())
    t_l_i[p - 1] = x
    result.append(sum(t_l_i))

print(*result, sep='\n')

Measured memory_bytes: 9104
class Counter(dict):
    def __missing__(self, i):
        return 0

n = int(input())

answers = Counter()

for i in range(n):
    answer = input()
    answers[answer] += 1

print('AC', 'x', answers['AC'])
print('WA', 'x', answers['WA'])
print('TLE', 'x', answers['TLE'])
print('RE', 'x', answers['RE'])



Measured memory_bytes: 9172
//Depth First Search
#include <iostream>

using namespace std;

static const int N = 100;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[N][N];
int colors[N] = {}, d[N] = {}, f[N] = {}, tt = 1;

void dfs_visit(int u) {
    if(colors[u] == GRAY || colors[u] == BLACK) return;
    d[u] = tt++;
    colors[u] = GRAY;
    for(int i = 0; i < n; i++) {
        if(M[u][i] == 1) dfs_visit(i);
    }
    f[u] = tt++;
    colors[u] = BLACK;
}

void dfs() {
    for(int i = 0; i < n; i++) {
        dfs_visit(i);
    }
    for(int i = 0; i < n; i++) {
        cout << i + 1 << " " << d[i] << " " << f[i] << endl;
    }
}

int main() {
    int u, k, v;
    cin >> n;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) M[i][j] = 0;
    }

    for(int i = 0; i < n; i++) {
        cin >> u >> k;
        for(int j = 0; j < k; j++) {
            cin >> v;
            M[u - 1][v - 1] = 1;
        }
    }

    dfs();
}


Measured memory_bytes: 3160
from sys import stdin, stderr
from functools import lru_cache

@lru_cache(maxsize=None)
def rec(i, m):
    if i == 0:
        return m == 0 or A[i] == m

    return rec(i - 1, m) or rec(i - 1, m - A[i])

n = int(input())
A = [int(i) for i in input().split()]
q = int(input())
M = [int(i) for i in input().split()]

for m in M:
    if rec(n - 1, m):
        print('yes')
    else:
        print('no')

Measured memory_bytes: 15396
/*input

*/
#include<bits/stdc++.h>
#define ull         unsigned long long
#define ll             long long
#define M             1000000007
#define pb             push_back
#define p_q         priority_queue
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (ll)x.size()    
#define endl        '\n'
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define ios            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp             make_pair
#define lb             lower_bound
#define ub            upper_bound
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ini(a,n,b)    for(ll int i=0;i<n;i++) a[i]=0;
#define F            first
#define S            second
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

bool DEBUG = 0;

void solve()
{
    //initialize();
    ll h,n;cin>>h>>n;
    ll s = 0;ll x;
    rep(i,0,n)
    {
        cin>>x;s+=x;
    }
    if (s >= h)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}


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

Measured memory_bytes: 3664
n = int(input())
prev_t = 0
prev_x = 0
prev_y = 0
ans = True
for i in range(n):
    t,x,y = map(int,input().split())
    d_t = t - prev_t
    d_x = abs(x - prev_x)
    d_y = abs(y - prev_y)
    distance = d_x + d_y
    if d_t < distance or (d_t % 2) != (distance % 2):
        ans = False
    prev_t = t
    prev_x = x
    prev_y = y

if ans:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
l,r = map(int,input().split())

if r - l > 2019:
    print(0)
else:
    tres = 2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            mod = (i % 2019) * (j % 2019) % 2019
            tres = min(tres,mod)
            if tres == 0:
                break
        if tres == 0:
            break
    print(tres)


Measured memory_bytes: 2940
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
string s;
ll n,x=0;
ll maxx=-1e18;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n>>s;n=s.size();
	maxx=max(maxx,x);
	for(int i=0;i<n;i++){
		if(s[i]=='I')x++;
		if(s[i]=='D')x--;
		maxx=max(maxx,x);
	}
	cout<<maxx;
	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a)  (a).begin(),(a).end()

vector<bool> seen;
vector<int> counter;

template <typename T>
void cout_vector(vector<T> A)
{
    for (T a : A)
        cout << a << " ";
    cout << endl;
}

void dfs(const Graph &G, int c, int p){
    for (int j: G[c]){
        if (j != p){
            counter[j] += counter[c];
            dfs(G, j, c);
        }
    }
}


int main()
{
    int N, Q;
    cin >> N >> Q;
    seen.assign(N, false);
    counter.assign(N, 0);
    Graph G(N);
    for (int i = 0; i < N - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    for (int i = 0; i < Q; i++)
    {
        int p, x;
        cin >> p >> x;
        p--;
        counter[p] += x;
    }
    dfs(G, 0, -1);
    for (int n: counter){
        cout << n << " ";
    }
    cout << "\n";
}

Measured memory_bytes: 179712
n = int(input())
a = list(map(int, input().split()))
d = [0]*8
over = 0
for i in a:
    lv = i//400
    if lv < 8:
        d[lv] = 1
    else:
        over += 1

print(max(sum(d), 1), sum(d)+over)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
using namespace std;
int main(){
    string a;
    cin>>a;
    string b=a;
    a="";//记得把原字符串清0
    int x=b.size();
    int i;
    for (i=0;i<x;i++) a=b[i]+a;//把字符串倒过来
    for(int i=0;i<x;i++){//字符替换
        if (a[i]=='b') a[i]='d';
        else if (a[i]=='d') a[i]='b';
        else if (a[i]=='p') a[i]='q';
        else if (a[i]=='q') a[i]='p';
    }
    if(a==b) cout<<"Yes"<<endl;//判断是否相同
    else cout<<"No"<<endl;
    return 0;
}

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

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define endl "\n"

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
void initialize( void );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
template <typename T, typename K> struct P {
	T a; K b;
};
typedef struct {
	vector <int> to;
	int cost;
} edge;
int main( void ){
	// initialize();
	double A, B, H, M;
	cin >> A >> B >> H >> M;
	printf("%.20lf\n", sqrt(A*A+B*B-2*A*B*cos(2*M_PI*(H/12-M/60+M/60/12))));
}

template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}
void initialize( void ){
	cout << fixed << setprecision( 10 );
}


Measured memory_bytes: 4216
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

int main(){
  int A, B; char op;
  cin >> A >> op >> B;

  if (op == '+'){
    cout << A + B << endl;
  }else{
    cout << A - B << endl;
  }
  
  return 0;
}


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

int main(){
    int n,m;
    cin >> m >> n;

    vector<int> x(n);
    rep(0,n) cin >> x[i];

    if(m >= n){
        cout << 0 << endl;
        return 0;
    }

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

    vector<int> l(n - 1);
    rep(1,n) l[i-1] = x[i] - x[i-1];

    sort(l.begin(),l.end(),greater<int>());

    int ans = x.back() - x.front();

    //rep(0,n) cout << x[i] << " ";
    //cout << endl;

    //rep(0,n-1) cout << l[i] << " ";
    //cout << endl;

    rep(0,m-1) ans -= l[i];

    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <deque>
using namespace std;

typedef long long i64;

i64 N;

int dig[50], tot;
deque<int> res;

int main() {
  scanf("%lld", &N);
  int num;
  for (int i = 40; i; --i) {
    i64 X = (1LL << i) - 1;
    if (X <= N) {
      num = i, N -= X;
      break;
    }
  }

  for (int i = num, now = 0; i >= 0; --i) {
    i64 X = 1LL << i;
    if (N >= X) {
      res.push_front(++now);
      N -= X;
    } 
    if (i) res.push_back(++now);
  }

  printf("%d\n", res.size() * 2);

  for (int i = 0; i < res.size(); ++i)
    printf("%d ", res[i]);
  
  // static i64 f[205];

  // i64 way = 0;
  // for (int i = 0; i < res.size(); ++i) {
  //   f[i] = 1;
  //   for (int j = 0; j < i; ++j)
  //     if (res[j] < res[i]) f[i] += f[j];
  //   way += f[i];
  // }
  // printf("%lld\n", way);
  
  for (int i = 0; i < res.size(); ++i)
    printf("%d ", i + 1);
  puts("");
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(){
    char s[1200];
    int n;
    
    scanf("%[^\n]",s);
    
    for(n=0;n<=strlen(s);n++){
        if(s[n]>=97&&s[n]<=122){
            s[n]=s[n]-32;
        }else if(s[n]>=65&&s[n]<=90){
            s[n]=s[n]+32;
        }
    }
    
    printf("%s\n",s);
    
    return 0;
}


Measured memory_bytes: 2096
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>

using namespace std;

int i,j,k,N,L;

char S[15];

int main()
{
  cin>>S;
  
  L=strlen(S);
  if(L%2==1)
  {
    cout <<"No";
    return 0;
  }
  
  for(i=0;i<L-1;i+=2)
  {
    if(S[i]=='h' && S[i+1]=='i')
    {
      continue;
    }
    else
    {
      cout <<"No";
      return 0;
    }
  }
  cout <<"Yes";
  
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace Snack
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine()
                            .Split(' ')
                            .Select(p => int.Parse(p))
                            .ToArray();
            var result = Lcm(ab[0], ab[1]);
            Console.WriteLine(result);
        }

        private static long Lcm(long a, long b)
        {
            return a * b / Gcd(a, b);
        }

        private static long Gcd(long a, long b)
        {
            if (a < b) return Gcd(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,m;
  while(cin>>n>>m,n||m){
    int l[n];
    for(int i=0;i<n;i++) cin>>l[i];
    bool flg=0;
    for(int i=0;i<(1<<m);i++){
      int tmp=__builtin_popcountll(i);
      if(tmp!=l[0]) continue;
      string s;
      for(int j=0;j<m;j++) s.push_back('0'+((i>>j)&1));
      bool ok=1;
      for(int j=1;j<n;j++){
	tmp-=(s[j-1]=='1');
	if(tmp==l[j]) s.push_back('0');
	else if(tmp==l[j]-1) s.push_back('1'),tmp++;
	else{
	  ok=0;
	  break;
	}
      }
      if(ok){
	cout<<s<<endl;
	flg=1;
	break;
      }
    }
    if(!flg) cout<<"Goofy"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3156
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class D
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		int MAX_LEN = 2000;

		int N = GetInt();
		int[] L = GetInts(N);

		long[] csum = new long[MAX_LEN + 1];
		for(int i = 0; i < N; i++)
			csum[L[i]]++;

		for(int i = 0; i < MAX_LEN; i++)
			csum[i + 1] += csum[i];

		long ans = 0;
		for(int i = 0; i < N; i++)
		{
			for(int j = 0; j < N; j++)
			{
				if(i == j)
					continue;

				int low = Math.Abs(L[i] - L[j]);
				int high = L[i] + L[j];

				long cnt = csum[high - 1] - csum[low];
				if(low < L[i] && L[i] < high)
					cnt--;

				if(low < L[j] && L[j] < high)
					cnt--;

				if(cnt > 0)
					ans += cnt;
			}
		}
		ans /= 6;

		Console.WriteLine(ans);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}


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






#define pf                  printf
#define sf(a)               scanf("%d",&a)
#define sfl(a)              scanf("%lld",&a)
#define sff(a,b)            scanf("%d %d",&a,&b)
#define sffl(a,b)           scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)         scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)        scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d)      scanf("%d %d %d %d",&a,&b,&c,&d)
#define sffffl(a,b,c,d)     scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define sfffff(a,b,c,d,e)   scanf("%d %d %d %d %d",&a,&b,&c,&d,&e)
#define sfffffl(a,b,c,d,e)  scanf("%lld %lld %lld %lld %lld",&a,&b,&c,&d,&e)
#define sfc(a)              scanf("%c",&a)
#define pii                 pair<int,int>
#define ms(a,b)             memset(a,b,sizeof(a))
#define pb(a)               push_back(a)
#define pbp(a,b)            push_back({a,b})
#define db                  double
#define ft                  float
#define ll                  long long
#define ull                 unsigned long long
#define pii                 pair<int,int>
#define ff                  first
#define ss                  second
#define sz(x)               x.size()
#define all(x)              x.begin(),x.end()
#define CIN                 ios_base::sync_with_stdio(0); cin.tie(0)
#define max3(a, b, c)       max(a, b) > max(b, c) ? max(a, b) : max(b, c)
#define min3(a, b, c)       min(a, b) < min(b, c) ? min(a, b) : min(b, c)
#define for0(i,n)           for(int i=0;i<n;i++)
#define for1(i,n)           for(int i=1;i<=n;i++)
#define forrev(i,n)         for(int i=n-1; i>=0; i--)
#define forab(i,a,b)        for(int i=a;i<=b;i++)
#define forba(i,b,a)        for(int i=b;i>=a;i--)
#define stlloop(x)          for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a)*((b)/gcd(a,b)))
#define case1(z)            cout<<"Case "<<z<<": "
#define case2(z)            printf("Case %d: ",z)
#define PI                  acos(-1) //3.14159265358979323846264338328
#define valid(tx,ty)        tx>=0 && tx<row && ty>=0 && ty<col
#define intlim              2147483648
#define N                   200005
#define inf                 100000008
#define mod                 1000000007

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

ll v[N];

int main()
{
    ll n,m;
    cin>>n>>m;
    if(n==m)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}
































Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int sec;
    int h,m,s;
    scanf("%d",&sec);
    
    h = sec / 3600;
    m = (sec % 3600) / 60;
    s = sec % 60;
    
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 2048
import numpy as np
N = int(input())
X = []
for i in range(N):
    X.append(list(map(int,input().split())))
temp = np.median(X,axis=0)
if N % 2 == 1:
    print(int(temp[1]-temp[0]+1))
else:
    print(int(2*temp[1]-2*temp[0]+1))

Measured memory_bytes: 71252
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let l: i64 = input();
    let r: i64 = input();
    let m: i64 = 2019;

    if r - l > 2019 {
        println!("0");
    } else {
        let mut ans = i64::max_value();
        for i in l..r {
            for j in i + 1..r + 1 {
                ans = std::cmp::min(ans, i * j % m);
            }
        }
        println!("{}", ans);
    }
}


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

int main()
{
    int n;
    
    while(cin>>n && n){
        
        map<int,int> mp;
        vector<int> v;
        
        for(int i=0; i<n; i++){
            int e,p,q;
            cin>>e>>p>>q;
            if(!mp[e])
                v.push_back(e);
            
            mp[e]+=p*q;
            
        }
        
        bool flg=false;
        
        for(int i=0; i<v.size(); i++){
            if(mp[v[i]]>=1000000){
                flg=true;
                cout<<v[i]<<endl;
            }
        }
            if(!flg){
                cout<<"NA"<<endl;
            }
        
    }
    
    return 0;
}

Measured memory_bytes: 1264