akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<iomanip>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;

int main() {
    int k; cin >> k;
    string s; cin >> s;
    if (s.size() <= k) cout << s << endl;
    else {
        cout << s.substr(0, k) << "..." <<  endl;
    }
}


Measured memory_bytes: 3628
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, cos, radians, pi, sin
from operator import mul
from functools import reduce
from operator import mul


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

t = I()
for _ in range(t):
    n = I()
    ans = 0
    q1 = []
    q2 = []
    L1 = []
    L2 = []
    for _ in range(n):
        k, l, r = LI()
        if l > r:
            L1 += [(k, l - r)]
        else:
            L2 += [(n - k, r - l)]
        ans += min(l, r)
    L1.sort()
    L2.sort()
    for ki, d in L1:
        heappush(q1, d)
        if len(q1) > ki:
            heappop(q1)
    for ki, d in L2:
        heappush(q2, d)
        if len(q2) > ki:
            heappop(q2)
    ans += sum(q1) + sum(q2)
    print(ans)











Measured memory_bytes: 106984
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7

n=int(input())
al=[chr(ord('a') + i) for i in range(26)]
d=deque([])
d.append([0])
# print(d)
while 1:
    if len(d[0])==n:
        break
    tmp=d.popleft()
    for i in range(max(tmp)+2):
        d.append(tmp+[i])
    
d=list(d)
d.sort()
for i in range(len(d)):
    tmp=""
    for j in range(len(d[0])):
        tmp+=al[d[i][j]]
    print(tmp)

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

#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define endl '\n'
#define boost ios::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL);
typedef long long li;
const int N = 1e6 + 10;
int dp[64][2];
int main(){

	/*#ifndef ONLINE_JUDGE
	freopen("input.txt" , "r" , stdin);
	freopen("output.txt" , "w" , stdout);
	#endif*/
  	li n,k;
  	cin>>n>>k;
  	li a[n];
  	li ans = 0;
  	for(int i = 0 ; i < n ; ++i)
  		cin>>a[i];

  	/*for(int i = 0 ; i < n ; ++i)
  		cout<<a[i]<<" ";
  	cout<<endl;*/

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

  		li val = 1LL<<i;
  		//cout<<val<<" ";
  		for(int j = 0 ; j < n ; ++j){

  			if(a[j]&val)
  				dp[i][1]++;
  			else dp[i][0]++;
  		}
  		//cout<<endl;
  	}

  	li x = 0;
  	for(int i = 40 ; i >= 0 ; --i){

  		if(dp[i][0]>dp[i][1] && (x|(1LL<<i))<=k){

  			x|=(1LL<<i);
  		}
  	}
  	/*for(int i = 0 ; i < 4 ; ++i)
  		cout<<dp[i][0]<<" "<<dp[i][1]<<endl;*/
  	li sum = 0;
  //	cout<<x<<endl;
  	for(int i = 0 ; i < n ; ++i){

  		sum += (a[i]^x);
  	}

  	cout<<sum<<endl;
}

Measured memory_bytes: 1024
def checkBingo(bList):
    ret = "No"
    for i in range(3):
        if bList[i][0] == -1 and bList[i][1] == -1 and bList[i][2] == -1:
            ret = "Yes"
    for i in range(3):
        if bList[0][i] == -1 and bList[1][i] == -1 and bList[2][i] == -1:
            ret = "Yes"
    if bList[0][0] == -1 and bList[1][1] == -1 and bList[2][2] == -1:
        ret = "Yes"
    if bList[0][2] == -1 and bList[1][1] == -1 and bList[2][0] == -1:
        ret = "Yes"
    return ret

def deleteNumber(bList, number):
    for i in range(3):
        for j in range(3):
            if bList[i][j] == number:
                bList[i][j] = -1

raw1 = map(int, input().split())
raw2 = map(int, input().split())
raw3 = map(int, input().split())
bingo = [list(raw1), list(raw2), list(raw3)]

n = int(input())
for i in range(n):
    number = int(input())
    deleteNumber(bingo, number)

print("{}".format(checkBingo(bingo)))




Measured memory_bytes: 3064
#include<stdio.h>

int Fibo[100];

int fibonacci(int n){
  if(n == 0 || n == 1){
    return Fibo[n] = 1;
  }
  if(Fibo[n] != 0){
    return Fibo[n];
  }
  return Fibo[n] = fibonacci(n-1) + fibonacci(n-2);
}

int main(){
  int n,a;
  scanf("%d",&n);

  a = fibonacci(n);

  printf("%d\n",a);

  return 0;
}



Measured memory_bytes: 2104
import sys, re
from math import ceil, floor, sqrt, pi, factorial#, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    n, m, x, y = i_map()
    x_list = i_list()
    y_list = i_list()

    x_list.sort()
    y_list.sort()

    for i in range(x+1,y+1):
        if x_list[n-1] < i and i <= y_list[0]:
            print('No War')
            exit()

    print('War')

if __name__ == '__main__':
    main()


Measured memory_bytes: 58988
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;
long long combi(long long n, long long k) {
	if (n == k || k == 0)
		return 1;
	else {
		return combi(n - 1, k - 1) + combi(n - 1, k);
	}
}
int main() {
	string s;
	cin >> s;
	bool f = true;
	REP(i, s.size()) {
		if (i % 2) {
			if (s[i] != 'R')f = true;
			else {
				f = false;
				break;
			}
		}
		else {
			if (s[i] != 'L')f = true;
			else {
				f = false;
				break;
			}
		}
	}
	if (f)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d", $n);

$array1 = explode(' ', trim(fgets(STDIN)));
$array2 = array_unique($array1);
$count  = count(array_diff_assoc($array1, $array2));

if ($count === 0) {
  echo 'YES';
} else {
  echo 'NO';
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int w, h, n; cin >> w >> h >> n;
  int ans[110][110] = {0};
  vector<int> x(n), y(n), a(n); for(int i = 0; i < n; i++) cin >> x[i] >> y[i] >> a[i];
  for(int i = 0; i < n; i++) {
    if(a[i] == 1) {
      for(int j = 0; j < x[i]; j++) {
        for(int k = 0; k < h; k++) ans[j][k] = 1;
      }
    } else if(a[i] == 2) {
      for(int j = x[i]; j < w; j++) {
        for(int k = 0; k < h; k++) ans[j][k] = 1;
      }
    } else if(a[i] == 3) {
      for(int j = 0; j < w; j++) {
        for(int k = 0; k < y[i]; k++) ans[j][k] = 1;
      }
    } else if(a[i] == 4) {
      for(int j = 0; j < w; j++) {
        for(int k = y[i]; k < h; k++) ans[j][k] = 1;
      }
    }
  }
  int cnt=0;
  for(int i = 0; i < w; i++) {
    for(int j = 0; j < h; j++) {
      if(ans[i][j] == 0) cnt++;
    }
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
def combi(n, m)
  return 1 if m == 0
  return n if m == 1
  return combi(n, n - m) if m > n - m
  fact_s(n, n - m + 1) / fact_s(m, 1)
end
def fact_s(n, m)
  (m..n).to_a.inject(&:*)
end

N = gets.chomp

def count_under(k, n)
  cnt = 0
  (1...(3**k)).each{|i|
    wk = i.to_s(3)
    wk = '0' * (k-wk.size) + wk
    next if (/0+/ =~ wk).nil?
    next if (/1+/ =~ wk).nil?
    next if (/2+/ =~ wk).nil?
    wk = wk.gsub(/0/, '3').gsub(/1/, '5').gsub(/2/, '7')
    break if wk > n
    cnt += 1
  }
  cnt
end

def calc(k)
  ret = 0
  d = Hash.new
  (1..k-2).each{|i|
    (1..k-i-1).each{|j|
      tmp = [i, j, k-i-j].sort
      d[tmp] = combi(k, i) * combi(k-i, j) if not d.key?(tmp)
      ret += d[tmp]
    }
  }
  ret
end

ans = 0
(3..N.size-1).each{|k|
  ans += calc(k)
}
if not (/[8-9]/ =~ N[0]).nil? then
  ans += calc(N.size)
elsif not (/[3-7]/ =~ N[0]).nil? then
  ans += count_under(N.size, N)
end

puts ans


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

using namespace std;

int main() {
	int n;
	int k;
	cin >> n >> k;
	vector<char> vi(k);
	int val;
	for(int i=0;i<k;i++)
	{
		cin >> vi[i];
	}
	while(1)
	{
		string st = to_string(n);
		int flg=1;
		for(int i=0;i<k;i++)
		{
			if(count(st.begin(),st.end(),vi[i]) > 0) 
			{
				flg=0;
			}
		}
		if(flg)
		{
			cout<<n<<endl;
			return 0;
		}
		n++;
	}
	return 0;
}

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

int main(){
	int h;
	int w;
	int a;
	int b;
	while(true) {
		cin >> h >> w;
		if ( h==0 && w==0 ) break;
		b=h;
		while ( b>0 ) {
			a=w;
			while ( a>0 ) {
				if ( ((w-a)+(h-b))%2==0 ) {
					cout << "#";
				}else {
					cout << ".";
				}
				a--;
			}
			cout << endl;
			b--;
		}
		cout << endl;
	}
    return 0;
}

Measured memory_bytes: 1152
#include<iostream>

using namespace std;

int main(void){
  char s[4];
  int a=0,b=0,c=0,i;
  
  cin>>s;
  
  for(i=0;i<3;i++){
    if(s[i]=='a')
      a++;
    if(s[i]=='b')
      b++;
    if(s[i]=='c')
      c++;
  }
  if(a==1&&b==1&&c==1)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  
  return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    ll count=0;
    --n;
   // printf("%d\n",n);
    for(int i=1;i<=n;i++){
        count+=n/i;
       // printf("count = %d\n",count);
    }
    printf("%lld\n",count);
}

Measured memory_bytes: 3828
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
  int n,i,s;
  float r;
  for(;;){
    cin >> n;
    if(n==0)break;
    if(n==1) {
      cout << "deficient number" << endl;
      continue;
    }
    r = sqrt(n);
    s = 1;
    i = 2;
    while(i < r){
      if((n % i) == 0) s += i + (n / i);
      i++;
    }
    if(n == s) cout << "perfect number" << endl;
    else if(n < s) cout << "abundant number" << endl;
    else cout << "deficient number" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int a;
	cin >> a;
	cout << a + a * a + a * a * a << endl;
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>
#include <iomanip>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);

void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}

int main() {
    string s;
    cin >> s;

    vector<vector<ll>> dp(s.size()+1,vector<ll>(4));
    dp[0][0]=1;
    for(int i=0;i<s.size();i++){
        for(int j=0;j<4;j++){
            if(s[i]!='?') add(dp[i+1][j],dp[i][j]);
            else add(dp[i+1][j],dp[i][j]*3%MOD);
        }
        if(s[i]=='A' || s[i]=='?') {
            add(dp[i+1][1],dp[i][0]);
        }
        if(s[i]=='B' || s[i]=='?') {
            add(dp[i+1][2],dp[i][1]);
        }
        if(s[i]=='C' || s[i]=='?') {
            add(dp[i+1][3],dp[i][2]);
        }
    } 

    cout << dp[s.size()][3] << endl;

    return 0;
}

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

#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define cl(x, v) memset((x), (v), sizeof(x))
#define gcd(x,y) __gcd((x),(y))

#ifndef ONLINE_JUDGE
  #define db(x) cerr << #x << " == " << x << endl
  #define dbs(x) cerr << x << endl
  #define _ << ", " <<
#else
  #define db(x) ((void)0)
  #define dbs(x) ((void)0)
#endif

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

const ld EPS = 1e-9, PI = acos(-1.);
const int INF = 0x3f3f3f3f, MOD = 1e9+7;
const int N = 1e6+5;

int n, m, x, y, vis[N], a[N], cnt, ch[N], mrk[N];
vector<int> adj[N], v[N];
vector<pii> s;
ll ans;

void dfs(int u) {
  vis[u] = 1;
  v[cnt].push_back(a[u]);
  for (int v : adj[u]) if (!vis[v]) dfs(v);
}

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &x, &y);
    adj[x].push_back(y);
    adj[y].push_back(x);
  }

  for (int i = 0; i < n; i++) if (!vis[i]) {
    dfs(i);
    sort(v[cnt].begin(), v[cnt].end());
    cnt++;
  }

  for (int i = 0; i < cnt; i++) for (int x : v[i]) s.push_back({ x, i });
  sort(s.begin(), s.end());

  int tot = 2*(n-m-1);
  for (int i = 0; i < s.size() and tot; i++) if (!ch[s[i].nd]) ans += s[i].st, mrk[i] = 1, tot--, ch[s[i].nd]=1;
  for (int i = 0; i < s.size() and tot; i++) if (!mrk[i]) ans += s[i].st, tot--;

  if (tot) printf("Impossible\n");
  else printf("%lld\n", ans);

  return 0;
}


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

S=str(input())
S1=""
S2=""
ans=0

for i in range(N):
    #同じ種類の単語を無視するため一度あったのはここで格納
    past=[]
    count=0
    S1="".join(S[0:i+1])
    #print(S1)
    S2="".join(S[i+1:len(S)])
    #print(S1+"と"+S2)
    for j in range(len(S2)):

        if S1.rfind(S2[j])!=-1 and not(S2[j] in past):
            
            count+=1
            past.append(S2[j])
            
    
    ans=max(ans,count)

print(ans)

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

using i64 = int_fast64_t;
using f64 = double;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n, h, w;
    cin >> n >> h >> w;
    i64 ans = 0;
    for (i64 i = 0; i < n; i++) {
        i64 a, b;
        cin >> a >> b;
        if (h <= a && w <= b) ans++;
    }
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
const int maxn=1e5+10;
using namespace std;

ll quickqow(ll a,ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1) ans*=a;
		a*=a;b>>=1;
	}
	return ans;
}
ll gcd(ll a,ll b)
{
	return b==0?a:gcd(b,a%b);
}
int cmp(int a,int b)
{
	return a>b;
}
int main()
{
	ll h,k,sum=0;
	vector<ll> v;
	cin>>h>>k;
	for(int i=1;i<=h;i++)
	{
		ll x;cin>>x;
		v.push_back(x);
	}
	sort(v.begin(),v.end(),cmp);
	for(int i=k;i<v.size();i++) sum+=v[i];
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <string>

using namespace std;

int main(){

  int c = 0, flag = true;
  string S;
  
  cin >> S;
  
  if(S[0] != 'A') flag = false;

  for(int i = 2; i < S.size()-1; i++){
    if(S[i] == 'C') c++;
  }
  if(1 != c) flag = false;

  for(int i = 1; i < S.size(); i++){
    if(S[i] != 'C'){
      if(S[i] <= 90) flag = false;
    }
  }

  if(flag){
    cout << "AC" << endl;
  }else{
    cout << "WA" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
int rdn()
{
  int ret=0;bool fx=1;char ch=getchar();
  while(ch>'9'||ch<'0'){if(ch=='-')fx=0;ch=getchar();}
  while(ch>='0'&&ch<='9')ret=ret*10+ch-'0',ch=getchar();
  return fx?ret:-ret;
}
const int N=1e5+5,mod=1e9+7;
int n,m,x[N];
struct Mtr{
  int a[3][3];
  Mtr(){memset(a,0,sizeof a);}
  Mtr operator* (const Mtr &b)const
  {
    Mtr c;
    for(int i=0;i<3;i++)
      for(int k=0;k<3;k++)
	for(int j=0;j<3;j++)
	  c.a[i][j]=(c.a[i][j]+(ll)a[i][k]*b.a[k][j])%mod;
    return c;
  }
  void init()
  {
    for(int i=0;i<3;i++)for(int j=0;j<3;j++)a[i][j]=1;
    a[0][1]=a[2][1]=a[2][2]=2; a[1][0]=0;
  }
}ans,b0,b1,tp,one;
void pw(int n)
{
  b0=one; tp.init();
  while(n)
    { if(n&1)b0=b0*tp; tp=tp*tp; n>>=1;}
}
int main()
{
  n=rdn();m=rdn();
  for(int i=1;i<=m;i++)x[i]=rdn(); x[++m]=n;
  b1.init(); b1.a[2][1]=b1.a[2][0]=0; b1.a[2][2]=1;
  for(int i=0;i<3;i++)one.a[i][i]=1;
  ans.a[0][0]=1; pw(x[1]); ans=ans*b0;
  for(int i=1;i<m;i++)
    {
      ans=ans*b1;
      pw(x[i+1]-x[i]-1); ans=ans*b0;
    }
  printf("%d\n",ans.a[0][2]);
  return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <cmath>

#define rep(i, x, n) for (int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

int main()
{
    int N, D;
    int X[11][11];
    cin >> N >> D;
    rep(i, 0, N)
    {
        rep(r, 0, D)
        {
            cin >> X[i][r];
        }
    }

    int count = 0;
    rep(i, 0, N)
    {
        rep(r, 0, N)
        {
            if (i == r)
            {
                continue;
            }
            int sum = 0;

            rep(d, 0, D)
            {
                sum += (X[i][d] - X[r][d]) * (X[i][d] - X[r][d]);
            }
            int root = sqrt(sum);
            if (root * root == sum)
            {
                count++;
            }
        }
    }
    cout << count/2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

struct UnionFind{
  vector<int> d;
  UnionFind(int n) : d(n, -1){}
  int find(int x){
    if(d.at(x) < 0) return x;
    return d.at(x) = find(d.at(x));
  }
  bool unite(int x, int y){
    x = find(x); y = find(y);
    if(x == y) return false;
    if(d.at(x) > d.at(y)) swap(x, y);
    d.at(x) += d.at(y);
    d.at(y)= x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -d.at(find(x)); }
};

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> p(n);
  UnionFind uf(n);
  rep(snip_i, n) cin >> p.at(snip_i);
  rep(i, m){
    int x, y;
    cin >> x >> y;
    x--; y--;
    uf.unite(x, y);
  }
  int ans = 0;
  rep(i, n){
    if(uf.same(p.at(i)-1, i)) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
    int h[10000],w[10000],hh=-1,ww=-1,i=0,j,k,l;
    while (!(hh==0 && ww==0)){
        scanf("%d %d",&hh,&ww);
        h[i]=hh,w[i]=ww,i++;
    }
    for(j=0;j<i-1;j++){
        for(l=0;l<h[j];l++){
            for(k=0;k<w[j];k++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}



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

using ll = long long;

int main()
{
        ll N, X;
        ll sum = 0;

        cin >> N >> X;
        
        sum += N;
        
        ll a, b;
        a = N - X, b = X;
        while ( b > 0 ) {
                ll q = a / b;
                sum += 2 * q * b;
                a -= q * b;
                swap(a, b);
        }

        cout << sum - a << endl;

        
        return ( 0 );
}


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

sum=sum+i;

}
for(int i=1;i<=n;i++)
{
if(i%3==0||i%5==0)
{
	sum=sum-i;
}


}

cout<<sum;
return 0;

}

Measured memory_bytes: 3596
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

void Main()
{
	std::string str;
	std::cin >> str;
	auto N = str.size();
	std::vector<index_t> indexes;
	for (auto i : boost::irange<index_t>(1, N))
	{
		if (str[i - 1] == 'R' && str[i] == 'L')
		{
			indexes.emplace_back(i);
		}
	}
	std::vector<index_t> count(N);
	for (auto i : boost::irange<index_t>(0, N))
	{
		if (str[i] == 'R')
		{
			auto index = *boost::lower_bound(indexes, i);
			if ((index - i) % 2 == 0)
			{
				++count[index];
			}
			else
			{
				++count[index - 1];
			}
		}
		else
		{
			auto index = *boost::lower_bound(indexes | adaptor::reversed, i, std::greater<>());
			if ((i - index) % 2 == 0)
			{
				++count[index];
			}
			else
			{
				++count[index - 1];
			}
		}
	}
	boost::copy(count, std::ostream_iterator<index_t>(std::cout, " "));
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 1864
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    int m = min(a+b, b+c);
    int res = min(m, c+a);
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()

using namespace std;


int main(){

    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;

    vector<vector<int>> dp;
    vector<int> tmpv;

    rep(i, n + 1){
        tmpv.pback(0);
    }

    rep(i, n + 1){
        dp.pback(tmpv);
    }

    for(int i = n - 2; i > -1; i--){
        for(int j = n - 1; i < j; j--){   

            if(s[i] == s[j]){
                int tmp = min({j - i, n - j ,dp[i + 1][j + 1] + 1});

                ans = max(ans,tmp);
                dp[i][j] = tmp;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main()
{
    int i,d,j,k,n;
    cin>>n; k=n;
    int s=0;
    while(k!=0)
    {
        s+=k%10;
        k=k/10;
    }
    if(n%s==0) cout<<"Yes";
    else cout<<"No";

}


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

const int MOD = (int)1e9+7;

int main() {
	int N;
	cin >> N;
	vector<int> H(N);
	for(int i=0;i<N;i++)	cin >> H.at(i);

	bool ans=true;
	int now=H.at(N-1);
	for(int i=N-1;i>=0;i--){
		if(now>=H.at(i)){
			now=H.at(i);
			continue;
		}
		if(now==H.at(i)-1)	now=H.at(i)-1;
		else	ans=false;
	}
	if(ans)	cout << "Yes" << endl;
	else	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int x,y;
	char a[150][150];
	scanf("%d",&x);
	scanf("%d",&y);
	for(int i=0;i<x;i++)
    {
        for(int j=0;j<y;j++)
        {
            cin>>a[i][j];
        }
    }
	for(int i=0;i<x;i++)
    {
        int r=0;
        for(int j=0;j<y;j++)
        {
            if(a[i][j]=='#')
            {
                r++;
                break;
            }
        }
        if(r!=0)
        {
            for(int k=0;k<y;k++)
            {
            int c=0;
            for(int j=0;j<x;j++)
            {
                if(a[j][k]=='#')
                {
                    c++;
                    break;
                }
            }
            if(c!=0)
            {
                printf("%c",a[i][k]);
            }
            }
            printf("\n");
        }

    }
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(c) begin(c), end(c)
#define ok() puts(ok?"Yes":"No");
template<class T> bool chmax(T &a, const T &b) { if(a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if(a > b) { a = b; return true; } return false; }
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

ll D,T,S;
int main() {
  cin >>D>>T>>S;
  bool ok = false;
  if (T*S>=D) ok = true;
  ok();
  return 0;
}

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

int main()
{
    int k,n,mx=-1;
    cin>>k>>n;
    int a[n]={};
    for(int i=0;i<n;i++)
        {
            cin>>a[i];
            if(i)
            {
                mx=max(mx,a[i]-a[i-1]);
            }
        }
    mx=max(mx,a[0]+k-a[n-1]);
    cout<<k-mx;
    return 0;
}



Measured memory_bytes: 4412
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int N;
    cin >> N;
    
    int H[100] = {};
    
    int n = N;
    int i = 0;
    
    while (n--){
        cin >> H[i];
        i++;
    }
    
    int view = 0;
    int max_H = 0;
    int a = 0;
    
    for(i=0;i<=N;i++){
        while(a<=i){
    max_H = max(max_H,H[a]);
           a++;
        if(max_H==H[i]){
            view++;
        }
        }
        
    }
    
    cout << view << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
char xxx[1000000];
int main()
{
	long long n,i,j,k,q,x,y,z,sum,a,b,c,d;
	for (i=0;i<510000;i++)
	{
		xxx[i]='*';
	}
	string s,s1,s2;
	char xx;
	cin>>s;
	cin>>q;
	for (i=0;i<s.length();i++)
	{
		xxx[i+200000]=s[i];
	}
	z=s.length()-1;
	sum=0;
	s1="";
	s2="";
	a=0;
	b=0;
	for (i=0;i<q;i++)
	{
		cin>>x;
		if (x==1)
		{
			sum++;
		}
		else
		{
			cin>>y>>xx;
			if ((sum%2==0 && y==1) || (sum%2==1 && y==2))
			{
				a++;
				xxx[200000-a]=xx;
			}
			else
			{
				b++;
				xxx[200000+b+z]=xx;
			}
		}
	}
	if (sum%2==0)
	{
		for (i=0;i<500055;i++)
		{
			if(xxx[i]!='*')
			{
				cout<<xxx[i];
			}
		}
		cout<<endl;
	}
	else
	{
		for (i=500055;i>=0;i--)
		{
			if(xxx[i]!='*')
			{
				cout<<xxx[i];
			}
		}
		cout<<endl;
	}
}

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

int main(void)
{
    int N;
    cin >> N;
    string s[N];
    for (int i = 0; i < N; i++) {
        cin >> s[i];
    }
    sort(s, s+N);

    int M;
    cin >> M;
    string t[M];
    for (int i = 0; i < M; i++) {
        cin >> t[i];
    }
    sort(t, t+M);

    int maxEarn = 0;

    for (int i = 0; i < N; i++) {
        int blueEarn = 1;
        string tmp = s[i];
        for (int j = i+1; j < N; j++) {
            if (s[i] == s[j]) {
                blueEarn++;
                i++;
            }
            else {
                break;
            }
        }
        for (int j = 0; j < M; j++) {
            if (s[i] == t[j]) {
                blueEarn--;
            }
        }
        if (maxEarn < blueEarn)
            maxEarn = blueEarn;
    }

    cout << maxEarn << endl;

    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long int
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;

    // Disjoint Set DataStructure
    int parent[100001];         // reserve space for map if n > 10000
    int urank[100001];
    int sz[100001];

    void create(ll x)
    {
        parent[x] = x ;
        urank[x] = 1 ;         // rank = no. of nodes in its subtree
        sz[x]=1;
    }

    ll find(ll x)
    {
        if( parent[x] != x )    //path compression
        {
            parent[x] = find(parent[x]) ;
        }
        return parent[x];
    }

    void merge(ll x, ll y)
    {
        ll xroot = find(x);
        ll yroot = find(y);

        if(xroot==yroot)
            return;

        if( urank[xroot] <= urank[yroot] )    // Union by rank
        {
            parent[xroot] = yroot ;
            urank[yroot] = urank[yroot] + urank[xroot] ;
            sz[yroot]+=sz[xroot];
        }
        else
        {
            parent[yroot] = xroot;
            urank[xroot] = urank[xroot] + urank[yroot] ;
            sz[xroot]+=sz[yroot];
        }
    }

    vector<int> v[100001],v2[100001];

    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int n,m,k,i,j,a,b;
            cin>>n>>m>>k;
            for(i=1;i<=n;++i)
                create(i);
            for(i=1;i<=m;++i)
            {
                cin>>a>>b;
                v[a].pb(b);
                v[b].pb(a);
                merge(a,b);
            }
            for(i=1;i<=k;++i)
            {
                cin>>a>>b;
                v2[a].pb(b);
                v2[b].pb(a);
            }
            int par[n+1];
            for(i=1;i<=n;++i)
                par[i]=find(i);
            int ans=0;
            for(i=1;i<=n;++i)
            {
                ans=sz[par[i]]-1;
                for(j=0;j<v[i].size();++j)
                {
                    if(par[i]==par[v[i][j]])
                        --ans;
                }
                for(j=0;j<v2[i].size();++j)
                {
                    if(par[i]==par[v2[i][j]])
                        --ans;
                }
                cout<<ans<<" ";
            }
            cout<<endl;
        }
        return 0;
    }


Measured memory_bytes: 13432
#!/usr/bin/env python3
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import lru_cache, reduce
#from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())

li = LI()
print(li[2],li[0],li[1])


Measured memory_bytes: 6604
# coding: utf-8
import time
import re
import math
import fractions

def main():
    s=input()
    if len(s)==len(set(list(s))):
        print("yes")
    else:
        print("no")
start=time.time()
main()
#print("処理速度 {}sec".format(time.time()-start))
#"YNeos"[True::2]
#A=list(map(int,input().split()))
#A,B,C=map(int,input().split())
#n=int(input())
# global n,A,s,memo,mx,mn,L,B



Measured memory_bytes: 5300
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class AC>void r(AC &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int x,y,z;
int main(){
    r(x);r(y);r(z);
    if((x*100+y*10+z)%4==0)puts("YES");
    else puts("NO");
    return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int a,b;
void solve(){
	cin >> a >> b;
	
	cout << max({a+b,a-b,a*b}) << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>
#include <complex>
#include <iostream>
#include <iterator>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int n;
vi w, s;
vi array;

int best;
vi bestarray;

void solve(int g, int st, int k)
{
	if(g >= best)
		return;
	
	if(k == n){
		best = g;
		bestarray = array;
		return;
	}
	
	reep(i, k, n){
		if(st >= w[array[i]]){
			swap(array[k], array[i]);
			solve(g+(k+1)*w[array[k]], min(st-w[array[k]], s[array[k]]), k+1);
			swap(array[k], array[i]);
		}
	}
}

int main()
{
	while(scanf("%d", &n), n){
		vector<string> f(n);
		w.resize(n);
		s.resize(n);
		rep(i, n){
			char name[32];
			scanf("%s%d%d", name, &w[i], &s[i]);
			f[i] = name;
		}
		
		best = 100000000;
		array.resize(n);
		rep(i, n)
			array[i] = i;
		solve(0, 10000000, 0);
		rep(i, n){
			puts(f[bestarray[i]].c_str());
		}
	}

	return 0;
}

Measured memory_bytes: 908
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

// ランレングス圧縮(Run Length Encoding)
vector<pair<char,int>> RLE(string S){
  vector<pair<char,int>> p;
  int N = S.size();
  for (int i=0;i<N;i++) {
    if (S[i]==S[i+1]){
      int cnt = 1;
      char c = S[i];
      while (i+1<N && S[i]==S[i+1]) {
        i++;
        cnt++;
      }
      p.push_back({c,cnt});
    }
    else p.push_back({S[i],1});
  }

  return p;
}

int main(){
  string S; cin >> S;
  int N = S.size();
  int a[N] = {};

  auto p = RLE(S);
  int cumsum = 0;
  for (int j=0;j<p.size();j+=2){
    int r = p[j].second;
    int l = p[j+1].second;
    a[cumsum+p[j].second-1] += r/2 + l/2 + r%2;
    a[cumsum+p[j].second] += r/2 + l/2 + l%2;
    cumsum += p[j].second + p[j+1].second;
  }
  rep(i,N) {
    if (i>0) cout << " ";
    cout << a[i];
  }
  cout << endl;  

  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 4816
#include <stdio.h>
int main()
{
  int i,j,k;
  scanf("%d %d %d",&i,&j,&k);
  if(i == 5 && j == 7 && k == 5){
    printf("YES\n");
  }else if(i == 7 && j == 5 && k == 5){
    printf("YES\n");
  } else if (i == 5 && j == 5 && k == 7){
    printf("YES\n");
  } else {
    printf("NO\n");
  }

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>

using namespace std;

int main(void) {
	int num, i = 0;
	double m, ans = 0;
	string s;
	cin >> num;
	for (; i < num; i++) {
		cin >> m >> s;
		if (s[0] == 'J')
			ans += m;
		else
			ans += m * 380000.0;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
map<i_i, int> mp;
int parent[100500];
int number[100500];
vector<int> children[100050];
vector<int> path[100500];
ll N;
ll s[100050];
ll unknown = -1;
ll SIZE[100500];
ll sum[100050];
ll ans[100050];

void bfs1(int from) {
    SIZE[from] = 1;
    for(int i = 0; i < path[from].size(); i++) {
        int to = path[from][i];
        if(to == parent[from]) {
            int a = min(to, from);
            int b = max(to, from);
            number[from] = mp[{a, b}];
            continue;
        }
        parent[to] = from;
        children[from].push_back(to);
        bfs1(to);
        SIZE[from] += SIZE[to];
    }
}

void bfs2(int from) {
    for(int i = 0; i < children[from].size(); i++) {
        int to = children[from][i];
        bfs2(to);
    }
    if(from == 1) return;
    int p = parent[from];
    if(SIZE[from] * 2 == N) {
        unknown = from;
        sum[p] += sum[from];
        return;
    }
    ll delta = (N - SIZE[from]) - SIZE[from];
    ll cost = (s[from] - s[p]) / delta;
    ans[number[from]] = cost;
    sum[p] += sum[from] + cost * SIZE[from];
    return;
}

int main() {
    //cout.precision(10);
    cin >> N;
    for(int i = 1; i < N; i++) {
        ll a, b;
        cin >> a >> b;
        if(a > b) swap(a, b);
        mp[{a, b}] = i;
        path[a].push_back(b);
        path[b].push_back(a);
    }
    for(int i = 1; i <= N; i++) {
        cin >> s[i];
    }
    parent[1] = 0;
    bfs1(1);
    for(int i = 1; i <= N; i++) {
        //cout << i << " " << SIZE[i] << " " << parent[i] << " " << number[i] << endl;
    }
    bfs2(1);
    if(unknown != -1) {
        ll delta = s[1] - sum[1];
        ll cost = delta / SIZE[unknown];
        ans[number[unknown]] = cost;
    }
    for(int i = 1; i < N; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 34688
from collections import Counter

def solve(h, w, a):
    c = Counter(list("".join(a)))
    g = [0] * 3
    for num in c.values():
        g[0] += int(num % 2 == 1)
        g[1] += 2 * int(num % 4 == 2)
        g[2] += (num // 4) * 4
    if (w % 2 == 0) and (h % 2 == 0):
        return "Yes" if (g[2] == h*w) else "No"
    if (w % 2 == 1) and (h % 2 == 1):
        return "Yes" if (g[0] == 1) and g[1] <= (h + w - 2) else "No"
    if w % 2 == 1:
        return "Yes" if (g[0] == 0) and (g[1] <= h) else "No"
    if h % 2 == 1:
        return "Yes" if (g[0] == 0) and (g[1] <= w) else "No"
    return "Yes"

h, w = map(int, input().split())
a = [input() for r in range(h)]
print(solve(h, w, a))

Measured memory_bytes: 9500
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int m = in.nextInt();
        final int n = in.nextInt();
        final long[] ms = new long[m];
        final long[] ns = new long[n];
        for (int i = 0; i < m; i++) {
            ms[i] = in.nextInt();
        }
        for (int i = 0; i < n; i++) {
            ns[i] = in.nextInt();
        }
        final long[][] sum = new long[m + 1][n + 1];
//        final long[][] dp = new long[m][n];
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
//                if (ms[i] == ns[j]) {
//                    dp[i][j] = sum[i][j] + 1;
//                } else {
//                    dp[i][j] = 0;
//                }
                sum[i + 1][j + 1] += sum[i + 1][j];
                sum[i + 1][j + 1] += sum[i][j + 1];
                sum[i + 1][j + 1] -= sum[i][j];
                sum[i + 1][j + 1] += 1_000_000_007;
                sum[i + 1][j + 1] %= 1_000_000_007;
                if (ms[i] == ns[j]) {
                    sum[i + 1][j + 1] += sum[i][j] + 1;
                }
                sum[i + 1][j + 1] %= 1_000_000_007;
//                dp[i][j] %= 1_000_000_007;
            }
        }
        System.out.println((sum[m][n] + 1) % 1_000_000_007);
    }
}


Measured memory_bytes: 81072
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
double pi=acos(-1);
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    ll ans=n*n*n;
    cout<<ans<<endl;



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  int N;
  cin >> N;
  vector<int> hana(N+1);
  hana[0]=0;
  int max = 0;
  for (int i = 1; i <= N; i++) {
    cin >> hana[i];
    if (max < hana[i]) {
      max = hana[i];
    }
  }
  int count = 0;
  for (int i = 1; i <= max; i++) {
    for (int j = 0; j < N; j++) {
      if(hana[j+1] >= i && hana[j] < i){
        count++;
      }
    }
  }
  cout << count <<endl;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
long long GCD(long long a,long long b)
{
	if(b==0)
		return a;
	return GCD(b,a%b);
} 
long long LCM(long long a,long long b)
{
	return a*b/GCD(a,b);
} 
int main()
{
	long long a,b;
	scanf("%lld %lld",&a,&b);
	printf("%lld",LCM(a,b));
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static int a;
    static int b;
    static int c;

    private static void init() {
        Scanner scanner = new Scanner(System.in);
        a = scanner.nextInt();
        b = scanner.nextInt();
        c = scanner.nextInt();
        scanner.close();
    }


    public static void main(String args[]) {
        init();

        if(b - a == c - b){
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 22612
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())
    A.sort()
    print(A[-1] - A[0])
    
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 61752
#include<iostream>
using namespace std;
int a[100000], n, k, m, r;
inline void Div(int l, int s) {
	int p = l * 10, q = s;
	for (int i = 0; i < r + 10; i++) {
		a[i] += p / q; p = (p%q) * 10;
	}
}
int main() {
	while (true) {
		for (int i = 0; i < 10200; i++)a[i] = 0;
		cin >> n >> k >> m >> r; if (n == 0)break;
		Div(1, n);
		if (m == 1) { for (int i = 1; i < n; i++) { Div(1, n*i); } }
		for (int i = r + 10; i >= 1; i--) {
			if (a[i] >= 10) { a[i - 1] += a[i] / 10; a[i] %= 10; }
		}
		cout << a[0] / 10 << '.'; for (int i = 0; i < r; i++)cout << a[i] % 10; cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3096
# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=LI()
cou=Counter(lis)
ans=0
for v in cou.keys():
    if cou[v]>=v:
        ans+=cou[v]-v
    else:
        ans+=cou[v]
print(ans)

Measured memory_bytes: 64424
import itertools
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N = int(sys.stdin.buffer.readline())
X, Y, H = list(zip(*[map(int, sys.stdin.buffer.readline().split()) for _ in range(N)]))
X = np.array(X, dtype=int)
Y = np.array(Y, dtype=int)
H = np.array(H, dtype=int)

# ゼロのやつ使いたくない
idx = (H > 0).argmax()
# 全探索して矛盾がないのを探す
for x, y in itertools.product(range(101), range(101)):
    height = H[idx] + abs(X[idx] - x) + abs(Y[idx] - y)
    ok = np.all(np.maximum(0, height - (np.abs(X - x) + np.abs(Y - y))) == H)
    if ok:
        print(x, y, height)
        exit()


Measured memory_bytes: 12512
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

//ll dx[4] = {1, 0, -1, 0};
//ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	int n, k;
	cin >> n >> k;
	if (k == 1) {
		dump(0);
	} else {
		dump(n - k);
	}
	return 0;
}

Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize ("Ofast")
//#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define d long double
#define pii pair<int,int>
#define pb push_back
#define pf push_front
#define cases int t;cin>>t;while(t--)
#define N 100003
#define M 103
#define inf LLONG_MAX
//int mod=1e9+7;
//int mod=998244353;

signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int n;
    cin>>n;
    vector<int> b(n+1);
    int i,j;
    for(i=1;i<=n;++i)
        cin>>b[i];

    vector<int> ans;    ans.clear();
    while(b.size()>1)
    {
        bool flag=0;
        for(i=b.size()-1;i>=1;--i)
        {
            if(b[i]==i)
            {
                ans.pb(i);
                b.erase(b.begin()+i);
                flag=1;
                break;
            }
        }
        if(!flag)
        {
            cout<<-1;
            return 0;
        }
    }

    while(ans.size())
    {
        cout<<ans.back()<<"\n";
        ans.pop_back();
    }


    return 0;
}


Measured memory_bytes: 256