akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define REP(i, n) for(long long i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(long long 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 VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;


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

    ll n,k;cin>>n>>k;
    ll ans=0;
    for(ll i=k;i<=n+1;i++){
        ans += ((2*n - i + 1) * i /2 - i*(i-1)/2 + 1);
        // ans %= mod; 
        // cout<<ans<<endl;
    }
    cout<<ans%mod<<endl;
    return 0;
}

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

import static java.lang.Character.isUpperCase;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int K = in.nextInt();
        int X = in.nextInt();
        int x = 500;
        if(x*K>=X)
        {
            System.out.println("Yes");
        }
        else
            {
                System.out.println("No");
            }






        }







    }
















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

#define int long long 

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

int findGCD(vector<int> arr) {
    int n = arr.size();
    int result = arr[0];
    for (int i = 1; i < n; i++) {
        result = gcd(arr[i], result);

        if (result == 1) {
            return 1;
        }
    }
    return result;
}


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

    int n, k;
    cin >> n>>k;
    vector<int> v(n);
    int mx=0;
    for(int& i : v)cin >> i,mx=max(i,mx);
    if(n==1){
        if(k==mx)cout<<"POSSIBLE\n";
        else cout<<"IMPOSSIBLE\n";
        return 0;
    }
    int res=findGCD(v);
    
    if(k%res==0 and k <= mx)cout<<"POSSIBLE\n";
    else cout<<"IMPOSSIBLE\n";
}



Measured memory_bytes: 4724
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int X = sc.nextInt();
			final int Y = sc.nextInt();
			
			int answer = 0;
			if(X == 1) {
				answer += 300000;
			}else if(X == 2) {
				answer += 200000;
			}else if(X == 3) {
				answer += 100000;
			}
			if(Y == 1) {
				answer += 300000;
			}else if(Y == 2) {
				answer += 200000;
			}else if(Y == 3) {
				answer += 100000;
			}
			
			if(X == 1 && Y == 1) {
				answer += 400000;
			}
			
			System.out.println(answer);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 24660
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    vector<int> v;
    int x,n,tmp;
    bool x_in_list= false;
    cin >>x >>n;
    for(int i=0;i<n;i++){
        cin >>tmp;
        v.push_back(tmp);
        if(tmp==x)x_in_list=true;
    }
    if(!x_in_list) {
        cout <<x;
        return 0;
    }
    v.push_back(x);
    sort(v.begin(),v.end());

    int indx;
    for(int i=0;i<v.size();i++){
        if(v[i] == x){
            indx = i;
            break;
        }
    }

    int ans1=1e9,ans2=1e9;
    bool found1= false,found2= false;
    for(int j=indx-1;j+1>=1;j--){
        if(v[j+1] - v[j] > 1){
            found1 = true;
            ans1 = v[j+1]-1;
            break;
        }
    }
    if(!found1) ans1 = v[0]-1;

    for(int j=indx+1;j<v.size();j++){
        if(v[j] - v[j-1] > 1){
            found2 = true;
            ans2 = v[j-1]+1;
            break;
        }
    }
    if(!found2) ans2 = v[v.size()-1]+1;
    if(abs(x-ans1) == abs(x-ans2)) cout <<min(ans1,ans2);
    else if(abs(x-ans1) < abs(x-ans2)) cout << ans1;
    else cout <<ans2;
    return 0;
}


Measured memory_bytes: 3140
import java.util.*
fun main(args: Array<String>) {
  val n = readLine()!!.toString().toInt()
  val map = hashMapOf<String, Int>()
  repeat(n) {
    val s = readLine()!!
    map[s] = (map[s]?:0)+1
  }
  
  val max = map.values.max()
  println(map.entries.filter { it.value == max }.map { it.key }.sorted().joinToString("\n"))
}

Measured memory_bytes: 85224
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <typeinfo>

int main(){
    std::string a, b, c;
    std::string str = "abc";
    std::cin >> a >> b >> c;
    str[0] = a[0];
    str[1] = b[1];
    str[2] = c[2];
    std::cout << str << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>
#include <math.h>
using namespace std;
 
int main() {
    double n,k;cin>>n>>k;
    n = n-k;
    k = k-1;
    double ko = ceil(n/k);
    cout<<ko+1;
    return 0;
}

Measured memory_bytes: 256
from operator import itemgetter
n=int(input())
ab=[]
for i in range(n):
    ab.append(list(map(int,input().split())))
c=sorted(ab, key=itemgetter(1), reverse=False)
f=True
t=0
for i in range(n):
    t = t + c[i][0]
    f=f and t<=c[i][1]
if f:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 55256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#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 out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

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

    int a,b; cin >> a >> b;
    out(2*b-a);

    return 0;
}

Measured memory_bytes: 256
from itertools import permutations

n, m = map(int, input().split())
graph = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

ans = 0
lst = [i for i in range(n)]
lsts = list(permutations(lst, n))

for lst in lsts:
    if lst[0] != 0:
        continue
    now = 0
    for l in lst[1:]:
        if not l in graph[now]:
            break
        now = l
    else:
        ans += 1
print(ans)

Measured memory_bytes: 8052
package main

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

type Process struct {
	Name string
	Time int
}

type Queue struct {
	xs   [100001]*Process
	head int
	tail int
}

func (q *Queue) enqueue(x *Process) {
	q.xs[q.tail] = x
	if q.tail >= len(q.xs)-1 {
		q.tail = 0
	} else {
		q.tail++
	}
}

func (q *Queue) dequeue() *Process {
	x := q.xs[q.head]
	if q.head >= len(q.xs)-1 {
		q.head = 0
	} else {
		q.head++
	}
	return x
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	n, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return n
}

func nextStr(sc *bufio.Scanner) string {
	sc.Scan()
	s := sc.Text()
	return s
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)
	q := nextInt(sc)

	var queue Queue
	for i := 0; i < n; i++ {
		queue.enqueue(&Process{
			Name: nextStr(sc),
			Time: nextInt(sc),
		})
	}

	sum := 0
	for n > 0 {
		p := queue.dequeue()
		if p.Time > q {
			sum = sum + q
			p.Time = p.Time - q
			queue.enqueue(p)
		} else {
			sum = sum + p.Time
			n--
			fmt.Print(p.Name)
			fmt.Print(" ")
			fmt.Println(sum)
		}
	}
}



Measured memory_bytes: 5196
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	map<string,int> seen;
	vector<string> w(n);
	for(int i = 0; i < n; ++i)cin>>w[i];
	seen[w[0]]++;
	for(int i = 1; i < n; ++i){
		if(w[i][0] != w[i - 1][w[i - 1].size()  - 1]){
			cout<<"No"<<endl;
			return 0;
		}
		else if(seen.find(w[i]) != seen.end()){
			cout<<"No"<<endl;
			return 0;
		}
		else{
			seen[w[i]]++;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 1200

int main() {

	char a[MAX];
	int i,j;

	i = 0;
	while (1) {
		scanf("%c", &a[i]);
		if (a[i] == '\n') break;

		if (a[i] >= 65 && a[i] <= 90) a[i] = a[i] + 32;
		else if (a[i] >= 97 && a[i] <= 122) a[i] = a[i] - 32;
		i++;
	}

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

		printf("%c", a[j]);

	}
	printf("\n");

	return 0;

}


Measured memory_bytes: 2068
n,m=map(int,input().split())
par=[i for i in range(n)] #親
rank=[1]*n #深さ
size=[1]*n #iを根とするグループのサイズ
#親を見つける
def find(x):
  if par[x]==x:
    return x
  else:
    return find(par[x])
  
#xの属するグループとyの属するグループを併合
def unite(x,y):
  x=find(x)
  y=find(y)
  if x==y:
    return
  if rank[x]<rank[y]:
    par[x]=y
    size[y]=size[y]+size[x]
  else:
    par[y]=x
    size[x]=size[x]+size[y]
    if rank[x]==rank[y]:
      rank[x]+=1
      
#xとyが同じグループに属するかどうか
def same(x,y):
  return find(x)==find(y)

#check=set()
for i in range(m):
  a,b=map(int,input().split())
  unite(a-1,b-1)
  
ans=0

for i in range(n):
  ans=max(ans,size[find(i)])
print(ans)



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

const int MAXN = 3e5+5;
const int INF = 1e9+7;
#define ll long long
#define pb push_back
#define endl '\n'
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

ll MOD(ll a){
    return ((a%INF)+INF)%INF;
}

ll inv(ll a){
    return poww(a,INF-2,INF);
}

int a[MAXN],b[MAXN],c[MAXN],dp[MAXN][3];

int main()
{
    fast_io;
    //cout << fixed << setprecision(15);

    int n;cin >> n;
    for(int i=1;i<=n;++i){
        cin >> a[i] >> b[i] >> c[i];
    }
    for(int i=1;i<=n;++i){
        dp[i][0] = a[i] + max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = b[i] + max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = c[i] + max(dp[i-1][1],dp[i-1][0]);
    }
    cout << max(dp[n][0],max(dp[n][1],dp[n][2]));
}


Measured memory_bytes: 5632
"""
Peaks
AtCoder丘陵にはN個の展望台があり、展望台iの標高はHiです。
また、異なる展望台どうしを結ぶM本の道があり、道jは展望台Ajと展望台Bjを結んでいます。
展望台iが良い展望台であるとは、展望台iから一本の道を使って辿り着けるどの展望台よりも展望台iの方が標高が高いことをいいます。
展望台iから一本の道を使って辿り着ける展望台が存在しない場合も、展望台iは良い展望台であるといいます。
良い展望台がいくつあるか求めてください。
"""
N, M = map(int, input().split())
H = list(map(int, input().split()))
# 全展望台が良いと仮定する(良い=1, 悪い=0)
n = [1] * N
# 各道について
for i in range(M):
    a,b = map(int, input().split())
    # 道について高さを評価し、低い方は良い展望台ではない
    if H[a-1] >= H[b-1]:
        n[b-1] = 0
    if H[a-1] <= H[b-1]:
        n[a-1] = 0
print(sum(n))


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 22;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

vll s;
vll p;

ll solve(ll n, ll k) {

  if(n == 0) return 1;
  if(k == 1) return 0;
  else if(k <= 1 + s[n-1]) return solve(n-1, k-1);
  else if(k == 2 + s[n-1]) return solve(n-1, s[n-1]) + 1;
  else if(k <= 2 + 2 * s[n-1]) return p[n-1] + 1 + solve(n-1, k - 2 - s[n-1]);
  else if(k == s[n]) return 2 * p[n-1] + 1;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  ll n, k; cin >> n >> k;
  s.resize(n+1);
  p.resize(n+1);
  s[0] = 1;
  p[0] = 1;
  FOR(i, 1, n+1) {
    s[i] = 3 + (s[i-1] * 2);
    p[i] = 1 + (p[i-1] * 2);
  }


  if(n == 0) cout << 1 << endl;
  else cout << solve(n, k) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
#define fi(i, n) for( int i=0 ; i<n ; i++ )
#define fir(i, n) for( int i=n-1; i>=0 ; i-- )
#define fj(j, n) for( int j=0 ; j<n ; j++ )
#define fjr(j, n) for( int j=n-1; j>=0 ; j-- )
#define f(i, a, b) for( int i=a ; i<b ; i++ )
#define vi vector<int>
#define pb push_back
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}

int main()
{
    ll a,b;
    cin>>a>>b;
    if(a>9 || b>9)
    {
        cout<<"-1";
        return 0;
    }
    cout<<a*b;
}


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

int main() {
  
  // 入力される正整数 A, B
  int A, B;

  cin >> A >> B;

  // A と B の 平均 x を四捨五入
  int x = round( (A + B) / 2.0 );

  cout << x << endl;

}


Measured memory_bytes: 384
#include<stdio.h>
int main(){
  int a, b, c, tmp;
  scanf("%d %d %d",&a, &b, &c);
   if(a > b){
    tmp=a; a=b; b=tmp;
   }
   if(b > c){
    tmp=b; b=c; c=tmp;
   }
   if(a > b){
    tmp=a; a=b; b=tmp;
   }
  printf("%d %d %d\n",a, b, c);
  return 0;
}


Measured memory_bytes: 2696
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>
#include <fstream>

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;

int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string s; cin >> s;
	if (s[0] == '7' or s[1] == '7' or s[2] == '7') cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

const int N = 5005, P = 1000000007;

int n, p[N];

int fa[N], cyc[N], sz[N];

int find(int x) {
	return fa[x] == x ? x : (fa[x] = find(fa[x]));
}

bool merge(int x, int y) {
	x = find(x), y = find(y);
	if (x == y) {
		cyc[x] = 1;
		return false;
	}
	fa[y] = x, cyc[x] |= cyc[y], sz[x] += sz[y];
	return true;
}

int fac[N], pw[N], f[N];

int main() {
	read(n);
	for (int i = 1; i <= n; ++i) {
		fa[i] = i, cyc[i] = 0, sz[i] = 1;
	}
	int k = 0;
	for (int i = 1; i <= n; ++i) {
		read(p[i]);
		if (~p[i]) {
			merge(i, p[i]);
		} else {
			++k;
		}
	}
	pw[0] = 1, fac[0] = 1;
	for (int i = 1; i <= n; ++i) {
		pw[i] = 1ll * pw[i - 1] * (n - 1) % P;
		fac[i] = 1ll * fac[i - 1] * i % P;
	}
	int ans = 0;
	int now = 0;
	f[0] = 1;
	for (int i = 1; i <= n; ++i) {
		if (find(i) == i) {
			if (cyc[i]) {
				ans = (ans + pw[k]) % P;
			} else {
				ans = (ans + 1ll * pw[k - 1] * (sz[i] - 1)) % P;
				++now;
				for (int j = now; j; --j) {
					f[j] = (f[j] + 1ll * f[j - 1] * sz[i]) % P;
				}
			}
		}
	}
	for (int i = 2; i <= now; ++i) {
		ans = (ans + 1ll * fac[i - 1] * f[i] % P * pw[k - i]) % P;
	}
	ans = (1ll * n * pw[k] + P - ans) % P;
	print(ans);
}

Measured memory_bytes: 3796
#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 <bitset>

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 long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<string, int> P;

//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(int i=0; i<(n); i++)

//constant
//--------------------------------------------
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;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/

//int Counter(int x)
/*int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}*/
int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}
LL sum(LL a, LL b){
    LL cnt=0;
    cnt=(b-a+1)*(a+b)/2;
    return cnt;
}
/*LL yaku(int x){
    vector<pair<LL, LL> a=[];
    LL xh;
    if(x==1){
        pair<LL, LL> tmp;
        tmp=MP(1,1);
        return tmp;
    }
    else{
        FOR(i, 1, x/2+1){
            if(x%i==0){
                a.append(MP(i,x/i));
            }
        }
    }
    return a;

}*/
LL cul(int a, int b){
    LL f = pow(a,4)+pow(a,3)*b+pow(a,2)*pow(b,2)+a*pow(b,3)+pow(b,4);
    return f;
} 
int main(){
    int n;
    cin >> n;
    VI a(n);
    //VI cnt(n-1,0);
    cin >> a[0];
    FOR(i,1,n){
        cin >> a[i];
        //cnt[i-1]=a[i]-a[i-1];
        //cout << cnt[i-1] << endl;
        }
    map<int, int> x;
    LL ans =0;
    REP(i,n){
       if(x[i-a[i]]!=0){
           ans+=x[i-a[i]];
       }
       x[a[i]+i]++;

    }
    cout << ans << endl;



}
    




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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    map<llint, llint> mp;
    llint a;
    for(int in=0;in<n;in++) {
        cin >> a;
        auto result = mp.insert(make_pair(a, 1));
        if(!result.second) mp[a]++;
    }

    llint h, w;
    h = -1;
    w = -1;

    for(auto imp:mp) {
        // cout << imp.first << " " << imp.second << endl;
        if(imp.second>=4) {
            if(h<imp.first) {
                h = imp.first;
                w = imp.first;
            }
            else if(h>=imp.first&&w<imp.first) {
                w = imp.first;
            }
            else ;
        }
        else if(imp.second>=2&&imp.second<=3) {
            if(h<imp.first) {
                w = h;
                h = imp.first;
            }
            else if(h>=imp.first&&w<imp.first) {
                w = imp.first;
            }
            else ;
        }
        else ;
    }
    if(h!=-1&&w!=-1) cout << h * w << endl;
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 6528
s = int(input())
data = [500, 5, 100, 50, 10, 1]
ans = []
if s == 0:
    print(0)
    quit()
for i in range(len(data)):
    r = s // data[i]
    ans.append(r)
    s %= data[i]
print(ans[0]*1000 + ans[1]*5)


Measured memory_bytes: 3060
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#define INF 1e9
using namespace std;
int main()
{
	int x;
	scanf("%d",&x);
	if(x>=30)printf("Yes");
	else printf("No");
	return 0;
}



Measured memory_bytes: 1732
#include <stdio.h>

int main()
{
   long int n,k[26]={0},max=0,count=0,i,min=9999;
   char  a[1000];
   gets(a);
   for(i=0;i<strlen(a);i++)
   {
       k[a[i]-97]++;
       if(max<k[a[i]-97])
       {
           max= k[a[i]-97];
       }
   }
   if(max!=1)
   {
       printf("no");
   }else{
       printf("yes");
   }
    
    
    
    return 0;
    
    
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

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

  vector<int> A(N);
  for(int i=0;i<N;i++) cin>>A[i];
  int ans=1; N-=K;
  while(N>0){
    N-=(K-1); ans++;
  }

  cout<<ans<<endl;

  return 0;
}


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

// author: Seong Yong-ju ( @sei40kr )

#define DEBUG(x) cout << #x << ": " << x << endl

#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (b) - 1; i >= (a); --i)

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i =  (n) - 1; i >= 0; --i)

#define ALL(a) (a).begin(), (a).end()

using namespace std;

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

  vector<pair<int, int>> ps;
  long n;
  REP(i, 4) {
    int v, p;
    v = static_cast<int>(pow(2, i));
    cin >> p;
    p *= 8;
    ps.emplace_back(p / v, v);
  }
  cin >> n;
  n *= 4;

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

  long ans = 0;
  while (0 < n) {
    for (const auto &pair : ps) {
      int p = pair.first, v = pair.second;
      if (v <= n) {
        long m = n / v;
        n %= v;
        ans += (long) p * v * m;
        break;
      }
    }
  }

  ans /= 8;
  cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Resources;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;

namespace CSharpSpiral {
	class Program {
		static void Main(string[] args) {
			var sw = new StreamWriter(Console.OpenStandardOutput()) {
				AutoFlush=
#if DEBUG
			true
#else
			false
#endif
			};
			Console.SetOut(sw);
			new Program().Solve(new ConsoleInput(
#if DEBUG
			new StreamReader("../../../inputData.txt")
#else
			Console.In
#endif
			, ' '));
			Console.Out.Flush();
		}
		public void Solve(ConsoleInput cin) {
			var N = cin.ReadInt;
			var S = cin.ReadLong;
			var A = cin.ReadIntArray(N);
			int e = 0;
			long sum = 0L;
			int res = int.MaxValue;
			for(int s = 0; s<N; s++) {
				if(sum<S) {
					if(++e>N) goto Ultimate;
					for(; e<=N; e++) {
						sum+=A[e-1];
						if(sum>=S) { break; }
						if(e>=N) goto Ultimate;
					}
				}
				//e: the min $end s.t. P[s,end)
				var _len = e-s;
				if(_len<res) 
					res=_len;
				sum-=A[s];
			}
		Ultimate:
			Console.WriteLine(res>N ? 0 : res);
		}
	}
	static class ExtendClass {
		public static void Swap<T>(this T[] A, int x, int y) {
			var tmp = A[x];
			A[x]=A[y];
			A[y]=tmp;
		}
		public static string Join<T>(this IEnumerable<T> X, string separator = " ") => string.Join(separator, X);
		public static IEnumerable<int> Indices<T>(this T[] X) => Enumerable.Range(0, X.Length);
		public static IEnumerable<int> Indices<T>(this T[,] X, int dim)
			=> Enumerable.Range(0, X.GetLength(dim));
		public static string Join<T>(this T[,] X, string separatorD2 = ",", string separatorD1 = "\n")
			=> X.Indices(0).Select(
				i => X.Indices(1).Select(j => X[i, j]).Join(separatorD2)
			).Join(separatorD1);
	}
	class ConsoleInput {
		private readonly TextReader _stream;
		private readonly char _separator = ' ';
		private readonly Queue<string> inputStream;
		public ConsoleInput(TextReader stream, char separator = ' ') {
			this._separator=separator;
			this._stream=stream;
			inputStream=new Queue<string>();
		}
		public string Read {
			get {
				if(inputStream.Count!=0) return inputStream.Dequeue();
				string[] tmp = _stream.ReadLine().Split(_separator);
				for(int i = 0; i<tmp.Length; ++i)
					inputStream.Enqueue(tmp[i]);
				return inputStream.Dequeue();
			}
		}
		public string ReadLine { get { return _stream.ReadLine(); } }
		public int ReadInt { get { return int.Parse(Read); } }
		public long ReadLong { get { return long.Parse(Read); } }
		public double ReadDouble { get { return double.Parse(Read); } }
		public string[] ReadStrArray(long N) {
			var ret = new string[N];
			for(long i = 0; i<N; ++i)
				ret[i]=Read;
			return ret;
		}
		public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i<N; ++i) ret[i]=ReadInt; return ret; }
		public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i<N; ++i) ret[i]=ReadLong; return ret; }
		public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i<N; ++i) ret[i]=ReadDouble; return ret; }
		public bool isEOF {
			get { return _stream.Peek()==-1; }
		}
	}
}


Measured memory_bytes: 24480
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        
        if (A >= 10 || B >= 10 ) {
            System.out.println(-1);
        }
        else {
            System.out.println(A * B);
        }
    }
}

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

int n,m,sig[5010];
int F[5010];
inline void Add(int &x,int y)
{
	y%=m; x+=y;
	if(x>=m) x-=m;
}
signed main()
{
	cin >> n >> m;
	for(int i=3,j=n;i<=j;i++,j--) sig[i]=sig[j]=i-2;
	for(int i=2;i<=n;i++) sig[i]++;
	F[0]=1;
	for(int ts=2;ts<=n;ts++) for(int i=sig[ts];i<=n;i++)			
		Add(F[i],F[i-sig[ts]]);
	int Ans=0;
	for(int i=0;i<n;i++)
		Add(Ans,(n-i)*F[i]%m);
	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 384
open System
open System.IO

let rec readlines () = seq {
    let line = Console.ReadLine()
    if not (isNull line) then
        yield line
        yield! readlines ()
}

let readFields() = readlines() 
                    |> Seq.filter (String.IsNullOrEmpty >> not) 
                    |> Seq.collect (fun(x) -> x.Split ' ' ) 
                    |> Seq.filter (String.IsNullOrEmpty >> not)


[<EntryPoint>]
let main argv =
    let key2count = readlines() 
                        |> Seq.skip 1
                        |> Seq.countBy id
                        |> Array.ofSeq

    let (key, max) = key2count |> Array.maxBy (fun (key, count) -> count )

    
    key2count |> Array.filter (fun (key, count) -> count = max) 
              |> Array.map (fun (key, count) -> key) 
              |> Array.sort
              |> Array.iter (printfn "%s")
    
    0

Measured memory_bytes: 53168
#include <stdio.h>

int main(void){
    int N, M;
    int odd, even;
    int ans = 0;
    scanf("%d %d",&N,&M);
    even = N * (N-1) / 2;
    odd = M * (M-1) / 2;
    ans = even + odd;
    printf("%d",ans);
}

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

int main(){
    long long s;
    cin >> s;
    int v = 1000000000;
    int x = (v - s % v) % v;
    int y = (s + x) / v;
    cout << "0 0 1000000000 1 " << x << ' ' << y << '\n';
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a<b){
		if(b<c){
			printf("Yes\n");
	}
		else{
			printf("No\n");

	}
}
	else{
	printf("No\n");
}
	return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
string L;
ll n, k, v[55], ans;

ll po(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return po(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = po(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll div(ll x)
{
	return po(x, mod - 2);
}

int main(void)
{
	cin >> n >> k;
	ans = -1000000000000;
	for (int i = 1; i <= n; i++)
	{
		cin >> v[i];
	}
	for (int i = 0; i <= n; i++)
	{
		for (int j = i; j <= n; j++)
		{
			ll num = n - (j - i), pt = 0;
			if (num > k) continue;
			ll re = k - num;
			vector<ll> take;
			for (int l = 1; l <= n; l++)
			{
				if (l <= i || l > j)
				{
					take.push_back(v[l]);
					pt += v[l];
				}
			}
			sort(take.begin(), take.end());
			for (int l = 0; l < min(re, num); l++)
			{
				pt -= min((ll)0, take[l]);
			}
			ans = max(ans, pt);
		}
	}
	cout << ans << endl;
	int www;
	cin >> www;
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;
vector<ll> memo(1000000,INF);

ll solve(ll n){
    if(n==0){
        return 1;
    }
    if(memo[n]!=INF){
        return memo[n];
    }
    ll bus=__builtin_popcount(n);
    ll a=n%bus;
    memo[n]=solve(a)+1;
    return memo[n];

}

ll modpow(ll a, ll n, ll mod){
    ll ret=1;
    while(n>0){
        if(n&1) ret=ret*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ret;
}

int main(){
    memo[0]=1;
    ll n;
    cin>>n;
    string x;
    cin>>x;
    ll s,m,l;
    m=0;
    for(ll i=0;i<n;i++){
        if(x[i]=='1') m++;
    }
    s=m-1;
    l=m+1;
    ll modm=0;
    ll modl=0;
    ll mods=0;
    if(s==0){
        for(ll i=n-1;i>=0;i--){
            if(x[n-1-i]=='1'){
                modm+=modpow(2,i,m);
                modm%=m;
                modl+=modpow(2,i,l);
                modl%=l;
            }
        }
        vector<ll> ans(n);
        for(ll i=n-1;i>=0;i--){
            if(x[n-1-i]=='0'){
                ll buf=modl;
                buf+=modpow(2,i,l);
                buf%=l;
                //cout<<"..."<<buf<<endl;
                ans[n-1-i]=solve(buf);
            }else{
                ans[n-1-i]=0;
            }
        }
        for(ll i=0;i<n;i++) cout<<ans[i]<<endl;
        return 0;
    }

    //cout<<mods<<endl;
    for(ll i=n-1;i>=0;i--){
        if(x[n-1-i]=='1'){
            modm+=modpow(2,i,m);
            modm%=m;
            modl+=modpow(2,i,l);
            modl%=l;
            mods+=modpow(2,i,s);
            mods%=s;
        }
    }
    vector<ll> ans(n);
    for(ll i=n-1;i>=0;i--){
        if(x[n-1-i]=='0'){
            ll buf=modl;
            buf+=modpow(2,i,l);
            buf%=l;
            //cout<<"..."<<buf<<endl;
            ans[n-1-i]=solve(buf);
        }else{
            ll buf=mods;
            buf-=modpow(2,i,s);
            buf%=s;
            if(buf<0){
                buf+=s;
            }
            //cout<<"..."<<buf<<endl;
            ans[n-1-i]=solve(buf);
        }
    }
    for(ll i=0;i<n;i++) cout<<ans[i]<<endl;
}

Measured memory_bytes: 12996
#include <cstdio>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <vector>
#include <utility>
#include <set>
#include <string>

int testcase_ends() {
  char buf[4096];
  if (scanf("%s", buf) != 1) return 1;
  std::string s = buf;
  scanf("%s", buf);
  std::string t = buf;

  if (s.length() > t.length()) std::swap(s, t);

  size_t lb = 0;
  size_t ub = s.length()+1;
  while (ub-lb > 1) {
    size_t mid = (lb+ub) >> 1;

    std::set<std::string> hh;
    for (size_t i = mid; i <= t.length(); ++i)
      hh.insert(t.substr(i-mid, mid));

    bool valid = false;
    for (size_t i = mid; i <= s.length(); ++i)
      if (hh.count(s.substr(i-mid, mid))) {
        valid = true;
        break;
      }

    (valid? lb: ub) = mid;
  }

  printf("%zu\n", lb);
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



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

typedef long long ll;

const int MAXN = 410;
const ll INF = 1e14;

ll dp[MAXN][MAXN],V[MAXN],pref[MAXN];
int N;

ll calc(ll a,ll b){
	if(a > b) return INF;
	return pref[b] - pref[a-1];
}

ll solve(int ini,int fim){
	if(dp[ini][fim] != -1) return dp[ini][fim];
	if(ini == fim) return dp[ini][fim] = 0;
	if(ini + 1 == fim) return dp[ini][fim] = V[ini] + V[fim];
	ll best = INF;
	for(int i = ini;i<fim;i++){
		ll cand = solve(ini,i) + solve(i+1,fim) + calc(ini,fim);
		best = min(best,cand);
	}
	return dp[ini][fim] = best;

}

int main()
{
	memset(dp,-1,sizeof(dp));
	cin >> N;
	for(int i = 1;i<=N;i++) cin >> V[i];
	for(int i = 1;i<=N;i++) pref[i] = pref[i-1] + V[i];
	cout << solve(1,N) << endl;
	return 0;
}

Measured memory_bytes: 4968
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using P = pair<int,int>;
using pq = priority_queue<int>;
typedef long long ll;
string yes = "Yes\n";
string no = "No\n";

int  main()
{
	string s; cin >> s;
	s[3] = '8';
	cout << s << endl;
	return (0);
}

Measured memory_bytes: 256
#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 unsigned long long int ull;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ff first
#define ss second
#define pb push_back
#define Inf  1e18
#define inf -1e18
#define mod 1000000007
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll,ll>;
using umll = unordered_map<ll,ll>;
using sll = set<ll>;
using msll = multiset<ll>;
using pll = pair<ll,ll>;
 
ll MUL(ll A,ll B){
  return (A%mod*B%mod)%mod;
}
 
ll ADD(ll A,ll B){
  return (A%mod+B%mod)%mod;
}
 
ull power(ll A,ll B) {
    ull RES = 1;
    while (B > 0)
    {
        if (B & 1)
            RES = RES*A;
        B = B>>1;
        A = A*A;
    }
  return RES;
}
 
 

 
void testcases(int cases){
			ll n;
			cin >> n;
			map<string ,int>verdict;
			while(n--){
				string s;
				cin >> s;
				verdict[s]++;
			}
			cout << "AC"  << " x " << verdict["AC"] << "\n"; 
			cout << "WA"  << " x " << verdict["WA"] << "\n"; 
			cout << "TLE"  << " x " << verdict["TLE"] << "\n"; 
			cout << "RE"  << " x " << verdict["RE"] << "\n"; 
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
    ll t;
   // cin >> t;
   t = 1;
    ll Case =1 ;
    while(t--)
    {
      testcases(Case++);
    }
}



Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int Mod=1e9+7;
const int INF=0x3f3f3f3f;

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N;
	cin>>N;
	int amin=2e9,amax=-2e9,bmin=2e9,bmax=-2e9;
	for(int i=1;i<=N;++i){
		int a,b;
		cin>>a>>b;
		amin=min(amin,a+b);
		amax=max(amax,a+b);
		bmin=min(bmin,a-b);
		bmax=max(bmax,a-b);
	}
	int ans=max(max(amax-amin,bmax-bmin),max(bmax-bmin,amax-amin));
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;

int main(void){
    vector<int> prime;
    vector<bool> p(10010, true);
    for (int i = 2; i <= 10000; i++) {
        if (p[i]) {
            for (int j = 2 * i; j <= 10000; j += i) p[j] = false;
        }
    }
    for (int i = 2; i <= 10000; i++) {
        if (p[i]) prime.push_back(i);
    }
    
    while (1) {
        int n, ans = 0;
        cin >> n;
        if (n == 0) return 0;
        
        int insum = 0, idx = 0;
        queue<int> que;
        while (idx < prime.size()){
            if (insum < n) {
                que.push(prime[idx]);
                insum += prime[idx];
                idx++;
            }
            else {
                if (insum == n) ans++;
                insum -= que.front();
                que.pop();
            }
            //cout << idx << " " << insum << endl;
        }
        cout << ans << endl;
    }
    
}



Measured memory_bytes: 3032
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<char>> input(int n, int m) {
    vector<vector<char>> table(n, vector<char>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b){
    if (a % b == 0){
        return(b);
    }else{
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
bool isprime(int n){
    if (n < 2) return false;
    else if (n == 2) return true;
    else if (n % 2 == 0) return false;

    for (int i = 3; i <= sqrt(n); i += 2){
        if (n % i == 0){
            return false;
        }
    }
    return true;
}

int main() {
  string s;
  cin >> s;
  int a,b;
  for(int i=0;i<s.size();i++){
    if(s[i]=='A'){
      a=i;
      break;
    }
  }
  reverse(s.begin(),s.end());
  for(int i=0;i<s.size();i++){
    if(s[i]=='Z'){
      b=i;
      break;
    }
  }
  b=s.size()-b;
  cout << b-a << endl;
}

Measured memory_bytes: 640
using System.Linq;
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var r = int.Parse(line[1]);
            if (n == 0 && r == 0) break;
            var a = new List<int>();
            for (int i = 0; i < n; i++) a.Add(n - i);
            for (int i = 0; i < r; i++)
            {
                string[] line2 = Console.ReadLine().Trim().Split(' ');
                var p = int.Parse(line2[0]);
                var c = int.Parse(line2[1]);
                doShuffle(a, p, c);
            }
            Console.WriteLine(a[0]);
        }
    }
    public static void doShuffle(List<int> a, int p, int c)
    {
        var b = new List<int>();
        for (int i = 0; i < c; i++) b.Add(a[p - 1 + i]);
        for (int i = 0; i < p - 1; i++) b.Add(a[i]);
        for (int i = p + c - 1; i < a.Count(); i++) b.Add(a[i]);
        a.Clear();
        foreach (var x in b) a.Add(x);
    }
}

Measured memory_bytes: 9732
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll mod = 1e9+7;
//LLONG_MIN

//AC

int main(void){
	ll n,a[100010],sum=0;
	cin>>n;
	rep(i,n)cin>>a[i];
	rep(i,n){
		sum+=a[i]-1;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
from sys import stdin
from itertools import product

def gcd(a, b):
    while a > 0 and b > 0:
        if a >= b:
            a %= b
        else:
            b %= a
    return max(a, b)

k = int(stdin.readline())
ls = [[0 for j in range(k+1)] for i in range(k+1)]
for i in range(1, k+1):
    for j in range(i, k+1):
        res = gcd(i, j)
        ls[i][j] = res
        ls[j][i] = res
_sum = 0
for i in product(range(1,1+k), repeat=3):
    _sum += ls[ls[i[0]][i[1]]][i[2]]
print(_sum)

Measured memory_bytes: 68476
N = int(input())
A = list(map(int, input().split()))

P = [0]*N

for i in range (0, N):
	P[A[i]]+=1

if P[0] != 1 and P[0]!=0:
	print(0)
	exit()

for i in range (1, N):
	if (i-N)%2 ==0:
		if P[i] > 0:
			print(0)
			exit()
	if (i-N)%2 != 0:
		if P[i] != 2 and P[i] !=0:
			print(0)
			exit()

print((2**(N//2))%(10**9+7))

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

int main(void) {
    int N, ans=0;
    cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];

    int Q;
    cin >> Q;
    vector<int> M(Q);
    rep(i,Q) cin >> M[i];

    set <ll> s;

    for(int j=0; j<(1<<N); j++){
      int sum = 0;
      for(int k=0; k<N; k++){
        if(j&(1<<k))
          sum += A[k];
      }
      s.insert(sum);
    }

    rep(i,Q){
      if(s.find(M[i])!=s.end())
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }

    return 0;
}



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

int main()
{
  ll n,k;
  cin >> n >> k;
  vector<ll> v(n);
  rep(n) cin >> v[i];
  sort(v.begin(),v.end());
  ll tmp = v[n-1] - v[0];
  for (ll i = 0; i+k-1 < n; i++)
  {
    tmp = min(tmp,v[i+k-1]-v[i]);
  }
  cout << tmp << endl;
  return 0;
}

Measured memory_bytes: 1024