akhauriyash/Code-Regression huggingface dataset:
/*
* @author:  codancer
* @createTime:  2020-04-12, 21:02:02
*/
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define fep(i,a,b) for(int i=(a);i>=(b);i--)
typedef vector<int> VI;
typedef vector<ll> VII;
typedef pair<int,int> pii;
ll qpow(ll a,ll b){
	ll ans=1;
	while(b){
		if(b&1) ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans%mod;
}
ll cnt[500005];
int main(){
	ll n,k;
	cin>>n>>k;
	ll ans=0;
	fep(i,k,1){
		cnt[i]=qpow(k/i,n);//gcd为i,2*i,3*i.....
		for(int j=2*i;j<=k;j+=i){
			cnt[i]-=cnt[j];
			cnt[i]+=mod;
			cnt[i]%=mod;
		}
		ans+=((ll)i*cnt[i])%mod;
		ans%=mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4372
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N, K = map(int, input().split())
    ans = [0] * N
    for _ in range(K):
        d = int(input())
        A = tuple(map(int, input().split()))
        for a in A:
            ans[a - 1] += 1
    print(len([a for a in ans if a == 0]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 9196
import java.io.*;
import java.util.*;
import java.lang.Math;
import java.util.Arrays;

public class Main {
    public static void main(final String[] args) {

        Scanner sc = new Scanner(System.in);

        
        while (true) {
            String S;
            int m;
            S = sc.next();
            if (S.equals("-"))
                break;
            m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                int h;
                h = sc.nextInt();
                String res;
                res = S.substring(h, S.length());
                res += S.substring(0, h);
                S = res;
            }
            System.out.println(S);
        }

    }
  
}


Measured memory_bytes: 26288
import Data.List
import Data.Array
import Data.Array.ST
import Control.Monad
import Control.Monad.ST
import qualified Data.ByteString.Char8 as B

main = do
    s <- B.getLine
    (x:y:_) <- map read.words<$>getLine::IO[Int]
    let (es,os) = (\(es,os)-> (map snd es, 0:map snd os)) $ partition (even.fst) $ zip [0..] $ unfoldr ps (0,s)
    putStrLn $ if dp x y es os then "Yes" else "No"

ps (i,bs)
    | B.null bs = if i==0 then Nothing else Just(i, (0,B.empty))
    | B.head bs == 'F' = ps (i+1, B.tail bs)
    | otherwise = Just (i, (0, B.tail bs))

dp tx ty (x:xs) (y:ys) = runST $ do
    ar <- newArray ((0,(-8000)),(8000,8000)) False::ST s (STUArray s (Int,Int) Bool)
    writeArray ar (0,x) True
    forM_ [(iv,j)|iv<-zip [1..] xs,j<-[(-mx)..mx]] $ \((i,v),j) -> do
        f1 <- if j-v>=(-mx) then readArray ar (i-1,j-v) else return False
        f2 <- if j+v<=mx then readArray ar (i-1,j+v) else return False
        writeArray ar (i,j) (f1 || f2)
    xf <- readArray ar (length xs, tx)
    writeArray ar (0,x) False
    writeArray ar (0,y) True
    forM_ [(iv,j)|iv<-zip [1..] ys,j<-[(-my)..my]] $ \((i,v),j) -> do
        f1 <- if j-v>=(-my) then readArray ar (i-1,j-v) else return False
        f2 <- if j+v<=my then readArray ar (i-1,j+v) else return False
        writeArray ar (i,j) (f1 || f2)
    yf <- readArray ar (length ys, ty)
    return (xf && yf)
    where
        mx = sum (x:xs)
        my = sum (y:ys)


Measured memory_bytes: 18172
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll K,ans=0; cin>>K;
  for(int i=1; i<=K; i++){
    for(int j=1; j<=K; j++){
      for(int k=1; k<=K; k++){
        ans+=gcd(gcd(i,j),k);
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3648
#include<stdio.h>

int linear_search(int *s, int n, int key)
{
    int i = 0;
    while(s[i] != key){
        i++;
    }
    if(i == n) return 0;
    return 1;
}

int main()
{
    int s[10001], key, i, n, q, cnt = 0;

    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d", &s[i]);
    }
    scanf("%d", &q);
    for(i = 0; i < q; i++){
        scanf("%d", &key);
        s[n] = key;
        if(linear_search(s, n, key)) cnt++;
    }
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 1836
import sys

def main(data):
    N, T = data[0].split(' ')
    routes = [(int(line.split(' ')[0]), int(line.split(' ')[1])) for line in data[1:int(N) + 1]]
    routes = list(filter(lambda x: x[1] <= int(T), routes))
    if len(routes) < 1:
        print('TLE')
    else:
        routes.sort(key=lambda x: x[0])
        print(routes[0][0])
    
if __name__ == '__main__':
    data = [line.strip() for line in sys.stdin]
    main(data)

Measured memory_bytes: 3064
import math
a,b,C=map(int, input().split())
c=math.radians(C)
S=a*b*math.sin(c)/2
d=math.sqrt(a**2+b**2-2*a*b*math.cos(c))
L=a+b+d
h = 2*S/a
print(S)
print(L)
print(h)


Measured memory_bytes: 5704
q,h,s,d = map(int,input().split())	
n = int(input())

q2 = q*8
h2 = h*4
s2 = s*2

k = min([q2,h2,s2,d])

q1 = q*4
h1 = h*2
r = min([q1,h1,s])

if n % 2 == 0:
    print((n//2)*k)
else:
    print((n//2)*k+r)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    ll N, A, B;
    cin >> N >> A >> B;
    if((B-A)%2 == 0){
        cout << (B-A)/2 << endl;
    }else{
        ll a = ((A-1)*2+1+(B-A))/2;
        ll b = ((N-B)*2+1+(B-A))/2;
        cout << min(a, b) << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin>>N;
    
    int res=N;
    for(int i=0;i<=N;i++){
        int cc=0;
        int t=i;
        while(t>0){
            cc+=t%6;
            t/=6;
        }
        t=N-i;
        while(t>0){
            cc+=t%9;
            t/=9;
        }
        if(res>cc)res=cc;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int l,n,x,w,a=0;
  cin>>l>>n;
  for(int i=0;i<n;i++){
    cin>>x>>w;
    a+=x*w;
  }
  if(a>0)cout<<1<<endl,cout<<-1<<' '<<a<<endl;
  if(a<0)cout<<1<<endl,cout<<1<<' '<<-a<<endl;
  if(a==0)cout<<'0'<<endl;
  return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>

int main()
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);

	if (a < b && b < c)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 2052
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
//#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
const long long int inf = 1e18+7;
const int mod = 998244353;

using namespace std;

inline ll int max(ll int a,ll int b) { return a>b?a:b; }
inline ll int min(ll int a,ll int b) { return a<b?a:b; }
inline ll int abs1(ll int a) { return a>0?a:-a; }

//const int maxn=

int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
	ll int x,k,d;
	
	while(cin>>x>>k>>d)
	{
		if(x<0)
			x=-x;
		
		ll int minn=inf;
		
		ll int cnt=min(k,x/d);
		
		x-=cnt*d;
		k-=cnt;
		
		
		
		if(k&1)
		{
			minn=min(minn,abs1(x+d));
			minn=min(minn,abs1(x-d));
		}
		else
		{
			minn=min(minn,x);
		}
		
		cout<<minn<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, k;
    cin >> a >> b >> k;
    int min_num = min(a, b);
    int i = min_num;
    int count = 0;
    while(i>0) {
        if(a%i==0&&b%i==0) {
            count++;
            if(count == k) {
                cout << i << endl;
                return 0;
            }
        }
        i--;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n+2];
  for(int i=0;i<n;i++)cin>>a[i];
 int dp[n];
  dp[0]=0;
  dp[1]=abs(a[1]-a[0]);
  for(int i=2;i<=n-1;i++){
    dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
  }
  cout<<dp[n-1]<<endl;
  return 0;
}

Measured memory_bytes: 1024
n, m = map(int,input().split())
total = 0
shops = [list(map(int,input().split())) for _ in range(n)]

shops.sort(key=lambda x:x[0])

for s in shops:
    if s[1] < m:
        m -= s[1]
        total += s[0]*s[1]
    else:
        total += s[0]*m
        print(total)
        exit()

Measured memory_bytes: 29152
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let a: i32 = read();
    let b: i32 = read();

    println!("{}", [a + b, a - b, a * b].iter().max().unwrap());
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

vector <vector <int> > edges;
vector <int> dist;
vector <int> indeg;
vector <bool> vis;

void dfs(int a){
    vis[a] = 1;
    
    for(int b : edges[a]){
        dist[b] = max(dist[b] , dist[a] + 1);
        indeg[b]--;
        
        if(indeg[b] == 0)
        {
            dfs(b);
        }
    }
    
}

int main()
{
    int n , m ;
    cin>>n>>m;
    edges = vector <vector <int > > (n);
    indeg = vector <int> (n);
    dist = vector <int> (n , 0);
    vis = vector <bool> (n , false);

    while(m--){
        int a , b;
        cin>>a>>b;
        a-- , b--;
        edges[a].push_back(b);
        indeg[b]++;
    }
    
    for(int i = 0; i < n ; i++)
    {
        if(!vis[i] && indeg[i] == 0){
            dfs(i);
        }
    }
    
    int ans = 0;
    for(int a : dist)
        ans = max(ans, a);
    
    cout<<ans<<endl;
    
    
    
    return 0;
}

Measured memory_bytes: 9600
n = int(input())
a = list(map(int, input().split()))
n = len(a)
a.sort()
a.append(-1)
ans = 0
i = 0
while i < n:
    cnt = 1
    while a[i] == a[i+1]:
        cnt += 1
        i += 1
        if i == len(a)-1:
            break
    if cnt > a[i]:
        ans += cnt - a[i]
    elif cnt < a[i]:
        ans += cnt
    i += 1
print(ans)

Measured memory_bytes: 14692
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << '\n'
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int a, b;
    cin >> a >> b;
    if (a < 10 && b < 10) {
        cout << a * b << endl;
    } else {
        cout << -1 << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;


int main(){

	vector<int> zeronum;
	zeronum.push_back(0);
	int count = 0;
	for(int i = 1; i <= 5000000; i++){
		int tmp = i;
		while(tmp % 5 == 0){
			count++;
			tmp /= 5;
		}
		zeronum.push_back(count);
	}

	int n = 0;
	while(cin >> n && n != 0){
		cout << zeronum[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 34024
import java.util.*;


public class Main {
    public static void main(String[] args) {
      
        Scanner sc = new Scanner(System.in);
        String[] S = sc.nextLine().split("");
        String[] T = sc.nextLine().split("");
        
        int count = 0; 
        
        for (int i = 0; i < 3; i++) {
            
            if (Arrays.asList(S[i]).contains(T[i])) {
                count++;
            }
            
        }
        System.out.println(count);

    }
}

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

typedef long long ll;
typedef long double ld;
typedef array<ll,2> pll;
const ll KMAX=100005,MOD=1e9+7;
ll dp[101][KMAX],sum[KMAX];
int main()
{
    ll n,k,x;
    cin>>n>>k;
    dp[0][0]=1;
    for(ll i=1;i<=n;i++){
        sum[0]=dp[i-1][0];
        for(ll j=1;j<=k;j++)
            sum[j]=(sum[j-1]+dp[i-1][j])%MOD;
        cin>>x;
        for(ll j=0;j<=k;j++){
            dp[i][j]=(sum[j]-((j-x-1>=0)?sum[j-x-1]:0)+MOD)%MOD;
        }
    }
    cout<<dp[n][k];
    return 0;
}

///ABCDEFGHIJKLMNOPQRSTUVWXYZ
///11110111101000000000000000


Measured memory_bytes: 82476
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    string S;
    cin >> S;
    if (S[0] == 'S') cout << "Cloudy" << endl;
    else if (S[0] == 'C') cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
using namespace std;
int main()
{
    int N,M;
    long long x,sum=0;
    priority_queue<int> q1;
    cin>>N>>M;
    for (int i=0;i<N;i++)
    {
        cin>>x;
        q1.push(x);
    }
    for (int i=0;i<M;i++)
    {
        int temp=q1.top();
        q1.pop();
        temp=temp/2;
        q1.push(temp);
    }
    while(!q1.empty())
    {
        sum+=q1.top();
        q1.pop();
    }
    cout<<sum<<endl;
}

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

int main(){
    int n,k;
    while(cin>>n>>k){
        int total[100010]={0},ip[100010]={0};
        if(n==0 && k==0)break;
        for(int i=0;i<n;i++){
            cin>>ip[i];
            if(i==k-1){
                for(int j=0;j<k;j++){
                    total[i]+=ip[i-j];
                }
            }
            if(i>k-1){
                total[i]=total[i-1]-ip[i-k]+ip[i];
            }
        }
        sort(total, total+n, greater<int>());
        cout<<total[0]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1964
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
long long calc(long long n, long long k)
{
    switch (k)
    {
    case 1:
        return n;
    case 2:
        return n * (n - 1) / 2;
    case 3:
        return n * (n - 1) * (n - 2) / 6;
    }
    return 1;
}

long long calc2(long k)
{
    switch (k)
    {
    case 1:
        return 9;
    case 2:
        return 81;
    case 3:
        return 729;
    }
    return 1;
}

long long count(std::string s, long i, long n, long k)
{
    if (n < k)
    {
        return 0;
    }
    if (k == 0)
    {
        return 1;
    }
    if (n == 1)
    {
        return s[i] - '0';
    }
    return ((s[i] - '1') <= 0 ? 0 : (s[i] - '1')) * calc(n - 1, k - 1) * calc2(k - 1) + (s[i] == '0' ? count(s, i + 1, n - 1, k) : calc(n - 1, k) * calc2(k)) + (s[i] == '0' ? 0 : count(s, i + 1, n - 1, k - 1));
}

int main()
{
    long long n, ans, k;
    std::string s;
    std::cin >> s;
    std::cin >> k;
    n = s.length();
    ans = count(s, 0, n, k);

    std::cout << ans << std::endl;
}

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

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = (int)1e9 + 7;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, y;
    cin >> n >> y;

    REP(i, n+1){
        REP(j, n-i+1){
            int k = n-i-j;
            if(k < 0) break;

            if(i * 10000 + j * 5000 + k * 1000 == y){
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

struct color_max {
    int color;
    int max_value;
    color_max(int color, int max_value) : color(color), max_value(max_value) {}
};

bool operator<(const color_max &a, const color_max &b)
{
    return a.max_value < b.max_value;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    FOR(i, 0, n-1) cin >> a[i];

    vector<int> dp(n);
    vector<int> color(n);

    multiset<int> color_set;
    set<color_max> color_value_set;
    int ans = 0;
    int color_max = 0;
    FOR(i, 0, n-1) {
        auto itr = color_set.upper_bound(-a[i]);  
        if(itr==color_set.end()) {
            color_set.insert(-a[i]);
            color_max++;
        } else {
            color_set.erase(itr);
            color_set.insert(-a[i]);
        }
    }

    cout << color_max << endl;

    return 0;
} 

Measured memory_bytes: 6144
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	var n int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &n)

	as := make([]int, n)
	for i := 0; i < n; i++ {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d", &as[i])
	}
	sort.Sort(sort.IntSlice(as))
	m := as[len(as)-1]
	as = as[0 : len(as)-1]
	index := sort.SearchInts(as, m/2)

	if index == len(as) {
		fmt.Println(m, as[index-1])
		return
	}
	if index == 0 {
		fmt.Println(m, as[index])
		return
	}
	if float64(as[index])-float64(m)/2.0 < float64(m)/2.0-float64(as[index-1]) {
		fmt.Println(m, as[index])
	} else {
		fmt.Println(m, as[index-1])
	}
}

func max(ns ...int) int {
	ret := math.MinInt64
	for _, n := range ns {
		if n > ret {
			ret = n
		}
	}
	return ret
}

func abs(n int) int {
	if n >= 0 {
		return n
	}
	return -n
}


Measured memory_bytes: 5504
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 2019;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

int powMod(int n, int p) {
  int res = 1;
  while (p) {
    if (p & 1) (res *= n) %= MOD;
    (n *= n) %= MOD;
    p >>= 1;
  }
  return res;
}
int invMod(int n) {
  return powMod(n, MOD - 2);
}

signed main() {
  string s;
  cin >> s;

  int N = s.size();

  map<int, int> m;
  m[0]++;
  vector<int> v(N+1, 0);

  int ten = 0;
  RREP(i, N){
    int d = s[i]-'0';
    v[i] = (d*powMod(10, ten)+v[i+1])%MOD;
    ten++;
    m[v[i]]++;
  }

  int ans = 0;
  for(auto p : m){
    ans += p.second*(p.second-1)/2;
  }

  cout << ans << "\n";


  return 0;
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    lint N, K;
    cin >> N >> K;
    vector<lint> A(N, 0);
    rep(i, N) cin >> A[i];

    for (int i = K; i < N; i++) {
        if (A[i] > A[i - K]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;

  int n,x,t;
  cin >> n >> x >> t;

  COUT( (n / x + (n % x > 0)) * t );
  return 0;
}

Measured memory_bytes: 3604
# include<iostream>
# include<cmath>
# include<algorithm>
using namespace std;
const int INF = pow(10,9)+7; 
int main ()
{
	 int K,N;
	 cin>>K>>N;
	 int A[2*N];
	 int t =0;
	 for(int i=0;i<N;i++)
	 {
	      int v;
	      cin>>v;
	      A[t++] = v;
	      if(v!=0)
	      A[t++] = v-K;
	 }
	 sort(A,A+t);	
	 int MIN = INF;
	 for(int i=0;i<N;i++)
	 {
	 	 MIN = min(MIN,A[i+N-1]-A[i]);
	 }	 
	 cout<<MIN<<endl; 	
}

Measured memory_bytes: 1792
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
//template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
//template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll mod=1e9+7;

int main()
{
    string s;
    cin >> s;
    bool flag=true;
    for(ll i=0;i<s.length();i+=2){
        if(s[i]!='h'|| s[i+1]!='i'){
            flag=false;
            break;
        }
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
} 

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

int main()
{
  int n;
  cin >> n;
  for (int dataset=0; dataset<n; dataset++)
  {
    int triangle[3];
    cin >> triangle[0] >> triangle[1] >> triangle[2];
    for (int i=0; i<3; i++)   //sort
    {
      int tmp;
      for (int j=i; j != 0 && triangle[j] > triangle[j-1]; j--)
      {
        tmp = triangle[j];
        triangle[j] = triangle[j-1];
        triangle[j-1] = tmp;
      }
    }

    if ( triangle[0]*triangle[0] == triangle[1]*triangle[1] + triangle[2]*triangle[2] )
    {
      cout << "YES" << endl;
    }
    else
    {
      cout << "NO" << endl;
    }
  }  
}

Measured memory_bytes: 1152
n=int(input())
ab = []
for _ in range(n):
    a, b = (int(x) for x in input().split())
    ab.append([a-b, a+b])
ab = sorted(ab, key=lambda x: x[1])

right_reach = ab[0][1]

count = 0

for i in range(1,n):
    if ab[i][0] < right_reach:
        count += 1
    else:
       right_reach =  ab[i][1]
print(n-count)

Measured memory_bytes: 67032
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1000000000
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    cin>>str;
    if(str[1]=='B') cout<<"ARC";
    else cout<<"ABC";

    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;


int main(){
    string s1, s2;
    int X, N;
    cin >> X >> N;
    vector<int> p(N);
    rep(i, N) cin >> p[i];
    for(int i = 0; X + i < 150 && X - i >= 0; i++){
        auto itr2 = find(all(p), X - i);
        if(itr2 == p.end()){
            cout << X - i << endl;
            return 0;
        }
        auto itr = find(all(p), X + i);
        if(itr == p.end()){
            cout << X + i << endl;
            return 0;
        }  
    }
}

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

#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;



int main()
{
    int a, b;
    cin >> a >> b;
    if (a <= 9 and b <= 9) cout << a*b << endl;
    else cout << -1 << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <string.h>
#include <math.h>
#include <string>
using namespace std;

int main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
 
	long h,k;
  cin>>h>>k;
  long hk = h*k;
  if(h>=2 && k>=2){
    if(hk%2 == 0)
      cout<<hk/2;
    else
    {
      cout<<hk/2+1;
    }
  } else{
    cout<<"1";
  }
  

  return 0;
}

Measured memory_bytes: 384
/**
 *    author:  tourist
 *    created: 28.04.2018 15:49:18       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  map<long long, int> mp;
  mp[0] = 1;
  long long s = 0;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    s += x;
    ans += mp[s];
    mp[s]++;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 12800
using System;
using System.Linq;

class B
{
    static void Main()
    {
        Console.ReadLine();
        var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var d = a.Where((pi, i) => pi != i + 1).Count();
        Console.WriteLine(d == 0 || d == 2 ? "YES" : "NO");
    }
}


Measured memory_bytes: 13396
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main() {
  int R;
  cin >> R;
  if (R < 1200) {
    cout << "ABC" << endl;
  } else if (R < 2800) {
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }
  return 0;
}

Measured memory_bytes: 764
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<ll> par;
//     vector<ll> siz;
    
//     UnionFind(ll N): par(N), siz(N,1) {
//         for (ll i=0;i<N;i++) par[i] = i;
//     }

//     ll root(ll x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         if (rx == ry) return;
//         // if (siz[rx] < siz[ry]) swap(rx,ry);
//         par[rx] = ry;
//         siz[ry] += siz[rx];
//     }

//     bool same(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         return rx == ry;
//     }

//     ll size(ll x) {
//         return siz[root(x)];
//     }
// };

//     vector<ll> par;
//     vector<ll> siz;
    
//     UnionFind(ll N): par(N), siz(N,1LL) {
//         for (ll i=0;i<N;i++) par[i] = i;
//     }

//     ll root(ll x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//         siz[ry] += siz[rx];
//     }

//     bool same(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         return rx == ry;
//     }

//     ll size(ll x) {
//         return siz[root(x)];
//     }
// };

int main(void) {
    int A, B, K;
    cin >> K >> A >> B;
    if (B/K - A/K == 0 && !(B%K == 0 || A%K == 0)) cout << "NG" << endl;
    else cout << "OK" << endl;

    return 0;
}


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

int main() {
    long n, m, a, b, cnt = 0, ans = 0;
    cin >> n >> m;
    map<long, long> mp;
    rep(i, n) {
        cin >> a >> b;
        mp[a] += b;
    }
    for(pair<long, long> p : mp) {
        if(cnt + p.second >= m) {
            ans += p.first * (m - cnt);
            break;
        }
        cnt += p.second;
        ans += p.first * p.second;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
// #include "bits:stdc++.h"
using namespace std;
#define pb push_back
#define LLINF 1234567890987654321
#define INF 1234567890
#define f first
#define s second
#define flase false
typedef long long ll;
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
ll n, m, mini[100001];
ll co = LLINF, ans;
int main()
{
	cin >> n >> m;
	for(ll i = 0; i < n; i++)mini[i] = n+2;
	for(ll i = 0; i < m; i++)
	{
		ll n1, n2;
		cin >> n1 >> n2;
		if(n1 > n2)swap(n1, n2);
		mini[n1] = min(mini[n1], n2);
		//mini[n2] = min(mini[n2], n1);
	}
	for(ll i = 1; i <= n; i++)
	{
		co = min(co, mini[i]);
		if(i+1 == co)
		{
			ans ++;
			co = LLINF;
		}
	}
	cout << ans << "\n";
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define FORR(i,a,b) for (int i = b - 1; i >= a; --i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)

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

	vector<ll> C(N), P(N);
	REP(i, N) {
		cin >> P[i];
		P[i] -= 1;
	}
	REP(i, N) cin >> C[i];

	ll ans = numeric_limits<ll>::min();
	REP(sp, N) {
		int x = sp;
		vector<ll> s;
		ll tot = 0;
		do {
			x = P[x];
			s.push_back(C[x]);
			tot += C[x];
		} while (x != sp);

		int l = s.size();
		ll t = 0;
		REP(i, l) {
			if (i + 1 > K) break;
			t += s[i];
			ll now = t;
			if (tot > 0) {
				ll e = (K - (i + 1)) / l;
				now += tot * e;
			}
			ans = max(ans, now);
		}
	}

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

Measured memory_bytes: 3800
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#define LL long long
#define MP make_pair
#define PII pair<int, int>
#define F first
#define S second
using namespace std;
int n;
int a[110];
int t=0;
int r=0;
int rr=1e9;
int main()
{
	cin >>n;
	for (int i=0;i<n;i++) cin >>a[i],t+=a[i];
	for (int i=0;i<n;i++) if (abs(a[i]*n-t)<rr) rr=abs(a[i]*n-t),r=i;
	cout <<r;
	return 0;
}

Measured memory_bytes: 256
line = input()
a, b, k = line.split(" ")
a = int(a)
b = int(b)
k = int(k)

if k >= a+b:
    print(0,0)
else:
    if a - k < 0:
        print(0, b-(k-a))
    else:
        print(a - k, b)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int64_t gcd(int64_t a, int64_t b) {
	if (a % b == 0) {
		return b;
	} else {
		return gcd(b, a % b);
	}
}

int main() {
	//input
	int64_t K;
	cin >> K;

	//calculation
	int64_t output = 0;

	for (int64_t i = 1; i <= K; i++) {
		for (int64_t j = 1; j <= K; j++) {
			for (int64_t k = 1; k <= K; k++) {
				output += gcd(i, gcd(j, k));
			}
		}
	}

	//output
	cout << output << endl;


	return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



void _main() {
        int x; cin >> x;
        cout << 1 - x;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

Measured memory_bytes: 3640
A=list(map(int,input().split()))
if A[0]==A[1]==5 and A[2]==7:
	print("YES")
elif A[0]==A[2]==5 and A[1]==7:
	print("YES")
elif A[1]==A[2]==5 and A[0]==7:
	print("YES")
else:
	print("NO")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define sh cin.tie(0); cin.sync_with_stdio(0); cout.tie(0);
#define FILE freopen("test.in", "r", stdin);
#define vprint(v) for (int ii = 0; ii < v.size(); ii++){cout << v[ii] << " ";}
#define debugv(v) if (v.size() != 0) {cout << "[ "; for (int __ = 0; __ < (int)(v.size()) - 1; __++){cout << v[__] << ", ";} cout << v[(int)(v.size()) - 1] << " ]" << endl;} else {cout << "[]" << endl;}
#define debug cout << "-----------------------------------------------" << endl;
#define print1(a) cout << "{ " << a << " }" << endl;
#define print2(a, b) cout << "{ " << a << ", " << b << " }" << endl;
#define print3(a, b, c) cout << "{ " << a << ", " << b << ", " << c << " }" << endl;
#define print4(a, b, c, d) cout << "{ " << a << ", " << b << ", " << c << ", " << d << " }" << endl;
using namespace std;
#define int long long
const int INF = 1e9 + 228;
const int MAXN = 1e5 + 228;
string n;
int k;

void solve1() {
	int ans = 0;
	for (int i = 0; i < n.size(); i++) {
		if (i != 0) {
			ans += 9;
			continue;
		}
		int f = n[0] - '0';
		ans += f;
		
	}
	cout << ans << endl;
}

void solve2() {
	int ans = 0;
	for (int i = 0; i < n.size(); i++) {
		for (int j = i + 1; j < n.size(); j++) {
			if (i != 0) {
				ans += 81;
				continue;
			}
			int f = n[0] - '0';
			ans += (f - 1) * 9;
			bool flag = 1;
			for (int y = 1; y < j; y++) {
				if (n[y] != '0')
					flag = 0;
			}
			if (!flag) {
				ans += 9;
				continue;
			}
			int s = n[j] - '0';
			ans += s;
		}
	}
	cout << ans << endl;
}

void solve3() {
	int ans = 0;
	for (int i = 0; i < n.size(); i++) {
		for (int j = i + 1; j < n.size(); j++) {
			for (int l = j + 1; l < n.size(); l++) {
				if (i != 0) {
					ans += 729;
					continue;
				}
				int f = n[0] - '0';
				f = max(f - 1, 0LL);
				ans += f * 81;
				if (n[0] == '0')
					continue;
				bool flag = 1;
				for (int y = 1; y < j; y++) {
					if (n[y] != '0')
						flag = 0;
				}
				if (!flag) {
					ans += 81;
					continue;
				}
				int s = n[j] - '0';
				s = max(s - 1, 0LL);
				ans += s * 9;
				if (n[j] == '0')
					continue;
				flag = 1;
				for (int y = j + 1; y < l; y++) {
					if (n[y] != '0')
						flag = 0;
				}
				if (!flag) {
					ans += 9;
					continue;
				}
				int t = n[l] - '0';
				ans += t;
			}
		}
	}
	cout << ans << endl;
}

string tos(int x) {
	string res = "";
	while (x > 0) {
		res += (x % 10);
		x /= 10;
	}
	return res;
}

signed main()
{
#ifdef LOCAL
    FILE;
#endif
    sh;
    cin >> n >> k;
    string kek = "";
    int id = -1;
    for (int i = 0; i < n.size(); i++) {
    	if (n[i] != '0' && id == -1) {
    		id = i;
    		break;
    	}
    }
    for (int i = id; i < n.size(); i++) {
    	kek += n[i];
    }
    n = kek;
    if (k == 1) {
    	solve1();
    } else if (k == 2) {
    	solve2();
    } else {
    	solve3();
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	int N;
	List<Set<Integer>> groups = new ArrayList<>();

	Main() {
		Scanner in = new Scanner(System.in);
		N = in.nextInt();
		in.close();
	}

	void makeGroups() {
		if (N % 2 == 0) {
			for (int i = 0; i < N / 2; ++i) {
				Set<Integer> set = new HashSet<>();
				set.add(i + 1);
				set.add(N - i);
				this.groups.add(set);
			}
		} else {
			for (int i = 0; i < N / 2; ++i) {
				Set<Integer> set = new HashSet<>();
				set.add(i + 1);
				set.add(N - i - 1);
				this.groups.add(set);
			}
			Set<Integer> s = new HashSet<>();
			s.add(N);
			this.groups.add(s);
		}
	}

	void show() {
		List<String> results = new ArrayList<>();
		for (int i = 0; i < this.groups.size(); ++i) {
			Set<Integer> grA = this.groups.get(i);
			for (int j = i + 1; j < this.groups.size(); ++j) {
				Set<Integer> grB = this.groups.get(j);
				for (Integer a : grA) {
					for (Integer b : grB) {
						results.add(a + " " + b);
					}
				}
			}
		}
		System.out.println(results.size());
		for (String line : results) {
			System.out.println(line);
		}
	}

	public static void main(String[] args) {
		Main ins = new Main();
		ins.makeGroups();
		ins.show();
	}

}


Measured memory_bytes: 25044
#include  <functional>
#include  <algorithm>
#include  <exception>
#include  <stdexcept>
#include  <streambuf>
#include  <iterator>
#include  <string.h>
#include  <stdlib.h>
#include  <typeinfo>
#include  <valarray>
#include  <iostream>
#include  <sstream>
#include  <istream>
#include  <stdio.h>
#include  <climits>
#include  <clocale>
#include  <complex>
#include  <csetjmp>
#include  <csignal>
#include  <cstdarg>
#include  <cstddef>
#include  <ctype.h>
#include  <cassert>
#include  <cstdlib>
#include  <utility>
#include  <cstring>
#include  <numeric>
#include  <ostream>
#include  <cwctype>
#include  <fstream>
#include  <iomanip>
#include  <math.h>
#include  <bitset>
#include  <cctype>
#include  <string>
#include  <vector>
#include  <limits>
#include  <locale>
#include  <memory>
#include  <cerrno>
#include  <time.h>
#include  <iosfwd>
#include  <cfloat>
#include  <cstdio>
#include  <cwchar>
#include  <cmath>
#include  <ctime>
#include  <deque>
#include  <queue>
#include  <stack>
#include  <list>
#include  <ios>
#include  <map>
#include  <set>
#include  <new>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
using namespace std;
int n,m;
int main()
{
    cin>>n;
    bool flag=0;
    for(int i=0;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
        m=m+(y-x+1);
    }
    cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <functional>
#include <utility>
#include <unordered_map>
#include <map>
#include <set>
#include <array>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
struct drug {
	int a, b, cost;
};

int dp[41][401][401];
int main() {
	int N, Ma, Mb;
	cin >> N >> Ma >> Mb;
	vector<drug> all(N);
	for (int i = 0; i < 41; i++)for (int j = 0; j < 401; j++)for (int k = 0; k < 401; k++)dp[i][j][k] = INF/2;
	for (int i = 0; i < N; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		all[i] = { a,b,c };
	}
	dp[0][0][0] = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 401; j++)for (int k = 0; k < 401; k++) {
			if (dp[i][j][k] != INF/2) {
				dp[i + 1][j + all[i].a][k + all[i].b] = min(dp[i + 1][j + all[i].a][k + all[i].b], dp[i][j][k] + all[i].cost);
				dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
			}
		}
	}
	int ans = INF/2;
	for (int i = 1; Ma*i < 401 && Mb*i < 401; i++) {
		ans = min(dp[N][Ma*i][Mb*i], ans);
	}
	if (ans == INF/2)cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 25984
import sys


# N, M = map(int, input().split())
# nums = list(map(int, input().split()))
# nums_2d = [list(map(int, input().split())) for _ in range(N)]


def main():
    c = input()
    alphabets = "abcdefghijklmnopqrstuvwxyz"

    idx = alphabets.index(c)
    print(alphabets[idx + 1])


if __name__ == '__main__':
    main()


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


Measured memory_bytes: 2116
N, W = map(int, input().split())
w, v = [0], [0]
for i in range(N):
    w_i, v_i = map(int, input().split())
    w.append(w_i)
    v.append(v_i)
sum_V = sum(v)
DP = [[float('inf') for c in range(sum_V+1)] for i in range(N+1)]

for i in range(0, N+1):
    for c in range(0, sum_V+1):
        if i == 0:
            if c == 0:
                DP[i][c] = 0
        elif c - v[i] < 0:
            DP[i][c] = DP[i-1][c]
        else:
            DP[i][c] = min(DP[i-1][c], DP[i-1][c-v[i]] + w[i])
ans = sum_V
while (DP[N][ans] > W):
    ans -= 1
print(ans)

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

int dfs(int cur, int a, int b, int c, int N, int A, int B, int C, int l[]){
  	if (cur == N){
    	if (min({a, b, c}) > 0)
        	return abs(a-A)+abs(b-B)+abs(c-C)-30;
    	else
            return 1000000000;
    }
    int ret0 = dfs(cur+1, a, b, c, N, A, B, C, l);
    int ret1 = dfs(cur+1, a+l[cur], b, c, N, A, B, C, l) + 10;
    int ret2 = dfs(cur+1, a, b+l[cur], c, N, A, B, C, l) + 10;
    int ret3 = dfs(cur+1, a, b, c+l[cur], N, A, B, C, l) + 10;
    return min({ret0, ret1, ret2, ret3});
}

int main(){
  	cin.tie(0);
  	ios::sync_with_stdio(false);
	int N, A, B, C;
  	cin >> N >> A >> B >> C;
  	int l[N];
  	for (int i = 0; i < N; i++) cin >> l[i];
  	int ans = dfs(0, 0, 0, 0, N, A, B, C, l);
	cout << ans << endl;
	return 0;
}

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

using namespace std;

const int MAX_N = 3005;

int n;

char ans[MAX_N];
char a[MAX_N], b[MAX_N];
int dp[MAX_N][MAX_N];

int main() {
  scanf("%s%s", &a, &b);
  for (int i = 1; i <= strlen(a); ++i) {
    for (int j = 1; j <= strlen(b); ++j) {
      if (a[i - 1] == b[j - 1]) {
        dp[i][j] = 1 + dp[i - 1][j - 1];
      } else {
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
      }
    }
  }
  int n = strlen(a), m = strlen(b), len = 0;
  while (n > 0 && m > 0) {
    if (a[n - 1] == b[m - 1]) {
      ans[++len] = a[n - 1];
      --n;
      --m;
    } else {
      if (dp[n][m] == dp[n - 1][m]) {
        --n;
      } else if (dp[n][m] == dp[n][m - 1]) {
        --m;
      }
    }
  }
  reverse(ans + 1, ans + len + 1);
  printf("%s", ans + 1);
  return 0;
}


Measured memory_bytes: 35456
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
using namespace std;
int main(){
    int n, a, b;
    cin >> n >> a >> b;
    int sum = 0;
    int ans = 0;

    for(int i = 1; i < n + 1; i++){
        sum = i/10000 + (i%10000)/1000 + (i%1000)/100 + (i%100)/10 + i%10;
        if(sum >= a && b >= sum) ans += i;
    }
    cout << ans << endl;
}

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

// #define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define vin(v,n) copy_n(istream_iterator<int>(cin),n,back_inserter(v));
#define all(v) v.begin(),v.end()
#define INF 2000000000
#define MOD 1000000007
#define ll long long 
#define vi vector<int>
#define ii pair<int,int>
#define si set<int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define f1(i,a,b) for(int i = a;i<b;i++)
#define f2(i,a,b) for(int i = a;i<=b;i++)

using namespace std;

int32_t main() 
{
	IOS;
	int n, k;
	cin >> n >> k;
	vi v;
	vin(v,n);
	vi dp(n+1, INF);
	dp[0] = 0;
	dp[1] = abs(v[1]-v[0]);
	f1(i,2,n)
	{
		int x = INT_MAX;
		f2(j,1,k)
			if(i-j>=0)
				x = min(x, dp[i-j]+abs(v[i]-v[i-j]));
		dp[i] = x;
	}
	
	cout << dp[n-1];

}


Measured memory_bytes: 1144