akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int read()
{
	int x=0;
	char ch=getchar();
	bool f=0;
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')
			f=1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		x=(x<<1)+(x<<3)+ch-'0';
		ch=getchar();
	}
	if(f==0)
		return x;
	return ~(x-1);
}
int main()
{
	int a,b,c;
	a=read();
	b=read();
	c=read();
	if(b-a==c-b)
		cout<<"YES";
	else
		cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
#define int long long
const int M = 2005;
const int N = 30005;
const int o = 15000;

bool ab[N],ac[N],bc[N];

bool match(char x,char y) {
    return x=='?' || y=='?' || x==y;
}
string a,b,c;
int la,lb,lc;
signed main() {   
    cin>>a>>b>>c;
    la=a.length();
    lb=b.length();
    lc=c.length();
    for(int i=0;i<la;i++) 
        for(int j=0;j<lb;j++)
           if(!match(a[i],b[j])) 
              ab[i-j+o]=1;
    for(int i=0;i<la;i++) 
        for(int j=0;j<lc;j++)
           if(!match(a[i],c[j])) 
              ac[i-j+o]=1;
    for(int i=0;i<lb;i++) 
        for(int j=0;j<lc;j++)
           if(!match(b[i],c[j])) 
              bc[i-j+o]=1;
    int ans=N;
    for(int i=-2*M;i<=2*M;i++) 
        for(int j=-2*M;j<=2*M;j++) 
        {
        if(!ab[i+o] && !ac[j+o] &&! bc[j-i+o]) {
            ans=min(ans, max(la,max(lb+i,lc+j))-min((int)0,min(i,j)));
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include<cstdio>
using namespace std;
int main()
{
    int a,b,c,d;
    scanf("%d",&a);
    d=a%10;
    a/=10;
    c=a%10;
    a/=10;
    b=a%10;
    a/=10;
    if(a+b+c+d==7)printf("%d+%d+%d+%d=7",a,b,c,d);
    else
    if(a+b+c-d==7)printf("%d+%d+%d-%d=7",a,b,c,d);
    else
    if(a+b-c+d==7)printf("%d+%d-%d+%d=7",a,b,c,d);
    else
    if(a+b-c-d==7)printf("%d+%d-%d-%d=7",a,b,c,d);
    else
    if(a-b+c+d==7)printf("%d-%d+%d+%d=7",a,b,c,d);
    else
    if(a-b+c-d==7)printf("%d-%d+%d-%d=7",a,b,c,d);
    else
    if(a-b-c+d==7)printf("%d-%d-%d+%d=7",a,b,c,d);
    else
    if(a-b-c-d==7)printf("%d-%d-%d-%d=7",a,b,c,d);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main (){
	
	int A[5], k;
	for(int i=0; i<5; i++){
		cin >> A[i];
	}
	cin >> k;
	
	if (A[4] - A[0] > k){
		cout << ":(";
	}else{
		cout << "Yay!";
	}
	
	return 0;
}

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


int main(){
  int a,b;
  cin>>a>>b;

  if(a < b) cout<<"a < b"<<endl;
  if(a > b) cout<<"a > b"<<endl;
  if(a == b) cout<<"a == b"<<endl;

  return 0;
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  ll n,a;cin>>n>>a;
  static ll x[55];
  REP(i,n){
    cin>>x[i];
  }
  // dp[枚数][選ぶ数][合計]
  static ll dp[55][55][5555];
  dp[0][0][0]=1;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      for(int k=0;k<5000;k++){
        if(dp[i][j][k]==0)continue;
        dp[i+1][j+1][k+x[i]]+=dp[i][j][k];
        dp[i+1][j][k]+=dp[i][j][k];
      }
    }
  }
  ll sm=0;
  for(int i=1;i<=n;i++)sm+=dp[n][i][i*a];
  P(sm);
  return 0;
}


Measured memory_bytes: 123136
#include<bits/stdc++.h>
using namespace std;
inline int read () {
	int num = 0;
	char c = ' ';
	bool flag = true;
	for (;c > '9' || c < '0';c = getchar())
		if (c == '-')
			flag = false;
	for (;c >= '0' && c <= '9';num = (num << 1) + (num << 3) + c - 48, c = getchar());
	return flag ? num : -num;
}
int main () {
	int a = read();
	int b = read();
	int c = read();
	int t1 = a * 10 + b + c;
	int t2 = b * 10 + a + c;
	int t3 = c * 10 + a + b;
	printf("%d",max(max(t1, t2), t3));
	return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
d={}
for i in range(n-1):
  if a[i] in d:
    d[a[i]]+=1
  else:
    d[a[i]]=1

for i in range(1,n+1):
  if i in d:
    print(d[i])
  else:
    print(0)


Measured memory_bytes: 33516
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
using namespace std;

#define Yes(a) a ? "Yes" : "No";
#define YES(a) a ? "YES" : "NO";
#define rep(i,n) for(int i=0;i<n;i++)

void sout(string* a, string* b) {
	if (*a > * b) {
		string c = *a;
		*a = *b;
		*b = c;
	}
}

int combination(int n, int k) {
	if (n > k && k > 0) {
		return (combination(n - 1, k) + combination(n - 1, k - 1));
	}
	else
		return 1;
}

int main() {
	int a[3], b[3];
	vector<int> s(4);
	for (int i = 0; i < 3; i++) {
		cin >> a[i] >> b[i];
		s.at(a[i] - 1)++;
		s.at(b[i] - 1)++;
	}
	sort(s.begin(), s.end());
	string ans;
	ans = YES(s.at(0) == 1 && s.at(1) == 1 && s.at(2) == 2);
	cout << ans << endl;
}

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

int n, c, s, f;
long long ans[505];
int main(){

    cin >> n;

    for(int i=0; i<n-1; ++i){
        cin >> c >> s >> f;
        ans[i] = s + c;
        for(int k=0; k<i; ++k){
            if(ans[k] < s){
                ans[k] = s + c;
            }else {
                if(ans[k] % f == 0){
                    ans[k] += c;
                }else{
                    ans[k] = f*(ans[k]/f + 1) + c;
                }
            }
        }
    }

    for(int i=0; i<n; ++i) cout << ans[i] << endl;
}




Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
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():
    n = I()
    v = [[] for i in range(n)]
    for i in range(n-1):
        a,b = LI()
        a -= 1
        b -= 1
        v[a].append(b)
        v[b].append(a)
    if n < 4:
        print(*range(1,n+1),sep = " ")
        return
    d = [-1]*n
    d[0] = 0
    q = deque([0])
    while q:
        x = q.popleft()
        nd = d[x]^1
        for y in v[x]:
            if d[y] < 0:
                d[y] = nd
                q.append(y)
    n1 = sum(d)
    n0 = len(d)-n1
    if n1 > n0:
        for i in range(n):
            d[i] ^= 1
        n0,n1 = n1,n0
    p = [(n+2)//3, (n+1)//3, n//3]
    k = [1,2,3]
    ans = [0]*n
    if n1 >= p[1]:
        for i in range(n):
            di = d[i]
            if not p[di]:
                di = 2
            ans[i] = k[di]
            k[di] += 3
            p[di] -= 1
    else:
        for i in range(n):
            di = d[i]
            if di == 1:
                di = 2
            while not p[di]:
                di += 1
            ans[i] = k[di]
            k[di] += 3
            p[di] -= 1
    print(*ans)
    return

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


Measured memory_bytes: 95924
from functools import reduce

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def gcdArr(a):
    return reduce(gcd, a)

n = int(input())
ret = 0
for a in range(1, n + 1):
    for b in range(1, n + 1):
        gcd_ = gcd(a, b)
        if gcd_ == 1:
            ret += n
            continue
        for c in range(1, n + 1):
            ret += gcd(gcd_, c)
print(ret)


Measured memory_bytes: 68804
import java.util.BitSet;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		BitSet bs = new BitSet(1300000);
		bs.set(2);
		for (int i = 3; i < bs.size(); i += 2) {
			boolean ok = true;
			for (int j = 3; j > 0 && (long) j * j <= i; j = bs.nextSetBit(j + 1)) {
				if (i % j == 0) {
					ok = false;
					break;
				}
			}
			if (ok) bs.set(i);
		}
		while (true) {
			int k = sc.nextInt();
			if (k == 0) break;
			int p = k;
			while (!bs.get(p)) --p;
			int n = bs.nextSetBit(k);
			System.out.println(n - p);
		}
	}

}

Measured memory_bytes: 24380
#include<bits/stdc++.h>
using namespace std;
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define pa pair<int,int>
#define mod 998244353
#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define cl(x) memset(x,0,sizeof x)
#ifdef Devil_Gary
#define bug(x) cout<<(#x)<<" "<<(x)<<endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define bug(x)
#define debug(...)
#endif

const int INF = 0x7fffffff;
const int N=2e5+5;
/*
char *TT,*mo,but[(1<<15)+2];
#define getchar() ((TT==mo&&(mo=(TT=but)+fread(but,1,1<<15,stdin),TT==mo))?-1:*TT++)//*/
inline ll read(){
    ll x=0,rev=0,ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')rev=1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
    return rev?-x:x;
}/*
struct Edge{
	int nxt,v;
//	int w;
//	int id;
}e[N<<1];
void add(int u,int v){
	e[++tot].v=v,e[tot].nxt=head[u],head[u]=tot;
	e[++tot].v=u,e[tot].nxt=head[v],head[v]=tot;
}*/


ll n,k,tmp;
ll a[N];
int main(){
#ifdef Devil_Gary
    freopen("in.txt","r",stdin);
//  freopen("out.txt","w",stdout);
#endif
	n=read(),k=read();
	for(int i=1;i<=n;i++){
		a[i]=read();
	}
	ll L=1,R=1e9;
	while(L<R){
		ll mid=L+R>>1;
		tmp=0;
		for(int i=1;i<=n;i++){
			tmp+=ceil((double)a[i]/mid)-1;
		}
		if(tmp<=k) R=mid;
		else L=mid+1;
	}
	cout<<L<<endl; 
	return 0;
}


Measured memory_bytes: 5144
// Last Change: 05/25/2019 21:42:27.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int main() {
  ll N, M;
  cin >> N >> M;

  ll A, B, C;

  // key:C, val=B
  map<ll, ll> mp;
  for (ll i = 0; i < N; ++i) {
    cin >> A;
    ++mp[A];
  }

  for (ll i = 0; i < M; ++i) {
    cin >> B >> C;
    mp[C] += B;
  }

  ll ans = 0;
  ll cur = 0;
  auto endPos = mp.rend();
  for (auto e = mp.rbegin(); e != endPos; ++e) {
    if (cur + e->second >= N) {
      ans += (N - cur) * e->first;
      break;
    } else {
      ans += e->first * e->second;
      cur += e->second;
    }
  }
  cout << ans << endl;

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 12800
import sys

def main():
    N,*S = map(int, open(0).read().split())
    S = sorted(S)

    g = [S.pop(-1)]

    for _ in range(N):
        c = []
        tmp = []
        for p in g:
            while S:
                s = S.pop(-1)
                if p > s:
                    c.append(s)
                    break
                else:
                    tmp.append(s)
            else:
                print('No')
                sys.exit()
        S.extend(tmp[::-1])
        g.extend(c)
        g.sort(reverse=True)
    print('Yes')

if __name__=='__main__':
    main()

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


int main(){
  int N;
  cin >> N;
  int ans = 0;
  for(int ii=1; ii<=N; ii+=2){
    int count = 0;
    for(int jj=1; jj<=ii; jj++){
      if(ii%jj==0) count++;
    }
    if(count==8) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecstr vector<string>
#define vecch vector<char>
#define vecpii vector<pii>
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}

string strin(){string s;cin>>s;return s;}
char chin(){char c;cin>>c;return c;}
ll lin() {ll x;scanf("%lld",&x);return x;}



int main(){
    int n=in(),m=in();
    vector<bool> bl(n,false);
    bl[0]=true;
    vecll a(n,1);
    rep(i,m){
        int x=in()-1,y=in()-1;
        a[x]--;
        a[y]++;
        if(bl[x]){
            bl[y]=true;
            if(a[x]==0)bl[x]=false;
        }
    }
    ll ans=0;
    rep(i,n)if(bl[i])ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
#include <bitset>
using namespace std;
 
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair
 
static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
typedef vector<vint> vvint;
static const int INF=1<<24;
 
template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
    v.assign(a,vector<T>(b,t));
}
 
//v.erase(unique(v.begin(),v.end()),v.end());

int main(){
  int m;
  while(cin>>m,m){
    const int n=m;
    bitset<55> v[n];
    rep(i,n){
      v[i].reset();
      v[i][i]=1;
    }
    vvint vv(30);
    rep(i,n){
      int r;
      cin>>r;
      rep(j,r){
	int t;
	cin>>t;
	vv[t-1].PB(i);
      }
    }
    bool f=true;
    rep(i,30){
      bitset<55> t;
      t.reset();
      rep(j,vv[i].size()){
	//cout<<vv[i][j]<<endl;
	t|=v[vv[i][j]];
      }
      //cout<<endl;
      rep(j,vv[i].size()){
	v[vv[i][j]]|=t;
      }
      rep(j,n){
	//ll t=v[j].to_ulong();
	//cout<<t<<endl;
	if(v[j].count()==n){
	  cout<<i+1<<endl;
	  f=false;
	  break;
	}
      }
      if(!f) break;
    }
    if(f) cout<<-1<<endl;
  }
}

Measured memory_bytes: 1236
def area(a1,a2,b):
    s1=a1*b
    if b%2==0:
        s2=a2*b//2
        s3=s2
    else:
        s2=a2*(b//2+1)
        s3=a2*(b//2)
    return max(s1,s2,s3)-min(s1,s2,s3)

H, W = map(int, input().split())

if H % 3 == 0 or W % 3 == 0:
    print(0)
    exit()
"""
ans2_1 = 10 ** 10
ans2_2 = 10 ** 10

ans3_1 = 10 ** 10
ans3_2 = 10 ** 10
"""

ans1 = W
ans4 = H


h1 = (H + 2) // 3
h2 = H - h1
ans2_1=area(h1,h2,W)

h1 = H // 3
h2 = H - h1
ans2_2=area(h1,h2,W)

w1 = (W + 2) // 3
w2 = W - w1
ans3_1=area(w1,w2,H)

w1 = W // 3
w2 = W - w1
ans3_2=area(w1,w2,H)

print(int(min(ans1, ans2_1, ans2_2, ans3_1, ans3_2, ans4)))


Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
/*        string[] input = ReadLine().Split(' ');
        long a = long.Parse(input[0]);
        long b = long.Parse(input[1]);
        long c = long.Parse(input[2]);
//        long d = long.Parse(input[3]);*/
//        string temp = ReadLine();
        int a = int.Parse(ReadLine());
//        int b = int.Parse(ReadLine());
//        int c = int.Parse(ReadLine());
//        int d = int.Parse(ReadLine());
//        string a = ReadLine();
//        string b = ReadLine();
//        string c = ReadLine();
        string[] input = ReadLine().Split(' ');
//        string ko = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        int count = 0;
        for(int i=0;i<a;i++){
            if(input[i] == "Y"){
                count++;
            }
        }
        if(count >0){
            WriteLine("Four");
        }else{
            WriteLine("Three");
        }
    }
}

Measured memory_bytes: 11092
#include<stdio.h>
int main(void)
{
		int a[100],n,k,p,j,i;
		scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%d %d",&k,&p);
			if(k%p==0){
			a[i]=p;
			}
			else{
				a[i]=k%p;
				}
		}
	for(j=0;j<n;j++){
			printf("%d\n",a[j]);
			}
	return 0;
}	

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

using namespace std;
typedef long long  ll;
typedef long double ld;
typedef pair<ll,ll> pp;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> super_set;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> multi_set;
#define x1 dfds
#define y1 dsfdsfe
#define pb push_back
#define forn(i,n) for(ll i = 1;i<=n;++i)
#define fi first
#define sc second
#define endl '\n'
#define po(x) (1ll<<x)
const ll DIM = 100+7;
const ll INF = 1e8;
vector<ll> x;
void next(){
    ll pos = -1;
    for(ll i = 0;i<x.size();i++){
        if (i==x.size()-1 && x[i]!=9){
            pos = i;
            break;
        }
        else if (i+1<x.size() && abs(x[i]+1-x[i+1])<=1 && x[i]!=9){
            pos = i;
            break;
        }
    }
    if(pos==-1){
        for(ll i=  0;i<x.size();i++)x[i] = 0;
        x.pb(1);
        return;
    }
    x[pos]++;
    ll num = max(0ll,x[pos]-1);
    for(ll i = pos-1;i>=0;--i){
        x[i] = num;
        num = max(0ll,num-1);
    }
}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    ll k;
    cin>>k;
    x.pb(1);

    while(--k){
        next();
    }
    reverse(x.begin(),x.end());
    for(ll to:x)cout<<to;
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
  
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt(), b = sc.nextInt(), h = sc.nextInt();
    sc.close();
    int ans = (a + b) * h / 2;
    System.out.println(ans);
  }
}


Measured memory_bytes: 22740
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
ll inf = 1000000000;
typedef pair<ll, ll> P;
int main() {
	int n;
	cin >> n;
	vector<P>p(n);
	for (int i = 0; i < n; i++) {
		ll x, l;
		cin >> x >> l;
		p[i] = make_pair(x+l, x-l);
	}
	sort(p.begin(), p.end());
	int cnt = 0;
	ll cur = -inf;
	for (int i = 0; i < n; i++) {
		if (cur > p[i].second)continue;
		cnt++;
		cur = p[i].first;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;


int main(){
    int N, K;
    cin >> N >> K;
    if(K == 1){
         cout << 0 << endl;
         return 0;
    }
    cout << N - K << endl;
    return 0;
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <time.h>
#include <random>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define LONG_INF 10000000000000000
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
long long s_ruiseki[200000] = {};
long long t_ruiseki[200000] = {};
int main() {
	string s, t;
	cin >> s >> t;
	for (int i = 0;i < s.length();++i) {
		if (s[i] == 'A') {
			s_ruiseki[i+1] = s_ruiseki[i] + 1;
		}
		else {
			s_ruiseki[i+1] = s_ruiseki[i] + 2;
		}
	}
	for (int i = 0;i < t.length();++i) {
		if (t[i] == 'A') {
			t_ruiseki[i+1] = t_ruiseki[i] + 1;
		}
		else {
			t_ruiseki[i+1] = t_ruiseki[i] + 2;
		}
	}
	int query;
	cin >> query;
	for (int test = 0;test < query;++test) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		long long e = s_ruiseki[b] - s_ruiseki[a - 1];
		long long f = t_ruiseki[d] - t_ruiseki[c - 1];
		if (e % 3 == f % 3) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 233;
ll powmod(ll a,ll p){
	ll res = 1,base = a;
	while(p){
		if(p&1)res = res*base%mod;
		base = base*base%mod;
		p >>= 1;
	}
	return res;	
}
int main()
{
	ll h,w,t;cin>>h>>w>>t;
	ll x = __gcd(h,t),y = __gcd(w,t);
	h /= x; w /= y;
	ll d = __gcd(h,w);
	ll ans = (powmod(2,h)+powmod(2,w)+powmod(2,d)+mod-3)%mod;
	ans = powmod(ans,x*y);
	cout << ans << endl;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  
  int result;
  if (B % A == 0) {
    result = A + B;
  } else {
    result = B - A;
  }
  
  cout << result << endl;
  
  return 0;
}

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

long gcd(long a, long b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    
    return b ? gcd(b, a % b) : a;
}

long lcm(long a, long b)
{
    return a * b / gcd(a, b);
}


int main(){
    long a,b;
    scanf("%ld %ld",&a,&b);
    long  ans=lcm(a,b);
    printf("%ld\n",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <deque>
#include <algorithm>

using namespace std;

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

	deque<int> b;
	int which = n % 2;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if ((which + i) % 2 == 0) {
			b.emplace_back(a);
		} else {
			b.emplace_front(a);
		}
	}

	cout << b[0];
	for (int i = 1; i < n; i++) {
		cout << " " << b[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 2944
N = int(input())
A = [int(x) for x in input().split()]
Base1 = 0
Base2 = 0
a = []
for x in range(N):
    if x % 2 == 0:
        Base1 += A[x]
        Base2 -= A[x]
    else:
        Base1 -= A[x]
        Base2 += A[x]

for i in range(N):
    if i % 2 == 0:
        tmp1 = Base1
        if i >= 2:
            a.append(a[i-2]-A[i-2]*2+A[i-1]*2)
            print(a[i])
        else:
            a.append(Base1)
            print(a[i])
    if i % 2 == 1:
        tmp2 = Base2
        if i >= 2:
            a.append(a[i-2]-A[i-2]*2+A[i-1]*2)
            print(a[i])
        else:
            a.append(Base2+A[i-1]*2)
            print(a[i])

Measured memory_bytes: 14400
#include<iostream>
using namespace std;
int main(){
	int masu[1007];
	int n,m[1007],x=0;int ans;
	int s;
	
	while(1){
	cin>>n>>s;
	if(n==0&&s==0)break;
	for(int i=0;i<n;i++)cin>>masu[i];
	for(int i=0;i<s;i++)cin>>m[i];
	
	for(int i=0;i<s;i++){
		
	x+=m[i];
		if(x>=n-1){
		ans=i+1;
		break;
		}
	x+=masu[x];

		if(x>=n-1){
		ans=i+1;
		break;
		}
		
}

	cout<<ans<<endl;
	ans=0;
	x=0;
	}

return 0;
}

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

using namespace std;

int my_max(int a, int b) {
    return a > b ? a : b;
}

int my_abs(int x) {
    return x < 0 ? -x : x;
}

int main() {

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    while(true) {
        c -= b;
        if(c<=0) {
            cout << "Yes" << endl;
            return 0;
        }

        a -= d;
        if(a<=0) {
            cout << "No" << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
int main(){
    double left,right;
    int a=0,b=0,c=0,d=0,a2=0,b2=0,c2=0,d2=0;
    while(scanf("%lf %lf",&left,&right)!=EOF){
        if(left>=1.1){
            a++;
        }else if(left>=0.6){
            b++;
        }else if(left>=0.2){
            c++;
        }else d++;
        if(right>=1.1){
            a2++;
        }else if(right>=0.6){
            b2++;
        }else if(right>=0.2){
            c2++;
        }else d2++;
    }
    printf("%d %d\n",a,a2);
    printf("%d %d\n",b,b2);
    printf("%d %d\n",c,c2);
    printf("%d %d\n",d,d2);
    return 0;
}

Measured memory_bytes: 628
#include <iostream>
using namespace std;
int main() {
    unsigned int n;
    cin>>n;
    unsigned int arr[n];
    for (int i = 0; i < n; i++)
        cin>>arr[i];
    unsigned long long operation = 0;
    for (int i = 0; i < n - 1; i++)
        if (arr[i] > arr[i+1]) {
            unsigned int x = arr[i] - arr[i + 1];
            arr[i + 1] += x;
            operation+=x;
        }
    cout<<operation;

}

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define MOD 1000000007

//cout << (c)?"Yay!":":(" << endl;

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

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


Measured memory_bytes: 256
package main

import "fmt"

func rot(d []int, a ...int) {
	d[a[0]], d[a[1]], d[a[2]], d[a[3]] = d[a[1]], d[a[2]], d[a[3]], d[a[0]]
}

func main() {
	d := make([]int, 7)
	for i := 1; i <= 6; i++ {
		var x int
		fmt.Scan(&x)
		d[i] = x
	}
	var s string
	fmt.Scan(&s)
	for i := 0; i < len(s); i++ {
		switch s[i] {
		case 'N':
			rot(d, 1, 2, 6, 5)
		case 'E':
			rot(d, 1, 4, 6, 3)
		case 'W':
			rot(d, 1, 3, 6, 4)
		case 'S':
			rot(d, 1, 5, 6, 2)
		}
	}
	fmt.Println(d[1])
}



Measured memory_bytes: 1160
#include <stdio.h>

int main() {
	int a=0, n, i, x;
	char p;
	scanf("%d", &n);
	for(i=0;i<n && a>=0;++i){
		scanf(" %c%d",&p,&x);
		if(p=='(') a += x;
		else a -= x;
	}
	puts(a?"NO":"YES");
	return 0;
}

Measured memory_bytes: 580
n=int(input())
a=[int(x) for x in input().split()]
if n==1:
    print(1)
    exit()
b=0;c=0;ans=1
for i in range(n-1):
    if a[i]<a[i+1]:
        b=1
    if a[i]>a[i+1]:
        c=1
    if b and c:
        ans+=1
        b=0;c=0
print(ans)

Measured memory_bytes: 14228
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=2e5+10;
ll n,ans;
ll a[N],b[N];
struct node{
	ll rt,val;
	bool operator <(const node & op) const{ return val<op.val; }	
};
priority_queue <node> pq;
int main(){
	scanf("%lld",&n);
	for(ll i=1;i<=n;i++) scanf("%lld",&a[i]);
	for(ll i=1;i<=n;i++){
		scanf("%lld",&b[i]);
		if(a[i]!=b[i]) pq.push((node){i,b[i]});
	}

	while(!pq.empty()){
		ll pt=pq.top().rt,pre=(pt-2+n)%n+1,suf=pt%n+1;
		pq.pop();
		ll opt=(b[pt]-a[pt])/(b[pre]+b[suf]);
		if(opt==0){puts("-1");exit(0);}
		b[pt]-=opt*(b[pre]+b[suf]);
		ans+=opt;
		if(a[pt]!=b[pt]) pq.push((node){pt,b[pt]});
	}
	printf("%lld",ans);
}

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

using namespace std;

const int N = 2e5 + 2;

int n, a[N], b[N];

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

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

      sort(b + 1, b + n + 1);

      for(int i = 1; i <= n; i ++){
            if(a[i] <= b[n / 2])
                  cout << b[n / 2 + 1] << endl;
            else
                  cout << b[n / 2] << endl;
      }
}


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

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

  ll tate = 0;
  for (auto mm : m) {
    if (mm.second >= 2) {
      tate = max(tate, mm.first);
    }
  }
  m[tate] -= 2;

  ll yoko = 0;
  for (auto mm : m) {
    if (mm.second >= 2) {
      yoko = max(yoko, mm.first);
    }
  }

  cout << tate * yoko << endl;

  return 0;
}

Measured memory_bytes: 6528
// Date: 2020-03-18

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

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define FIO ios::sync_with_stdio(false);cin.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define D(x) cout<<#x<<" = "<<x<<endl;
#define SZ(x) ((int)x.size())
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 1e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int n;
string s;
VI p[26];
int main() {
    FIO;
    cin >> s;
    int n = s.size();
    rep(i, 0, n-1) p[s[i]-'a'].pb(i);
    int x = -1, y = -1;
    rep(i, 0, 25) {
        int sz = SZ(p[i]);
        if(sz < 2) continue;
        int cur = p[i][0], sum = 0, pre = 0;
        rep(j, 1, sz-1) {
            while(cur <= p[i][j]) {
                if(s[cur] == i+'a') sum++;
                else sum--;
                cur++;
            }
            if(sum > 0) {
                x = p[i][pre];
                y = p[i][j];
            } else sum = 1, pre = j;
        }
    }
    if(x != -1) ++x, ++y;
    cout << x << " " << y << endl;

    return 0;
}

Measured memory_bytes: 1104
#include<bits/stdc++.h>
using namespace std;
#define ms(x,y) memset(x, y, sizeof(x))
#define lowbit(x) ((x)&(-x))
#define sqr(x) ((x)*(x))
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

const LL MOD = 1e9+7;

void run_case() {
    int n, k;
    cin >> n >> k;
    LL ans = 0;
    for(int i = k; i <= n+1; ++i) {
        LL t1 = 1LL*(i-1)*i/2;
        LL t2 = 1LL*(n+n-i+1)*i/2;
        (ans += t2 - t1 + 1) %= MOD;
    }
    cout << ans;
}


int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cout.flags(ios::fixed);cout.precision(9);
    //int t; cin >> t;
    //while(t--)
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {

	static int N;
	static int[][][] field;
	static int[][] already;
	static boolean[][] isLoop;
	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		for(;;){
			N=cin.nextInt();
			if(N==0)break;
			field=new int[N][N][2];
			already=new int[N][N];
			isLoop=new  boolean[N][N];
			for(int i=0;i<N;i++){
				for(int j=0;j<N;j++){
					field[j][i][0]=cin.nextInt();
					field[j][i][1]=cin.nextInt();
				}
			}int ans=0,cnt=1;;
			for(int i=0;i<N;i++){
				for(int j=0;j<N;j++){
					int[] a=a(j,i,cnt++);
//					System.out.println(j+" "+i+" "+a[0]+" "+a[1]);
					if(a[0]==j&&a[1]==i&&!isLoop[j][i]){
						ans++;
//						System.out.println("aaaaaa"+j+" "+i);
						b(j,i);
					}
				}
			}
			System.out.println(ans);
		}
	}
	static void b(int y,int x){
		if(isLoop[y][x])return;
		isLoop[y][x]=true;
		int a=field[y][x][0];
		int b=field[y][x][1];
		b(a,b);
	}
	static int[] a(int y,int x,int cnt){
//		System.out.println("   "+y+" "+x);
		//field[y][x]
		int a=field[y][x][0];
		int b=field[y][x][1];
		if(already[y][x]==cnt)return new int[]{y,x};
		already[y][x]=cnt;
		
		return a(a,b,cnt);
	}
}

Measured memory_bytes: 60208
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	string s; cin >> s;
	set<string> sp1;
	set<string> sp2;
	set<string> sp3;
	for( char c : s ){
		string t = ""s+c;
		for( auto b : sp2 ){
			sp3.insert(b+t);
		}
		for( auto a : sp1 ) sp2.insert(a+t);
		sp1.insert(t);
	}
	cout << sp3.size() << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }


void solve(LL n, LL k, LL c, string s, vector<LL>& left){
    LL next = 1;
    for(LL i = 0; i < n; ++i){
        if(s[i] != 'x'){
            left[i] = next;
            ++next;
            i += c;
            if(next > k) return;
            continue;
        }
    }
}

int main(){
    LL n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;

    vector<LL> left(n), right(n);
    solve(n, k, c, s, left);
    reverse(s.begin(), s.end());
    solve(n, k, c, s, right);
    reverse(right.begin(), right.end());

    LL w_day = *max_element(right.begin(), right.end()) + 1;
    LL ans = 0;
    for(LL i = 0; i < n; ++i){
        if(left[i] == w_day-right[i] && left[i] > 0){
            cout << i+1 << endl;
        }
    }
    return 0;
}




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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);

struct UnionFind {
	vector<int> par;
	UnionFind(int n) : par(n, -1) 
	{ 
	}

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int n, m, k;
	cin >> n >> m >> k;

	vector<set<int>> dame(n);
	UnionFind uf(n);

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		dame[a].insert(b);
		dame[b].insert(a);
		uf.merge(a, b);
	}

	for (int i = 0; i < k; i++) {
		int c, d;
		cin >> c >> d;
		c--; d--;
		if (!uf.issame(c, d)) continue;
		dame[c].insert(d);
		dame[d].insert(c);
	}

	for (int i = 0; i < n; i++) {
		int ans = uf.size(i) - dame[i].size() - 1;
		cout << ans << " ";
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 24704
n=int(input())
a=list(map(int,input().split()))
b=[]
f=1
for i in a:
    if i%2==0:
        b.append(i)
for j in b:
    if not (j%3==0 or j%5==0):
        f=0
if f:
    print("APPROVED")
else:
    print("DENIED")

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long
#define MAX_V
const double PI=3.14159265358979323846;

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain; 

ll gcd(ll a, ll b){
    ll tmp;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }

    ll r = a%b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];

    vector<int> l(n);   /* 0からiまで */
    vector<int> r(n);   /* iからn-1まで */
    l[0] = a[0];
    r[n-1] = a[n-1];

    REPN(i, 1, n) {
        l[i] = gcd(l[i-1], a[i]);
        //cout << i << " " << l[i] << endl;
    }

    REP_REV(i, n-1) {
        r[i] = gcd(r[i+1], a[i]);
        //cout << i << " " << r[i] << endl;
    }
    
    int ans = 0;

    REP(i, n) {
        int tmp;
        if(i == 0) tmp = r[1];
        else if(i == n - 1) tmp = l[n-2];
        else tmp = gcd(l[i-1], r[i+1]);
        ans = max(tmp, ans);
    }

    cout << ans << endl;

    return 0;
}
 

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

struct mint{
    using i64 = int_fast64_t;
    i64 x;
    const i64 MOD = 1000000007;

    mint(const i64 y = (i64)0) noexcept : x(y) { if(x >= MOD) x %= MOD; }
    mint operator+() const noexcept {return x;}
    mint operator-() const noexcept {return -x;}

    mint operator+(const mint y) const noexcept {return (mint)*this += y; }
    mint operator-(const mint y) const noexcept {return (mint)*this -= y; }
    mint operator*(const mint y) const noexcept {return (mint)*this *= y;}
    mint operator/(const mint y) const noexcept {return (mint)*this /= y;}

    mint& operator+=(const mint y) noexcept {
        x += y.x; 
        if(x >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint y) noexcept {
        x -= y.x;
        if(x < 0) x += MOD;
        return *this;
    }
    mint& operator*=(const mint y) noexcept {
        x *= y.x;
        if(x >= MOD) x %= MOD;
        return *this;
    }
    mint& operator/=(mint y) noexcept {
        i64 exp = MOD - 2;
        while(exp){
            if(exp & 1) *this *= y;
            y *= y;
            exp /= 2;
        }
        return *this;
    }
    friend std::ostream& operator<< (std::ostream& os, const mint& m);
    friend std::istream& operator>> (std::istream& in, mint& m);
};
std::ostream& operator<<(std::ostream& os, const mint& m){
    os << m.x;
    return os;
}
std::istream& operator>> (std::istream& in, mint& m){
    in >> m.x; 
    if(m.x < 0) m.x += 1000000007;
    if(m.x >= 1000000007) m.x %= 1000000007;
    return in; 
}

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

    mint ans = 1;
    for(int i = 1; i <= N; i++) ans *= (mint)i;
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]"<<endl;
  return os;
}

const long long MOD = 1000000007;

void solve(long long N, long long M, std::vector<long long> S, std::vector<long long> T){
  vector<vector<ll>> dp(N,vector<ll>(M)),d2sum(N+1,vector<ll>(M+1));
  For(i,N)For(j,M){
    if(T[j]==S[i]){
      dp[i][j]=1+d2sum[i][j];
    }else{
      dp[i][j]=0;
    }
    d2sum[i+1][j+1]=dp[i][j]+d2sum[i][j+1]-d2sum[i][j]+d2sum[i+1][j];
    d2sum[i+1][j+1]=(d2sum[i+1][j+1]+MOD)%MOD;
  }
  cout<<(d2sum[N][M]+1+MOD)%MOD<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> S(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&S[i]);
    }
    std::vector<long long> T(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&T[i]);
    }
    solve(N, M, std::move(S), std::move(T));
    return 0;
}


Measured memory_bytes: 62976
public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt(), ans = 0, colors[] = new int[9];
        for (int i = 0, temp; i < n; i++)
            if (++colors[temp = Color.getColor(scanner.nextInt()).ordinal()] == 1 && temp != 8)
                ans++;
        System.out.println(Math.max(1, ans) + " " + (ans + colors[8]));
    }

    enum Color {
        GRAY(1, 399),
        BROWN(400, 799),
        GREEN(800, 1199),
        LIGHT_BLUE(1200, 1599),
        BLUE(1600, 1999),
        YELLOW(2000, 2399),
        ORANGE(2400, 2799),
        RED(2800, 3199),
        FREE(3200, 4800);

        int min, max;
        Color(int min, int max) {
            this.min = min;
            this.max = max;
        }

        static Color getColor(int rate) {
            for (Color color : values())
                if (color.min <= rate && rate <= color.max)
                    return color;
            return null;
        }
    }
}

Measured memory_bytes: 22228
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<cstdio>
#include<algorithm>


using namespace std;

int main(void)
{
	int n;
	cin >> n;
	vector<double> a(n);

	double i,max,min;
	max = -1000000000000;
	for (i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	min = a[0];
	for (i = 1; i < n; i++)
	{
		if (max < a[i] - min)
		{
			max = a[i] - min;
		}
		if (min > a[i])
		{
			min = a[i];
		}
		
	}
	printf("%.lf\n",max);
	
	return 0;
}


Measured memory_bytes: 4428
//waz
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))
 
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;
 
#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))
 
int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}
 
const int N = 1e5 + 10;
 
map<int, int> h[N];
 
set<int> edge[N];
 
queue<PII> q;
 
void link(int u, int v)
{
	edge[u].insert(v);
	edge[v].insert(u);
	if (u > v) swap(u, v);
	++h[u][v];
	if (h[u][v] == 2)
	{
		q.push(mp(u,v));
	}
	if (h[u][v] > 2)
	{
		puts("NO");
		exit(0);
	}
}
 
void cut(int u, int v)
{
	edge[u].erase(v);
	if (u > v) swap(u, v); 
	h[u].erase(v);
}
 
int fa[N], n;
 
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
 
int main()
{
	gi(n);
	for (int i = 1; i <= n; ++i) fa[i] = i;
	for (int i = 1; i < n; ++i)
	{
		int u, v;
		gii(u, v);
		link(u, v);
	}
	for (int i = 1; i < n; ++i)
	{
		int u, v;
		gii(u, v);
		link(u, v);
	}
	for (int i = 1; i < n; ++i)
	{
		int u, v;
		do
		{
			if (q.empty())
			{
				puts("NO");
				return 0;
			}
			u = q.front().fi;
			v = q.front().se;
			u = find(u);
			v = find(v);
			q.pop();
		} while (u == v);
		if (SZ(edge[u]) > SZ(edge[v])) swap(u, v);
		fa[u] = v;
		cut(v, u);
		for (auto x : edge[u])
		{
			x = find(x);
			if (x == v) continue;
			link(x, v);
			cut(x, u);
		}
		edge[u].clear();
	}
	puts("YES");
	return 0;
} 

Measured memory_bytes: 38144
<?php
  list($n,$a,$b,$c) = explode(" ", trim(fgets(STDIN)));
  $l=[];
  for ($i=0; $i<$n; $i++) {
    list($l[]) = explode(" ", trim(fgets(STDIN)));
  }

  echo dfs($n,0,0,0,0,0);

  function dfs($n,$i,$a1,$a2,$a3,$mp){
    global $a, $b, $c, $l;
    if($n == $i){
      if($a1==0||$a2==0||$a3==0){
        return PHP_INT_MAX;
      }
      $mp+=abs($a-$a1);
      $mp+=abs($b-$a2);
      $mp+=abs($c-$a3);
      //echo $a1." ".$a2." ".$a3." ".$mp.PHP_EOL;
      return $mp;
    }
    if($a1==0){
      $r1 = dfs($n,$i+1,$a1+$l[$i],$a2,$a3,$mp);
    }else{
      $r1 = dfs($n,$i+1,$a1+$l[$i],$a2,$a3,$mp+10);
    }
    if($a2==0){
      $r2 = dfs($n,$i+1,$a1,$a2+$l[$i],$a3,$mp);
    }else{
      $r2 = dfs($n,$i+1,$a1,$a2+$l[$i],$a3,$mp+10);
    }
    if($a3==0){
      $r3 = dfs($n,$i+1,$a1,$a2,$a3+$l[$i],$mp);
    }else{
      $r3 = dfs($n,$i+1,$a1,$a2,$a3+$l[$i],$mp+10);
    }
    $r4 = dfs($n,$i+1,$a1,$a2,$a3,$mp);
    
    return min($r1,$r2,$r3,$r4);
  }
    

Measured memory_bytes: 16112
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const LL INF = 1e18;
const LL MOD = 998244353;

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 modpow(LL a, LL b, LL mod)
{
  // a^b を mod で割った余りを計算する。
    LL res = 1;
    while (b > 0)
    {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  VLL D(n);
  INPUT(D);
  if (D[0] != 0)
  {
    cout << 0 << endl;
    return 0;
  }
  VLL ap(n+1, 0);
  REP(i, n) ap[D[i]]++;
  if (ap[0] > 1)
  {
    cout << 0 << endl;
    return 0;
  }
  VLL ct(n+1, 0);
  LL ans = 1;
  UNIQUE(D);
  //ENDL
  //REP(i, D.size()) cout << ap[i] << " ";
  //ENDL
  REP2(i, 1, D.size())
  {
    if (D[i] != D[i-1]+1)
    {
      cout << 0 << endl;
      return 0;
    }
  }
  REP2(i, 2, D.size())
  {
      //cout << ap[i-1] << " ^ " << ap[i] << endl;
      ans *= modpow(ap[i-1], ap[i], MOD);
      ans %= MOD;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560