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

namespace CSharp
{
    class Program
    {
        static void Main()
        {
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var H = input[0];
            var W = input[1];

            input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var h = input[0];
            var w = input[1];

            Console.WriteLine($"{(H - h) * (W - w)}");
        }
    }
}


Measured memory_bytes: 11348
import scala.collection.mutable

object Main extends App {

  import scala.io.StdIn._
  import scala.math._

  val Array(n, k) = readLine.trim.split(' ').map(_.toInt)
  val tweet = Array.tabulate(n){_ ⇒ readLine.trim.toInt}
  val resCount = Array.tabulate(n){_ ⇒ 0}
  for (t ← tweet if t != 0){
    resCount(t - 1) += 1
  }
  val queue:mutable.Queue[Int] = mutable.Queue()
  for (i ← resCount.indices if resCount(i) == 0){
    queue.enqueue(i)
  }
  for (_ ← 1 to k){
    for (_ ← queue.indices){
      val i = queue.dequeue()
      if (tweet(i) != 0){
        queue.enqueue(tweet(i) - 1)
        tweet(i) = 0
      }
    }
  }
  println(
    tweet.count(_ == 0)
  )


  implicit class Extension[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}


Measured memory_bytes: 87660
#include <iostream>
#include <stdio.h>
using namespace std;

const int mx = 1e2 + 5;

int main()
{
    int n, a[mx];

    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    
    long long t = 0;
    for (int i = 1; i < n; i++)
    for (int j = i + 1; j <= n; j++) t += (long long)a[i] * (long long)a[j];

    printf("%lld", t);

    return 0;
}

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

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

  long result = 0;
  for (long i = 1; i <= N; i++) {
    if (i % 3 != 0 && i % 5 != 0) result += i;
  }
  cout << result << endl;
}



Measured memory_bytes: 3624
#include<iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)

using namespace std;

int main(){
  string S;
  ll A, bb, lb, ans;
  long double B;

  cin >> A >> B;

  bb = round(B*100);

  cout << A*bb/100 << endl;

  return 0;
}


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

int main(void){
    ll n;
    cin >> n;

    pair<ll, ll> s[n];
    rep(i, n){
        cin >> s[i].first;
        s[i].second = i + 1;
    }

    sort(s, s + n);

    rep(i, n){
        cout << s[i].second << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 2432
#include <cstdio>

using namespace std;

char mp[10][10];

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

void def(int x, int y){
	mp[y][x] = '0';
	
	for (int i = 0; i < 12; i++){
		int tx = x + dx[i];
		int ty = y + dy[i];
		
		if (mp[ty][tx] == '1' && ty < 8 && tx < 8) def(tx, ty);
	}
}

int main(){
	
	int n;
	int x, y;
	int cc = 0;

	scanf("%d", &n);
	
	for (int num = 0; num < n; num++){
		
		for (int i = 0; i < 8; i++){
			scanf("%s",  mp[i]);
		}
		scanf("%d %d", &x, &y);
		def(x - 1, y - 1);
		
		printf("Data %d:\n", num + 1);
		
		for (int i = 0; i < 8; i++){
			printf("%s\n",  mp[i]);
		}
	}
}

Measured memory_bytes: 1036
#include <iostream>

using namespace std;
using ll = long long;

ll mod = 1000000007;

ll modinv(ll a) {
  ll n = mod - 2;
  ll res = 1;
  while (0 < n) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int main() {
  ll x, y;
  cin >> x >> y;
  ll a = (2 * y - x) / 3;
  ll b = y - 2 * a;

  ll res = 0 <= a && 0 <= b && a + 2 * b == x && 2 * a + b == y;
  for (ll i = 0; i < a + b; ++i)
    res = res * (a + b - i) % mod;
  for (ll i = 0; i < a; ++i)
    res = res * modinv(a - i) % mod;
  for (ll i = 0; i < b; ++i)
    res = res * modinv(b - i) % mod;
  cout << res << endl;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vii;

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

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); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

// ────────────────────────────────────────────────────

int main() {
	char e;
	int y;

	cin >> e >> y;

	if (e == '0') {
		if (y >= 1989) cout << "H" << y % 1989 + 1 << endl;
		else if (y >= 1926) cout << "S" << y % 1926 + 1 << endl;
		else if (y >= 1912) cout << "T" << y % 1912 + 1 << endl;
		else cout << "M" << y % 1868 + 1 << endl;
	}
	else if (e == '4') cout << 1989 + y - 1 << endl;
	else if (e == '3') cout << 1926 + y - 1 << endl;
	else if (e == '2') cout << 1912 + y - 1 << endl;
	else cout << 1868 + y - 1 << endl;
}


Measured memory_bytes: 3124
/**
 * @author      : omgursocute
 * @created     : 21/02/2020
 * @task        : B
 */

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main() {
	// freopen("B.inp", "r", stdin);
	// freopen("B.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);

	int n;
	cin >> n;
	string ans = "APPROVED";
	while(n--) {
		int x;
		cin >> x;
		if(x % 2 == 0) {
			if(x % 3 && x % 5) ans = "DENIED";
		}
	}

	cout << ans;

	return 0;
}



Measured memory_bytes: 256
#MLE注意！ not は使わず !=

def main():
    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
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,m = map(int, input().split())
    a = list(map(int, input().split()))
    res = n-sum(a)
    if res < 0:
        print(-1)
    else:
        print(res)

if __name__ == '__main__':
    main()

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

int main(){
	int n, m;
	cin >> n >> m;
	vector<int> height(n+1);
	vector<int> ma(n+1);

	for(int i = 1; i <= n; i++){
		cin >> height.at(i);
		ma.at(i) = 0;
	}

	for(int i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		ma.at(a) = max(ma.at(a), height.at(b));
		ma.at(b) = max(ma.at(b), height.at(a));
	}

	int ans = 0;
	for(int i = 1; i <= n; i++){
		ans += height.at(i) > ma.at(i);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4028
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ w, h, x, y ] <- readInts
	printf "%.5f %d\n" ( ( fromIntegral $ w * h ) / 2.0 :: Double ) ( which 1 0 $ x * 2 == w && y * 2 == h :: Int )

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

int main(){
	ll N, M;
	cin >> N >> M;
	if (2*N >= M) {
		cout << M/2 << endl;
		return 0;
	}

	ll ans = N;
	M -= 2*N;
	ans += M/4;
	cout << ans << endl;

return 0;
}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int a[300000];
ll sum1[300000],sum2[300000];

int main(){
	int n;cin>>n;
	rep(i,n)scanf("%d",&a[i]);
	rep(i,n){
		sum1[i+1]=sum1[i]+a[i];
	}
	for(int i=n-1;i>=0;i--){
		sum2[i]=sum2[i+1]+a[i];
	}
	ll Min=LLONG_MAX;
	rep(i,n){
		Min=min(Min,abs(sum1[i]-sum2[i]));
	}
	cout<<Min<<endl;
}

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

int main(){
    double N; cin >> N;
    if((int)N%2==0){
        double pro = (N/2)/N;
        cout << pro << endl;
    }
    else{
        double pro = (N+1)/2/N;
        cout << pro << endl;
    }
}

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

int fac[1000];
int main() {
    int a, b, k;
    scanf("%d%d%d", &a, &b, &k);
    int cnt = 0;
    for (int i = (a > b ? b : a); i >= 1; i--) {
        if (a % i == 0 && b % i == 0) {
            fac[++cnt] = i;
        }
    }
    printf("%d\n", fac[k]);
    return 0;
}

Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))

cnt = [0] * (n+1)
res = 0
for v in a:
    if v <= n:
        cnt[v] += 1
    else:
        res += 1

for i in range(1, n+1):
    if cnt[i] < i:
        res += cnt[i]
    else:
        res += cnt[i] - i

print(res)

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

int main() {
  string s,t;
  cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if(s<t){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3592
n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = [[int(i) for i in input().split()] for i in range(m)]

bc.sort(key = lambda x:x[1], reverse = True)

a.sort()

a_count = 0
for b, c in bc:
        if c > a[a_count]:
                for i in range(b):
                        if c > a[a_count]:
                                a[a_count] = c
                                a_count += 1    
                        else:
                                break
                        if a_count == n:
                                        break

        else:
                break
        if a_count == n:
                break        

print(sum(a))

Measured memory_bytes: 27076
#include <cstdio>

using namespace std;

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

/*
  0 -> right
  1 -> left-down
  2 -> down 
  3 -> right-up
*/

int main(){
  int n, T = 1;

  while(scanf("%d" ,&n), n){
    printf("Case %d:\n" ,T++);

    int table[n][n], x = 0, y = 0, num = 0, dir = 0;
    if(n % 2){
      while(true){
	table[y][x] = ++num;

	if(num == n*n){
	  table[n-1][n-1] = num;
	  break;
	}

	switch(dir){
	case 0:
	  x += dx[dir];
	  y += dy[dir];
	  
	  if(y == 0){
	    dir = 1;
	  }else{
	    dir = 3;
	  }
	  break;
	case 1:
	  x += dx[dir];
	  y += dy[dir];
	  
	  if(y == n-1 && x){
	    dir = 0;
	  }else if(x == 0){
	    dir = 2;
	  }
	  break;
	case 2:
	  x += dx[dir];
	  y += dy[dir];
	  
	  if(x == 0){
	    dir = 3;
	  }else{
	    dir = 1;
	  }
	  break;
	case 3:
	  x += dx[dir];
	  y += dy[dir];
	  
	  if(y == 0 && x != n-1){
	    dir = 0;
	  }else if(x == n-1){
	    dir = 2;
	  }
	  break;
	}
      }
    }else{
      while(num != n*n){
	table[y][x] = ++num;
	if(num == n*n){
	  table[n-1][n-1] = num;
	  break;
	}

	switch(dir){
	case 0:
	  x += dx[dir];
	  y += dy[dir];
	  
	  if(y == 0){
	    dir = 1;
	  }else{
	    dir = 3;
	  }
	  break;
	case 1:
	  x += dx[dir];
	  y += dy[dir];
	  
	  if(y == n-1){
	    dir = 0;
	  }else if(x == 0){
	    dir = 2;
	  }
	  break;
	case 2:
	  x += dx[dir];
	  y += dy[dir];
	  
	  if(x == 0){
	    dir = 3;
	  }else{
	    dir = 1;
	  }
	  break;
	case 3:
	  x += dx[dir];
	  y += dy[dir];
	  
	  if(x == n-1){
	    dir = 2;
	  }else if(y == 0){
	    dir = 0;
	  }
	  break;
	}
      }
    }

    for(int i = 0 ; i < n ; i++){
      for(int j = 0 ; j < n ; j++){
	printf("%3d" ,table[i][j]);
      }
      printf("\n");
    }
  }

  return 0;
}

Measured memory_bytes: 1044
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
const long MOD = 1000000007;
#define all(a) a.begin(), a.end()
#define show(ans)  cout << ans << endl;

long board[501][501];

int main() {long N, M, Q;
cin >> N >> M >> Q;
vector<long> L(M), R(M), p(Q), q(Q);
rep(i, M) cin >> L[i] >> R[i];
rep(i, Q) cin >> p[i] >> q[i];

rep(i, M){
    board[L[i]][R[i]]++;
}
rep(i, 501){
    rep(j, 500){
        board[i][j+1] += board[i][j];
    }
}
rep(i, 501){
    rep(j, 500){
        board[j+1][i] += board[j][i];
    }
}
rep(i, Q){
    long ans;
    ans = board[q[i]][q[i]]-board[q[i]][p[i]-1]-board[p[i]-1][q[i]]
    +board[p[i]-1][p[i]-1];
    show(ans);
}


// show(ans);
  return 0;
 
}



Measured memory_bytes: 7552
/* 
 * Project: AtCoder Beginners Contest 102 B - Maximum Difference
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/06/07
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int n;
int a[100];

void solve() {

    sort(a, a+n);
    int diff = a[n-1] - a[0];
    printf("%d\n", diff);

}

int main() {

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

    solve();

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

std::map<long long, long long> dp;
long long dfs(long long x){
  long long res;
  if(dp[x] > 0){
    return dp[x];
  }
  res = 1 + 2*dfs(x/2);
  return dp[x] = res;
}
int main(){
  using namespace std;
  long long h;
  cin>>h;
  dp[1] = 1;
  long long ans = dfs(h);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
//#define int unsigned long long
#define all(x) (x).begin(), (x).end()
#define double long double

using namespace std;

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 MOD = 1e9 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;



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

	int  N; cin >> N;
	print(N*N * 3);
}


Measured memory_bytes: 256
#
# abc061 a
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """1 3 2"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """6 5 4"""
        output = """No"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """2 2 2"""
        output = """Yes"""
        self.assertIO(input, output)


def resolve():
    A, B, C = map(int, input().split())
    if A <= C <= B:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16116
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  
  ll N,K;
  cin>>N>>K;
  
  vector<ll>a(N);
  vector<ll>b(N);
  vector<pair<ll,ll>>S(N);
  vector<ll>date(N);

  
  ll unko=0;
  
  rep(i,N){
cin>>a[i]>>b[i];
    S[i].first=a[i];
    S[i].second=b[i];
  }
  
  sort(all(S));
  
  rep(i,N){
    unko+=S[i].second;
    date[i]=unko;
  }
  
  
  ll sum=0;
  rep(i,N){
    if(date[i]>=K){
      cout<<S[i].first<<endl;
      break;
    }
    
  }
}

  


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    vector<int> a;
    for (int i = 0; i < n; ++i) {
      int x;
      cin >> x;
      a.push_back(x);
    }
    const vector<int> _a = a;

    const int N = 100000 + 5;
    static int dp[N][2];
    fill(&dp[0][0], &dp[N - 1][2 - 1] + 1, (1 << 28));
    dp[0][0] = 1;
    dp[0][1] = 1;
    for (int i = 0; i + 1 < n; ++i) {
      if (a[i] <= a[i + 1]) dp[i + 1][0] = min(dp[i + 1][0], dp[i][0]);
      if (a[i] >= a[i + 1]) dp[i + 1][1] = min(dp[i + 1][1], dp[i][1]);
      dp[i + 1][0] = min(dp[i + 1][0], dp[i][1] + 1);
      dp[i + 1][1] = min(dp[i + 1][1], dp[i][0] + 1);
      dp[i + 1][0] = min(dp[i + 1][0], dp[i][0] + 1);
      dp[i + 1][1] = min(dp[i + 1][1], dp[i][1] + 1);
    }
    // for (int i = 0; i < n; ++i) cout << dp[i][0] << ' '; cout << endl;
    // for (int i = 0; i < n; ++i) cout << dp[i][1] << ' '; cout << endl;
    cout << min(dp[n - 1][0], dp[n - 1][1]) << endl;
  }
  
  return 0;
}


Measured memory_bytes: 1912
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
s=input()
k=int(input())
c=0
for a in s:
    if a!="1":
        ans=a
        break
    else:
        c+=1
if k<=c:
    print(1)
else:
    print(ans)

Measured memory_bytes: 77408
#include<stdio.h>
int main(){
	int i,j,x,ms,s,o[]={0,2,6,4,1,3,7,5};
	int c[]={1,2,1,2,1,4,1,4},p[10];
	while(scanf("%d",&p[0])!=EOF){
		x=ms=0;
		for(i=0;i<8;i++){
			if(i!=0)scanf("%d",&p[i]);
			if(p[i]>c[i])ms+=p[i]-c[i];
		}
		for(i=0;i<8;i++){
			s=0;
			for(j=0;j<8;j++){
				if(p[j]>c[(j+o[i])%8])s+=p[j]-c[(j+o[i])%8];
				//printf("%d ",c[(j+o[i])%8]);
			}
			//printf("i=%d o=%d s=%d\n",i,o[i],s);
			if(s<ms)x=i,ms=s;
		}
		for(i=0;i<8;i++)printf("%s%d",(i==0)?"":" ",c[(i+o[x])%8]);
		printf("\n");
	}
	return 0;
}

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

int main(){
  int A1,A2,A3;
  int sum;
  cin >> A1 >> A2 >> A3;
  sum = A1 + A2 + A3;
  if(sum <= 21){
    cout << "win";
    return 0;
  }
  cout << "bust";
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp33 {
    class Program {
        static void Main(string[] args) {
            int X = int.Parse(Console.ReadLine());
            
            if (X == 3 || X == 5 || X == 7) {
                Console.WriteLine("YES");
            } else {
                Console.WriteLine("NO");
            }

        }
    }
}


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

int n;
int a[100010];
int b[100010];
int c[100010];

int gcd(int x, int y){
	if(x % y == 0) return y;
	return gcd(y, x % y);
}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=0; i<n; ++i) cin >> a[i];
	b[0] = a[0];
	c[n-1] = a[n-1];
	for(int i=1; i<n; ++i){
		b[i] = gcd(a[i], b[i-1]);
	}
	for(int i=n-2; i>=0; --i){
		c[i] = gcd(a[i], c[i+1]);
	}
	int ans = max(b[n-2], c[1]);
	for(int i=1; i<n-1; ++i){
		ans = max(ans, gcd(b[i-1], c[i+1]));
	}
	cout << ans << "\n";
}

Measured memory_bytes: 1408
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll a, b, c;
  cin>>a>>b>>c;
  cout<<a+b+c-max(max(a, b),c)<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
from itertools import accumulate, groupby
mod = 10**9 + 7

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

n = ni()
tp, xp, yp = 0, 0, 0
for _ in range(n):
    t, x, y = na()
    ta, l = t-tp, abs(x - xp) + abs(y - yp)
    if ta >= l and ta % 2 ==l % 2:
        continue
    else:
        print("No")
        quit()
print("Yes")

Measured memory_bytes: 3064
import numpy as np
from scipy.sparse import csr_matrix, csgraph
N, M = map(int, input().split())
row, column, _ = np.array([tuple(map(lambda n: int(n) - 1, input().split())) for _ in range(M)], dtype=np.int32).T
matrix = csr_matrix(([1] * M, (row, column)), shape=(N, N), dtype=np.int32)
print(csgraph.connected_components(matrix)[0])


Measured memory_bytes: 29552
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>

int main() {
  intmax_t a;
  intmax_t b0, b1;
  scanf("%jd %jd.%jd", &a, &b0, &b1);
  intmax_t b = b0 * 100 + b1;
  a *= b;
  a /= 100;
  printf("%jd\n", a);
}


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

int main() {
  //宣言
  int N,M,A;
  vector<int> ans(50,0);
  
  
  //入力
  cin >> N >> M;
  
  //処理
    for(int i=0;i<2*M;i++){
    cin >> A ;
    ans.at(A-1)++;
  }
  
  //出力
  for(int i=0;i<N;i++){
    cout << ans.at(i) << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
  long int  n,k,t,min,max,s;
  scanf("%ld %ld %ld",&n,&k,&t);
  if(k>t||n<1||(n==1&&k!=t))
  {
    printf("0\n");
  }

else
{
   max=(n-1)*t+k;
  min =(n-1)*k+t;
  s=max-min+1;
  printf("%ld\n",s);
   
}
 return 0;

}

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

#define all(x) (x).begin(), (x).end()
#define int long long

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int x, k;
    cin >> x >> k;
    x %= k;
    cout << min(x, abs(x - k));
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        long a = scanner.nextLong();
        long b = scanner.nextLong();
        if ((a+b) %2 == 0) {
            System.out.println((a+b) /2);
        } else {
            System.out.println("IMPOSSIBLE");
        }

    }
}

Measured memory_bytes: 20820
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  string a;
  cin >> a;
  string ans;
  REP(i, a.size()){
    if(i %2 ==0){
      ans += a[i];
    }
  }
  cout << ans << endl;
}


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

long walk(long x, long k, long d){
    if (x <= d){
        if (k % 2 == 0) return x;
        else return d - x;
    }
    else {
        long res = x / d;
        if (res >= k) return x - d * k;
        else if ((k - res) % 2 == 0) return x % d;
        else return d - (x - d * res);
    }
}

int main(){
    long X, K, D;
    cin >> X;
    cin >> K;
    cin >> D;

    if (X < 0) X = -X;

    cout << walk(X, K, D);

    return 0;
}


Measured memory_bytes: 3632
p=10**9+7
n,k=map(int,input().split())

ans=[0]*(n+2)
ans[0]=1

for i in range(1,n+2):
    mae=(i-1)*i//2
    usiro=(n*2-i+1)*i//2
    ans[i]=usiro-mae+1

kotae=0
for i in range(k,n+2):
    kotae+=ans[i]%p


#print(ans)

kotae%=p
print(kotae)

Measured memory_bytes: 19960
import java.util.Scanner;



public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		String[]s = new String[h];
		for (int i=0;i<h;i++) {
			s[i]=sc.next();
		}
		
		int[][] xMin = new int[h][w];
		int[][] xMax = new int[h][w];
		int[][] yMin = new int[h][w];
		int[][] yMax = new int[h][w];
		
		for (int i=0;i<h;i++) {
			int tmpYMin = 0;
			for (int j=0;j<w;j++) {
				if (s[i].charAt(j)=='#') {
					tmpYMin = j+1;
				} else {
					yMin[i][j]=tmpYMin;
				}
			}
			int tmpYMax = w-1;
			for (int j=w-1;j>=0;j--) {
				if (s[i].charAt(j)=='#') {
					tmpYMax = j-1;
				} else {
					yMax[i][j]=tmpYMax;
				}
			}
		}
		
		for (int j=0;j<w;j++) {
			int tmpXMin = 0;
			for (int i=0;i<h;i++) {
				if (s[i].charAt(j)=='#') {
					tmpXMin = i+1;
				} else {
					xMin[i][j]=tmpXMin;
				}
			}
			int tmpXMax = h-1;
			for (int i=h-1;i>=0;i--) {
				if (s[i].charAt(j)=='#') {
					tmpXMax = i-1;
				} else {
					xMax[i][j]=tmpXMax;
				}
			}
		}
		
		int ans = 0;
		for (int i=0;i<h;i++) {
			for (int j=0;j<w;j++) {
				ans = Math.max(ans, xMax[i][j]-xMin[i][j]+yMax[i][j]-yMin[i][j]+1);
			}
		}
		
		System.out.println(ans);
	}
}






Measured memory_bytes: 120528
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC085A
{
    class Program
    {
        static void Main(string[] args)
        {
            String s;
            s = Console.ReadLine();
            char[] cs = s.ToCharArray();
            cs[3] = '8';
            Console.WriteLine(cs);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace ConsoleApplication1
{
    class Dice : IEquatable<Dice>
    {
        protected string[] val = new string[6];

        public Dice(string[] str)
        {
            Array.Copy(str, val, 6);
        }

        public bool Equals(Dice dice2)
        {
            if ((val[0] == dice2.val[2] && val[5] == dice2.val[3]) || (val[0] == dice2.val[3] && val[5] == dice2.val[2]))
            {
                string tmp = dice2.val[1];
                dice2.val[1] = dice2.val[2];
                dice2.val[2] = dice2.val[4];
                dice2.val[4] = dice2.val[3];
                dice2.val[3] = tmp;
            }

            for (int i = 0; i < 3; i++)
            {
                if (val[0] == dice2.val[0] && val[5] == dice2.val[5])
                    break;
                string tmp = dice2.val[0];
                dice2.val[0] = dice2.val[1];
                dice2.val[1] = dice2.val[5];
                dice2.val[5] = dice2.val[4];
                dice2.val[4] = tmp;
            }

            for (int i = 0; i < 3; i++)
            {
                if (val[1] == dice2.val[1] && val[4] == dice2.val[4])
                    break;
                string tmp = dice2.val[1];
                dice2.val[1] = dice2.val[2];
                dice2.val[2] = dice2.val[4];
                dice2.val[4] = dice2.val[3];
                dice2.val[3] = tmp;
            }

            if (val[0] == dice2.val[0] && val[1] == dice2.val[1] && val[2] == dice2.val[2] && val[3] == dice2.val[3] && val[4] == dice2.val[4] && val[5] == dice2.val[5])
                return true;
            else return false;
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            int num = int.Parse(Console.ReadLine());
            Dice[] dices = new Dice[num];

            for(int i=0;i<num;i++)
            {
                dices[i] = new Dice(Console.ReadLine().Split(' '));
            }

            bool res = true;
            for(int i=0;i<num;i++)
            {
                for(int j=i+1;j<num;j++)
                {
                    if (dices[i].Equals(dices[j])) { res = false;  break; }
                }
            }

            Console.WriteLine(res?"Yes":"No");
        }
    }
}

Measured memory_bytes: 8940
#include <iostream>
using namespace std;
int main(void){
   // n*mの行列A, m*lの行列Bを入力とし、n*lの行列Cを出力
   // 1行目 n, m, l  2行目 n*mの行列A, m*lの行列B
   int n, m, l;
   
   scanf("%d %d %d", &n, &m, &l);
   int A[n][m];
   int B[m][l];
   long long int qu[n][l];
   
   
   // 行列Aを二次元配列Aに格納
   for(int i=0;i<n;i++){
        for(int k=0;k<m;k++){
            scanf("%d", &A[i][k]);
        }
   }
   
   // 行列Bを二次元配列Bに格納
   for(int i=0;i<m;i++){
        for(int k=0;k<l;k++){
            scanf("%d", &B[i][k]);
        }
   }
    // 行列の積(AB)を算出
    // quの行変更
    for(int k=0;k<n;k++){
        // quの列変更
        for(int q=0;q<l;q++){
            qu[k][q]=0;
            // 足し算する用
            for(int p=0;p<m;p++){
                qu[k][q] += A[k][p] * B[p][q];
            }
            if(q==0){
                printf("%lld",qu[k][q]);
            }else{
                printf(" %lld",qu[k][q]);
            }
        }
        printf("\n");
    }
}



Measured memory_bytes: 3332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

int main() {
    int A, B, C;  cin >> A >> B >> C;
    int K;  cin >> K;

    vector<int> n = {A, B, C};
    sort(n.begin(), n.end());
    rep(i, K) {
        n[2] = n[2] * 2;
    }
    cout << n[0] + n[1] + n[2] << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

int main(){
  int n,m; cin >> n >> m;
  vvi G(m);
  rep(i, m){
    int k; cin >> k;
    rep(j, k){
      int s; cin >> s; s--;
      G[i].push_back(s);//G[i]は電球iに繋がっているスイッチの番号を格納
    }
  }
  vi p(m); rep(i, m) cin >> p[i];

  int ans = 0;
  for (int bit = 0; bit < (1<<n); bit++) {
    vi s(n,0);
    rep(i, n) if(bit & (1<<i)) s[i]++;
    
    bool ok = true;
    rep(i, m){
      int sum = p[i];
      for(int j : G[i]) sum += s[j];
      if(sum%2 == 1) ok = false;
    }

    if(ok) ans++;
  }

  std::cout << ans << '\n';
}


Measured memory_bytes: 256
n=int(input())
a=[int(i) for i in input().split()]
x=[0,0,0]

for i in a:
  if i % 4==0:
    x[2]+=1
  elif i % 2==0:
    x[1]+=1
  else:
    x[0]+=1

if (x[1]==0 and x[2] >= x[0]-1 and x[2]>0) or x[2] >= x[0] or x[0]==0:
  print('Yes')
else:
  print('No')



Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define ref goto refrain

void sort(int*a,int n){
	int count=0;
	for(int i=0;i<n;i++){
		int minj=i;
		for(int j=i;j<n;j++){
			if(a[j]<a[minj]) minj=j;
		}
		if(i!=minj){
			int tem=a[i];
			a[i]=a[minj];
			a[minj]=tem;
			count++;
		}
	}
	cout<<a[0];
	for(int i=1;i<n;i++){
		cout<<" "<<a[i];
	}
	cout<<endl;
	cout<<count<<endl;
}

int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,n);
	return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

string s;

void solve(){
    cin >> s;
    int ord_a='a';
    int ans=1000;
    rep(k,26){
        string s_=s,nex="";
        int cnt=0;
        while (s_.length()>0){
            //cout << s_ << endl;
            bool flag=true;
            rep(i,s_.length()) {
                if (s_[0]!=s_[i]) {
                    flag=false; 
                    break;
                }
            }
            if (flag) break;
            rep(i,s_.length()-1){
                if (s_[i+1]==k+ord_a) nex+=s_[i+1];
                else nex+=s_[i];
            }
            cnt+=1;
            s_=nex;
            nex="";
        }
        ans=min(ans,cnt);

    }
    cout << ans << endl;
}

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

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

int main() {
    int n, w;
    cin >> n >> w;
    int weight[n] = {0};
    int value[n] = {0};
    for (int i = 0; i < n; i++) {
        cin >> weight[i] >> value[i];
    }

    vector<vector<ll>> dp(
        n, vector<ll>(w + 1, 0));  // n個目までの荷物で重量w以下となる最大価値

    // 1個目の荷物を入れるかどうか
    for (int j = 0; j <= w; j++) {
        if (j - weight[0] >= 0) {
            dp[0][j] = value[0];
        }
    }

    // 2~n個目の荷物を入れるかどうか
    for (int i = 1; i < n; i++) {       // 荷物
        for (int j = 0; j <= w; j++) {  // 重量
            // i個目の荷物を入れるとき
            if (j - weight[i] >= 0) {
                dp[i][j] = max(dp[i][j], dp[i - 1][j - weight[i]] + value[i]);
            }
            // 入れないとき
            dp[i][j] = max(dp[i][j], dp[i - 1][j]);
        }
    }

    cout << dp[n - 1][w] << endl;
    return 0;
}

Measured memory_bytes: 79360
#include <stdio.h>
int main(void) {
    int m,n,player[1000],count,out,potato,i;
    while (1) {
        scanf("%d %d",&n,&m);
        if (m==0&&n==0) break;
        for (i=0; i<n; i++) player[i]=0;
        count=0,potato=0,out=0;
        while (out<n-1) {
            while (count<m) {
                while (player[potato]!=0) {
                    potato++;
                    if (potato==n) potato=0;
                }
                potato++;
                if (potato==n) potato=0;
                count++;
            }
            if (potato==0) {
                player[n-1]=1;
            } else {
                player[potato-1]=1;
            }
            out++;
            count=0;
        }
        while (player[potato]!=0) {
            potato++;
            if (potato==n) potato=0;
        }
        printf("%d\n",potato+1);
    }
    return 0;
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}

//char->int
int ctoi(char c){
    return c-'0';
}

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}



int main(){
    int x,y;
    cin >> x >> y;

    for(int i=0;i<=x;i++){
        if(i*2+(x-i)*4==y){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	string t,s;
	cin>>t>>s;
	int c=0;
	for(int i=0;i<3;i++)
	{
		if(t[i]==s[i])
		c++;
	}
	cout<<c;
}

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

int main(void){
	int i,f,f1,f2,l,n,ans,ans2,at,b[1000];
	char s[1000][32];

	n=0;
	ans=0;
	f2=0;
	f1=0;
	for(i=0;i<1000;i++)b[i]=0;
	while(scanf("%s",s[n])!=EOF)n++;
	
	
	for(i=0,at=0;i<n;i++){
		if(at<strlen(s[i])){
			ans2=i;
			at=strlen(s[i]);
		}
		
		for(l=i+1;l<n;l++){
			if(strcmp(s[i],s[l])==0)
			b[i]++;
			if(f2<b[i]){
				f1=i;
				f2=b[i];
			}
		}
		
	}
	
	printf("%s %s\n",s[f1],s[ans2]);
	
	return 0;
	
}
	

Measured memory_bytes: 0
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans, cnt, sum int

func main() {
	reader.Split(bufio.ScanWords)
	_, _ = strconv.Atoi(read())
	M, _ := strconv.Atoi(read())
	var Max, Min int = 0, 1e9
	for i := 0; i < M; i++ {
		t, _ := strconv.Atoi(read())
		v, _ := strconv.Atoi(read())
		Max = max(Max, t)
		Min = min(Min, v)
	}

	fmt.Println(max(Min-Max+1, 0))
}

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

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i] < a[j] }

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] < h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())

using namespace std;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

using ll = long long;
constexpr int mod = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u * v / gcd(u, v);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);

    int A, B, C;
    cin >> A >> B >> C;

    int ans = 0;
    if (A % 2 == B % 2 && B % 2 == C % 2) {

    }
    else if (A % 2 == B % 2) {
        A++; B++;
        ans++;
    }
    else if (B % 2 == C % 2) {
        B++; C++; ans++;
    }
    else {
        C++; A++; ans++;
    }


    int m = max({ A,B,C });
    ans += (m - A) / 2;
    ans += (m - B) / 2;
    ans += (m - C) / 2;
    cout << ans << endl;
    return 0;

}

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

int main() {
    int a;
    cin >>a;
    vector<int> vec(a);
    rep(i,a){
        cin>>vec.at(i);
    }
    int max = *std::max_element(vec.begin(), vec.end());
    int sum = std::accumulate(vec.begin(),vec.end(),0)-max;
    if(max<sum){
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
}



Measured memory_bytes: 256