akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;	

int main() {
	int x, a;
	cin >> x >> a;
	if (x < a) {
		cout << 0 << endl;
	}
	else {
		cout << 10 << endl;
	}
}


Measured memory_bytes: 3636
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main() {
  int x;
  cin>>x;
  
  set<int> s;
  s.insert(x);
  
  int i=2;
  while(1){
    if(x%2==0) x=x/2;
    else x=3*x+1;
    if(s.find(x)!=s.end()) break;
    s.insert(x);
    i++;
  }
  
  cout<<i<<endl;
  
  return 0;
}

Measured memory_bytes: 3592
<?php
$nl=(int)trim(fgets(STDIN));
$prtw=explode(' ',trim(fgets(STDIN)));
$intw=explode(' ',trim(fgets(STDIN)));

$pstw=array($nl);
for($i=0;$i<$nl;$i++){$pstw[$i]=0;}

function to_pstw($pri,$ini,$psi,$nl){
	global $prtw,$intw,$pstw;

	$a=$prtw[$pri];
	$pstw[$psi+$nl-1]=$a;

	if($nl<=1){return;}

	$i=0;
	while($intw[$ini+$i]!=$a){++$i;}

	if($i>0){to_pstw($pri+1,$ini,$psi,$i);}
	if($nl-$i-1>0){to_pstw($pri+$i+1,$ini+$i+1,$psi+$i,$nl-$i-1);}
}

to_pstw(0,0,0,$nl);
printf($pstw[0]);
for($i=1;$i<$nl;$i++){printf(" %d",$pstw[$i]);}
printf("\n");

Measured memory_bytes: 15552
#21
n=int(input())
a=list(map(int,input().split()))
a.sort()

m = a[-1]
a_minus_m = [abs(aa-m/2) for aa in a]

mi = 10**10
i_mi=0
for i,aa in enumerate(a_minus_m):
    if aa<mi:
        mi =aa
        i_mi=i

r = a[i_mi]
print(m,r)

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


int main() {
    int N;cin >> N;
    int mod;mod = 1000000007;
    long long int ans = 1;
    for (int i = 1;i <= N;i++){
        ans*=i;
        ans%=mod;
    }
    cout << ans << endl;

}       

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

int main() {
  int N;
  cin >> N;

  // ここにプログラムを追記
  string S[100];

  /* 入力ループ */
  for(int i=0; i<N; i++) {
    cin >> S[i];
  }

  int p=0,w=0,g=0,y=0;
  for(int i=0; i<N; i++) {
    if(S[i] == "P") {
      p++;
    } else if(S[i] == "W") {
      w++;
    } else if(S[i] == "G") {
      g++;
    } else if(S[i] == "Y") {
      y++;
    } else {
        ;/* No function */
    }
  }

  /* 出力ループ */
  if(y > 0) {
    cout << "Four" << endl;
  } else {
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
n = gets.to_i
a = (1..n).map { gets.to_f }
val_count = Hash[a.group_by(&:itself).map {|k, v| [k, v.size] }]
count_accum = 0
point = {}
val_count.keys.sort.each do |x|
  point[x] = count_accum * 3 + val_count[x] - 1
  count_accum += val_count[x]
end
a.each {|x| puts point[x] }


Measured memory_bytes: 9024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define ve vector

ll dp[3100][3100];

int main(){
    int n;
    cin >> n;
    ve<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        dp[i][i] = 0;
    }
    for(int len = 1; len < n+1; len++){
        for(int i = 0; i+len < n+1; i++){
            int j = i+len;
            if((n-len)%2==0){
                dp[i][j] = max(dp[i+1][j] + a[i], dp[i][j-1] + a[j-1]);
            }else{
                dp[i][j] = min(dp[i+1][j] - a[i], dp[i][j-1] - a[j-1]);
            }
        }
    }
    cout << dp[0][n] << endl;
    return 0;
}

Measured memory_bytes: 73984
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  int N;
  cin >> N;
  int max=0,sum=0;
  vector<int> L(N);
  for(int i=0; i<N; i++){
    cin >> L.at(i);
    sum += L.at(i);
    if(max<L.at(i)) max = L.at(i);
  }
  if(max<sum-max) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007
#A
def A():
    t,x = LI()
    print(t/x)

#B
def B():
    n = I()
    a = LI()
    m = max(a)
    if m >= sum(a)-m:
        print("No")
    else:
        print("Yes")


#C
def C():
    n,m = LI()
    x = LI()
    x.sort()
    l = [x[i+1]-x[i] for i in range(m-1)]
    l.sort()
    l = l[::-1]
    ans = sum(l[max(n-1,0):])
    print(ans)

#D
def D():
    n,k = LI()
    a = LI()
    k = list(map(int,list(bin(k)[2:])))
    l = len(k)
    for i in range(n):
        a[i] = list(map(int,list(bin(a[i])[2:])))
        l = max(l,len(a[i]))
    for i in range(n):
        for j in range(l-len(a[i])):
            a[i].insert(0,0)
    for j in range(l-len(k)):
        k.insert(0,0)
    s = [[0,0] for i in range(l)]
    pow2 = [1 for i in range(l)]
    for i in range(l-1)[::-1]:
        pow2[i] = pow2[i+1]*2
    for i in a:
        for j in range(l):
            s[j][0] += pow2[j]*i[j]
            s[j][1] += pow2[j]*(not i[j])
    dp = [0 for i in range(l+1)]
    small = False
    for i in range(l):
        if not small:
            if not k[i]:
                dp[i+1] += dp[i]+s[i][0]
            else:
                if s[i][0] >= s[i][1]:
                    dp[i+1] += dp[i]+s[i][0]
                    small = True
                else:
                    dp[i+1] += dp[i]+s[i][1]
        else:
            dp[i+1] += dp[i]+max(s[i])
    print(dp[l])

#E
if __name__ == "__main__":
    C()

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 14332
#include <stdio.h>

int main(){

  int i,n,S[100000],q,T[50000],count = 0;
  int left,right,mid;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }

 scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }

  for(i=0;i<q;i++){
    left = 0;
    right = n;
    while(left < right){
      mid = (left + right)/2;
      if(S[mid] == T[i]){
	count++;
	break;
      }
      else if(T[i] < S[mid]){
	right = mid;
      }
      else{
	left = mid +1;
      }
    }
  }

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

  return 0;
}

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

#define ll long long
ll dp[100005], hgt[100005], n;

ll solve (ll i) {
	if (i == 0) {
		return 0;
	}

	if (dp[i] != -1) {
		return dp[i];
	}

	dp[i] = solve(i - 1) + abs (hgt[i] - hgt[i - 1]);
	if (i >= 2)
		dp[i] = min (dp[i], solve (i - 2) + abs (hgt[i] - hgt[i - 2]));
	return dp[i];
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
	cin >> n;
	for (ll i = 0; i < n; i++) {
		cin >> hgt[i];
	}
	memset (dp, -1, sizeof dp);
	cout << solve (n - 1) << "\n";
}

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

int main() {
  vector<int> X(3);
  rep(i,3) cin >> X.at(i);
  
  swap(X.at(0), X.at(1));
  swap(X.at(0), X.at(2));
  
  for(auto e:X) cout << e << " ";
  cout << endl;
  return 0;
}




Measured memory_bytes: 3624
S = input()
Scnt = S.count('S')
result = 0
result2 = 0

for i in range(3):
    if S[i] == 'R':
        result = result + 1
    else:
        if result2 < result:
            result2 = result
        result = 0
 
if result > result2:
    print(result)
else:
    print(result2)


Measured memory_bytes: 9100
#include <bits/stdc++.h>
using namespace std;
using pp=pair<int,char>;
using ll=long long;

int main() {
  int N;
  cin >> N;
  vector<int> V(N, 0);
  int a, ans=0;
  for (int i=0; i<N; i++) {
    cin >> a;
    if (a>N) {ans++;}
    else {
      V[a-1]++;
    }
  }
  for (int i=0; i<N; i++) {
    if (V[i]>i+1) {
      ans+=V[i]-(i+1);
    }
    else if (V[i]<i+1) {
      ans+=V[i];
    }
  }
  cout << ans << endl;
}
 

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

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

  int n;
  cin >> n;

  string s;
  cin >> s;

  int l = 0, r = n-1, ans = 0;
  while (l < r) {
    while (l < n && s[l] == 'R') ++l;
    while (r >= 0 && s[r] == 'W') --r;
    if (l < r) ++ans;
    else break;
    ++l;
    --r;
  }
  cout << ans << '\n';

}


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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n;
  string s, t;
  Solver(LL n) : n(n){};

  void solve() {
    cin >> s >> t;
    for (int i = 0; i < n; ++i) {
      cout << s[i] << t[i];
    }
    cout << endl;
  }
};
class Solver2 {
 public:
  int n, m;
  Solver2(LL n, LL m) : n(n), m(m){};

  void solve() {
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


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

class card{
public:
	char mark;
	int num;
};

void trace(card k[], int n){
	for(int i = 0 ; i < n ; i++){
		if(i != 0){
			cout << " ";
		}
		cout << k[i].mark << k[i].num;
	}
	cout << endl;
}

void bubblesort(card a[], int n){
	bool flag = 1;

	for(int i = 0 ; flag ; i++){
		flag = 0;
		for(int j = n - 1 ; j  >= i + 1 ; j--){
			if(a[j].num < a[j-1].num){
				swap(a[j],a[j-1]);
				flag = 1;
			}
		}
	}
	trace(a,n);
}

void selectionsort(card a[], int n){
	int min;
	bool flag;

	for(int i = 0 ; i < n - 1 ; i++){
		min = i;
		flag = 0;

		for(int j = i + 1 ; j < n ; j++){
			if(a[min].num > a[j].num){
				min = j;
				flag = 1;
			}
		}
		if(flag){
			swap(a[min],a[i]);
		}
	}

	trace(a,n);
}

bool isStable(card selection[], card bubble[], int n){
	for(int i = 0 ; i < n ; i++){
		if((selection[i].num != bubble[i].num) || (selection[i].mark != bubble[i].mark)){
			return false;
		}
	}
	return true;
}

int main(){
	int n;
	card a[MAX];
	card b[MAX];
	cin >> n;

	for(int i = 0 ; i < n ; i++){
		cin >> a[i].mark;
		cin >> a[i].num;
		b[i] = a[i];
	}

	bubblesort(a,n);
	cout << "Stable" << endl;
	selectionsort(b,n);
	if(isStable(b,a,n)){
		cout << "Stable" << endl;
	} else {
		cout << "Not stable" << endl;
	}

}

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

t = 1000000000000001

def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
    
    
    
print(num2alpha(N).lower())

Measured memory_bytes: 9172
n, m = map(int, input().split())
stu = []
check = []
for i in range(n):
    stu.append(list(map(int, input().split())))
for i in range(m):
    check.append(list(map(int, input().split())))
for i in stu:
    min_dis = 4 * 10 ** 8 + 1
    for j, k in enumerate(check):
        dis = abs(i[0] - k[0]) + abs(i[1] - k[1])
        if dis < min_dis:
            ans = j + 1
            min_dis = dis
    print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

const long long inf=1e16;

typedef pair<int,int> P;

P ps[4040];
int N;

vector<int> p1,n1,p2;

vector<int> xs;
vector<int> nearest;
vector<vector<long long> > dp;
vector<long long> tmp;

void init(){
	p1.clear();
	n1.clear();
	p2.clear();
	xs.clear();
	nearest.clear();
	dp.clear();
}

int main(){
	while(true){
		scanf("%d",&N);
		if(N==0) break;
		init();
		for(int i=0;i<N;i++){
			int p,d;
			scanf("%d%d",&p,&d);
			ps[i]=P(p,d);
		}
		sort(ps,ps+N);
		if(N==2){
			printf("%d\r\n",ps[1].first-ps[0].first);
			continue;
		}
		for(int i=0;i<N;i++){
			if(ps[i].second==1){
				p2.push_back(ps[i].first);
			}else{
				p1.push_back(ps[i].first);
				n1.push_back(ps[i].second);
			}
		}
		if(n1.size()==0){
			printf("-1\r\n");
			continue;
		}else if(n1.size()==1){
			if(n1[0]<p2.size()){
				printf("-1\r\n");
			}else{
				long long ans=0;
				for(int i=0;i<p2.size();i++){
					int tmp=abs(p2[i]-p1[0]);
					ans+=tmp;
				}
				printf("%lld\r\n",ans);
			}
			continue;
		}else if(p2.size()==0){
			printf("%d\r\n",p1[p1.size()-1]-p1[0]);
			continue;
		}
		int cnt=0;
		for(int i=0;i<n1.size();i++){
			if(i==0||i+1==n1.size()){
				n1[i]--;
			}else{
				n1[i]-=2;
			}
			cnt+=n1[i];
		}
		if(cnt<p2.size()){
			printf("-1\r\n");
			continue;
		}
		for(int i=0;i<p1.size();i++){
			for(int j=0;j<n1[i];j++){
				xs.push_back(p1[i]);
			}
		}
		for(int i=0;i<p2.size();i++){
			int id=distance(xs.begin(),lower_bound(xs.begin(),xs.end(),p2[i]));
			if(id!=xs.size()&&id!=0){
				int r=abs(xs[id]-p2[i]);
				int l=abs(xs[id-1]-p2[i]);
				if(r>l) id--;
			}
			nearest.push_back(id);
		}
		int l=p2.size();
		tmp.clear();
		for(int i=0;i<2*l+1;i++) tmp.push_back(inf);
		for(int i=0;i<l;i++) dp.push_back(tmp);
		for(int i=0;i<2*l+1;i++){
			int k=nearest[0]+i-l;
			if(k>=0&&k<xs.size()){
				dp[0][i]=abs(xs[k]-p2[0]);
			}
			if(i>0) dp[0][i]=min(dp[0][i],dp[0][i-1]);
		}
		for(int i=1;i<l;i++){
			for(int j=0;j<2*l+1;j++){
				int k=nearest[i]+j-l-1;
				if(k+1<0||k+1>=xs.size()){
					if(j>0){
						dp[i][j]=min(dp[i][j],dp[i][j-1]);
					}
					continue;
				}
				int d=k-nearest[i-1];
				int prev=d+l;
				if(prev>l*2) prev=l*2;
				if(prev<0){
					if(j>0){
						dp[i][j]=min(dp[i][j],dp[i][j-1]);
					}
					continue;
				}
				if(dp[i-1][prev]==inf){
					if(j>0){
						dp[i][j]=min(dp[i][j],dp[i][j-1]);
						continue;
					}
				}
				dp[i][j]=dp[i-1][prev]+abs(xs[k+1]-p2[i]);
				if(j>0) dp[i][j]=min(dp[i][j],dp[i][j-1]);
			}
		}
		printf("%lld\r\n",dp[l-1][2*l]+p1[p1.size()-1]-p1[0]);
	}
	return 0;
}

Measured memory_bytes: 291500
#include<iostream>
using namespace std;
int main() {
	int a[9999] = { 0 };
	for (int i = 0; i < 10000; i++){
		cin >> a[i];
		if (a[i] == 0){
			for (int i = 0; i < 10000; i++){
				if (a[i] == 0){
					return 0;
				}
				cout << "Case " << i+ 1 << ": " << a[i] << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2996
s = input()
t = input()

s_d = {}
t_d = {}
for i in range(len(s)):
    if s[i] not in s_d:
        new_num = len(s_d)+1
        s_d[s[i]] = new_num
        s_valid = -1
    else:
        s_valid = s_d[s[i]]

    if t[i] not in t_d:
        new_num = len(t_d)+1
        t_d[t[i]] = new_num
        t_valid = -1
    else:
        t_valid = t_d[t[i]]

    if s_valid != t_valid:
        print('No')
        break

else:
    print('Yes')

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

  int N,M;

  cin >> N ;

  vector<int> T(N);
  
  rep(i,N) cin>> T.at(i);

  cin >> M ;

  vector<int> p(M);
  vector<int> x(M);

  rep(i,M) cin >> p.at(i) >> x.at(i);//入力終了

  rep(i,M){
    int L=p.at(i)-1;
    int temp=T.at(L);
    T.at(L)=x.at(i);//置き換え作業

    int ans=0;
    rep(j,N) ans+=T.at(j);
    cout << ans << endl;

    T.at(L)=temp;//元に戻す
  }

  return 0;
}

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

int main(){
	int n,m;
	cin>>n>>m;
	vector<vector<int> > v;
	vector<int>c;
	for(int i=0;i<n;i++){
		v.push_back(c);
	}
	int a,b;
	for(int i=0;i<m;i++){
		cin>>a>>b;
		v[a-1].push_back(b-1);
	}
	for(int i=0;i<v[0].size();i++){
		a=v[0][i];
		for(int j=0;j<v[a].size();j++){
			if(v[a][j] == n-1){
				cout<<"POSSIBLE"<<endl;
				return 0;
			}
		}
	}
	cout<<"IMPOSSIBLE"<<endl;
	return 0;
}

Measured memory_bytes: 9708
x = int(input())
l_t = [int(i)for i in input().split()]
print(' '.join([str(p) for p in l_t]))
for i in range(1,x):
    v = l_t[i]
    j = i - 1
    while j >= 0 and l_t[j] > v:
        l_t[j + 1] = l_t[j]
        j = j - 1
    l_t[j + 1] = v
    print(' '.join([str(p) for p in l_t]))
    


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

int main() {
    int N;
    cin >> N;
    int a = N % 10;
    if(a == 2 || a == 4 || a == 5 || a == 7 || a == 9){
        cout << "hon" << endl;
    }
    if(a == 0 || a == 1 || a == 6 || a == 8){
        cout << "pon" << endl;
    }
    if(a == 3){
        cout << "bon" << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
N = int(input())
A = list(map(int, input().split()))
cumsum = [0]
cumsumx = [0]
for i in range(N):
  cumsum.append(cumsum[i] + A[i])
  cumsumx.append(cumsumx[i] ^ A[i])
res = 0
"""
for i in range(1, N + 1):
  for j in range(i, N + 1):
    #print(i, j, cumsum[j - 1] - cumsum[i], cumsumx[j] ^ cumsumx[i - 1])
    if cumsum[j] - cumsum[i - 1] == cumsumx[j] ^ cumsumx[i - 1]:
      res += 1
"""   
for i in range(1, N + 1):
  l = i
  r = N
  j = (l + r) / 2

  while True:
    j = (l + r) // 2
    if r - l < 2:
      #print(i, j, l, r)
      break
    if cumsum[j] - cumsum[i - 1] == cumsumx[j] ^ cumsumx[i - 1]:
      l = j
    else:
      r = j
  #print(i, j)
  if j < N:
    if cumsum[j + 1] - cumsum[i - 1] == cumsumx[j + 1] ^ cumsumx[i - 1]:
        j += 1
  res += j - i + 1
    
print(res)
#print(cumsum)
#print(cumsumx)

Measured memory_bytes: 100300
#include <stdio.h>

int key(int,int);

int n,a[2000];

int main(){
  int q,m,i;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(key(0,m)) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}

int key(int x,int y){
  int rec;
  if(y==0) return 1;
  if(x>=n) return 0;
  rec=key(x+1,y) || key(x+1,y-a[x]);

  return rec;
}



Measured memory_bytes: 2084
import java.util.Scanner;

	public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			long n = sc.nextLong();
			long ret = 0;
			
			for(int i=1;i<=n;i++) {
				if(i%3!= 0 && i%5!=0) {
					ret+=i;
				}
			}
			
			System.out.println(ret);
		}
	}

Measured memory_bytes: 35764
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int H, W, N;
  cin >> H >> W >> N;
  vector<int> a(N);
  rep(i, N)cin >> a[i];
  
  vector<vector<int>> ans = vector<vector<int>>(H, vector<int>(W));
  int index = 0;
  for(int i = 0;i < H; i++){
    if(i % 2 == 0){
      // cout << "right" << endl;
      for(int j = 0; j < W; j++){
	ans[i][j] = index + 1;
	a[index]--;
	if(a[index] == 0)index++;
      }
    }else{
      // cout << "left" << endl;
      for(int j = W - 1; j >= 0; j--){
	ans[i][j] = index + 1;
	a[index]--;
	if(a[index] == 0)index++;
      }
    }
  }

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(j == 0)cout << ans[i][j];
      else cout << " " << ans[i][j];
    }
    cout << endl;
  }
  return 0;
}


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

#define int long long
const int M = 1000000007;

int sq(int n) {
	return (n*n) % M;
}

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

	// sequence is mostly 1
	// two non-1s consecutive --> sequence terminates
	// operations:
	// place 1 --> place anything next --> 1 way to
	// place k > 1
	//		--> jump to i+k, placing full 1 along the way --> 1 way
	//		--> jump to INF, placing a non-1 value --> (n-1) ways
	// O(N^2) dp --> how to O(N)?
	// at position n --> can place anything --> still terminates --> n ways
	// at position > n --> consider to be terminated --> n+3
	// terminate at position n and > n
	// ans = dp[n]*n + dp[n+3]
	
	int n; cin >> n;
	vector<int> dp(n+5);
	dp[0] = 1; dp[1] = M - 1;
	for (int i = 0; i <= n; i++) {
		if (i) dp[i] += dp[i-1];
		dp[i] %= M;
		if (dp[i] < 0) dp[i] += M;
		
		int val = dp[i];
		// at n --> terminates placing anything
		if (i == n) {
			break;
		}
		
		// one way to reach the next
		dp[i+1] = (dp[i+1] + val) % M;
		dp[i+2] = (dp[i+2] - val) % M;
		
		if (!i) continue;
		
		// one way to reach each of min(i+2+1, n) using 1 --> sum n-1
		int reachable = max(0LL, n - (i+2));
		int inf_reach = (n-1) - reachable;
		
		dp[i+3] = (dp[i+3] + val) % M;
		dp[n+1] = (dp[n+1] - val) % M;
		
		dp[n+3] = (dp[n+3] + val*inf_reach) % M;
		
		// terminate immediately --> (n-1)*(n-1) ways
		dp[n+3] = (dp[n+3] + val*sq(n-1)) % M;
	}
	
	for (int i = 1; i <= n; i++) {
		//cout << dp[i] << ' ';
	}
	//cout << dp[n+3] << '\n';
	
	cout << (dp[n]*n + dp[n+3]) % M << '\n';

	return 0;
}

Measured memory_bytes: 8064
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (N, K): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };
    let (R, S, P): (i64, i64, i64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };
    let T: Vec<char> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    };

    let mut free = vec![true; N];
    let mut res = 0;
    for i in 0..N {
        if i < K || free[i - K] || T[i] != T[i - K] {
            res += match T[i] {
                'r' => P,
                's' => R,
                _ => S,
            };
            free[i] = false;
        }
    }
    let ans = res;

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<bitset>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<numeric>
#include<set>
using namespace std;

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

#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)

long long INF=1e9;
const long long mod=2019;
#define ll long long

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int>a(n),b(n);
    rep(i,n-1){
        cin>>b[i];
    }
    a[n-1]=b[n-2];
    for(int i=n-2;i>=1;i--){
        a[i]=min(b[i],b[i-1]);
    }
    a[0]=b[0];
    int sum=0;
    rep(i,n){
        sum+=a[i];
    }
    cout<<sum<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	int n, m;
	cin >> n >> m;
	cout << (100*(n-m) + 1900*m)*pow(2, m);
	

}


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

#define MAXN 10000009

ll spf[MAXN];

void sieve()
{
    spf[1] = 1;
    for (ll i=2; i<MAXN; i++)

        spf[i] = i;

    for (ll i=4; i<MAXN; i+=2)
        spf[i] = 2;

    for (ll i=3; i*i<MAXN; i++)
    {
        if (spf[i] == i)
        {

            for (ll j=i*i; j<MAXN; j+=i)

                if (spf[j]==j)
                    spf[j] = i;
        }
    }

}
int main()
{
    sieve();

    ll i,n,ans = 1,num,p,cnt;

    scanf("%lld",&n);

    ll div;
    for(i = 2 ; i<=n; i++)
    {

        num = i;
        p = -1;
        cnt = 0ll;
        div = 1ll;
        while (num > 1ll)
        {
            if(p == -1)
            {
                p = spf[num];
                cnt++;
            }
            else if(p == spf[num])
            {
                cnt++;
            }
            else if(p != spf[num])
            {
                div *= (cnt+1);
                p = spf[num];
                cnt = 1;
            }
            num = num / spf[num];
        }

        div *= (cnt+1ll);

        ans += (i*div);
        // cout << i << " " << num <<" " << cnt << " " << div << endl;
    }

    printf("%lld\n",ans);
}


Measured memory_bytes: 81948
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
const int maxc = 26;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double pi = acos(-1.0);
const double eps = 1e-8;
inline int read(){
    int f = 1,x = 0; char ch = getchar();
    while(ch < '0' || ch > '9'){if(ch == '-')f = -1;ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = x * 10 + ch - 48;ch = getchar();}
    return f * x;
}
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll qw(ll x,ll y){ll ans = 1;while(y){if(y&1) ans *= x;x *= x;y >>= 1;}return ans;}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool is_prime(ll x){if(x <= 1) return 0;for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;	}
int n,h[maxn];
void solve(){
	int ans = 0,tmp = 0;
	for(int i = 1;i < n;i++){
		if(h[i] <= h[i-1]) tmp++;
		else{
			ans = max(tmp,ans);
			tmp = 0;
		}
	}
	ans = max(tmp,ans);
	cout << ans << endl;
} 
int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	rep(i,0,n-1) cin >> h[i];
	solve();
	return 0;	
}

Measured memory_bytes: 640
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    VV vec(10, V(10));
    rep3(i,1,n+1){
        string s = to_string(i);
        vec[s[0] - '0'][s[s.size() - 1] - '0']++;
    }
    ll sum = 0;
    rep(i,10){
        rep(j,10){
            sum += vec[i][j] * vec[j][i];
            sum %= MOD;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
const long long MOD = 1e9+7, INF = 1e18;
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a=b;return true;}return false;}



signed main(){
	int N;
	cin >> N;
	string A,B,C;
	cin>>A>>B>>C;
	int ans = 0;
	REP(i,N){
		set<int>st;
		st.insert(A[i]);
		st.insert(B[i]);
		st.insert(C[i]);
		if(st.size()==1)continue;
		else if(st.size()==2)ans++;
		else ans+=2;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
string s;
cin >> s;
rep(i,s.size()){
  if(s[i]=='7'){
    cout <<"Yes" << endl;
    return 0;
  }
}
cout << "No" << endl;
return 0;
}

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

int main(){
 string a;
  cin>>a;
  int c,d;
  c=0;
  d=a.size();
  for(int i=0;i<d;i++){
    if(i%2==0&&a[i]=='0'){
c++;
  }
    if(i%2==1&&a[i]=='1'){
      c++;
    }
  }
  c=min(c,d-c);
       cout<<c<<endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main() {
    int c,r;
    cin >> c >> r;
    int a[c][r];
    int s = 0;
    for(int i=0;i < c;i++){
        int sum = 0;
        for(int j=0;j < r;j++){
            cin >> a[i][j];
            sum += a[i][j];
            cout << a[i][j] << " ";
        }
        s += sum;
        cout << sum << endl;
    }
    
    for(int i=0;i < r;i++){
        int sum=0;
        for(int j=0;j < c;j++){
            sum+=a[j][i];
        }
        cout << sum << " ";
    }
    cout << s << endl;
}


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

using namespace std;

int n;
int arr[100100];

int main() {
    int i;
    scanf("%d",&n);
    for (i=0;i<n;i++) scanf("%d",&arr[i]);
    int maxi = 0, mini = 987654321;
    for (i=0;i<n;i++) {
        maxi = max(maxi,arr[i]);
        mini = min(mini,arr[i]);
    }
    if (maxi-mini>1) {
        printf("No\n");
        return 0;
    }
    if (maxi==mini) {
        if (arr[0]<=n/2||arr[0]==n-1) printf("Yes\n");
        else printf("No\n");
        return 0;
    }
    int cnt = 0;
    for (i=0;i<n;i++) {
        if (arr[i]==mini) cnt++;
    }
    if (maxi-cnt<=(n-cnt)/2&&maxi>=cnt+1) printf("Yes\n");
    else printf("No\n");

    return 0;
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    vector<double> p(n);
    for(i = 0;i < n;++i){
        cin >> p.at(i);
    }
    vector<vector<double>> dp(n,vector<double>(n+1, 0.0));
    dp.at(0).at(0) = 1.0 - p.at(0);
    dp.at(0).at(1) = p.at(0);
    for(i = 1;i < n;++i){
        for(j = 0;j <= i+1;++j){
            if(j == 0) dp.at(i).at(j) = dp.at(i-1).at(j)*(1.0 - p.at(i));
            else dp.at(i).at(j) = dp.at(i-1).at(j-1)*p.at(i) + dp.at(i-1).at(j)*(1.0 - p.at(i));
        }
    }
    double ans = 0;
    for(i = n;i > n/2;--i){
        ans += dp.at(n-1).at(i);
    }
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 70656
{-# LANGUAGE BangPatterns #-}

module Main
  ( main
  )
where

import           Control.Applicative
import           Control.Monad
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as MV
import           Control.Monad.ST
import           Data.Ord

parse = fst . fromJust
parseInt = parse . BS.readInt
parseInteger = parse . BS.readInteger
readInt = parseInt <$> BS.getLine
readInteger = parseInteger <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine
readIntegerList = map parseInteger . BS.words <$> BS.getLine

main = do
  [n, k] <- readIntList
  print $ calcLog n k

calcLog 0 k = 0
calcLog x k = 1 + calcLog (x `div` k) k


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define RALL(a)     (a).rbegin(),(a).rend()
#define PRINT(a)   cout << (a) << endl

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

using ll = long long int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

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; }

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

int main(){
  ll n, x,m;
  ll en;
  cin >> n >> x >> m;

  set<int> st;
  st.insert(x);
  ll now=x;
  vector<ll> list;
  list.emplace_back(now);

  int cnt=1;
  for(ll i=0; i < n-1; i++){
    now = (now*now)%m;

    if(now==0){
      ll ans=0;
      REP(j,list.size()){
        ans += list[j];
      }
      cout << ans << endl;
      return 0;
    }

    if(st.count(now)){
      en = now;
      break;
    }
    st.insert(now);
    list.emplace_back(now);
  }

  ll ans=0;
  if(st.size() == n){
    REP(i,list.size()){
      ans += list[i];
    }
    cout << ans << endl;
  }else{
    // cout << list.size() << endl;

    // cout << en << endl;

    int p=0;
    while(list[p]!=en)p++;
    // cout << p << endl;
    REP(i,p)ans+=list[i];
    // cout << ans << endl;
    ll tmp=0;
    FOR(i,p,list.size())tmp+=list[i];
    // cout << tmp << endl;
    n -= p;
    ans += (tmp * (n/(list.size()-p)));
    REP(i,(n%(list.size()-p)))ans+=list[i+p];
    cout << ans << endl;
  }
}



Measured memory_bytes: 6000
#include <stdio.h>

int main (void) {
    int a1, a2, a3;
    scanf("%d %d %d", &a1, &a2, &a3);

    if (a1 + a2 + a3 >= 22) {
        printf("bust\n");
    } else {
        printf("win\n");
    }
    return 0;
}

Measured memory_bytes: 128
// "header" {{{
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <tuple>
#include <iomanip>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int int64_t
#define Fixed fixed << setprecision(10)
#define moke_pair make_pair
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class T,class U> using umap = unordered_map<T,U>;
template <class T> inline int getint(T s){ 
    int n;
    cout << s;
    cin >> n;
    return n;
}

inline int64_t updiv(int64_t n,int64_t d){
    return ((n + d -1) / d);
}
/*
inline double Sqrt( const double &x) 
{
	double         xHalf = 0.5 * x;
	int64_t  tmp   = 0x5FE6EB50C7B537AAl - ( *(int64_t*)&x >> 1);
	double         xRes  = * (double*)&tmp;

	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	return xRes * x;
}
*/
// }}}

//UnionFind{{{
struct UnionFind {
    vector < int > par;
    vector < int > siz;

    UnionFind(int n): par(n), siz(n, 1) { //初期化
        for(int i = 0; i < n; i++) par[i] = i;
    }
	
    int root(int x){ //根の更新＋判定
        if(par[x] == x) return x;
		else return par[x] = root(par[x]);
    }

    int size(int x){ //サイズ
		return siz[root(x)];
	}

    bool same(int x, int y){ //グループの判定
		return root(x) == root(y);
	}

    bool unite(int x, int y){ //つなげる
        if((x=root(x))==(y=root(y))) return false;
        if( siz[y] > siz[x] ) swap(x,y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }
};
//}}}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    UnionFind uf(n+1);
    vector<int> p(n+1),x(m),y(m);
    reps(i,n){
        cin >> p[i];
    }
    rep(i,m){
        cin >> x[i] >> y[i];
        uf.unite(x[i],y[i]);
    }
    int cnt = 0;
    reps(i,n){
        cnt += (uf.same(i,p[i]));
    }

    cout << cnt << '\n';

    return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
long long n,m,i,j,a[202],b[102];
int main()
{
	cin>>n;
	for(i=1;i<=n*2;i++)
	{
		cin>>a[i]; 
	}
	sort(a+1,a+n*2+1);
	for(i=1;i<=2*n;i+=2)
	  {
	    m=m+a[i];
	  }
	cout<<m;
	return 0;
} 

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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;
}

int main(){

    ll n;
    cin >> n;
    ll x, y;
    x = y = 0;
    ll crt;
    crt = 0;
    bool ok = true;
    for(int i = 0; i < n; i++){
        int t, a, b;
        cin >> t >> a >> b;
        if(abs(x-a)+abs(y-b) > t-crt){
            ok = false;
        }
        else if(abs(x-a)+abs(y-b) < t-crt){
            if((abs(x-a)+abs(y-b)) % 2 != 0){
                if(t-crt % 2 == 0) ok = false;
            }
            else{
               if(t-crt % 2 != 0) ok = false;
            }
        }
        x = a;
        y = b;
        crt = t;
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
 
using namespace std;
 
int main()
{
    int N, x, tmp;   cin >> N >> x;
    ll ans = 0;
    vector<int> v(N);
    for(int i=0; i<N; i++)  cin >> v[i];
    for(int i=1; i<N; i++){
        tmp = v[i-1] + v[i];
        if(tmp > x){
            if(tmp - x <= v[i]){
                v[i] -= (tmp - x);
                ans += tmp - x;
            }else{
                v[i-1] -= (tmp - x - v[i]);
                ans += tmp - x;
                v[i] = 0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }

const int maxn = 1e6 + 7;
const ll mod = 1e9+7;

ll fac[maxn], ifac[maxn];
ll inv[maxn]; // https://cp-algorithms.com/algebra/module-inverse.html

void gen() {
    fac[0] = ifac[0] = inv[0] = 1LL;
    fac[1] = ifac[1] = inv[1] = 1LL;
    for (ll i = 2; i < maxn; i++) {
        fac[i] = fac[i-1] * i;
        fac[i] %= mod;
        inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;
        ifac[i] = ifac[i-1] * inv[i];
        ifac[i] %= mod;
    }
    assert(fac[3] == 6LL);
}

ll nCk(ll nn, ll kk) {
    ll ans = fac[nn] * ifac[kk];
    ans %= mod;
    ans *= ifac[nn-kk];
    ans %= mod;
    return ans;
}

ll pow8[maxn];

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    ll n; cin >> n;

    if (n <= 1) out(0);

    ll ans = 1LL;
    ll cur8 = 8LL;
    pow8[0] = 1LL;
    for (int i = 1; i <= n; i++) {
        ans *= 10LL;
        ans %= mod;
        pow8[i] = cur8;
        cur8 *= 8LL;
        cur8 %= mod;
    }

    gen();

    ans -= pow8[n];
    while (ans < 0LL) ans += mod;
    ans %= mod;

    ll rem = 0LL;
    for (int i = 1; i <= n; i++) {
        rem += (nCk(n,i) * pow8[n-i]);
        rem %= mod;
    }

    ans -= 2LL*rem;
    while (ans < 0) ans += mod;
    ans %= mod;

    out(ans);
    
    return 0;
}


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

#define ll long long int

int main()
{
  ll n;
  cin>>n;
  ll val=sqrt(n);
  ll mini=INT_MAX;
  while(1){
      if(n%val==0)
      {
          mini=(val-1)+((n/val)-1);
          break;
      }
      val--;
      
  }
  
  cout<<mini;
  return 0;
}
      

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<set>
#include<math.h>
#include<queue>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=1e6+7;
int t,a[maxn];
char ans[maxn];
int main(){
    ll n,k=0;
    cin>>n;
    while(n>=26){
        int x=n%26;
        if(x==0) x=26;
        a[k++]=x-1+'a';
        if(n%26==0) n--;
        n/=26;
    }
    if(n>=1) a[k++]=n-1+'a';
    for(int i=k-1;i>=0;i--){
        printf ("%c",a[i]);
    }



}



Measured memory_bytes: 3092
import sys
inputs = sys.stdin.readlines()
n, m = map(int, inputs[0].split())
acs = [0]*n
was = [0]*n
for X in inputs[1:]:
    p, s = X.split()
    p = (int(p)-1)
    if acs[p] == 0:
        if s == 'AC':
            acs[p] = 1
        else:
            was[p] += 1

print(*[sum(acs), sum(w for a, w in zip(acs, was) if a)])

Measured memory_bytes: 12564
#!/usr/bin/env python3
# n,m = map(int,sys.stdin.readline().split())
# a = list(map(int,sys.stdin.readline().split()))
# a = [sys.stdin.readline() for s in range(n)]
# s = sys.stdin.readline().rstrip()
# n = int(sys.stdin.readline())
# d = collections.defaultdict(list)
import sys
sys.setrecursionlimit(15000)

s = sys.stdin.readline().rstrip()
if s.find("7") != -1:
    print("Yes")
    exit(0)
print("No")


Measured memory_bytes: 9092
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i = 0; i < (n); ++i )
#define rep_rev(n,i) for(ll i = n; i >= 0; --i )
using namespace std;
const long long INF = 1LL << 60;

int a,b;
string str,str2;
int main(){
  cin >> a >> b;
  if(a < b) rep(i,b) cout << a;
  else rep(i,a) cout << b;
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}

// konoshita kara kaku

int main(void){
	long long n=llin(),i,j,k;
	for(i=1;i<=3500;i++){
		for(j=1;j<=3500;j++){
			if(!(4*i*j-n*i-n*j))continue;
			if((n*i*j)%(4*i*j-n*i-n*j))continue;
			k=(n*i*j)/(4*i*j-n*i-n*j);
			if(k>0){
				printf("%lld %lld %lld\n",i,j,k);
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 100001
using namespace std;
int n;
double pw,vw[N],pf[N],vf[N],th[N];
const double EPS = 1e-10;

double f(double x){
  double cost=x*pw;
  for(int i=0;i<n;i++){
    double v = th[i]-x*vw[i];
    if(v>0)cost+=pf[i]*(v/vf[i]);
  }
  return cost;
}

double search(){
  double L=0,R=101;
  while(abs(L-R)>EPS){
    double M1=(L+(R-L)/3);
    double M2=(L+2*(R-L)/3);
    if(f(M1)<f(M2))R=M2-EPS;
    else L=M1+EPS;
  }
  return L;
}


int main(){
  while(cin>>n,n){
    cin>>pw;
    for(int i=0;i<n;i++)cin>>vw[i]>>pf[i]>>vf[i]>>th[i];
    printf("%.15f\n",f(search()));
  }
  return 0;
}

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

int main () {

    int N, K;
    string S;
    cin >> N >> S >> K;

    for (int i = 0; i < N; i ++) {
        if (S[i] != S[K - 1]) {
            S[i] = '*';
        }
    }

    cout << S << endl;

}

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

using namespace std;

int main(){
	int antena[5], k;
	for(int i = 0; i < 5; ++i) cin >> antena[i];
	cin >> k;
	
	for(int i = 4; i >= 0; --i){
		for(int j = i - 1; j >= 0; --j){
			if(antena[i] - antena[j] > k){
				cout << ":(" << endl;
				return 0;
			}
		}
	}
	cout << "Yay!" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

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 isLowerCase(char c){
  return (c>='a'&&c<='z');
}

ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n,k;cin>>n>>k;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin>>p[i];
  }
  sort(all(p));
  int ans=0;
  for(int i=0;i<k;i++){
    ans+=p[i];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3596
#include <iostream>
     
    void solve_A() {
    	int N; std::cin >> N;
    	int mod_1 = N % 10;
    	N /= 10;
    	int mod_2 = N % 10;
    	N /= 10;
    	int mod_3 = N % 10;
    	N /= 10;
    	if (mod_1 == 7 || mod_2 == 7 || mod_3 == 7) {
    		std::cout << "Yes";
    	}
    	else {
    		std::cout << "No";
    	}
     
    }
     
    int main()
    {
     
    	solve_A();
        return 0;
    }

Measured memory_bytes: 3636