akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int check(int n){
  if(n > 21) return 0;
  return n;
}
int main(void){
  int n,sum=0,f=0;
  while(cin >> n && n){
    if(n>10) n = 10;
    if(n==1) f = 10;
    sum += n;
    if(getchar() == '\n'){
      cout << max(check(sum),check(sum+f)) << endl;
      sum = 0;
      f = 0;
    }
  }
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N;
string S;
ll cnt[26];

int main(){
  cin >> N >> S;
  for (int i = 0; i < N; i++){
    cnt[S[i] - 'a']++;
  }
  
  ll ans = 1;
  for (int i = 0; i < 26; i++){
    ans *= cnt[i] + 1; ans %= MOD;
  }
  ans--;
  if (ans < 0) ans += MOD;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3764
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <map>

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

int main() {
	int n, m, c;
	cin >> n >> m >> c;
	int B[20];
	int A[20][20];
	int i;
	int count = 0;
	rep(i, m)cin >> B[i];
	rep(i, n) {
		int j;
		int sum = 0;
		rep(j, m) {
			cin >> A[i][j];
			sum += A[i][j] * B[j];
					
		}
		if (sum + c > 0)count++;
	}
	cout << count;

	return 0;
}



Measured memory_bytes: 256
//vinay
#include<bits/stdc++.h>
using namespace std;
//#define mod 10e9+7;
#define ll long long int
#define flash ios_base::sync_with_stdio(false);cin.tie(0);
// C++ program to print all 
// permutations with duplicates allowed 
//vector<int > a;
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    float d, t, s;
    cin >> d >> t >> s;
    float p = d/s;
    if(p <= t){
        cout <<"Yes" << endl;
    }
    else
    {
        cout <<"No" << endl;
    }
    
}

Measured memory_bytes: 3728
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    a,b,k = LI()
    if a < k:
        b -= k-a
        if b < 0:
            b = 0
        a = 0
    else:
        a -= k
    print(a,b)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 39024
def resolve():
  n, y = map(int, input().split())
  for i in range(n + 1):
    for j in range(n + 1 - i):
      k = n - i - j
      if i * 10000 + j * 5000 + k * 1000 == y:
        print(i, j, k)
        return
  print(-1, -1, -1)
  return

if __name__ == "__main__":
  resolve()


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

int T,N,K,X[100000+10],A[100000+10];
int main() {
  int sum;
  cin>>T;
  //pair<int,int,int>
  for(int t=0;t<T;t++)
    {
      sum=0;
      cin>>N>>K;
      for(int i=0;i<N;i++)
	cin>>X[i];
      for(int i=0;i<N-1;i++)
	A[i]=X[i+1]-X[i];
      sort(A,A+N-1);
      for(int i=0;i<N-K;i++)
	sum+=A[i];
      cout<<sum<<endl;
    }
      
}

Measured memory_bytes: 3800
import std;

void main() {
    string s = read;
    foreach (c; s) {
        if (c == '?') write('D');
        else write(c);
    }
    writeln();
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T=string)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readints = reads!int;


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

#define ls st<<1
#define rs st<<1|1
#define LL long long 
#define CLR(a,b) memset(a,(b),sizeof(a))

const int MAXN = 1e3+11;
const int mod = 1e9+7;
const int INF = 0x3f3f3f3f; 

/* ------------------------基本函数-------------------------*/
long long read()
{
    long long res = 0;
    char ch = 0;
    while (ch < '0' || ch > '9')
        ch = getchar();
    while (ch >= '0' && ch <= '9')
    {
        res = res * 10 + ch - '0';
        ch = getchar();
    }
    return res;
}
bool prime(int x) {
	if(x==2 || x==3) 
		return true;
	if(x%2==0 || x%3==0 || x==1)
		return false;
	int k = sqrt(x)+1;
	for(int i = 5; i < k; i++) {
		if(x%i==0 || x%(i+2)==0)
			return false;
	}
	return true;
} 

LL pow_mod(int a, int b, int c) {
	LL ans = 1;
	while(b) {
		if(b&1)
			ans = (ans*1) % c;
		a = (a*a) % c;
		b /= 2;
	}
	return ans;
}
int gcd(int a, int b) {
	if(!b) 
		return a;
	return gcd(b,a%b);
}
/*-------------------------------------------------------*/


int main() {
	string s;
	while(cin >> s) {
	for(int i = 0; i < s.size(); i++) {
		if(s[i] == ',') s[i] = ' ';
	}
	cout << s << endl;
	
	}
	
return 0;
}

Measured memory_bytes: 256
def I(): return int(input())
def LI(): return list(map(int,input().split()))
##################################################
N = I()
a = [x for x in LI() if x%2==0]
ans = 0
while 1:
    if len(a)==0:
        print(ans)
        break
    ans += len(a)
    a = [x/2 for x in a if x/2%2==0]

Measured memory_bytes: 4148
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mp make_pair
# define P pair<int, int>
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
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; }

static const ll INF = 1e15;

int h, w;

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


int main() {
  optimize_cin();
  cin >> h >> w;
  int ch, cw, dh, dw; cin >> ch >> cw >> dh >> dw;
  --ch; --cw; --dh; --dw;
  vector<string> v(h);
  rep(i, h){
    cin >> v[i];
  }

  vector<vector<ll>> dist(h, vector<ll>(w, INF));
  dist[ch][cw] = 0;
  queue<P> p;
  p.emplace(ch, cw);

  while(!p.empty()){
    P lookin = p.front();
    p.pop();
    int nowx = lookin.first, nowy = lookin.second;

    queue<P> q;
    q.emplace(lookin);

    while(!q.empty()){
      P now = q.front();
      q.pop();
      int x = now.first, y = now.second;
      ll nowdist = dist[x][y];

      rep(i, 4){
        int newx = x + dx[i], newy = y + dy[i];
        if(newx < 0 || h <= newx || newy < 0 || w <= newy) continue;
        if(v[newx][newy]=='#') continue;
        if(dist[newx][newy] <= nowdist) continue;
        dist[newx][newy] = nowdist;
        q.emplace(newx, newy);
      }

      for(int i = -2; i <= 2; i++){
        for(int j = -2; j <= 2; j++){
          int newx = x + i, newy = y + j;
          if(newx < 0 || h <= newx || newy < 0 || w <= newy) continue;
          if(v[newx][newy]=='#') continue;
          if(dist[newx][newy] <= nowdist + 1) continue;
          p.emplace(newx, newy);
          dist[newx][newy] = nowdist + 1;
        }
      }
    }
  }

  if(dist[dh][dw] != INF) cout << dist[dh][dw] << endl;
  else cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 12672
{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Char
import Data.Int
import Data.Foldable
import Data.List
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Debug.Trace

solve :: Int -> Int -> Int
solve !n !l = expected - mostCloseTo0
 where
  apples = map (\i -> l + i - 1) [1 .. n]
  mostCloseTo0 =
    (\xs -> if null xs then maximum (filter (< 0) apples) else minimum xs)
      $ filter (>= 0) apples
  expected = sum apples

main = do
  let readInt :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readInt = fmap (first fromIntegral . second B.tail) . B.readInt

  (n, l) <-
    (\vec -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 readInt <$> B.getLine
  print $ solve n l


Measured memory_bytes: 508
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <numeric>

using namespace std;

int main() {
    char c;
    cin >> c;

    switch (c) {
        case 'A':
            cout << 'T' << endl;
            break;
        case 'T':
            cout << 'A' << endl;
            break;
        case 'C':
            cout << 'G' << endl;
            break;
        case 'G':
            cout << 'C' << endl;
            break;
    }
}


Measured memory_bytes: 888
use std::*;

#[allow(dead_code)]
fn read<T: str::FromStr>() -> T {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|a| a.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2d<T: str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let v = read_vec::<i64>();
    let (a, b, c, x, y) = (v[0], v[1], v[2], v[3], v[4]);
    let mut min = i64::MAX;

    for i in 0..2 * cmp::max(x, y) {
        let tmp = i * 2 * c + cmp::max(0, x - i) * a + cmp::max(0, y - i) * b;
        min = cmp::min(tmp, min);
    }
    println!("{}", min);
}


Measured memory_bytes: 4352
import Data.List

ints :: String -> [Int]
ints s = map read $ words s

getLines :: IO [[Int]]
getLines = do
  s <- getLine
  let [a, b] = ints s
  if a == 0 && b == 0
    then return []
    else do
      rest <- getLines
      return ([a, b] : rest)

calc :: Int -> Int -> String
calc w h =
  intercalate "\n" ([replicate w '#'] ++
                    replicate (h-2) ("#" ++ replicate (w-2) '.' ++ "#") ++
                    [replicate w '#'])

main :: IO ()
main = do
  xs <- getLines
  putStrLn $ intercalate "\n\n" [calc w h | ys <- xs, let [h, w] = ys]
  putStrLn ""

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

int main() {
    //
    int num;
    int x = 0;
    int y = 0;

    cin >> num;
    
    vector<int> vec(num);
    vector<int> vec2(num);
    for (int i = 0; i < num; i++) cin >> vec.at(i);
    for (int i = 0; i < num; i++) cin >> vec2.at(i);

    for (int i = 0; i < num; i++) {
        if (vec.at(i) - vec2.at(i) >= 0) {
            x += vec.at(i);
            y += vec2.at(i);
        }
    }

    cout << x - y<< endl;
    //
}


Measured memory_bytes: 3604
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
using namespace std;

int main(){
  int n,m;
  cin>>n>>m;
  if(n%2==1){
    for(int i=1;i<=m;i++){
      cout<<i<<" "<<n+1-i<<"\n";
    }
  }else if(n%4==2){
    int k=(n-2)/4;
    for(int i=1;i<=min(m,k);i++){
      cout<<i<<" "<<n+1-i<<"\n";
    }
    if(m>=k+1){
      for(int i=k+1;i<=m;i++){
        cout<<i<<" "<<n-i<<"\n";
      }
    }
  }else{
    int k=(n-4)/4;
    for(int i=1;i<=min(m,k+1);i++){
      cout<<i<<" "<<n+1-i<<"\n";
    }
    if(m>=k+2){
      for(int i=k+2;i<=m;i++){
        cout<<i<<" "<<n-i<<"\n";
      }
    }
  }
}


Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl
#define pno cout << "no" << endl
#define pYe cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pYE cout << "YES" << endl
#define pNO cout << "NO" << endl
#define prin(num) cout << num << endl
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define mp make_pair
#define INF 100000000000
#define MOD 1000000007LL
#define MAX 100005
#define NIL -1
#define WHITE 0
#define BLACK 1
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;
class Edge {
public:
    ll t;
    ll w;
    Edge() {}
    Edge(ll t, ll w): t(t), w(w) {}
};


int main(void) {
    ll N;
    ll a[100000];
    ll sub[100000];
    ll i;
    ll sum=0;
    ll count;
    cin >> N;
    for(i=0; i<N; i++) {
        cin >> a[i];
        sum+=a[i];
    }
    
    for(i=0; i<N; i++) {
        sub[i]=a[(i+1)%N]-a[i];
    }
    
    if(sum*2%(N*(N+1))!=0) {
        pNO;
        return 0;
    }
    
    count=sum*2/N/(N+1);
    
    ll ans=0;
    for(i=0; i<N; i++) {
        sub[i]-=count;
        
        if(sub[i]<0 && abs(sub[i])%N==0) {
            ans+=abs(sub[i])/N;
        }
    }
    
    if(ans==count) pYE;
    else pNO;
}

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

int main()
{
	int N, Y, x, y, z;
	
	cin >> N >> Y;
	
	for (x=0; x<=Y/10000; x++)
	   for (y=0; y<=Y/5000; y++)
	   {
	   	  z=N-x-y;
	   	  if (z>=0&&x*10000+y*5000+z*1000==Y)
	   	  {
	   	  	  cout << x << " " << y << " " << z << endl;
	   	  	  return 0;
	   	  }
	   }
	cout << "-1 -1 -1" << endl;
	return 0;
}

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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  while(a>0&&c>0){
    c=c-b;
    if(c>0){
    a=a-d;}
  }
  if(c<=0){
    cout<<"Yes";
  }
  if(a<=0){
  cout<<"No";}
  return 0;
}

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

using namespace std;


bool gives_one(long long n, long long k) {
    if ((n - 1) % k == 0) return true;
    if (n % k == 0) return gives_one(n / k, k);
    return false;
}

vector<long long> divisors(long long n) {
    vector<long long> ds;
    for (long long i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ds.push_back(i);
            if (i * i != n) {
                ds.push_back(n / i);
            }
        }
    }
    return ds;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long n;
    cin >> n;
    auto ds1 = divisors(n);
    auto ds2 = divisors(n - 1);
    vector<long long> ds(ds1.begin(), ds1.end()); //, ds2.begin(), ds2.end());
    ds.insert(ds.begin(), ds2.begin(), ds2.end());
    sort(ds.begin(), ds.end());
    ds.resize(unique(ds.begin(), ds.end()) - ds.begin());
    int answer = 0;
    for (auto d : ds) {
        if (d > 1 && gives_one(n, d)) {
            ++answer;
            cerr << d << " ";
        }
    }
    cerr << endl;
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<iostream>
#include<set>
#include<map>
using namespace std;
#define mp make_pair
#define ll long long
#define re register
typedef pair<int,int> pii;
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi()
{
	int f=1,sum=0;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=210;
int n,a[N];
int main()
{
	n=gi()<<1;for(int i=1;i<=n;i++)a[i]=gi();
	sort(a+1,a+n+1);int ans=0;
	for(int i=1;i<=n;i+=2)ans+=a[i];
	printf("%d\n",ans);
	return 0;
}


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

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

    int n;
    cin >> n;
    vector<int> h(n);
    REP(i, n) cin >> h[i];

    int count = 0;
    int maxi = 0;
    REP(i, n - 1) {
        if (h[i] >= h[i + 1]) count++;
        else count = 0;
        maxi = max(maxi, count);
    }

    cout << maxi << '\n';
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#define N 100
#define INF 1000000000
#define white 0
#define black 1
#define gray 2

int n,A[N][N];

int prim(){
  int i,a,sum=0,minv;
  int d[N],p[N],color[N];

  for(i=0;i<n;i++){
    d[i]=INF;
    p[i]=-1;
    color[i]=white;
  }
  d[0]=0;

  while(1){
    minv=INF;
    a=-1;
    for(i=0;i<n;i++){
      if(minv>d[i] && color[i]!=black){
	a=i;
	minv=d[i];
      }
    }
    if(a==-1)break;
    color[a]=black;

    for(i=0;i<n;i++){
      if(color[i]!=black && A[a][i]!=INF){
	if(d[i]>A[a][i]){
	  d[i]=A[a][i];
	  p[i]=a;
	  color[i]=gray;
	}
      }
    }
  }
  for(i=0;i<n;i++){
    if(p[i]!=-1)
      sum+=A[i][p[i]];
  }





  return sum;
}



int main(){
  int i,j,e;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&e);
      A[i][j]=(e==-1)?INF : e;
    }
  }
  printf("%d\n",prim());

  return 0;
}



Measured memory_bytes: 2104
#include <iostream>

int main()
{
	int n, m;
	std::cin >> n >> m;
	int* a = new int[n];
	int total;
	for (int i = 0; i < n; i++)
	{
		std::cin >> a[i];
		total+=a[i];
	}
	float min = ((float)total)/((float)(4*m));
	int passed = 0;
	while (n > 0)
	{
		if (a[n-1] >= min)
		{
			passed++;
			if (passed == m)
			{
				std::cout << "Yes";
				return 0;
			}
		}
		n--;
	}
	std::cout << "No";
}


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


int main() {
    map<string, vector<int>> mp;
    vector<int> scores;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        string s;
        int k;
        cin >> s >> k;
        scores.push_back(k);
        mp[s].push_back(k);
    }

    for (auto it = mp.begin(); it != mp.end(); it++) {
        auto vec = mp[it->first];
        sort(vec.begin(), vec.end());
        reverse(vec.begin(), vec.end());

        for (auto elem : vec) {
            cout << find(scores.begin(), scores.end(), elem) - scores.begin() + 1 << endl;
        }
    }
    return 0;

}


Measured memory_bytes: 256
#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)

typedef vector<int> vi;

int main() {
	int n;
	cin >> n;
	vi v(n * 2);
	
	REP(i, n * 2) scanf("%d", &v[i]);
	
	sort(v.begin(), v.end());
	
	int ans = 0;
	for (int i = 0; i < n * 2; i += 2) {
		ans += min(v[i], v[i + 1]);
	}
	
	cout << ans << endl;
	
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n, m; cin >> n >> m;
    vector<int> v(n, 1);
    vector<bool> f(n, false); f[0] = true;
    REP(q, m) {
        int x, y; cin >> x >> y; --x, --y;
        assert(v[x] > 0);
        if (f[x]) {
            f[y] = true;
        }
        if (v[x] == 1) {
            f[x] = false;
        }
        --v[x];
        ++v[y];
    }
    int ans = 0;
    REP(i, n) ans += f[i];
    cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long
#define fi first
#define sc second
#define pii pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define msi map<string,int>
#define si set<int>
#define all(v) v.begin(),v.end()
#define sz(v)  int((v).size())
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define dep(i,a,b)    for(int i=a;i>=b;i--)
#define isinarr(i,n) ((i>=0)?((i<n)?1:0):0)
#define fastio  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ppb pop_back
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define PI 3.14159265
#define mp make_pair
#define inparr(a,n) rep(i,0,n)cin>>a[i];
#define give(x,y) cout<<x<<" "<<y<<endl;
#define setp(n) cout<<fixed<<setprecision(n);
#define    endl '\n'

using namespace std;
int i,j,k,l;
void solve()
{
	int n,k;
	cin>>n>>k;
	int mini=n;
	n=n%k;
	i=0;
	while(i<10000000)
	{
		n=abs(n-k);
		mini=min(n,mini);
		i++;
	}
	cout<<mini;
} 



signed main()
{
    fastio
    int t=1;
    while(t--)
        solve();
    return 0;
}

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

int row[300020];
int maxi[300020];
int col[300020];
vector<pii> cols;
map<pii, int> m;
int main() {
	int H, W, M, ans = 0;
	scanf("%d%d%d",&H,&W,&M);
	for(int i=0,x,y; i<M; i++) {
		scanf("%d%d",&x,&y);
		m[{x,y}] = 1;
		row[x]++;
		col[y]++;
	}
	for(int i=1; i<=W; i++) {
		cols.push_back({col[i],i});
	}
	sort(cols.begin(), cols.end(), greater<pii>());
	for(int i=1; i<=H; i++) {
		for(int j=0; j<W; j++) {
			if(!m.count({i,cols[j].second})) {
				maxi[i] = max(maxi[i],cols[j].first + row[i]); 
				break;
			}
			else {
				maxi[i] = max(maxi[i],cols[j].first + row[i]-1);
			}
		}
		ans = max(ans, maxi[i]);
	}
	printf("%d",ans);
}



Measured memory_bytes: 28572
import java.util.*;
import javax.lang.model.util.ElementScanner6;

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

        // 入力
        int n = sc.nextInt();
        int[] a = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            a[i] = sc.nextInt();
        }

        int search_target = 1;
        int out = 0;
        for (int i = 1; i <= n; i++) {
            if (a[i] == search_target) {
                search_target++;
                continue;
            } else {
                out++;
            }
        }
        if (out == n) {
            out = -1;
        }

        // 出力
        System.out.println(out);
    }
}

Measured memory_bytes: 76912
s = input()
if s[0] == "A":
    x = s.find("C")
    if 2<=x and x != len(s)-1:
        s = [i for i in s]
        s[0]="a"
        s[x]="c"
        s = "".join(s)
        if s.islower():
            print("AC")
            exit()
print("WA")

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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
  for(int i=0;i<1000;i++){
      int c[3]={i/100,(i/10)%10,i%10};
      int f = 0;
      for(int j=0;j<n;j++){
          if(s.at(j)==('0'+c[f]))f++;
          if(f==3)break;
      }
      if(f==3)ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000000
int sum[29][9];

int main(){
  int n,m;
  int d[39][39];
  int c[509][509];
  cin>>n>>m;
  for(int i=1;i<=m;i++){
    for(int j=1;j<=m;j++){
      cin>>d[i][j];
    }
  }
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      cin>>c[i][j];
    }
  }

  for(int i=1;i<=m;i++){
    for(int j=1;j<=n;j++){
      for(int k=1;k<=n;k++){
	sum[i][(j+k)%3]+=d[c[j][k]][i];
      }
    }
  }

  int ans=INF;
  for(int i=1;i<=m;i++){
    for(int j=1;j<=m;j++){
      for(int k=1;k<=m;k++){
	if(i==j||j==k||k==i)continue;
	ans=min(ans,sum[i][0]+sum[j][1]+sum[k][2]);
      }
    }
  }

  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 1280
def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)
      
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        if isCLKWISE(phU) : continue
        while(True):
            del phU[-2]
            try:
                if isCLKWISE(phU) : break
            except IndexError : break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        if isCLKWISE(phL) : continue
        while(True):
            del phL[-2]
            try:
                if isCLKWISE(phL) : break
            except IndexError : break      
    ph = phU + phL[1:-1]
    return ph
  
n = range(int(input()))
P = [[int(x) for x in input().split()] for _ in n]
Q = ConvexHullScan(P)
Q.reverse()
print(len(Q))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]
R = Q[idx:] + Q[:idx]
for r in R : print(r[0],r[1])

Measured memory_bytes: 33772
N = int(input())
D = list()
D.append(0)
for i in range(1, N + 1):
	x, y = input().split()
	s = 1 + D[i - 1]if x == y else 0
	D.append(s)
if 3 in D:
	print('Yes')
else:
	print('No')


Measured memory_bytes: 9204
# https://atcoder.jp/contests/abc113/tasks/abc113_c

n, m = map(int, input().split())

ans = [0] * m
cities = []
for i in range(m):
    p, y = map(int, input().split())
    cities.append((i, p, y))
prefec = [[] for _ in range(n)]
cities.sort(key=lambda x: x[2]) # 年でsort

for i, p, y in cities:
    prefec[p - 1].append((i))

for i in range(len(prefec)):
    pre = prefec[i]
    for j in range(len(pre)):
        index = pre[j]
        head = '000000' + str(i + 1)
        head = head[-6:]
        tail = '000000' + str(j + 1)
        tail = tail[-6:]
        ans[index] = head + tail

for r in ans:
    print(r)

Measured memory_bytes: 92760
#include<stdio.h>
int main()
{
  
  int i = 0;
  int j = 0;
  int N,v,k;

  scanf("%d",&N);

  int A[N];

  for(i = 0 ; i < N ; i++)
    scanf("%d",&A[i]);
  
  for(i = 1 ; i <= N ; i++){
    v = A[i];
    j = i-1;
    
    for(k = 0 ; k < N-1 ; k++){
      printf("%d ",A[k]);
    }
    printf("%d",A[N-1]);
    printf("\n");

    
    while( j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
      A[j+1] = v;
    }
  }
  return 0;
}



Measured memory_bytes: 2144
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	int a, b, c;
	cin >> a >> b >> c;
	cout << max(a, max(b, c)) - min(a, min(b, c)) << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
ls = []
for i in range(n):
    city, point = map(str, input().split())
    ls.append([i+1, city, int(point)])

ls.sort(key=lambda l:l[2], reverse=True)
ls.sort(key=lambda l:l[1])

for i in ls:
    print(i[0])


Measured memory_bytes: 3060
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

//long mod = 10^^9 + 7;
long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto D = RD;
	auto S = RD;
	auto T = RD;

	writeln(T*S >= D ? "Yes" : "No");
	stdout.flush;
	debug readln;
}


Measured memory_bytes: 2744
#include <bits/stdc++.h>
using namespace std;
#define LL long int

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

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

    vector<int> c(n - 1);
    for(int i = 0; i < n - 1; ++i) cin >> c[i];

    int ans = 0,rec = -1;

    for(int i = 0; i < n; ++i){
        ans += b[a[i]];
        if(rec + 1 == a[i]){
            ans += c[rec];
        }
        rec = a[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long int
#define FIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(in) in.begin(), in.end()

void in(ll* x, ll n){
    for(ll i = 0 ; i < n ; i++){
        cin >> x[i];
    }
}

int main(){
    FIO;
    ll n;   cin >> n;
    ll a[n], b[n], c[n];
    for(ll i = 0 ; i < n ; i++){
        cin >> a[i];    a[i]--;
    }
    in(b, n);   in(c, n-1);
    ll ans = b[a[0]];

    for(ll i = 1 ; i < n ; i++){
        ans += b[a[i]];
        if(a[i] - a[i-1] == 1){
            ans += c[a[i-1]];
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
namespace my_std{
	using namespace std;
	#define pii pair<int,int>
	#define fir first
	#define sec second
	#define MP make_pair
	#define rep(i,x,y) for (int i=(x);i<=(y);i++)
	#define drep(i,x,y) for (int i=(x);i>=(y);i--)
	#define go(x) for (int i=head[x];i;i=edge[i].nxt)
	#define templ template<typename T>
	#define sz 101010
	typedef long long ll;
	typedef double db;
	templ inline bool chkmax(T &x,T y){return x<y?x=y,1:0;}
	templ inline bool chkmin(T &x,T y){return x>y?x=y,1:0;}
	templ inline void read(T& t)
	{
		t=0;char f=0,ch=getchar();double d=0.1;
		while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
		while(ch<='9'&&ch>='0') t=t*10+ch-48,ch=getchar();
		if(ch=='.'){ch=getchar();while(ch<='9'&&ch>='0') t+=d*(ch^48),d*=0.1,ch=getchar();}
		t=(f?-t:t);
	}
	template<typename T,typename... Args>inline void read(T& t,Args&... args){read(t); read(args...);}
}
using namespace my_std;

int n,m;
struct hh{int t,nxt;}edge[sz<<1];
bool vis[sz];
int head[sz],ecnt;
int deg[sz];
void make_edge(int f,int t)
{
	edge[++ecnt]=(hh){t,head[f]};
	head[f]=ecnt;
	edge[++ecnt]=(hh){f,head[t]};
	head[t]=ecnt;
	++deg[f],++deg[t];
}

void out(string s){cout<<s;exit(0);}

int p1,p2;
int e;
int dfs(int x,bool t)
{
	if (x==p1&&!t) return 1;
	if (x==p2) return ++e,2; 
	#define v edge[i].t
	go(x) if (!vis[(i+1)>>1])
	{
		vis[(i+1)>>1]=1;
		int r=dfs(v,0);
		if (r==1&&x!=p1) return 1;
		if (r==2&&x!=p1) return 2;
	}
	#undef v
	return 0;
}

int main()
{
	read(n,m);
	int x,y;
	rep(i,1,m) read(x,y),make_edge(x,y);
	rep(i,1,n) if (deg[i]&1) out("No");
	rep(i,1,n) if (deg[i]>=6) out("Yes");
	int cnt=0;vector<int>v;
	rep(i,1,n) if (deg[i]==4) ++cnt,v.push_back(i);
	if (cnt>=3) out("Yes");
	if (cnt<=1) out("No");
	p1=v[0],p2=v[1];
	dfs(p1,1);
	out((e==2)?"Yes":"No"); 
	return 0;
}

Measured memory_bytes: 3456
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
 
##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)
 
##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力
 
# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと
 
##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順
 
# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順
 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    N = str(N)
    ans = 0
    for i in N:
        if i == "2":
            ans += 1
            
    print(ans)
    
    
    
if __name__ == "__main__":
	main()


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

typedef long long ll;
int MOD = 1000000007;

int main() {
  string S; cin >> S;
  
  if (S[S.size()-1] == 's') S = S + "es";
  else S = S + "s";
  
  cout << S << endl;  
}

Measured memory_bytes: 3588
using namespace std;

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <numeric>
typedef long long ll;
typedef pair<int,int> p;

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


int main()
{
  string s1, s2;
  cin >> s1 >> s2;
  if (s1 == s2)
  {
    cout << "EQUAL" << endl;
  }
  else if (int(s1.size()) > int(s2.size()))
  {
    cout << "GREATER" << endl;
  }
  else if (int(s1.size()) < int(s2.size()))
  {
    cout << "LESS" << endl;
  }
  else
  {
    int i = 0;
    while (true)
    {
      // cout << "s1: " << s1[i] << endl;
      // cout << "s2: " << s2[i] << endl;
      if (s1[i] > s2[i])
      {
        cout << "GREATER" << endl;
        return 0;
      }
      else if (s1[i] < s2[i])
      {
        cout << "LESS" << endl;
        return 0;
      }
      i++;
    }
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define ll long long

int INF = 1e5 + 10;
int main(){
	int n;
	cin>>n;
	int ans = INF;
	for(int i=1;i<=(n>>1);i++){
		int sum = 0;
		int tmp = i;
		while(tmp!=0){
			sum += tmp%10;
			tmp /= 10;
		}
		tmp = n - i;
		while(tmp!=0){
			sum += tmp%10;
			tmp/=10;
		}
		ans = min(sum,ans);
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

ll n, a, b;
vector<ll> h;

bool func(ll s){
    ll res = 0;
    rep(i, n){
        ll p = h[i] - s * b;
        if(p > 0) res += (p + a - b - 1) / (a - b);
    }
    if(res <= s) return true;
    else return false;
}

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

    cin >> n >> a >> b;
    h.resize(n);
    rep(i, n) cin >> h[i];

    ll r = 1e10;
    ll l = -1;

    while(r - l > 1){
        ll mid = (l + r) / 2;
        if(func(mid)) r = mid;
        else l = mid;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;

int main(){
  int N,K;
  cin>>N>>K;
  vb D(10, true);//使える
  for(int i=0; i<K; i++){
    int d;
    cin>>d;
    D[d] = false;
  }
/*
  for(bool d: D){
    cout<<d<<endl;
  }
//*/

  for(int i=N; i<1000000; i++){
    bool ok = true;
    int buf = i;
    while(buf>0){
      int j = buf%10;
      if(!D[j]){
        ok=false;break;
      }
      buf/=10;
    }
    if(ok){
      cout<<i<<endl;
      break;
    }
  }
//*/
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;


const long long int MAX = 102000000;
int main() {
	long long int w, h, v, t, x, y, p, q; cin >> w >> h >> v >> t >> x >> y >> p >> q;
	long long int dis = v*t;

	long long int ans = 0;
	for (long long int cy = -(MAX/(2*h)); cy <= MAX / (2 * h); ++cy) {
		long long int dy = (q- y) + cy*h * 2;
		if ((dis*dis) - (dy*dy) >= (p-x)*(p-x)) {
			long long int dx = sqrt(dis*dis - dy*dy);
			long long int l = (dx + (p - x)) / (w * 2);
			long long int r = (dx + (x - p)) / (w * 2);
			ans += l + r + 1;
		}
		else {
			if (cy >100)break;
		}
	}
	for (long long int cy = -(MAX / (2 * h)); cy <= MAX / (2 * h); ++cy) {

		long long int dy = (q + y) + cy*h * 2;
		if ((dis*dis) - (dy*dy) >= (p - x)*(p - x)) {
			long long int dx = sqrt(dis*dis - dy*dy);
			long long int l = (dx + (p - x)) / (w * 2);
			long long int r = (dx + (x - p)) / (w * 2);
			ans += l + r + 1;
		}
		else {
			if (cy >100)break;
		}
	}
	for (long long int cy = -(MAX / (2 * h)); cy <= MAX / (2 * h); ++cy) {

		long long int dy = (q - y) + cy*h * 2;
		if ((dis*dis) - (dy*dy) >= 0) {
			long long int dx = sqrt(dis*dis - dy*dy);
			long long int l = max(0, int((dx+2*w -p-x) / (w * 2)));
			long long int r = max(0, int((dx + 2 * w -2*w+p+x) / (w * 2)));
			ans += l + r;
		}
		else {
			if (cy >100)break;
		}
	}
	for (long long int cy = -(MAX / (2 * h)); cy <= MAX / (2 * h); ++cy) {

		long long int dy = (q + y) + cy*h * 2;
		if ((dis*dis) - (dy*dy) >= 0) {
			long long int dx = sqrt(dis*dis - dy*dy);
			long long int l = max(0, int((dx + 2 * w - p - x) / (w * 2)));
			long long int r = max(0, int((dx + 2 * w - 2 * w + p + x) / (w * 2)));
			ans += l + r;
		}
		else {
			if (cy >100)break;
		}
	}
	cout << ans << endl;
	cin >> ans;

	return 0;

	
}

Measured memory_bytes: 3100
#include <cstdio>
#include <iostream>
#include <cmath>
#include <set>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
using namespace std;
typedef long long ll;
int main()
{
    //freopen("a.in","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    cout<<n*(n-1)/2+m*(m-1)/2<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define sf scanf
#define pf printf
#define INF (ll)1e15
#define mod 1000000007

///#define isValid(n,m,nx,ny)nx>=0&&nx<n&&ny>=0&&ny<m
///int kx[]={1, 1, -1, -1, 2, 2, -2, -2}; //knight moves
///int ky[]={2,-2,  2, -2, 1,-1,  1, -1}; //knight moves
///int dx[]={1,-1,0,0,1,-1,1,-1};//eight direction
///int dy[]={0,0,1,-1,1,-1,-1,1};//eight direction
 
///using namespace __gnu_pbds;
using namespace std;
 
///inline double toRad(double deg){return deg*PI/180;}
///inline double toDeg(double rad){return rad*180/PI;}
///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
 
const int S=123456;
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    #endif
    int n,m;
    while(sf("%d",&n)==1)
    {
        int ara[n+5];
        for(int i=0;i<n;i++)sf("%d",&ara[i]);

        int gcd=0;
        for(int i=0;i<n;i++)gcd=__gcd(gcd,ara[i]);

        pf("%d\n",gcd);
    }   
    return 0;
}
 









 




























Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr ll INF = (1LL << 55);

int main(){
  int h, n;
  cin >> h >> n;
  vector<int> a(n), b(n);
  rep(i,n) cin >> a[i] >> b[i];
  vector<ll> dp(h+1,INF);
  dp[0] = 0;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < h; j++) {
      if (dp[j] == INF) continue;
      if (a[i] + j < h) dp[j + a[i]] = min(dp[j + a[i]], dp[j] + b[i]);
      else dp[h] = min(dp[h], dp[j] + b[i]);
    }
  }
  cout << dp[h] << endl;
  return 0;
} 

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
map<int, int> factor;
/* function */
void primeFactrization(int n) {
    int x = n;
    if (x < 2) {
        return ;
    }
    for (int i = 2; i * i <= n; i++) {
        while (x % i == 0) {
            factor[i]++;
            x /= i;
        }
    }
    if (x != 1) { factor[x]++; }
}
/* main */
int main(){
    int N;
    cin >> N;
    for (int i = 1; i <= N; i++) { primeFactrization(i); }

    int ans = 0;
    vector<int> nums{74, 14, 4, 24, 2,};
    map<int, int> cnt;
    for (int n : nums) {
        for (auto f : factor)
            if (f.second >= n) cnt[n]++;
    }
    ans += cnt[74];
    ans += cnt[14] * (cnt[4] - 1);
    ans += cnt[24] * (cnt[2] - 1);
    ans += cnt[4] * (cnt[4] - 1) / 2 * (cnt[2] - 2);
    cout << ans << '\n';
}

Measured memory_bytes: 256
/**
	If you only do what you can do, 
	You will never be more than you are now!
	----------------------------------------
	We must all suffer from one of two pains: the pain of discipline or the pain of regret. 
	The difference is discipline weighs grams while regret weighs tons.
**/
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>

using namespace std;

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

#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define show(a) cerr << #a <<" -> "<< a <<"\n"
#define fo(a, b, c, d) for(int (a) = (b); (a) <= (c); (a) += (d))
#define foo(a, b, c ,d) for(int (a) = (b); (a) >= (c); (a) -= (d))
//#define int ll

const int N = 100;
const int MOD = 1e9 + 7;

int n;
ll cnt[N];
vector <bool> v;
char a[N], b[N];

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	fo(i, 1, n, 1) {
		cin >> a[i];
	}	
	fo(i, 1, n, 1) {
		cin >> b[i];
	}
	fo(i, 1, n, 1) {
		if(a[i] == b[i]) v.pb(0);
		if(a[i] != b[i]) {
			++i;
			v.pb(1);
		}
	}
//	fo(i, 0, sz(v) - 1, 1) {
//		cout << v[i] <<' ';
//	}
	if(v[0] == 0) cnt[0] = 3;
	else cnt[0] = 6;
	fo(i, 1, sz(v) - 1, 1) {
		if(v[i - 1] == 0 && v[i] == 0) cnt[i] = 2;
		if(v[i - 1] == 1 && v[i] == 1) cnt[i] = 3;
		if(v[i - 1] == 0 && v[i] == 1) cnt[i] = 2;
		if(v[i - 1] == 1 && v[i] == 0) cnt[i] = 1;
	}	
	ll ans = 1;
	fo(i, 0, sz(v) - 1, 1) {
//		cout << cnt[i] <<' ';
		ans *= cnt[i];
		ans %= MOD;
	}
	cout << ans;
	return 0;
}




Measured memory_bytes: 256
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000005
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
#define pa pair<int,int>
#define pb push_back
#define be begin()
#define en end()
#define ret return puts("-1"),0;
#define mod 1000000007
#define N 500055
#define int ll
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,sum[N],fa[N],mx1,tot,z[N],a,b,c,mi,ans,lon[N];
int nedge,Next[N*2],head[N],to[N*2];
#define V to[i]
void add(int a,int b,int c){
	Next[++nedge]=head[a];head[a]=nedge;to[nedge]=b;lon[nedge]=c;
}
void add_ne(int a,int b){add(a,b,c);add(b,a,c);}
void dfs(int x){
	sum[x]=1;
	int mx=0;
	go(i,x){
		if (fa[x]==V) continue;
		fa[V]=x;dfs(V);sum[x]+=sum[V];mx=max(mx,sum[V]);
	}
	mx=max(mx,n-sum[x]);
	if (mx<mx1) mx1=mx,tot=0;
	if (mx==mx1) z[++tot]=x;
}
void dfs2(int x){
	sum[x]=1;
	go(i,x){
		if (fa[x]==V) continue;
		fa[V]=x;dfs2(V);sum[x]+=sum[V];ans+=sum[V]*lon[i]*2;
	}
}
signed main(){
	n=read();
	F(i,1,n-1){
		a=read();b=read();c=read();
		add(a,b,c);add(b,a,c);
	}
	mx1=inf;dfs(1);
	fa[z[1]]=0;dfs2(z[1]);
	if (tot==1){
		int mi=inf;
		go(i,z[1]) mi=min(mi,lon[i]);
		ans-=mi;
	}
	else{
		go(i,z[1]) if (V==z[2]) ans-=lon[i];
	}
	wrn(ans);
	return 0;
}

Measured memory_bytes: 22912
fun main(args : Array<String>) {
    val x = readLine()!!.toLong()
    println(prime(x))
}

fun prime(from : Long) : Long {
    var current = from
    while (true) {
        val max = Math.sqrt(current.toDouble()).toLong()
        if ((2..max).all { i -> current % i != 0L }) {
            return current
        }
        current++
    }
}

Measured memory_bytes: 33568
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top, S[1000];

void push(int x) {
	S[++top] = x;
} 

int pop() {
	top--;

	return S[top+1];
}

int main() {
	int a, b;
	top = 0;
	char s[100];

	while (scanf("%s", s) != EOF) {
		if (s[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
		} else if (s[0] == '-') {
			b = pop();
			a = pop();
			push(a - b);
		} else if (s[0] == '*') {
			a = pop();
			b = pop();
			push(a * b);
		} else {
			push(atoi(s));
		}
	}

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

	return 0;


}


Measured memory_bytes: 2720
#include <iostream>

int main(void) {
  int tmp;
  int K;  //操作回数
  int i;
  int sum = 0;  //合計の数字を格納
  int max = 0;  //最大の数字を格納

  for(i=0; i<3; i++) {
    std::cin >> tmp;
    sum += tmp;
    if(max<tmp) {
      max = tmp;
    }
  }

  sum -= max;
  std::cin >> K;

  for(i=0; i<K; i++) {
    max *= 2;
  }

  std::cout << sum+max << std::endl;
  
  return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define el endl
#define INF 1e15
typedef long long ll;
typedef long double ld;
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

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() {
    int n;
    cin >> n;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];
    vector<ll> dp(n+1, INF);
    dp[0] = 0;
    for(int i = 1; i < n; i++){
        chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
        if(i > 1) chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }
    cout << dp[n-1] << endl;
}




Measured memory_bytes: 1792