akhauriyash/Code-Regression huggingface dataset:
ri = lambda: map(int, raw_input().split())

x = input()
k, r = input(), ri()

j, v, lb, rb, pt = 0, 0, 0, x, 0
L, R = 0, x
for i in xrange(input()):
    t, a = ri()
    while j < k and r[j] <= t:
        d = r[j] - pt
        pt = r[j]
        if j % 2 == 0:
            v -= d
            lb = max(lb - d, 0)
            rb = max(rb - d, 0)
        else:
            v += d
            lb = min(lb + d, x)
            rb = min(rb + d, x)
        L = max(L, -v)
        R = min(R, x - v)
        j += 1
    ans = 0
    if L <= a <= R:
        ans = a + v
    else:
        ans = lb if a < L else rb
    if j % 2 == 0:
        ans = max(ans - (t - pt), 0)
    else:
        ans = min(ans + (t - pt), x)
    print ans

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

int main() {
  int n, k;
  cin >> n >> k;
  int pos = 0;
  
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    if (x == 1) {
      pos = i;
    }
  }
  
  int ans = INT_MAX;

  for (int i = 0; i < k; i++) {
    int spos = pos - i;
    if (spos >= 1 && spos <= n) {
      int left = 0, right = 0;
      if (n - (spos + k-1) >= 1 && n - (spos + k-1) <= n)
        right = (n - (spos + k-1) + k-2) / (k-1);
      if (spos - 1 >= 1 && spos - 1 <= n)
        left = (spos - 1 + k-2) / (k-1);
      ans = min(right + left + 1, ans);
    }
  }
  cout << ans << '\n';
  
  return 0;
}

Measured memory_bytes: 256
N = int(input())
a = [0] + list(map(int, input().split()))
b = [0]*(N+1)

for i in range(N, 0, -1):
  sum = 0
  for j in range(i+i, N+1, i):
    sum ^= b[j]
  b[i] = sum ^ a[i]

ans = []
for i in range(1, N+1):
  if b[i] == 1:
    ans.append(i)

print(len(ans))
for i in range(0, len(ans)):
  if i == len(ans) - 1:
    print(ans[i])
  else:
    print(ans[i], end=" ")


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

using namespace std;

#define LL long long

LL a, b, n;

int main (void)
{
	scanf("%lld%lld%lld",&a,&b,&n);
	if (n<=b-1) printf("%lld\n",(LL)floor(1.0*a*n/b));
	else printf("%lld\n",(LL)floor(1.0*a*(b-1)/b));
	
	return 0;
}

Measured memory_bytes: 3872
import sys

*T, = map(int ,sys.stdin.read().split())

def main():
    res = 0
    e = 10
    for t in T:
        res += 10 * ((t + 10 - 1) // 10)
        e = min(e, (t - 1) % 10 + 1)

    res -= (10 - e)
    return res

if __name__ == '__main__':
    ans = main()
    print(ans)

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

int main() {
  int m,d;
  cin >> m >> d;

  int answer = 0;
  for (int i = 1; i <= m; i++) {
    for (int day = 10; day <= d; day++) {
      int d1 = day % 10;
      int d2 = day / 10;
      if(d1 * d2 == i && 2 <= d1 && 2 <= d2) answer++;
    }
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)

using namespace std;

int main(){
	long long H, N;
	cin >> H >> N;
	long long sum = 0;
	rep(i, N) {
		long long tmp;
		cin >> tmp;
		sum += tmp;
	}
	if(sum >= H) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}


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

vector<string> x;

int main() {
	string s;
	cin >> s;
	int k;
	cin >> k;
	int min_s;
	for (int i = 1; i <= k; i++) {
		for (int j = 0; j <= s.size() - i + 1; j++) {
			string v;
			v = s.substr(j, i);
			bool flag = 0;
			for (int i = 0; i < x.size(); i++) {
				if (x[i] == v) { flag = 1; break; }
			}
			if (!flag) {
				x.push_back(v);
			}
		}
	}
	sort(x.begin(), x.end());
	cout << x[k] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define FOR(i,a,n) for(register int i=a; i<=n; ++i)
#define FDR(i,a,n) for(register int i=a; i>=n; --i)
#define mem(a) memset(a, 0, sizeof(a))
#define pb push_back()
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int maxn = 100005;
const int MOD = 1000000009;
int a[100];
struct A
{
    ll p, c;
};
A node[1005];
int main()
{
    ios::sync_with_stdio(false);
    ll d, g;
    cin >> d >> g;
    for(int i = 1; i <= d; i++)
    {
        cin >> node[i].p >> node[i].c;
    }
    FOR(i,1,d)a[i] = i;
    ll ans = INF;
    do
    {
        ll sum = 0;
        ll tot = 0;
        for(int i = 1; i <= d; i++)
        {
            if(g-sum > a[i]*100*node[a[i]].p){
                sum += a[i]*100*node[a[i]].p;
                tot += node[a[i]].p;
                sum += node[a[i]].c;
                if(sum >= g)break;
            }
            else {
                if((g-sum)%(a[i]*100) != 0)tot++;
                tot += (g-sum)/(a[i]*100);
                break;
            }
        }
//        cout << tot << endl;
        ans = min(ans, tot);
    }while(next_permutation(a+1, a+1+d));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

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

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

const int MAX = 10000;

int main() {
	int N;
	cin >> N;
	int a[MAX], b[MAX];
	ll numPlusBi=0, numMinusAi=0;

	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i < N; ++i) {
		cin >> b[i];
	}

	for (int i = 0; i < N; ++i) {
		if (a[i] - b[i] > 0) {
			numPlusBi += (a[i] - b[i]);
		}
		else if (b[i] - a[i] >0) {
			numMinusAi += (b[i] - a[i])/2;
		}
	}

	if (numMinusAi >= numPlusBi) cout << "Yes";
	else cout << "No";

	system("pause");
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define inf 1000000000
#define maxs(x,y) (x = max(x , y))
#define mins(x,y) (x = min(x , y))
using namespace std;
typedef long long int ll;

int main(){
  int N,i,ans,tmp=0,a,b;
  cin >> N;

  for(i=1 ; i<=N ; i++){
    a = i;
    b = 0;
    for(; a%2 == 0 ;){
      a /= 2;
      b++;
    }
    tmp = max(tmp,b);
    if(tmp == b){
      ans = i;
    }
  }

  cout << ans << endl;
  
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

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

template<class T> inline bool in_range(T y, T x, T H, T W) { return 0<=y&&y<H&&0<=x&&x<W; }

int main() {

  int H, W; cin >> H >> W;
  int sum = 0;
  rep(i, H) {
    string A; cin >> A;
    sum += count(A.begin(), A.end(), '#');
  }

  cout << (sum == H + W - 1 ? "P":"Imp") << "ossible\n";
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ALL(a)  (a).begin(),(a).end()
 
const ll mod = 1000000007;
const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;
 
template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}
 
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


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

    bool ans = true;

    if (n%2==0){
        for (ll i = 0; i < n/2; i++){
            if (s[i] != s[n/2+i])ans=false;   
        }

    }else{
        ans= false;
    }

    cout << (ans? "Yes":"No");


}


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

uint64_t div_count(uint64_t val, uint64_t div) {
  if(div == 0) return 0;
  uint64_t ret = 0;
  while((val % div) == 0) {
    val /= div;
    ret++;
  }
  return ret;
}

template<typename T>
T lowest_common_multiple(const vector<T>& v) {
  using const_iterator = typename vector<T>::const_iterator;
  T ret = 0;
  for(const_iterator it = v.begin(); it != v.end(); ++it) {
    if((*it) == 0) return 0;
    if(ret == 0) ret = (*it);
    else ret = (ret * (*it)) / __gcd(ret, (*it));
  }
  return ret;
}

int main() {
  uint64_t n, m;
  cin >> n >> m;
  set<uint64_t> a;
  for(uint64_t i = 0; i < n; ++i) {
    uint64_t v;
    cin >> v;
    a.insert(v);
  }

  uint64_t div_2_count = 0;
  vector<uint64_t> a_v;
  a_v.reserve(a.size());
  for(set<uint64_t>::iterator it = a.begin(); it != a.end(); ++it) {
    // 2 で割れる回数をチェック
    if(it == a.begin()) {
      div_2_count = div_count((*it), 2);
    } else if(div_2_count != div_count((*it), 2)) {
      // 2 で割れる回数が異なる数字がある場合、半公倍数はない
      cout << 0 << endl;
      return 0;
    }
    a_v.push_back((*it)/2);
  }

  uint64_t lcm = lowest_common_multiple(a_v);
  if(lcm > 0) {
    uint64_t c = (m / lcm);
    cout << ((c % 2) == 0 ? c / 2 : c / 2 + 1) << endl;
  } else cout << 0 << endl;

  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
int main(void){
    // Your code here!
    
  int a,b,c,d,p;
  scanf("%d",&a); scanf("%d",&b); scanf("%d",&c); scanf("%d",&d); scanf("%d",&p);
  int x,y;
  x=a*p; 
  if(p<=c) y=b;
  else y=b+d*(p-c);
  if(x<y) printf("%d\n",x);
  else printf("%d\n",y);
    return 0;
  }



Measured memory_bytes: 2112
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll k;
    cin >> k;
    map <ll,ll> mapp;
    for (ll x=-3000;x<=3000;x++){
        mapp[x*x*x*x*x] = x;
    }
    bool ok = true;
    for (ll x=-3000;x<=3000 && ok;x++){
        if (mapp.find(x*x*x*x*x+k) != mapp.end()){
            cout << mapp[x*x*x*x*x+k] << " " << x << endl;
            return 0;
        }
    }
} 

Measured memory_bytes: 4016
n,m = map(int,input().split())
a = set([int(input()) for _ in range(m)])
dp = [0]*(n+1)
dp[0] = 1
for i in range(1,n+1):
  dp[i] = (dp[i-1]+dp[i-2])%(10**9+7)
  if i in a: dp[i]=0
print(dp[n])


Measured memory_bytes: 13216
n=int(input())
a=[]
for _ in range(n):
    a.append(int(input()))

b=a.copy()

import heapq
#これを加える！！！！
def _heappush_max(heap, item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappop_max(heap):
    """Maxheap version of a heappop."""
    lastelt = heap.pop()    # raises appropriate IndexError if heap is empty
    if heap:
        returnitem = heap[0]
        heap[0] = lastelt
        heapq._siftup_max(heap, 0)
        return returnitem
    return lastelt

b = sorted(b,reverse=True)

b1 = _heappop_max(b)
b2 = _heappop_max(b)

for i in range(n):
    if a[i]==b1:
        print(b2)
    else:
        print(b1)


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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;
    s1[0] -= 32;
    s2[0] -= 32;
    s3[0] -= 32;
    cout << s1[0] << s2[0] << s3[0] << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int x = cin.nextInt();
        int y = cin.nextInt();
        int z = cin.nextInt();

        System.out.println((x + y >= z) ? "Yes" : "No");
    }
}

Measured memory_bytes: 23764
import java.io.*;
import java.util.*;

class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        int n=Integer.parseInt(bu.readLine());
        int a[]=new int[n],b[]=new int[n],i;
        String s[]=bu.readLine().split(" ");
        for(i=0;i<n;i++)
        a[i]=Integer.parseInt(s[i]);
        s=bu.readLine().split(" ");
        for(i=0;i<n;i++)
        b[i]=Integer.parseInt(s[i]);

        Queue<Integer> q=new LinkedList<>();
        for(i=0;i<n;i++)
        {
            if(a[i]==b[i])
            {
                if(q.isEmpty()) q.add(i);
                else
                {
                    if(a[q.peek()]!=b[i])
                    {
                        int t=q.poll();
                        b[t]=b[i];
                        b[i]=a[t];
                    }
                    else q.add(i);
                }
            }
        }

        int sz=0;
        while(!q.isEmpty() && q.size()!=sz)
        {
            sz=q.size();
            for(i=0;i<n;i++)
            if(a[i]!=b[i] && !q.isEmpty() && a[i]!=a[q.peek()] && b[i]!=a[q.peek()])
            {
                int t=q.poll();
                b[t]=b[i];
                b[i]=a[t];
            }
        }
        if(!q.isEmpty()) sb.append("No");
        else
        {
            sb.append("Yes\n");
            for(i=0;i<n;i++)
            sb.append(b[i]+" ");
        }
        System.out.print(sb);
    }
}


Measured memory_bytes: 79368
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>

int main()
{
    int n;
    while(scanf("%d",&n)==1){
        if(n==0){
            break;
        }
        else{
            double a[100000];
            for(int i=0;i<n;i++){
            scanf("%lf",&a[i]);
            }
            double sum = 0;
            for(int i=0;i<n;i++){
                sum += a[i];
            }
            double h = sum/n;
            int count = 0;
            for(int i=0;i<n;i++){
                if(a[i]<=h){
              count++;
                }
            }
            printf("%d\n",count);

        }
    }
    return 0;
}


Measured memory_bytes: 2776
import sys
input = sys.stdin.readline

H, W = map(int, input().split())
c = [input().rstrip() for _ in range(H)]
ans = 0
for w in range(W-1):
    cum1 = [[0] * (H + 1) for _ in range(H + 1)]
    for d in range(H):
        for i in range(H - d):
            cum1[d][i+1] = cum1[d][i] + (c[i][w] == c[d+i][w+1])
    cum2 = [[0] * (H + 1) for _ in range(H + 1)]
    for d in range(H):
        for i in range(H - d):
            cum2[d][i+1] = cum2[d][i] + (c[d+i][w] == c[i][w+1])
    dp = [[0] * (H + 1) for _ in range(H + 1)]
    for i in range(1, H+1):
        for j in range(1, H+1):
            dp[i][j] = min(dp[i-1][j], dp[i][j-1])
            if i >= j:
                dp[i][j] += cum1[i-j][j]
            else:
                dp[i][j] += cum2[j-i][i]
    ans += dp[H][H]
print(ans)


Measured memory_bytes: 227664
#include <stdio.h>

int main(void) {

	int H, W;
	int i, j;

	while (1) {

		scanf("%d %d", &H, &W);

		if (H == 0 && W == 0)
			break;

		for (i = 0; i < H; i++) {
			for (j = 0; j < W; j++) {

				printf("#");
			}
			printf("\n");
		}

		printf("\n");
	}
	
	return(0);

}


Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class T>
inline bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T>
inline bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

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

    while(true){
        int N,A,B,C,X; cin >> N >> A >> B >> C >> X;
        if(N==0) break;
        int Y[N]; rep(i,N) cin >> Y[i];
        vi v;
        v.eb(X);
        int now=X;
        rep(i,10000){
            now=(A*now+B)%C;
            v.eb(now);
        }
        int pos=0;
        int ans=-1;
        rep(i,10001){
            if(Y[pos]==v[i]) pos++;
            if(pos==N) {
                ans=i;
                break;
            }
        }
        cout << ans << "\n";
    }
}


Measured memory_bytes: 3152
import copy

def bubble_sort(A, N):
	cnt = 0
	flag = 1
	while flag:
		flag = 0
		for i in range(N-1, 0, -1):
			if A[i][1:] < A[i-1][1:]:
				temp = A[i]
				A[i] = A[i-1]
				A[i-1] = temp
				flag = 1

	return A

def selection_sort(A, N):
	cnt = 0
	for i in range(N):
		minj = i
		for j in range(i, N):
			if A[j][1:] < A[minj][1:]:
				minj = j
		A[i], A[minj] = A[minj], A[i]

	return A

N = int(input())
A = list(input().split())

B = bubble_sort(copy.copy(A), N)
print(' '.join(B))
print('Stable')
C = selection_sort(copy.copy(A), N)
print(' '.join(C))
if B==C:
	print('Stable')
else:
	print('Not stable')


Measured memory_bytes: 6344
#include <bits/stdc++.h>
#define rep(i, n)     for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n)    for (int i = 1; i <= (int)(n); ++i)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define rrep(i, n)    for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n)   for (int i = (int)(n); i >= 1; --i)
#define allrep(V, v)  for (auto &&V : v)
#define all(x)        (x).begin(), (x).end()
using lint = long long;
constexpr int    INF  = 1 << 30;
constexpr lint   INFL = 1LL << 62;
constexpr int    MOD  = 1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;

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

  int n, k;
  cin >> n >> k;
  int maxi = (n - 1) * (n - 2) / 2;
  if (k > maxi) {
    cout << -1 << endl;
    return 0;
  }
  int m = n - 1;
  vector<pair<int, int>> graph(m);
  rep (i, m) graph[i] = {1, i + 2};
  int def = maxi - k;
  m += def;
  irep (i, 2, n + 1) {
    irep (j, i + 1, n + 1) {
      if (def == 0) break;
      graph.push_back({i, j});
      --def;
    }
  }
  cout << m << endl;
  allrep (g, graph) {
    cout << g.first << " " << g.second << "\n";
  }
  return 0;
}

Measured memory_bytes: 384
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

vector<int> L;
int N,K;
int main(){
    cin>>N>>K;
    REP(i,N){
        int a;
        cin>>a;
        L.push_back(a);
    }
    sort(L.begin(),L.end(),std::greater<int>());
    LL sum=0;
    REP(i,K){
        sum+=L[i];
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
//#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
inline void out(int x){
	if(x>=10)out(x/10);
	putchar(x%10+'0');
}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int x;
	cin>>x;
	cout<<1-x<<endl; 
	return 0;
}


Measured memory_bytes: 3564
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		long ans = 0;
		
		for(int i = 1 ; i <= n ;i++) {
			long temp = (long) n/i;
			ans += (long)temp*(temp+1)*i/2;
		}
		System.out.println(ans);
	}
	
		
}


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

int main() {
  string S, T; cin >> S >> T;
  int L = S.size();
  int M = T.size();
  // dp[i][j] := 文字列 S_i まで、文字列 T_j までにおける共通する文字数
  vector<vector<int>> dp(L+1, vector<int>(M+1, 0));
  for (int i = 0; i < L; i++) {
    for (int j = 0; j < M; j++) {
      if (S.at(i) == T.at(j)) dp.at(i+1).at(j+1) = dp.at(i).at(j) + 1;
      else dp.at(i+1).at(j+1) = max(dp.at(i+1).at(j), dp.at(i).at(j+1));
    }
  }
  // 復元
  string ans = "";
  int i = L; int j = M;
  while (i > 0 && j > 0) {
    if (dp.at(i).at(j) == dp.at(i-1).at(j)) {
      // [i][j] -> [i+1][j]
      i--;
    }
    else if (dp.at(i).at(j) == dp.at(i).at(j-1)) {
      // [i][j] -> [i][j+1]
      j--;
    }
    else {
      // [i][j] -> [i+1][j+1]
      ans = S.at(i-1) + ans;
      i--; j--;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
ll mod=1e9+7;
#define PI acos(-1)
struct edge{int from, to;};

int main(){
    int n,m;
    cin>>n>>m;
    if(n==m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
a = int(input())
ans = 0
for i in range(1,a+1):
    s = str(i)
    if s[-1]== '0':continue
    elif len(s) == 1:
        ans+=1
    elif s[0] == s[1] and len(s)==2:
        ans+=3
    elif int(s[0])>int(s[1]) and len(s)==2 and '0' not in s:
        ans+=2
    elif len(s)==2:continue
    elif s[0] == s[2] and len(s)==3:
        ans += 3+2*(int(s[1])+1)
    elif len(s) == 3 and int(s[0])>int(s[2]):
        ans +=22
    elif len(s) == 3 and s[2] != '0':
        ans +=2 

    elif len(s) == 4 and s[0] == s[-1]:
        ans += 3+2*(10+int(s[1]+s[2])+1)
    elif len(s) == 4 and int(s[0])>int(s[-1]):
        ans += 222
    elif len(s)==4:
        ans +=22

    elif len(s) == 5 and s[0] == s[-1]:
        ans += 3+2*(110+int(s[1]+s[2]+s[3])+1)
    elif len(s) == 5 and int(s[0])>int(s[-1]):
        ans += 2222
    elif len(s)==5:
        ans +=222

    elif len(s) == 6 and s[0] == s[-1]:
        ans += 3+2*(1110+int(s[1]+s[2]+s[3]+s[4])+1)
    elif len(s) == 6 and int(s[0])>int(s[-1]):
        ans += 22222
    elif len(s)==6:
        ans +=2222
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  int n;cin>>n;
  int w[n];

  REP(i,n){
    cin>>w[i];
  }

  int ans = INF;
  int sum[n];
  sum[0] = w[0];
  for(int i=1;i<n;i++){
    sum[i] = sum[i-1] + w[i];
  }

  REP(i,n-1){
    int s = abs((sum[n-1] - sum[i]) - sum[i]);
    ans = min(ans,s);
  }

  cout<<ans<<endl;

 

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string n;
	cin>>n;
	for(int i=0;i<n.size();i++){
		if(i%2==0){
			if(n[i]!='h'){
				break;
			}else if(n[i+1]!='i'){
				break;
			}
		}else if(i%2==1){
			if(n[i]!='i'){
				break;
			}
		}
		if(i==n.size()-1){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
N,M = gets.split.map(&:to_i)
A = readlines.map(&:to_i)
MOD = 1000000007 

dp = []
dp[N] = dp[N-1] = 1
A.each {|i| dp[i] = 0 }

(N-2).downto(0) do |i|
  dp[i] = (dp[i+1] + dp[i+2]) % MOD unless dp[i]
end
puts dp[0]


Measured memory_bytes: 9084
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * @author khokharnikunj8
 */

public class Main {
    public static void main(String[] args) {
        new Thread(null, new Runnable() {
            public void run() {
                new Main().solve();
            }
        }, "1", 1 << 26).start();
    }

    void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CTravelingSalesmanAroundLake solver = new CTravelingSalesmanAroundLake();
        solver.solve(1, in, out);
        out.close();
    }

    static class CTravelingSalesmanAroundLake {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int k = in.scanInt();
            int n = in.scanInt();
            int[] ar = new int[n];
            for (int i = 0; i < n; i++) ar[i] = in.scanInt();
            int ans = Integer.MAX_VALUE;
            for (int i = 0; i < n - 1; i++) {
                ans = Math.min(ans, ar[i] + (k - ar[i + 1]));
            }
            ans = Math.min(ans, ar[n - 1] - ar[0]);
            out.println(ans);
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        public int scanInt() {
            int integer = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = scan();
                }
            }
            return neg * integer;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}



Measured memory_bytes: 28372
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;

namespace agc28_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = ReadLine().Split().Select(int.Parse).ToArray();
            string s = Console.ReadLine();
            string t = Console.ReadLine();

            int n = input[0];
            int m = input[1];

            long lcm = Lcm(n,m);

            long ln = lcm/n;
            long lm = lcm/m;
            Dictionary<long, char> dic = new Dictionary<long, char> ();

            for (int i = 0; i < n; i++){
                dic[ln*i+1] = s[i];
            }

            bool judge = true;
            for (int i = 0; i < m; i++){
                if(dic.ContainsKey(lm*i+1)){
                    if(dic[lm*i+1] != t[i]){
                        judge = false;
                    }
                }
            }

            if(judge){
                WriteLine(lcm);
            }else{
                WriteLine("-1");
            }
        }

        static long Gcd(long a, long b) {
            if (a < b)
                // 引数を入替えて自分を呼び出す
                return Gcd(b, a);
            while (b != 0) {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }

        public static long Lcm(long a, long b) {
            return a * b / Gcd(a, b);
        }
    }
}


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

int main() {
    long long int n, p = 1, i;

    scanf("%lld", &n);

    for (i = 1; i <= n; i++) {
        p *= i;
        p %= 1000000007;
    }

    printf("%lld", p);
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N;
  cin>>N;
  vector<int> A(N);
  for(int &i:A)cin>>i;
  uint32_t x=0;
  int sum=0,ans=0;
  for(int l=0,r=0;l<N;){
    for(;r<N;r++){
      if((x^A[r])!=(sum+A[r]))break;
      x^=A[r];
      sum+=A[r];
    }
    ans+=r-l;
    x^=A[l];
    sum-=A[l];
    l++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4768
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

int N, K;
int D[10];
vector<int> d;
vector<int> num;

void rec(int n) {
    if (n > 100000) return;
    num.push_back(n);
    for (int e : d) rec(n*10 + e);
}

void solve() {
    cin >> N >> K;
    for (int i = 0; i < K; i++) cin >> D[i];

    for (int i = 0; i < 10; i++) {
        bool flag = true;
        for (int j = 0; j < K; j++) {
            if (D[j] == i) flag = false;
        }
        if (flag) d.push_back(i);
    }

    for (int e : d) {
       if (e) rec(e);
    }

    sort(num.begin(), num.end());

    int ans = *lower_bound(num.begin(), num.end(), N);
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    solve();

    return 0;
}

Measured memory_bytes: 3720
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long
#define MOD 1000000007

const ll inf = 1e18L + 5;

void max_self(int& a, int b ){
    a = max(a, b);
}

int main() {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    int R, C;
    cin>>R>>C;

    vector<vector<char> > grid(R+1, vector<char> (C+1, '.'));
    vector<vector<int> > mat(R+1, vector<int>(C+1, 0) );

    for( int i = 1; i <= R; i++ ) {
        for( int j = 1; j <= C; j++ ) {
            cin>>grid[i][j];
        }
    }

    mat[1][1] = 1;
    for( int i = 1; i <= R; i++ ) {
        for( int j = 1; j <= C; j++ ) {
            if( grid[i][j] == '#' )
                continue;
            max_self(mat[i][j], mat[i-1][j] + mat[i][j-1]);
            mat[i][j] = mat[i][j] % MOD;
        }
    }

    cout<<mat[R][C];
    return 0;
}

Measured memory_bytes: 5248
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include <vector>
#include <cassert>
#include<cmath>
using namespace std;
int main() {
	int N;
	int p[20];
	int maxprice = -1;
	int sum = 0;
	cin >> N;
	int i;
	for (i = 0; i < N; ++i) {
		cin >> p[i];
	}

	for (i = 0; i < N; ++i) {
		if (p[i] >maxprice) {
			maxprice = p[i];

		}
		sum += p[i];
		//cout << "sum" << sum << endl;
	}
	//cout << "max" << maxprice << endl;
	sum = sum - maxprice + (maxprice / 2);
	cout << sum << endl;


}



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

using namespace std;

int H, W;
char mapc[50][50];
int mapi[50][50];
int dx[8] = {0,  0, 1, -1, 1, -1,  1, -1};
int dy[8] = {1, -1, 0,  0, 1,  1, -1, -1};

int cntB(int y, int x) {
  int cnt = 0;
  for (int k = 0; k < 8; k++) {
    int nx = x + dx[k];
    int ny = y + dy[k];
    if (0 <= nx && nx < W && 0 <= ny && ny < H) {
      if (mapc[ny][nx] == '#') {
        cnt++;
      }
    }
  }
  return cnt;
}

int main() {
  memset(mapi, -1, sizeof(mapi));
  cin >> H >> W;

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> mapc[i][j];
    }
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (mapc[i][j] == '#') {
        continue;
      }
      mapi[i][j] = cntB(i, j);
    }
  }

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

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

int main()
{
  int n, s, i;
  int h, m;
  int a[200];

  cin >> n;
  for (i = 0; i < n; i++){
    cin >> h >> m;
    m += h * 60;
    a[i] = m;
  }
  cin >> s;
  n += s;

  for (; i < n; i++){
    cin >> h >> m;
    m += h * 60;
    a[i] = m;
  }

  sort(a, a + n);

  cout << a[0] / 60 << ":";
  printf("%.2d", a[0] % 60);
  for (int i = 1; i < n; i++){
    if (a[i] == a[i - 1]) continue;
    cout << " " << a[i] / 60 << ':'; 
    printf("%.2d", a[i] % 60);
  }

  cout << endl;

  return 0;
}

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

#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MAXX 100005

#define PI 3.14159265358979323846264338327950

#define ll long long int

int main()
{
    FAST;
    ll b,d=0,e;
    int a,c=1;
    cin>>a;
    int k[a+5];
    k[0]=0;
    while (c<=a)
    {
	cin>>k[c];
    if (k[c]<k[c-1])
    {
    	d=d+k[c-1]-k[c];
    	k[c]=k[c-1];
	}
	c++;
	}
	cout<<d;
}


Measured memory_bytes: 4344
#include<bits/stdc++.h>
#define re register
using namespace std;
int h[100010], t, cnt;
char a[100010];
struct node {
	int fro;
    int to;
}el[100010];
int main() {
        scanf("%s", a + 1);
        int cntl = 0;
        int sst = strlen(a + 1);
        memset(h, 0, sizeof(h));
        t = -1;
        for (re int i = 1; i <= sst; i++) {
         if (a[i] == 'L') {
             if (t == -1) {
                 el[++cnt].fro = i;
                 el[cnt].to = i;
                 t = 0;
			 }
			else el[cnt].to = i;
		}
		else t = -1;
		}
        el[0].to = 0;
     for (re int i = 1; i <= cnt; i++) {
         int dis = (el[i].fro - el[i - 1].to - 1);
         int disl = (el[i].to - el[i].fro + 1);
         if (dis % 2 == 1) {
             h[el[i].fro] += (dis / 2);
             h[el[i].fro - 1] += (dis / 2) + 1;
			}
		else {
             h[el[i].fro] += (dis / 2);
             h[el[i].fro - 1] += (dis / 2);
		}
         if (disl % 2 == 1) {
             h[el[i].fro - 1] += (disl / 2);
             h[el[i].fro] += (disl / 2) + 1;
			}
			else {
             h[el[i].fro - 1] += (disl / 2);
             h[el[i].fro] += (disl / 2);
			}

		}
     for (re int i = 1; i <= sst; i++) {
         printf("%d ", h[i]);
		}

 return 0;
	}

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

fn main() {
    let a: i64 = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let s: Vec<char> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    };

    let ans = if a >= 3200 { s.iter().map(|&c| c).collect::<String>() } else { "red".to_string() };

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


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <array>

using namespace std;

int main() {
	array<int, 3> nums;
	cin >> nums[0] >> nums[1] >> nums[2];
	int count=0;
	while(!all_of(nums.begin(), nums.end(), [&nums](int n){return n==nums[0];})){
		++count;
		auto max_it = max_element(nums.begin(), nums.end());
		bool two_max=false;
		for(auto it=nums.begin(); it!=nums.end();++it){
			if(max_it!=it && (*max_it)==(*it)){
				two_max=true;
				break;
			}
		}
		if(two_max){
			auto min_it = min_element(nums.begin(), nums.end());
			(*min_it)+=2;
		}else{
			for(auto it=nums.begin(); it!=nums.end();++it){
				if(it!=max_it){
					++(*it);
				}
			}
		}
	}
	cout << count;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 1e5+5;
ll n, k, h[A], dp[A];
ll table1()
{
	dp[0] = 0, dp[1] = abs(h[1] - h[0]);
	for (int i = 2; i < n; i++)
		dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
	return dp[n-1];
}
ll table2()
{
	dp[0] = 0;
	for (int i = 1; i < n; i++)
	{
		dp[i] = 1e9;
		for (int j = max(0, i - (int)k); j < i; j++)
			dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
	}
	return dp[n-1];
}
int main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin >> n;
	//cin >> k;
	for (int i = 0; i < n; cin >> h[i++]);
	cout << table1();
	//cout << table2();
	return 0;
}


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

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

int main() {
  int N;
  cin >> N;
  ll power=1;
  for(int i = 1; i <= N; i++) {
    power = (power * i) % 1000000007;
  }
  cout << power << endl;
  return 0;
}



Measured memory_bytes: 3596
# A - Diverse Word
def is_various(s):
	if len(s) == len(set(s)):
		return True


import string
lower = string.ascii_lowercase

S = input()

for c in lower:
	next = S + c
	
	if  len(set(next)) == len(S) + 1:
		print(next)
		exit()

for i in range(1, len(S) + 1):
	left = S[:len(S)-i]
	right = S[-i:]
	
	start = right[0]
	is_start = False

	for c in lower:
		if is_start:
			next = left + c
			
			if is_various(next):
				print(next)
				exit()
		
		if c == start:
			is_start = True
		
print(-1)

Measured memory_bytes: 9836
#Together

N = int(input())
a = list(map(int, input().split()))

b = []

for ai in a:
    b.append(ai-1)
    b.append(ai)
    b.append(ai+1)
#print(b)

import collections
cnt = collections.Counter(b)
#print(cnt)
print(max(cnt.values()))

Measured memory_bytes: 27232
import java.util.*;
import java.math.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入
		String s = sc.next();
		List<String> strList = Arrays.asList(s.split(""));
		List<Integer> intList =new ArrayList<>();
		int countOne =0;
		int countZero =0;

		for(String str:strList){
			int num = Integer.parseInt(str);
			if(num==1){
				countOne++;
			}else if (num==0){
				countZero++;
			}
		}


        // System.out.println(countOne);
        // System.out.println(countZero);

        int halfResult = Math.min(countOne,countZero);
        System.out.println(halfResult*2);
 
	}
}


Measured memory_bytes: 33512
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

a = LIST()
ans = 0
a.sort()
m = a[-1]
d = 0
if 3 * m % 2 == sum(a) % 2:
    d = m
else:
    d = m + 1
ans = 0
while not a[0] == a[1] == a[2]:
    if a[0] < d and a[1] < d:
        ans += 1
        a[0] += 1
        a[1] += 1
    elif a[0] < m:
        ans += 1
        a[0] += 2
    else:
        ans += 1
        a[1] += 2
    if a[0] > d or a[1] > d:
        break
    debug(a)
print(ans)

Measured memory_bytes: 3956
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
  int k, n, disSum = 0, disMax = 0;
  cin >> k >> n;
  int a[n], b[n];
  for(int i=0; i<n; i++) {
    cin >> a[i];
    if (i>0) b[i]=a[i]-a[i-1];
    else b[i] = a[i];
    
  }
  b[0] += k-a[n-1];
  for(int i=0; i<n; i++) {
    // cout << b[i] << ' ' << endl;
    disSum += b[i];
    if (disMax<b[i]) disMax = b[i];
  }
  
  cout << disSum - disMax << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int m, n;
    while(cin >> m >> n, m){
        vector<int> v(n);
        for (auto &&i : v) scanf("%d", &i);
        int ng = *max_element(v.begin(),v.end())-1, ok = 1500001;
        while(ok-ng > 1){
            int mid = (ok+ng)/2;
            int val = 0, cnt = 1;
            for (int i = 0; i < n; ++i) {
                if(val+v[i] > mid){
                    cnt++; val = v[i];
                }else {
                    val += v[i];
                }
            }
            if(cnt <= m) ok = mid;
            else ng = mid;
        }
        cout << ok << "\n";
    }
    return 0;
}


Measured memory_bytes: 3148
#include<iostream>
using namespace std;
int main(){
	int H, W;

	while (1){
		cin >> H >> W;

		if (H >= 2){
			for (int i = 0; i < W; i++){
				cout << "#";
			}
			cout << endl;
		}
		

		for (int i = 0; i < H - 2; i++){
			cout << "#";

			for (int i = 0; i < W - 2; i++){
				cout << ".";
			}

			cout << "#";
			cout << endl;
		}

		for (int i = 0; i < W; i++){
			cout << "#";
		}
		
		

		if (H == 0 && W == 0){
			break;
		}
		cout << endl;
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3096
N=int(input())
money=[]
for _ in range(N):
    money.append([i for i in input().split()])
sum=0
for i in range(N):
    if money[i][1]=='BTC':
        sum+=float(380000*float(money[i][0]))
    else:
        sum+=float(money[i][0])

print(sum)

Measured memory_bytes: 3060
fun main(args: Array<String>) {
  val (A,B,K) = readLine()!!.split(" ").map(String::toLong)
  if (A-K >= 0) {
    println("${A-K} $B")
  } else if (A-K < 0 && B-(K-A) >= 0) {
    println("0 ${B-(K-A)}")
  } else {
    println("0 0")
  }
}

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

using namespace std;

typedef long long ll;
ll a[123456];
map<ll, int>mp;

// Returns value of Binomial Coefficient C(n, k)
ll binomialCoeff(int n, int k)
{
	ll res = 1;

	if ( k > n )
        return 0;

	// Since C(n, k) = C(n, n-k)
	if ( k > n - k )
		k = n - k;

	// Calculate value of [n * (n-1) *---* (n-k+1)] / [k * (k-1) *----* 1]
	for (int i = 0; i < k; ++i)
	{
		res *= ll(n - i);
		res /= ll(i + 1);
	}

	return res;
}

class DCandyDistribution {
public:
	void solve(std::istream& in, std::ostream& out) {
		int n, m;
		in >> n >> m;
		mp.clear();
		memset(a, 0, sizeof(a));
		ll sum = 0;
		for (int i = 1; i <= n; ++i) {
			in >> a[i];
			if(i != 0)a[i] += a[i-1];
			a[i] %= m;
			mp[a[i]]++;
		}


		for (auto it = mp.begin(); it != mp.end(); ++it) {
			if(it->second >= 2 && it->first != 0)sum += binomialCoeff(it->second, 2);
			else if(it->first == 0)sum += binomialCoeff(it->second, 2) + it->second;
		}

//		for (auto it = mp.begin(); it != mp.end(); ++it)
//        {
//            sum += binomialCoeff(it->second, 2); if( it->first == 0 ) sum += it->second;
//		}
		out << sum << endl;
	}
};

int main() {
	DCandyDistribution solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main(void) {
    int n;cin>>n;
    int i = 1;
    
    do {
        int x = i;
        if (x % 3 == 0) {
            cout << " " << i;
            continue;
        }

        while (x > 0) {
            if (x % 10 == 3) {
                cout << " " << i;
                break;
            }
            x /= 10;
        }
    } while (++i <= n);
    cout << endl;
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
int k,s,i;
int main ()
{
	cin >> k;
	s=7%k; i=1;
	while (s!=0)
	{
		i++;
		s=(10*s+7)%k;
		if (i>1000000)break;
	}
	if (i>1000000)cout<<-1;else
	cout<<i;
}

Measured memory_bytes: 3608