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

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1e9+7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

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

template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
///////////////////////////////////////////////
/*(._.)*/
int main(){
	string S;
	cin >> S;
	int N = S.length();

	vector<int> U;
	int count = 1;
	REP(i,S.size()-1){
		if (S[i] == S[i+1]){
			count++;
		}else{
			U.PB(count);
			count = 1;
		}
	}
	U.PB(count);

	vector<int> A(N);
	vector<int> ansv;

	int usize = U.size();
	REP(i,usize/2){
	    int R = U[2*i];
	    int L = U[2*i+1];
	    int lans = (R+1)/2 + L/2;
	    int rans = (L+1)/2 + R/2;
	    ansv.PB(lans);
	    ansv.PB(rans);
	}

	int ind = 0;
	REP(i,N){
	    if ((S[i] == 'R') and (S[i+1] == 'L')){
	    	A[i] = ansv[ind];
	    	ind++;
	    	A[i+1] = ansv[ind];
	    	ind++;
	    }
	}

	REP(i,N){
	    cout << A[i] << " ";
	}

	cout << endl;

}


Measured memory_bytes: 1976
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <stack>
#include <cstring>

using namespace std;

int main(){
	int n;
	int max,tmpmax1,tmpmax2;
	while(cin >> n && n != 0){
		max = -100001;
		int *factor = new int[n];
		
		for(int i = 0; i < n; i++){
			cin >> factor[i];
		}

		for(int i = 0; i < n; i++){
			tmpmax1 = 0;
			tmpmax2 = -100001;
			for(int j = i; j < n; j++){
				tmpmax1 += factor[j];
				if(tmpmax2 < tmpmax1){
					tmpmax2 = tmpmax1;
				}
			}
			if(max < tmpmax2){
				max = tmpmax2;
			}
		}
		delete [] factor;
		cout << max << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1200
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    a:usize,
    b:[usize;a],
    }
    let mut v=0;
    for i in 0..a {
        if i+1<b[i]&&b[b[i]-1]==i+1{v+=1}
    }
    println!("{}",v)
}

Measured memory_bytes: 3256
ABCD=list(map(int,list(input())))
for i in range(2**3):
    op=[0]*3
    for j in range(3):
        op[j]=i%2
        i//=2
    val=ABCD[0]
    for j in range(3):
        if op[j]==1:
            val+=ABCD[j+1]
        else:
            val-=ABCD[j+1]
    if val==7:
        ans=str(ABCD[0])
        for j in range(3):
            if op[j]==1:
                ans+="+"
            else:
                ans+="-"
            ans+=str(ABCD[j+1])
        print(ans+"=7")
        exit()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int N, K, s;
ll sum, ans, a;

int main()
{
    cin >> N >> K;
    vector<ll> T, S;
    T.push_back(0);
    S.push_back(0);

    for (int i = 0; i < N; i++)
    {
        cin >> a;
        T.push_back(T.back() + a);
        S.push_back(S.back() + max(0LL, a));
    }

    for (int i = K; i <= N; i++)
        ans = max((S[N] - S[i]) + S[i - K] + max(0LL, T[i] - T[i - K]), ans);

    cout << ans << "\n";
}

Measured memory_bytes: 2036
# -*- coding: utf-8 -*-

def Roller_Coaster(N, K, member):
        a = list(filter(lambda x: x >= K, member))
        return len(a)

if __name__ == "__main__":
    [N, K] = list(map(int, input().split()))
    member = list(map(int, input().split()))
    print(Roller_Coaster(N,K,member))


Measured memory_bytes: 11892
n = int(input())
s = input()
e_l = [0] * (n+1)
w_l = [0] * (n+1)
for i in range(n):
    if s[i] == 'E':
        e_l[i+1] = e_l[i] + 1
    else:
        e_l[i+1] = e_l[i]
for j in range(n, 0, -1):
    if s[j-1] == 'W':
        w_l[j-1] = w_l[j] + 1
    else:
        w_l[j-1] = w_l[j]
ans = 0
for k in range(n):
    res = e_l[k+1] + w_l[k]
    ans = max(ans, res)
print(n-ans)

Measured memory_bytes: 17556
#include<bits/stdc++.h> 
using namespace std;
//#define for(i,a,b) for(int i=(a);i<=(b);i++)
#define ppi pair<int,int>
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
const int N = 105;
const double pi = acos(-1.0);
const ll mod = 1e9+7;
void init(){ios::sync_with_stdio(false);cin.tie(0);} 
template<class T>inline void read(T &res)
{
	char c;T flag=1;
	while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
	while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
int main()
{
	ll a,s=100,cnt=0;
	cin>>a;
	while(s<a)
	{
		s=s+(ll)s*0.01;
		cnt++;
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

/**
 * 500 Yen Coins
 */
public class Main {

	public static void main(String...args) {
		try (Scanner sc = new Scanner(System.in)) {
			int k = sc.nextInt();
			int x = sc.nextInt();

			if (500 * k < x) {
				System.out.println("No");
			} else {
				System.out.println("Yes");
			}
		}
	}
}

Measured memory_bytes: 21716
from bisect import bisect_right

N = int(input())
HPs = [tuple(map(int, input().split())) for i in range(N)]

HPs.sort(key=lambda x: x[0] + x[1])

# i人目まで考慮して、j人積んだ場合の積まれている高さの最小値
# 計算量削減のため、dp[j]=∞であるjのうち、最小のj以外は省略する
INF = float('inf')
dp = [0] + [INF]
lenDP = 2
num = 0
for i, (H, P) in enumerate(HPs, 1):
    iH = bisect_right(dp, H)
    x = lenDP - N + i - 2

    if x <= 0:
        dp0 = [0] + [hgt + P for hgt in dp[:iH]] + [INF] * (len(dp) - iH)
        dp = [x if x <= y else y for x, y in zip(dp0, dp)]
    else:
        # 最終的な答えに影響を与えなくなった要素を省略する
        dp0 = [hgt + P for hgt in dp[x-1:iH]] + [INF] * (len(dp) - iH)
        dp = [x if x <= y else y for x, y in zip(dp0, dp[x:])]
        lenDP -= x
        num += x

    if dp[-1] != INF:
        dp += [INF]
        lenDP += 1

print(num + len(dp) - 2)


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int Cnter(string a,string b){
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  int ret = 0;
  for(int i = 'a'; i <= 'z'; ++i){
    ret += binary_search(a.begin(),a.end(),i)&&binary_search(b.begin(),b.end(),i);
  }
  return ret;
}

int main(){
  string s; cin >> s;
  bool f = true;
  f &= s.front() == 'A';
  int cnt = 0;
  for(int i = 2; i < (int)s.size()-1; ++i){
    cnt += s[i] == 'C';
  }
  f &= cnt == 1;
  cnt = 0;
  for(int i = 0; i < (int)s.size(); ++i){
    cnt += s[i] >= 'A' && s[i] <= 'Z';
  }
  f &= cnt == 2;
  cout << (f ? "AC" : "WA") << endl;
}


Measured memory_bytes: 3628
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n, m = sc.next()
    val num = (n + m).toInt

    println(if (math.sqrt(num) % 1 == 0) {
      "Yes"
    } else {
      "No"
    })

  }
}


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

#define Solved int main()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define forn(i, n) for(int i = 1; i <= n; i++)
#define rep(i, x, y) for(int i = x; i <= y; i++)
#define sz(x) (int)x.size()
#define pii pair<int, int>
#define ll long long
#define ull unsigned long long
#define ld long double
#define mii map<int, int>
#define all(x) x.begin(), x.end()
#define lb lower_bound
#define ub upper_bound
using namespace std;

inline ll bip(ll x,ll n,ll mod){ll res=1;while(n){if(n&1){res=(res*x)%mod;}x=(x*x)%mod;n>>=1;}return res;}

const int maxn = 1e9;
const ll inf = 1e18;
const int mod = 998244353;
//const int mod = 1e9 + 7;
const int N = 1e5 + 10;

int n, W, w[101], v[101];
ll dp[101][N];

void solve() {
    cin >> n >> W;

    forn (i, n)
        cin >> w[i] >> v[i];//, dp[i][w[i]] = v[i];

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= W; j++) {
            dp[i][j] = dp[i - 1][j];
            if (j >= w[i]) dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
        }
    }

    cout << dp[n][W];

}

Solved {
    SpeedForce;
	int tt = 1;
    //cin >> tt;
	while (tt--) {
		solve();
		cout << '\n';
	}

}


Measured memory_bytes: 78464
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    long long a[n];
    long long tmp = 1e9+1;
    vector<bool> ch(tmp,false);
    int flag=0;
    for( int i=0; i<n; i++){
        cin >> a[i];
        if(ch[a[i]]==false){
            ch[a[i]] = true;
        }else{
            flag = 1;
            break;
        }
    }
    if(flag==0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }       
}




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

class Mondai
{
    static void Main()
    {
        var line = Console.ReadLine().Split(' ').Select(n => decimal.Parse(n)).ToArray();
        var W = line[0];
        var H = line[1];
        var x = line[2];
        var y = line[3];
        var menseki = W * H / 2;
        var manakaX = W / 2;
        var manakaY = H / 2;
        var hukusu = 0;
        if (manakaX == x && manakaY == y) hukusu = 1;
        Console.WriteLine($"{menseki} {hukusu}");
    }
}


Measured memory_bytes: 13396
from collections import deque


class Dinic:
    def __init__(self, v, inf=10**9 + 7):
        self.V = v
        self.inf = inf
        self.G = [list() for _ in range(v)]
        self.level = [-1 for _ in range(v)]
        self.iter = [0] * v

    def addedge(self, fr, to, cap):
        """
        G[fr] = [to, cap, rev]
        """
        go = [to, cap, None]
        go[2] = back = [fr, 0, go]
        self.G[fr].append(go)
        self.G[to].append(back)

    def bfs(self, st, en):
        q = deque([st])
        self.level = [-1 for _ in range(self.V)]
        self.level[st] = 0
        while q:
            cur = q.popleft()
            for x, cap, _ in self.G[cur]:
                if cap and self.level[x] < 0:
                    self.level[x] = self.level[cur] + 1
                    q.append(x)
        return self.level[en] > 0

    def dfs(self, v, t, f):
        if v == t:
            return f
        for e in self.iter[v]:
            w, cap, rev = e
            if cap and self.level[v] < self.level[w]:
                d = self.dfs(w, t, min(f, cap))
                if d:
                    e[1] -= d
                    rev[1] += d
                    return d
        return 0

    def flow(self, s, t):
        flow = 0
        while self.bfs(s, t):
            self.iter = list(map(iter, self.G))
            f = self.dfs(s, t, self.inf)
            while f:
                flow += f
                f = self.dfs(s, t, self.inf)
        return flow

def main():
    n = int(input())
    a = list(map(int, input().split()))
    D = Dinic(n+2)
    ret = 0
    for i,e in enumerate(a, 1):
      if e > 0:
        ret += e
        D.addedge(i, n+1, e)
      else:
        D.addedge(0, i, -e)
    for i in range(1, n//2 + 1):
      for j in range(i*2, n+1, i):
        D.addedge(i, j, 10**12)
    loss = D.flow(0, n+1)
    return ret - loss

print(main())

Measured memory_bytes: 3444
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main{

    public static final int FIRST_NUMBER = 0;
    public static final int SECOND_NUMBER = 1;

    public static void main(String[] args) throws NumberFormatException, IOException {

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	// ???????????°
	int vertical = Integer.parseInt(br.readLine());
	// ?¨?????????°
	int horizontal = Integer.parseInt(br.readLine());

	// ?????????????????°??????????????????
	List<int[]> changeRequests = new ArrayList<>();
	for (int i = 0; i < horizontal; i++) {
	    String[] changeRequestStr = br.readLine().split(",");
	    int[] changeRequest = new int[2];
	    changeRequest[FIRST_NUMBER] = Integer.parseInt(changeRequestStr[FIRST_NUMBER]);
	    changeRequest[SECOND_NUMBER] = Integer.parseInt(changeRequestStr[SECOND_NUMBER]);
	    changeRequests.add(changeRequest);
	}

	// ?????\???????????????????´???????????????????????????????
	int[] outputArray = getDrawedArray(changeRequests, vertical, horizontal);

	// ???????????????????????????????????¨?????\???????????????????????????????????????1??????????????????
	for (int i = 1; i < outputArray.length; i++) {
	    System.out.println(outputArray[i]);
	}

    }

    private static int[] getDrawedArray(List<int[]> changeRequests, int amidaLength, int loopCount) {
	// ?????\?????????????????????????????????????????????
	// outputArray[0]????????¨?????????
	int[] outputArray = new int[amidaLength + 1];
	for (int i = 1; i < outputArray.length; i++) {
	    outputArray[i] = i;
	}

	// ?????????????????????????£????????????\????????????
	for (int[] changeRequest : changeRequests) {
	    int mediator = 0;
	    mediator = outputArray[changeRequest[FIRST_NUMBER]];
	    outputArray[changeRequest[FIRST_NUMBER]] = outputArray[changeRequest[SECOND_NUMBER]];
	    outputArray[changeRequest[SECOND_NUMBER]] = mediator;

	}

	return outputArray;

    }

}

Measured memory_bytes: 24196
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD=1e9+7;

int h,w;
vector<string> v;

bool canMove(int x,int y){
    return x<h&&y<w&&v[x][y]=='.';
}

int32_t main(){
    
    cin>>h>>w;
    v.resize(h);
    for(auto &i : v) cin>>i;

    vector<vector<int>> dp(h,vector<int>(w,0));dp[0][0]=1;

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(canMove(i+1,j)) dp[i+1][j]=(dp[i+1][j]+dp[i][j])%MOD;
            if(canMove(i,j+1)) dp[i][j+1]=(dp[i][j+1]+dp[i][j])%MOD;
        }
    }

    cout<<dp[h-1][w-1]<<"\n";
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i_len=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back
#define mp make_pair

int main()
{
    ll N;
    cin >> N;
    vec v(N);
    REP(i,0,N) cin >> v[i];
    
    sort(ALL(v));
    double sum = v[0];
    REP(i,1,N) sum = (sum + v[i]) / 2.0;
    cout << setprecision(12) << sum << endl;

    return 0;
}

/*



*/

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int a = Integer.parseInt(br.readLine());
		String s = br.readLine();

		if(a >= 3200){
			System.out.println(s);
		}
		else {
			System.out.println("red");
		}

	}

}


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


void solve(long long K, std::string S){


    if( S.length() <= K ){
        cout << S << endl;
    }else{
        cout << S.substr(0, K) << "..." << endl;
    }

    return;

}

int main(){
    long long K;
    scanf("%lld",&K);
    std::string S;
    std::cin >> S;
    solve(K, S);
    return 0;
}


Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=4e5+5;
int main()
{
	int n,i,a[maxn]={0},l=1;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]==l)l++;
	}
	if(l==1)puts("-1");
	else
	printf("%d\n",n-(l-1));
}

Measured memory_bytes: 1792
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
[k,a,b]=i2()

s=a-1
if s>=k:
   s=k+1
else:
   if a>=b:
      s=k+1
   else:
      if k>=2:
         if b-a>1:
          s=(b-a)*((k-(a-1))//2)+a+(k-(a-1))%2
         else:
          s=k+1
      else:
          s=2
print(s)

Measured memory_bytes: 38388
//A - αlphabet
//Hiia
#include <stdio.h>
#include <stdlib.h>//rannsuu, zettaichi(absolute)
#include <time.h>
//srand((unsigned int) time(0));
#include <math.h>//koudona keisann
#include <string.h>//hairetsu
//#define max(p,q)((p)>(q)?(p):(q))//yoku wakarannkedo bennrisou
//#define min(p,q)((p)<(q)?(p):(q))//ue ni onaji
//#define N

int main()
{
  char x;
  scanf("%c", &x);
  if('a'<=x && x<= 'z') {
    printf("a");
  }
  else{
    printf("A");
  }


  return 0;
}


Measured memory_bytes: 1600
import itertools

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

#l = list(set(L))

cnt = 0

for x in itertools.combinations(L, 3):
    if x[0]==x[1] or x[1]==x[2] or x[0]==x[2]:
        continue

    if x[0]+x[1] < x[2]:
        continue
    if x[1]+x[2] < x[0]:
        continue
    if x[0]+x[2] < x[1]:
        continue

    if x[0] > x[1]:
        if x[0]-x[1] >= x[2]:
            continue
    else:
        if x[1]-x[0] >= x[2]:
            continue
        
    if x[1] > x[2]:
        if x[1]-x[2] >= x[0]:
            continue
    else:
        if x[2]-x[1] >= x[0]:
            continue

    if x[0] > x[2]:
        if x[0]-x[2] >= x[1]:
            continue
    else:
        if x[2]-x[0] >= x[1]:
            continue
    
    cnt += 1

print(cnt)


    

Measured memory_bytes: 9152
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

m = [
     1,
     6,
     6 ** 2,
     6 ** 3,
     6 ** 4,
     6 ** 5,
     6 ** 6,
     9,
     9 ** 2,
     9 ** 3,
     9 ** 4,
     9 ** 5,
]

dp = [[10 ** 18 for _ in range(N + 1)] for _ in range(len(m) + 1)]
dp[0][0] = 0

for i in range(1, len(m) + 1):
     for j in range(N + 1):
          dp[i][j] = dp[i - 1][j]

     for j in range(1, N + 1):
          if j - m[i - 1] >= 0:
               dp[i][j] = min(dp[i][j], dp[i][j - m[i - 1]] + 1)

print(dp[len(m)][N])

Measured memory_bytes: 24308
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#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 <ctime>
#include <string.h>
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define INF                         (int)1e9
#define EPS                         1e-9
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define MOD                         1000000007
typedef long long ll;
/*For you see , each day i love you
 more.Today more than yesterday
  less than tomorrow.*/
using namespace std;

int main()
{
	int n;s(n);
	vector<ll> vec;
	
	int zero = 0;
	for(int i = 0;i<n;i++)
	{
		ll x;cin>>x;
		vec.push_back(x);
		if(x == 0) zero = 1;	
	}
	
	if(zero)
	{
		cout<<"0"<<endl;return 0;
	}
	
	ll mul = 1;
	for(int i = 0;i<n;i++)
	{
		if(mul > 1000000000000000000/vec[i])
		{
			printf("-1\n");return 0;
		
		}
		else
		{
				mul*=vec[i];
		}
	}
	
	cout<<mul<<endl;
	return 0;
}

Measured memory_bytes: 4392
def main():
    N, K = map(int, input().split())

    edges = []
    for u in range(1, N):
        edges.append((0, u))

    count = (N - 1) * (N - 2) // 2
    to_join = count - K

    v = 1
    while v < N and to_join:
        for u in range(v + 1, N):
            edges.append((v, u))
            to_join -= 1
            if to_join == 0: break
        v += 1

    if to_join:
        print(-1)
    else:
        print(len(edges))
        for edge in edges:
            print(*map(lambda x: x + 1, edge))


if __name__ == '__main__':
    main()

# 中心0を取り囲む
# (n-1)個の頂点
# (n-1)C2の最短距離2の組が存在
# (n-1)個の頂点同士の組のいくつかを直接連結すると最短距離1にできる


Measured memory_bytes: 4120
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int l[10];
int main()
{
	int N, A, B, C;
	cin >> N >> A >> B >> C;
	for (int i = 0; i < N; i++) {
		cin >> l[i];
	}
	int ans = mod, sum = 0;
	for (int bit = 0; bit < (1 << (N * 2)); bit++) {
		int tmp = bit;
		int a = 0, b = 0, c = 0, sum = 0;
		int x = 0, y = 0, z = 0;
		for (int i = 0; i < N; i++) {
			int s = tmp % 4;
			if (s == 0) {
				a += l[i];
				x++;
			}
			else if (s == 1) {
				b += l[i];
				y++;
			}
			else if (s == 2) {
				c += l[i];
				z++;
			}
			tmp /= 4;
		}
		if (x == 0 ||  y== 0 || z == 0) continue;
		sum += (x - 1) * 10;
		sum += (y - 1) * 10;
		sum += (z - 1) * 10;
		sum += abs(A - a);
		sum += abs(B - b);
		sum += abs(C - c);
		ans = min(sum, ans);
	}
	cout << ans << endl;
}

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

int main() {
    int k, x;
    cin >> k >> x;
    if (1000001-x<k) {
        int i=x-k+1;
        while (i<1000000) {
            cout << i << " ";
            i++;
        }
        cout << i << endl;
    }
    else if(1000001+x<k) {
        int i=-1000000;
        while(i<x+k-1) {
            cout << i << " ";
            i++;
        }
        cout << i << endl;
    }
    else {
        for (int i=x-k+1;i<x+k-1;i++) {
            cout << i << " ";
        }
        cout << x+k-1 << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long  int n,m,x,s=0;
    cin>>n>>m;
    int ara[n+2];

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

  for(int i=0;i<n-m;i++)
  {
      s+=ara[i];
  }
  cout<<s<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

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

  ll n;cin>>n;
  ll ans = 0;
  reps(_k,1e7){
    ll k = _k;
    if(k==1) continue;
    ll m = n;
    while(m%k == 0) m/=k;
    if(m%k == 1){
      ans++;
    }
  }
  vector<ll> yakusu;
  if(n > 1e7) ans++;
  n--;
  reps(p,1e7){
    if(n%p == 0){
      yakusu.push_back(p);
      yakusu.push_back(n/p);
    }
  }
  rep(i,yakusu.size()){
    if(yakusu[i] > 1e7) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

void solve(istream& cin, ostream& cout) {
  int n, m;
  cin >> n >> m;
  int ans = (1900 * m + 100 * (n - m)) * pow(2, m);
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 4076
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

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

    vector<string> strings;
    string s;
    for (int i = 0; i < N; i++) {
        cin >> s;
        strings.push_back(s);
    }

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

    string ans = "";
    for (auto s : strings) {
        ans += s;
    }

    cout << ans << endl;

    return 0;
}

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

#define STRING(str) #str
#define ll long long

template <typename T >
void print_vec_1d(vector<T> x, string name) {
	cout << name << endl;
	cout << "[ ";
	for (int i=0;i<x.size();i++) {
		cout << x[i];
		if (i != x.size()-1) cout << ", ";
		else cout << " ]" << endl;
	}
}

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

	dsu d(N);
	vector<pair<int, int>> vec;
	vector<int> ind(N);
	// vector<int> X_Y(N);
	// vector<int> Y_X(N);
	for (int i=0;i<N;i++) {
		int X, Y;
		cin >> X >> Y;
		X--;
		Y--;
		// X_Y[X] = Y;
		// Y_X[Y] = X;
		vec.push_back(make_pair(X, Y));
		ind[Y] = i;
	}

	sort(vec.begin(), vec.end());
	stack<pair<int, int>> st;
	for (int i=N-1;i>=0;i--) {
		int X = vec[i].first;
		int Y = vec[i].second;
		if (st.size() == 0) {
			pair<int, int> tmp = make_pair(Y, Y);
			st.push(tmp);
		} else { // st.size() > 0
			pair<int, int> rem = st.top();
			int l = rem.first;
			int r = rem.second;

			if (Y > r) {
				pair<int, int> tmp = make_pair(Y, Y);
				st.push(tmp);
			} else { // Y < r
				if (Y < l) {
					while (st.size()>0 && (Y < l)) {
						pair<int, int> rem_tmp = st.top();
						int lll = rem_tmp.first;
						int rr = rem_tmp.second;
						if (rr < Y) break;
						l = lll;
						st.pop();
					}
					pair<int, int> pp = make_pair(min(l, Y), r);
					st.push(pp);
				}
			}
		}
	}


	vector<int> ans_X(N);
	// cout << "stack" << endl;
	while (!st.empty()) {
		pair<int, int> ppp = st.top();
		st.pop();

		int l = ppp.first;
		int r = ppp.second;
		int val = r-l+1;
		for (int i=l;i<=r;i++) {
			ans_X[i] = val;
		}
		// cout << ppp.first << " " << ppp.second << endl;
	}


	vector<int> ans(N);
	for (int i=0;i<N;i++) {
		ans[ind[i]] = ans_X[i];
	}

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

Measured memory_bytes: 8012
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
using Graph = vector<vector<int>>;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ
/*






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


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n ;
  string s ;
  cin >> n >> s ;
  vector<ll> r(n,0) ;
  vector<ll> g(n,0) ;
  vector<ll> b(n,0) ;
  
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      if(s[j]=='R'){
        r[i]++ ;
      }
      else if(s[j]=='G'){
        g[i]++ ;
      }
      else{
        b[i]++ ;
      }
    }
  }
  
  
  ll ans = 0 ;
  
  /*
  REP(i,n){
    cout << i << " " <<r[i] <<" " << g[i] <<" " << b[i] <<endl ;
  }
  */
  
  
  for(int i=0;i<n-2;i++){
    for(int j=i+1;j<n-1;j++){
      if(s[i]!=s[j]){
        if(s[i]=='R' && s[j]=='B'){
          if(g[j]==0){
            continue ;
          }
          ans += g[j] ;
          if(s[2*j-i]=='G' && 2*j-i<n){
            ans-- ;
          }
        }
        else if(s[i]=='B' && s[j]=='R'){
          if(g[j]==0){
            continue ;
          }
          ans += g[j] ;
          if(s[2*j-i]=='G' && 2*j-i<n){
            ans-- ;
          }
        }
        else if(s[i]=='G' && s[j]=='R'){
          if(b[j]==0){
            continue ;
          }
          ans += b[j] ;
          if(s[2*j-i]=='B' && 2*j-i<n){
            ans-- ;
          }
        }
        else if(s[i]=='R' && s[j]=='G'){
          if(b[j]==0){
            continue ;
          }
          ans += b[j] ;
          if(s[2*j-i]=='B' && 2*j-i<n){
            ans-- ;
          }
        }
        else{
          if(r[j]==0){
            continue ;
          }
          ans += r[j] ;
          if(s[2*j-i]=='R' && 2*j-i<n){
            ans-- ;
          }
        }
      }
    }
  }
  
  cout << ans <<endl ;
          
  
  
  
  return 0 ;
}

Measured memory_bytes: 3664
#include <stdio.h>

int stack[50];
int temp[50];

int main(void){
    int n,r,i,j;
    while(scanf("%d %d",&n, &r),n||r){
        for(i=0;i<n;i++){//stack[0]:?????????(n) stack[n-1]:?????????(1)
            stack[i]=n-i;
        }
        for(i=0;i<r;i++){
            int p,c;
            scanf("%d %d", &p, &c);
            for(j=0;j<c;j++){//?????????p????????????c??????temp????§????
                temp[j]=stack[p-1+j];
            }
            for(j=p-2;j>=0;j--){//?????????p-1??????c??????????§????
                stack[j+c]=stack[j];
            }
            for(j=0;j<c;j++){//temp??????c?????????????±±??????????§????
                stack[j]=temp[j];
            }
        }
        printf("%d\n", stack[0]);
    }
    return 0;
}

Measured memory_bytes: 600
a = int(input())
b = list(map(int, input().split()))

sorted_b = [i+1 for i in range(a)]

diff = [x-y for (x,y) in zip(sorted_b, b)]

if len([i for i in diff if i != 0]) <= 2:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std; 
int main(void){
	int n;
	int x[101];
	int m;
	int a[101];
	cin>>n;
	int i;
	for(i=1;i<=n;i++){
		cin>>x[i];
	}
	cin>>m;
	for(i=0;i<m;i++){
		cin>>a[i];
	}
	for(i=0;i<m;i++){
		if(x[a[i]]+1!=x[a[i]+1]&&x[a[i]]+1!=2020){
			x[a[i]]++;
		}
	}
	for(i=1;i<=n;i++){
		cout<<x[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3084
#include "bits/stdc++.h"
using namespace std;
#define MODULO 1000000007
#define PI 3.14159265359
typedef long long int ll;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
     char  x,y,z;
     char a,b,c;
     cin>>x>>y>>z>>a>>b>>c;
     int ct=0;
     if(x==a)
     ct++;
     if(y==b)
     ct++;
     if(z==c)
     ct++;
     cout<<ct<<endl;
	 
    return 0;
}


Measured memory_bytes: 3652
#!/usr/bin/env python3

S = input()
N = len(S)
count = 0
is_ok = True

right_index = 0
left_index = N - 1

while right_index < left_index:

    if right_index == left_index:
        break

    if S[right_index] == S[left_index]:
        right_index += 1
        left_index -= 1
        continue
    if S[right_index] == "x":
        count += 1
        right_index += 1
        continue

    if S[left_index] == "x":
        count += 1
        left_index -= 1
        continue

    count = -1
    break

ans = count

print(ans)


Measured memory_bytes: 3316
A, B, C, D = gets.chomp.split(" ").map(&:to_i)

answer = 0

all = (B - A + 1)
a = (B.div(C) - (A-1).div(C))
b = (B.div(D) - (A-1).div(D))
c = (B.div(C.lcm(D)) - (A-1).div(C.lcm(D)))

p all - a - b + c


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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int beg = 0, end = 0;
  for(int i = 0; i < n; i++) {
    if(s[i] == 'A') {
      beg = i;
      break;
    }
  }
  for(int i = n; i >= 0; i--) {
    if(s[i] == 'Z') {
      end = i;
      break;
    }
  }
  cout << end - beg + 1 << endl;
  return 0;
}


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

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

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

const int MAX = 2*1e5 + 5;
const int INF = 1001001001;
const int MOD = 998244353;

struct mint {
    long long x;
    mint(long long x=0):x(x % MOD + (0 <= x ? 0 : MOD)) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint& a) { if ((x += a.x) >= MOD) x -= MOD; return *this; }
    mint& operator-=(const mint& a) { if ((x -= a.x) < 0) x += MOD; return *this; }
    mint& operator*=(const mint& a) { (x *= a.x) %= MOD; return *this; }
    mint operator+(const mint& a) const { return mint(x) += a; }
    mint operator-(const mint& a) const { return mint(x) -= a; }
    mint operator*(const mint& a) const { return mint(x) *= a; }

    // for prime mod
    mint inv() const {
        long long a = x, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        return mint(u);
    }
    mint& operator/=(const mint& a) { return *this *= a.inv(); }
    mint operator/(const mint& a) const { return mint(x) /= a; }
};
istream& operator>>(istream& is, const mint& a){ return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a){ return os << a.x; }

vector<int> G[MAX];

mint dfs(int n) {
    mint res = 1;
    for (int &i : G[n]) {
        res *= dfs(i);
    }
    return res += 1;
}

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

    vector<P> p(N);
    rep(i, N) cin >> p[i].first >> p[i].second;

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

    set<P> s;
    repr(i, N) {
        while (s.size() && s.begin()->first < p[i].first + p[i].second) {
            G[i].push_back(s.begin()->second);
            s.erase(s.begin());
        }
        s.emplace(p[i].first, i);
    }

    mint ans = 1;
    for (P i : s) ans *= dfs(i.second);
    cout << ans << endl;
}

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

#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
int main() {
	int n;
	cin >> n;
	while(n--) {
		string a, b;
		int x[84], y[84], s[84], max;
		cin >> a >> b;
		if(a.length() > 80 || b.length() > 80) {
			cout << "overflow" << endl;
			continue;
		}
		int i = 0, j = 0;
		for(; a[i] != '\0'; ++i) {
			x[i] = a[i] - '0';
		}
		for(; b[j] != '\0'; ++j) {
			y[j] = b[j] - '0';
		}
		
		if(i > j) {
			for(int k = j - 1; k >= 0; k--) {
				y[i-j+k] = y[k];
			}
			rep(k,i-j) {
				y[k] = 0;
			}
			max = i;
		} else if(i < j) {
			for(int k = i - 1; k >= 0; k--) {
				x[j-i+k] = x[k];
			}
			rep(k,j-i) {
				x[k] = 0;
			}
			max = j;
		} else max = i;
		bool f = 0;
		for(int k = max - 1; k >= 0; k--) {
			int c = x[k] + y[k];
			if(f) c++;
			if(c >= 10) {
				f = 1, c -= 10;
			} else f = 0;
			s[k] = c;
		}
		if(f) {
			max++;
		}
		if(max > 80) cout << "overflow" << endl;
		else {
			string ans;
			if(f) {
				ans += "1";
				max--;
			}
			rep(k,max) {
				ans += s[k] + '0';
			}
			cout << ans << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1208
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class AKthTerm {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1,
                         51};
        int K;
        cin >> K;
        cout << v[K - 1] << endl;

    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    AKthTerm solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e16
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define M 1010
ll a[M],b[M];
vvll v(M+1);
ll n,m,targ;
ll mem[1<<13];

int main(){
	IOS;
	rep(i,0,1<<12)mem[i]=md;
	cin>>n>>m;
	targ=(1<<n)-1;
	rep(i,0,m){
		cin>>a[i]>>b[i];
		rep(j,0,b[i]){ll x;cin>>x;x--;v[i].pb(x);}
	}
	mem[0]=0;
	rep(i,0,m){
		ll mask=0;
		rep(j,0,b[i])mask=mask|(1<<v[i][j]);
		rep(j,0,1<<n)mem[mask|j]=min(mem[j]+a[i],mem[mask|j]);
	}
	ll t=mem[targ];
	if(t==md)cout<<-1;
	else cout<<t;
	return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define bit(x,j) ((x>>j)&1)
using namespace std;
// bitset<8>set1(p);
// __builtin_popcountll(x);
// bitset<100> b("1010");
ll int mod=998244353;
int mul(ll int x, ll int y)
{
    return (x * 1ll * y) % mod;
}

int add(int x, int y)
{
    x += y;
    while(x >= mod) x -= mod;
    while(x < 0) x += mod;
    return x;
}

long long power(long long a, long long b,ll m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = mul(res,a);
        a = mul(a,a);
        b >>= 1;
    }
    return res%m;
    }


  ll int binomial(ll int n, ll int k) 
{ 
    ll int C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll int i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (int j = min(i, k); j > 0; j--) 
            C[j] = add(C[j],C[j-1]); 
    } 
    return C[k]%mod; 
} 
  vector<int> pr;
  bool prime[10000000];
void Sieve(ll int n) 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            pr.push_back(p);
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
}
 


//It reurns Fn,Fn+1
pair<int, int> fib (int n) {
    if (n == 0)
        return {0, 1};

    auto p = fib(n >> 1);
    int c = p.first * (2 * p.second - p.first);
    int d = p.first * p.first + p.second * p.second;
    if (n & 1)
        return {d, c + d};
    else
        return {c, d};
}
int sum(int n)  
{  
    if (n == 0)  
    return 0;  
    return (n % 10 + sum(n / 10));  
}  
ll int factorial(ll int n,ll int m) 
{ 
    ll int fact = 1; 
    for(int i=2;i<=n;i++) { 
        fact = (fact * i)%m; 
    } 
    return fact%m; 
} 

int reduce(int x, int y) 
{ 
    int d; 
    d = __gcd(x, y); 
  
    x = x / d; 
    y = y / d; 
    return x; 
} 

int binarySearch(int arr[], int l, int r, int x) 
{ 
    if (r >= l) { 
        int mid = l + (r - l) / 2; 
  
        if (arr[mid] == x) 
            return mid; 
  
        if (arr[mid] > x) 
            return binarySearch(arr, l, mid - 1, x); 
  
        // Else the element can only be present 
        // in right subarray 
        return binarySearch(arr, mid + 1, r, x); 
    } 
  
    // We reach here when element is not 
    // present in array 
    return -1; 
} 
vector<int>v[100005];
int vis[100005];
void dfs(int n)
{
   vis[n]=1;
   for(int i=0;i<v[n].size();i++)
   {
       if(vis[v[n][i]]==0)
       {
           dfs(v[n][i]);
       }
   }
}
int main() {
  ios;
  ll int n,m;
  cin>>n>>m;
  while(m--)
  {
      int l,r;
      cin>>l>>r;
      v[l].push_back(r);
      v[r].push_back(l);
  }
  ll int l=0;
  for(int i=1;i<=n;i++)
  {
      if(vis[i]==0)
      {
      l++;
      dfs(i);
      }
  }
  cout<<l-1<<endl;
}


Measured memory_bytes: 10008
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch FiveAntennas | diff FiveAntennas.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address FiveAntennas.cpp && ./a.out

/*
 
 4/7/2019
 
 19:55-19:59 WA
 
 */

int K;
LL A[5];

void solve() {
  cout<<(A[4]-A[0]<=K?"Yay!":":(")<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  REP(i,5) cin>>A[i];
  cin>>K;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
    int area = a*b;
    int length = (2*a)+(2*b);
    System.out.println(area +" "+length);
  }
}

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

int a[100000], n, m;
ll sum[300000], sum2[300000];

int dist(int a, int b, int c) {
	return min((b + m - a) % m, (b + m - c) % m + 1);
}
int main() {
	scanf("%d%d", &n, &m);
	rep(i, n)scanf("%d", &a[i]), a[i]--;
	rep(i, n - 1) {
		sum[a[i] + 1]++;
		if (a[i] < a[i + 1]) {
			sum[a[i + 1] + 1]--;
			sum2[a[i + 1] + 1] -= a[i + 1] - a[i];
		}
		else {
			sum[a[i + 1] + m + 1]--;
			sum2[a[i + 1] + m + 1] -= a[i + 1] + m - a[i];
		}
	}
	for (int i = 1; i < m * 2; i++) {
		sum[i] += sum[i - 1];
		sum2[i] += sum2[i - 1] + sum[i];
		if (i >= m)sum2[i - m] += sum2[i];
	}
	ll ans = 0;
	int id = max_element(sum2, sum2 + m) - sum2;
	rep(i, n - 1) {
		ans += dist(a[i], a[i + 1], id);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 4224
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var NM = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (N, M) = (NM[0], NM[1]);

        var ans = (N == M) ? "Yes" : "No";

        WriteLine(ans);
    }
}


Measured memory_bytes: 27768
s = input()
if s == 'SAT':
	print(1)
elif s == 'FRI':
	print(2)
elif s == 'THU':
	print(3)
elif s == 'WED':
	print(4)
elif s == 'TUE':
	print(5)
elif s == 'MON':
	print(6)
elif s == 'SUN':
	print(7)


Measured memory_bytes: 2940