akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int DivCounter(int n) {
	int count = 0;
	for (int i = 1; i < n + 1; ++i)
	{
		if(n%i==0) ++count;
	}
	return count;
}

int main() {
	int n; cin >> n;
	int ans;
	for (int i = 1; i < n+1; ++i)
	{
		if(i%2==1)
		{
			if(DivCounter(i)==8) ans++;
		}
	}

    
    cout << ans << endl;
	
	



}

Measured memory_bytes: 256
#include <iostream>
#include<stdlib.h>
#include<math.h>
using namespace std;
int x[100000];
int s;
int dis(int s,int a,int b);
int main(void){
    // Your code here!
    int n,k;
    bool flag=true;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>x[i];
        if(x[i-1]<0&&x[i]>=0){
            s=i;
            flag=false;
        }
    }
    if(flag)if(x[0]>=0)s=0;
    else s=n;
    
    int dis_kouho=900000001;
    
    int t=fmax(0,s-k);
    for(int i=fmin(s,n-k);i>t-1;i--){
        dis_kouho=fmin(dis_kouho,dis(s,i,i+k-1));
    }
    cout<<dis_kouho;
}
int dis(int s,int a,int b){
    if(a==s||b==s-1) return fmax(abs(x[a]),abs(x[b]));
    return fmin(abs(x[a]),abs(x[b]))+abs(x[a])+abs(x[b]);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define INF 1000000000000
typedef long long ll;

int main()
{
  int n, m;
  string s;
  vector<char> a(26);

  cin >> s;

  REP(i, ('z' - 'a') + 1)
  {
    a[i] = 'a' + i;
  }
  REP(i, s.size())
  {
    a[s[i] - 'a'] = '0';
  }
  REP(i, a.size())
  {
    if (a[i] != '0')
    {
      cout << a[i] << endl;
      break;
    }
    else if (i == a.size() - 1)
    {
      cout << "None" << endl;
    }
  }
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
# define maxh 2000
# define maxw 2000

int main() {
  int H,W,maxi(0);
  char S[maxh][maxw];
  cin>>H>>W;
  for (int h(0);h<H;h++)
    for (int w(0);w<W;w++)
      cin>>S[h][w];

  int l[H][W]={0};
  int r[H][W]={0};
  int u[H][W]={0};
  int s[H][W]={0};
  for (int h(0);h<H;h++){
    for (int w(0);w<W;w++){
      if (S[h][w]=='#') l[h][w]=0;
      else if (w==0) l[h][w]=1;
      else l[h][w]=l[h][w-1]+1;

      if (S[h][w]=='#') s[h][w]=0;
      else if(h==0) s[h][w]=1;
      else s[h][w]=s[h-1][w]+1;
    }
  }
  for (int h(H-1);h>=0;h--){
    for (int w(W-1);w>=0;w--){
      if (S[h][w]=='#') r[h][w]=0;
      else if (w==W-1) r[h][w]=1;
      else r[h][w]=r[h][w+1]+1;

      if (S[h][w]=='#') u[h][w]=0;
      else if(h==H-1) u[h][w]=1;
      else u[h][w]=u[h+1][w]+1;
      maxi=max(maxi,l[h][w]+r[h][w]+u[h][w]+s[h][w]-3);
    }
  }
  cout << maxi;
}


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

int main(){
	long X, Y;
	cin >> X >> Y;

	double buf = 2*X-Y/2;
	bool flg = false;
	if(Y%2 == 0){
		if(0<=buf && buf <=X) flg = true;
	}

	if(flg){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


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

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
namespace __gnu_pbds {
    typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
}
using namespace __gnu_pbds;

#define endl '\n'
#define ll long long
#define LSB __builtin_ctzll
#define sc(a) scanf("%d",&a)
#define MSB 63-__builtin_clzll
#define scl(a) scanf("%lld",&a)
#define BITS __builtin_popcountll
#define mem(a , v)  memset(a , v , sizeof(a))
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int MOD = 1e9+7;
const int MAX = 1e5+55;
const int INF = 1e9+77;
const ll INFINF = 1e18+1e17;
const double PI = acos(-1.0);

ll power(ll x,ll y){
         if(y==0)
         return 1;
         ll s=power(x,y/2);
         s*=s;
         if(y&1)
         s*=x;
         return s;
}






int main(){

ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//freopen("digits.in" , "r" , stdin);
//freopen("digits.out" , "w" , stdout);


     bool can=0;
     ll ans=INFINF;

     ll n,m,k;
     cin>>n>>m>>k;
     ll x[n][m+1];
     for(int i=0;i<n;i++){
        for(int j=0;j<=m;j++){
            cin>>x[i][j];
        }
     }

     for(int mask=0;mask<(1<<n);mask++){

        ll now[m];
        mem(now,0);
        ll how=0;
        for(int i=0;i<n;i++){
            if(mask&(1<<i)){
                for(int j=1;j<=m;j++){
                    now[j-1]+=x[i][j];
                }
                how+=x[i][0];
            }
        }

        bool is=1;
        for(int i=0;i<m;i++){
            if(now[i]<k){
                is=0;
                break;
            }
        }
        if(is){
            can=1;
            ans=min(ans,how);
        }

     }



     if(!can){
        cout<<-1;
        return 0;
     }
     cout<<ans;






     return 0;

}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main () {
  string A, B, C;
  cin >> A >> B >> C;
  char a = A.at(0) - 'a' + 'A', b = B.at(0) - 'a' + 'A', c = C.at(0) - 'a' + 'A';
  cout << a << b << c << endl;
  return 0;
}

Measured memory_bytes: 384
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ x, y ] <- readInts
	print $ which x (-1) $ x `mod` y /= 0


Measured memory_bytes: 508
#include<stdio.h>
#include<stdlib.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

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

typedef struct{
    int n; //ブロック中の文字数
    int c; //ブロックの文字
    int begin; //ブロック開始場所の添字
    int end; //ブロック終了場所の添字
}block;

void array_blocked_3(int* S, int N, block* A){
    int a=0;
    int count=1;

    A[a].begin=0;

    for(int i=1;i<N;i++){
        if(S[i-1]==S[i]){
            count++;
        }
        else{
            A[a].n=count;
            A[a].c=S[i-1];
            A[a].end=i-1;
            a++;
            A[a].begin=i;
            count=1;
        }
    }
    A[a].n=count;
    A[a].c=S[N-1];
    A[a].end=N-1;
    return;
}

//昇順
int asc(const void* a, const void* b){
    return *(int*)a-*(int*)b;
}

//ブロック降順
int block_asc(const void* a, const void* b){
    block p=*(block*)a;
    block q=*(block*)b;
    return q.n-p.n;
}

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

    //奇数番目、偶数番目の要素数
    int n=N/2;

    //奇数番目、偶数番目の数列を分けて格納→昇順ソート
    int* odd;
    int* even;
    NEW(odd,n);
    NEW(even,n);
    for(int i=0;i<n;i++){
        scanf("%d",&odd[i]);
        scanf("%d",&even[i]);
    }

    qsort(odd,n,sizeof(int),asc);
    qsort(even,n,sizeof(int),asc);

    block* b_odd;
    block* b_even;
    NEW(b_odd,n);
    NEW(b_even,n);
    for(int i=0;i<n;i++){
        b_odd[i].n=-1;
        b_even[i].n=-1;
    }
    array_blocked_3(odd,n,b_odd);
    array_blocked_3(even,n,b_even);

    int odd_block_num=0;
    int even_block_num=0;
    for(int i=0;i<n;i++){
        if(b_odd[i].n==-1) break;
        else odd_block_num++;
    }
    for(int i=0;i<n;i++){
        if(b_even[i].n==-1) break;
        else even_block_num++;
    }
    qsort(b_odd,odd_block_num,sizeof(block),block_asc);
    qsort(b_even,even_block_num,sizeof(block),block_asc);

    int ans;
    if(b_odd[0].c!=b_even[0].c) ans=N-(b_odd[0].n+b_even[0].n);
    else{
        if(b_odd[1].n==-1 && b_even[1].n==-1) ans=n;
        else if(b_odd[1].n==-1 && b_even[1].n!=-1) ans=MIN(N-(b_even[0].n),N-(b_odd[0].n+b_even[1].n));
        else if(b_odd[1].n!=-1 && b_even[1].n==-1) ans=MIN(N-(b_odd[0].n),N-(b_odd[1].n+b_even[0].n));
        else ans=MIN(N-(b_odd[1].n+b_even[0].n),N-(b_odd[0].n+b_even[1].n));
    }
    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 2744
#include <stdio.h>
int main(){
    int n,m;
    char c[2],a[128];
    while(1){
        scanf("%d",&n);
        if(n==0)return 0;
    for(int i=0;i<128;i++)a[i]=i;
    for(int i=0;i<n;i++){
        scanf("%s %s",&c[0],&c[1]);
        a[c[0]]=c[1];
    }
    scanf("%d",&m);
    for(int i=0;i<m;i++){
        scanf("%s",&c[0]);
        printf("%c",a[c[0]]);
    }
        printf("\n");
    }
}

Measured memory_bytes: 2532
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var n = Console.ReadLine().ToInt();
      	var k = new int[n];
		for(int i = 0; i < n; i++)
        {
         	k[i] = Console.ReadLine().ToInt(); 
        }
      	Array.Sort(k);
      long wa = 0;
      	for(int i = 0; i < n; i++)
        {
         if(i == n-1)
           wa += k[i]/2;
           else
          wa += k[i];
        }
      Console.WriteLine(wa);
    }
  static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 20;
typedef long long ll;
ll n, m, mark[N], d = 0, a = 0;
vector <int> v[N];
queue <int> q;
void dfs(int x){
	for(int i = 0; i < v[x].size(); i ++){
		if(mark[v[x][i]] == 0){
			mark[v[x][i]] = 1;
			q.push(v[x][i]);
		}
	}
}
int main(){
	cin >> n >> m;
	a = n;
	for(int i = 0 ; i < m ; i ++){
		int x, y;
		cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	dfs(1);
	if(mark[a] != 0){
		cout << "POSSIBLE";
	}
	while(!q.empty()){
		for(int i = 0; i < v[q.front()].size(); i ++){
			if(v[q.front()][i] == a){
				d = 1;
				break;
			}
		}
		if(d == 1){
			break;
		}
		q.pop();
	}
	if(d == 1){
		cout << "POSSIBLE";
	}
	else{
		cout << "IMPOSSIBLE";
	}
	return 0;
}

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


int main() {
    ll W,H,x,y;
    cin>>W>>H>>x>>y;
    cout<<W*H/2.0<<" ";
    if(x==W/2.0&&y==H/2.0){
        cout<<1<<endl;
    }
    else cout<<0<<endl;
}

Measured memory_bytes: 256
use std::io::*;

fn dfs(y: usize, x: usize, used: &mut Vec<Vec<bool>>, g: &Vec<Vec<char>>) -> bool {
    let h = g.len();
    let w = g[0].len();
    let mut res = false;
    used[y][x] = true;
    if y == h - 1 && x == w - 1 {
        for i in 0..h {
            for j in 0..w {
                if g[i][j] == '#' && !used[i][j] {
                    return false;
                }
            }
        }
        return true;
    } else {
        if x + 1 < w && g[y][x + 1] == '#' {
            res |= dfs(y, x + 1, used, &g);
        }
        if y + 1 < h && g[y + 1][x] == '#' {
            res |= dfs(y + 1, x, used, &g);
        }
    }
    used[y][x] = false;
    res
}

fn main() {
    let mut s: String = String::new();
    stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let h: usize = itr.next().unwrap().parse().unwrap();
    let w: usize = itr.next().unwrap().parse().unwrap();
    let g: Vec<Vec<char>> = (0..h)
        .map(|_| itr.next().unwrap().chars().collect())
        .collect();

    let mut used = vec![vec![false; w]; h];
    if dfs(0, 0, &mut used, &g) {
        println!("Possible");
    } else {
        println!("Impossible");
    }
}


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

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	rep(i,n) {
		cin >> v[i];
		v[i]--;
	}
	vector<int> flag(n);
	int cur = 0;
	int cnt = 0;
	while (true) {
		if (cur == 1) {
			cout << cnt << endl;
			return 0;
		}
		if (flag[cur]) {
			cout << -1 << endl;
			return 0;
		}
		flag[cur]++;
		cnt++;
		cur = v[cur];
	}
}

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

#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define pb push_back
#define inf 1e+18L
#define MOD 1000000007

int main()
{
    FastIO 
    int n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    int forward[n];
    int backward[n];
    for(int i=0, j=0; (i<n) and (j<k); i++)
    {
        if(s[i] == 'o')
        {
            forward[j++] = i;
            i += c;
        }
    }
    for(int i=n-1, j=k-1; (i>=0) and (j>=0); i--)
    {
        if(s[i] == 'o')
        {
            backward[j--] = i;
            i -= c;
        }
    }
    for(int i=0; i<k; i++)
    {
        if(forward[i] == backward[i])
            cout << forward[i] + 1 << "\n";
    }
    return 0;
}

Measured memory_bytes: 3348
import sys
input = sys.stdin.readline
n,m = map(int, input().split(' '))
abe = [list(map(int, input().split())) for i in range(m)]
graph = [[] for i in range(n+1)]
visited = [0]*(n+1)
for a,b,e in abe:
    graph[a].append(b)
    graph[b].append(a)
stack = []
cnt = 0
append = stack.append
pop = stack.pop
for i in range(1,n+1):
    if visited[i] != 1:
        cnt += 1
        append(i)
    while stack:
        x = pop()
        visited[x] = 1
        for y in graph[x]:
            if visited[y] != 1:
                append(y)
print(cnt)

Measured memory_bytes: 76380
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		long a = stdIn.nextLong();
		long b = stdIn.nextLong();
		long k = stdIn.nextLong();
		
		if(a >=k) {
			System.out.println((a-k)+" "+b);
		}else if((a+b) <= k) {
			System.out.println(0+" "+0);
		}else{
			System.out.println(0+" "+(b-(k-a)));
		}
		
		
		
		
		
		
		
	}

}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define ri register
#define int long long
using namespace std; const int N=200010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
int n,D,X,a[N];
signed main()
{
    n=read(), D=read(), X=read();
    for(ri int i=1;i<=n;i++) a[i]=read();
    int res=X;
    for(ri int i=1;i<=n;i++) res+=(D-1)/a[i]+1;
    printf("%lld\n",res);
    return 0;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n, h;
    cin >> n >> h;
    int a = 0;
    priority_queue<int> b;
    int ta, tb;
    rep(i, n) {
        cin >> ta >> tb;
        a = max(a, ta);;
        b.push(tb);
    }
    int ans = 0;
    while(h > 0) {
        if (b.top() > a && b.size()) {
            h -= b.top();
            b.pop();
            ans++;
        } else {
            ans += (h + (a - 1)) / a;
            break;
        }
    }

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

Measured memory_bytes: 892
#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back

using namespace std;

// #define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline void chmax(T& a,T const& b){a=max(a,b);}
template<class T> inline void chmin(T& a,T const& b){a=min(a,b);}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60; 

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,K,Q; cin >> N >> K >> Q;
  vl a(N); rep(i,N) cin >> a[i];
  ll ans = LINF;
  rep(i,N){
    vl s,x;
    rep(j,N){
      if(a[j]<a[i]){
        if(s.size()>=K){
          sort(ALL(s));
          rep(k,s.size()-K+1) x.pb(s[k]);
        }
        s.clear();
      }else{
        s.pb(a[j]);
      }
    }
    dump(s);
    if(s.size()>=K){
      sort(ALL(s));
      rep(k,s.size()-K+1) x.pb(s[k]);
    }
    sort(ALL(x));
    dump(x);
    if(x.size()>=Q) chmin(ans,x[Q-1]-x[0]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
import numpy as np


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

s = np.array([])

for i in range(N):
    s = np.append(s, np.array(list(map(int, input().split()))))

s = s.reshape((N, 2))

pos = np.where(s[:, 1] <= T)

if pos[0].shape == (0,):
    print('TLE')
else:
    print(int(np.sort(s[pos], axis=0)[0][0]))

Measured memory_bytes: 21260
#include <bits/stdc++.h>
using namespace std;
int main (){
    int n;
    cin >> n;
    string s;
    cin >> s;
    for(int i=0;i<s.size();i++){
        s[i]=(s[i]+n);
        
        if((int)s[i]>90){
            s[i]=s[i]-91+65;
        }
    }
    cout << s << endl;

    return 0;
}

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

int main(){
   int X[5];

   while(1){
	int con1=0,con2=0,con3=0;
	
	cin >> X[0];
	if(X[0] == 0) break;

	for(int i=1;i<5;i++){
		cin >> X[i];
	}

	for(int i=0;i<5;i++){
		if(X[i] == 1) con1++;
		if(X[i] == 2) con2++;
		if(X[i] == 3) con3++;
	}

	if(((con1 != 0)&&(con2 != 0)&&(con3 != 0))||((con1 == 0)&&(con2 == 0))||((con2 == 0)&&(con3 == 0))||((con1 == 0)&&(con3 == 0))){
		for(int i=0; i<5; i++){
			cout << "3" << "\n";
		}

	}else if(con1 == 0){
		for(int i=0; i<5; i++){
			if(X[i] == 2) {
				cout << "1";
			}else{
				cout << "2";
			}

			cout << endl;
		}
	}else if(con2 == 0){
		for(int i=0; i<5; i++){
			if(X[i] == 3) {
				cout << "1";
			}else{
				cout << "2";
			}

			cout << endl;
		}
	}else if(con3 == 0){
		for(int i=0; i<5; i++){
			if(X[i] == 1) {
				cout << "1";
			}else{
				cout << "2";
			}

			cout << endl;
		}
	}
   }

   return 0;
}

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

int main()
{
  int x, y;
  int a = 0;
  int b = 0;
  cin >> x >> y;

  switch (x){
    case 1:
    case 3:
    case 5:
    case 7:
    case 8:
    case 10:
    case 12:
    a++;
    break;
  }
  switch (y){
    case 1:
    case 3:
    case 5:
    case 7:
    case 8:
    case 10:
    case 12:
    b++;
    break;
  }

  switch (x){
    case 4:
    case 6:
    case 9:
    case 11:
    a += 2;
    break;
  }
  switch (y){
    case 4:
    case 6:
    case 9:
    case 11:
    b += 2;
    break;
  }

  if(x == 2)a += 3;
  if(y == 2)b += 3;

  if(a == b){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int a, b, c; cin >> a >> b >> c;
	for (int i = c; i <= c + 3600; i += 60) {
		if (i % (a + b) <= a) {
			cout << i << endl;
			char c; cin >> c;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 3108
a, b = map(int, input().split())
tmp_cost = int(a/0.08)
ans = -1

while int(tmp_cost*0.08) <= a and int(tmp_cost*0.1) <= b:
    if int(tmp_cost*0.08) == a and int(tmp_cost*0.1) == b:
        ans = tmp_cost
        break
    else:
        tmp_cost += 1
print(ans)

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

int main(){
  int a,s,k;
  cin >> a >>s;
  vector<int>b(a);
  for(int i=0;i<a;i++){
    cin >> b.at(i);
  }
  sort(b.begin(),b.end());
  k=b.at(s-1)-b.at(0);
  for(int i=0;i<a-s+1;i++){
    if(k>(b.at(s+i-1)-b.at(i))){
      k=b.at(s+i-1)-b.at(i);
    }
  }
  cout <<k<<endl;
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int A, B, M; cin >> A >> B >> M;
    vector<int> a(A);
    for (int i = 0; i < A; i++) cin >> a[i];
    vector<int> b(B);
    for (int i = 0; i < B; i++) cin >> b[i];
    int ma = *min_element(a.begin(), a.end());
    int mb = *min_element(b.begin(), b.end());
    int ans = ma + mb;
    for (int i = 0; i < M; i++) {
        int x, y, c; cin >> x >> y >> c;
        x--, y--;
        int tmp = max(0, a[x] + b[y] - c);
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	static final long INF = 0x3f3f3f3f3f3f3f3fL;
	boolean check(long p, long q, long r, long s) {
		return Math.abs(p - q) > Math.abs(r - s);
	}
	void main() {
		int n = sc.nextInt();
		int[] aa = new int[n];
		long sum = 0;
		for (int i = 0; i < n; i++)
			sum += aa[i] = sc.nextInt();
		long b = aa[0], c = aa[1], d = aa[2], e = sum - b - c - d;
		long ans = INF;
		for (int h = 1, i = 2, j = 3, a; i + 1 < n; i++) {
			while (h >= 2 && (a = aa[h - 1]) > 0 && check(b, c, b - a, c + a)) {
				b -= a; c += a;
				h--;
			}
			while (i - h >= 2 && (a = aa[h]) > 0 && check(b, c, b + a, c - a)) {
				b += a; c -= a;
				h++;
			}
			while (j - i >= 2 && (a = aa[j - 1]) > 0 && check(d, e, d - a, e + a)) {
				d -= a; e += a;
				j--;
			}
			while (n - j >= 2 && (a = aa[j]) > 0 && check(d, e, d + a, e - a)) {
				d += a; e -= a;
				j++;
			}
			long x = Math.min(Math.min(b, c), Math.min(d, e));
			long y = Math.max(Math.max(b, c), Math.max(d, e));
			ans = Math.min(ans, y - x);
			a = aa[i];
			c += a; d -= a;
		}
		println(ans);
	}
}


Measured memory_bytes: 62848
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        int monsterHP;
        int attackDMG;

        Scanner scanner = new Scanner(System.in);
        String inputData = scanner.nextLine();
        scanner.close();

        String[] editInputData = inputData.split(" ");

        monsterHP = Integer.parseInt(editInputData[0]);
        attackDMG = Integer.parseInt(editInputData[1]);

        int count = 0;

        while(monsterHP > 0) {
            monsterHP -= attackDMG;
            count++;
        }

        System.out.println(count);

    }
}

Measured memory_bytes: 23636
#include <stdio.h>
#include <stdlib.h>
#define N 10000

int  main()
{
  int i,j,n,*A,*B,C[N + 1];

  scanf("%d",&n);
  A = malloc(sizeof(int) * n + 1);
  B = malloc(sizeof(int) * n + 1);
  
  for(i = 0;i < n;i++) scanf("%d",&A[i]);

  for(i = 0;i < 10000;i++) C[i] = 0;

  for(j = 0;j < n;j++) C[A[j]]++;

  for(i = 1;i < 10000;i++) C[i] = C[i] + C[i - 1];

  for(j = n;j >= 0;j--)
    {
      B[C[A[j]]] = A[j];
      C[A[j]]--;
    }

  for(i = 1;i <= n;i++)
    {
      if(i > 1) printf(" ");
      printf("%d",B[i]);
    }
  printf("\n");

  return 0;
}



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

int main(){
  unsigned long long H, W, h, w, num;
  cin >> H >> W;
  //cerr << "H=" << H << endl;
  //cerr << "W=" << W << endl;

  if(H ==1 || W == 1){
          cout << 1 << endl;
  }
  else{
        if(W % 2 == 0){
                  num = W/2*H;
        }
        else{
                  num = (W/2+1)*H-H/2;

        //cerr << "h=" << h << endl;
        }
        //cerr << "w=" << w << endl;
        //cerr << "num=" << num << endl;

        cout << num << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
const int mod=(1e9)+7;
const int maxn=(1e5)+10;
char s[maxn];
int n,dp[maxn][15];
void update(int &x,int y) {
	x+=y;
	if (x>=mod) x-=mod;
}
int main() {
	//freopen("1.txt","r",stdin);
	scanf("%s",s+1);
	n=strlen(s+1);
	dp[0][0]=1;
	for (int i=0;i<n;i++) {
		for (int j=0;j<13;j++) {
			if (s[i+1]=='?') {
				for (int k=0;k<10;k++)
					update(dp[i+1][(j*10+k)%13],dp[i][j]);
			} else update(dp[i+1][(j*10+s[i+1]-'0')%13],dp[i][j]);
		}
	}
	printf("%d\n",dp[n][5]);
	return 0;
}

Measured memory_bytes: 6144
N, M, K = map(int,input().split())
MOD = 998244353

fac = [1 for i in range(N+1)]
for n in range(1,N+1):
    fac[n] = (n*fac[n-1])%MOD

fac_inv = [1 for i in range(n+1)]
fac_inv[N] = pow(fac[N],MOD-2,MOD)
for n in range(N-1,-1,-1):
    fac_inv[n] = (fac_inv[n+1]*(n+1))%MOD

def C(n,k):
    global MOD
    return (fac[n]*fac_inv[k]*fac_inv[n-k])%MOD

print(sum([C(N-1,b)*M*pow(M-1,N-1-b,MOD)%MOD for b in range(K+1)])%MOD)

Measured memory_bytes: 103484
#include <stdio.h>
#include <stdlib.h>
int n;
 int c[10001] = {};

CountingSort(int *a,int *b,int k){
  int i,j;
 
  
  // for(i = 0;i <= k;i++) c[i] = 0;
  
  // printf("\n");
  for(i = 1;i <= k;i++){
    c[i] = c[i] + c[i - 1];
  }

  
  for(j = n;j >= 1;j--){
    // printf("a = %d,b = %d,c = %d\n",a[j],b[c[a[j]]],c[a[j]]);
    b[c[a[j]]] = a[j];
    // printf("a[%d] = %d,b[c[a[%d]]] = %d,c[a[%d]] = %d\n",j,a[j],j,b[c[a[j]]],j,c[a[j]]);
    c[a[j]]--;
  }
}

int main(){
  int i,k = 0;
  int *a,*b;

  scanf("%d",&n);

  a = malloc(sizeof(int) * (n + 1));
  b = malloc(sizeof(int) * (n + 1));

  for(i = 0;i <= n;i++){
    a[i] = 0;
    b[i] = 0;
  }
  
  for(i = 1;i <= n;i++){
    scanf("%d",&a[i]);
    c[a[i]]++;
    if(a[i] > k) k = a[i];
  }
 
  CountingSort(a,b,k);

  for(i = 1;i <= n;i++){
    if(i != n ) printf("%d ",b[i]);
    else printf("%d\n",b[i]);
  }
  return 0;
}
    
    

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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
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; }

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


int main() {
    cout<<fixed<<setprecision(10);
    ll x; cin>>x;
    if(x>=30) puts("Yes");
    else puts("No");

    return 0;

}

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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i=(int)(b-1);i>=(int)(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 ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x)*(x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main() {
    int N, A, B, C, X;
    while (cin >> N >> A >> B >> C >> X, N|A|B|C|X) {
        vi y(N);
        REP(i, N) cin >> y[i];
        int idx = 0;
        REP(i, 10001) {
            if (X == y[idx]) {
                idx++;
                if (idx == N) {
                    cout << i << endl;
                    goto END;
                }
            }
            X = (A * X + B) % C;
        }
        cout << -1 << endl;
END: {}
    }
}

Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int main()
{
    int r, D, x;
    cin >> r >> D >> x;
    for (int i = 0; i < 10; i++)
    {
        x = x * r - D;
        cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 5
main() {
	int T[N];
	while( cin >> T[0] && T[0] ) {
		for ( int i = 1; i < N; i++ ) cin >> T[i];
		for ( int i = 0; i < N; i++ ) {
			int w = 0, l = 0;
			for ( int j = 0; j < N; j++ ) {
				if ( T[i]%3 == T[j]-1 ) w++;
				if ( T[j]%3 == T[i]-1 ) l++;
			}
			if ( w && !l ) cout << 1 << endl;
			else if ( l && !w ) cout << 2 << endl;
			else cout << 3 << endl;
		}
	}
}

Measured memory_bytes: 3092
// Problem : C - Multiplication 3
// Contest : AtCoder - AtCoder Beginner Contest 169
// URL : https://atcoder.jp/contests/abc169/tasks/abc169_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

// sprawdz MODULO!
int main() {
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	ll a; long double b;
	cin >> a >> b;
	cout << (ll)(a * b);
	return 0;
}
 


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


int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for(ll &i:A)cin >> i;
    ll count =0;
    for(ll i=1;i<N;i++){
        if(A[i-1]>A[i]){
            count+=A[i-1]-A[i];
            A[i]=A[i-1];
        }
        
    }
    cout << count << endl;
}


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

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF INT_MAX/3

typedef vector<int> vec;
typedef vector<vec> mat;

mat operator*(const mat& a,const mat& b){
  int n=a.size();
  mat res(n,vec(n,-INF));
  rep(k,n)rep(i,n)rep(j,n){
    maxch(res[i][j],a[i][j]); maxch(res[i][j],b[i][j]);
    if(a[i][k]==-INF||b[k][j]==-INF)continue;
    maxch(res[i][j],a[i][k]+b[k][j]);
  }
  return res;
}

vector<mat> p2;

mat pow(int sz,int n){
  mat res(sz,vec(sz,0));
  rep(i,20){
    if((n>>i)&1)res=res*p2[i];
  }
  return res;
}

int N,M,K;

signed main(){
  scanf("%d%d%d",&N,&M,&K);
  mat d(N,vec(N,-INF));
  rep(i,M){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    maxch(d[a][b],c);
  }

  mat cm=d;
  rep(i,20){
    p2.push_back(cm); cm=cm*cm;
  }

  int maxl=K;
  int lb=0,ub=K+1;
  while(ub-lb>1){
    int X=(ub+lb)/2;
    mat tmp=pow(N,X);
    bool ok=false,dame=true;
    rep(i,N){
      rep(j,N){
        if(tmp[i][j]>=0)dame=false;
        if(tmp[i][j]>=K){
          ok=true; break;
        }
      }
      if(ok)break;
    }
    if(dame){
      ub=X; maxl=X-1;
      continue;
    }
    if(ok)ub=X;
    else lb=X;
  }

  if(ub==maxl+1) cout<<-1<<endl;
  else cout<<ub<<endl;

  if(ub<=100&&ub<=maxl){
    vector<mat> ms;
    mat crt(N,vec(N,-INF));
    rep(i,N)crt[i][i]=0;
    ms.push_back(crt);
    rep(i,ub){
      crt=crt*d;
      ms.push_back(crt);
    }
    int s=-1,t=-1,mx=0;
    rep(i,N)rep(j,N)if(crt[i][j]>=K&&crt[i][j]>mx){
      s=i; t=j; mx=crt[i][j];
    }
    vector<int> res;
    res.push_back(t);
    for(int i=ms.size()-1;i>0;i--){
      rep(j,N){
        if(j==t)continue;
        if(ms[i-1][s][j]+d[j][t]==ms[i][s][t]){
          t=j; break;
        }
      }
      res.push_back(t);
    }
    reverse(all(res));
    cout<<res[0];
    repl(i,1,res.size())cout<<" "<<res[i];
    cout<<endl;
  }
  return 0;
}



Measured memory_bytes: 8200
#include <iostream>
#include <string>
#include <vector>

#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)

using lint = long int;
using llint = long long int;
using namespace std;

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

    vector<int> mods;
    for (int i = 1; i <= 100; i++) {
        if (a % i == 0 && b % i == 0)
            mods.push_back(i);
    }

    cout << mods.at(mods.size() - k) << endl;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define INF pow(10, 9) + 7
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define chmax(x, y) x = max(x, y)
#define print(x) cout << x << endl
#define ALL(v) v.begin(), v.end()
#define SUM(v) accumulate(ALL(v), 0)
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SORT(v) sort(ALL(v))
#define REV(v) reverse(ALL(v))
typedef long long int ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;
using vvs = vector<vector<string>>;

void solve(){
	
	ll N, K;
	cin >> N >> K;
	vl A(N);
	rep(i, N) cin >> A[i];	
	
	rep(i, min(K, (ll)50)){
		
		vl acc(N);
		
		rep(i, N){
			acc[max((ll)0, i - A[i])] += 1;
			if(i + A[i] + 1 <= N - 1)  acc[i + A[i] + 1] -= 1;
		}

		A[0] = acc[0];
		rep2(i, 1, N) A[i] = acc[i] + A[i - 1];
		
	}
	
	rep(i, N) cout << A[i] << " ";		

}	

int main(){
    
    fastio;
	solve();
    
	return 0;
	
}



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

n = int(input())

a = []

for i in range(n):
    a.append((i, int(input())))

a_sorted = sorted(a, key = lambda k:k[1])
max_index = a_sorted[-1][0]

#print(a_sorted)

a_max = a_sorted[-1][1]
a_sec_max = a_sorted[-2][1]

for i in range(0,n):
    if i != max_index:
        print(a_max)
    else:
        print(a_sec_max)


Measured memory_bytes: 34692
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <iostream>
#include <cassert>
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define per(i, a, b) for (int i = a; i >= b; --i)
#define rvc(i, S) for (int i = 0; i < S.size(); ++i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;

typedef long long LL;
typedef pair<int, int> pii;
typedef vector<int> VI;

int n;
pii pr[100005];

bool cmp(pii a,pii b){
	return a.fi+a.se > b.fi+b.se;
}

int main(){
	cin>>n;
	rep(i,1,n)cin>>pr[i].fi>>pr[i].se;
	sort(pr+1,pr+n+1,cmp);
	LL s=0;
	rep(i,1,n){
		if(i&1)s+=pr[i].fi;
		else s-=pr[i].se;
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 1024
import numpy as np
n = int(input())
s = input()

cnt = 0
for i in range(1,n):
  tmp = 0
  for a in set(list(s[:i])):
    tmp += max(np.sign(s[i:].find(a)+0.5),0)
  cnt = max(cnt,tmp)
print(int(cnt))

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

#define rep(i,N) repf(i,0,N)
#define reps(i,N) repfs(i,0,N)
#define repf(i,a,b) for(int i=a;i<b;i++)
#define repfs(i,a,b) for(int i=a+1;i<=b;i++)
#define repr(i,N) for(int i=N-1;i>=0;i--)
#define reprs(i,N) for(int i=N;i>0;i--)

#define d(a) if(isDebugMode) cout<<#a<<"="<<a<<","
#define d2(a,b) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b
#define d3(a,b,c) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c
#define d4(a,b,c,d) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<","<<#d<<"="<<d
#define da(arr,N){if(isDebugMode){rep(i,N){if(arr[i]==INF)printf("INF ");else cout<<arr[i]<<" ";} cout<<endl;}}
#define da2(arr,N,M){if(isDebugMode)rep(i,N){rep(j,M){if(arr[i][j]==INF)printf(" INF");else printf(" %3d",arr[i][j]);}cout<<endl;}}
#define pb push_back
#define pob pop_back

auto chmax =[](int &a,int b){ a = max(a, b);};
auto chmin =[](int &a,int b){ a = min(a, b);};

typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
const int MOD = 1000000007;
const int dx[4] = { 0, 1, 0,-1};
const int dy[4] = { 1, 0,-1, 0};

bool isDebugMode=1;
//--------------------------------------//
int n,a,b;
ll v[50];

ll nCr(ll n,ll r){
	ll rec = 1;
    for (ll i = 1; i <= r; ++i) {
        rec *= n--;
        rec /= i;
    }
    return rec;
}

void solve(){
	sort(v,v+n);
	double ave=0;
	ll base=0;
	ll basecount=0;
	rep(i,a){
		ll l=v[n-i-1];
		ave+=l;
		if(base!=l){
			basecount=1;
			base=l;
		}
		else basecount++;
	}
	ave=ave/(double)a;
	printf("%.6lf\n",ave);
	ll count=0;
	rep(i,n){
		if(base==v[i]) count++;
	}
	if(base==v[n-1]){
		ll ans=0;
		for(ll i=a;(i<=count&&i<=b);i++){
			ans+=nCr(count,i);
		}
		cout<<ans<<endl;
	}
	else{
		cout<<nCr(count,basecount)<<endl;
	}
}

int main(){
	cin>>n>>a>>b;
	rep(i,n) {
		cin>>v[i];
	}
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1e18;
int main() {
    string S,T;
    cin>>S>>T;
    ll len1=S.size(),len2=T.size();
    ll min1=INF;
    for(ll i=0;i<len1;i++){
        if(i+len2>len1) break;
        ll now=0;
        for(ll j=i;j<i+len2;j++){
            if(S[j]!=T[j-i]){
                now++;
            }
        }
        min1=min(min1,now);
    }
    cout<<min1;
    return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int A[] = new int[100];
    int B[] = new int[100];
    int C[] = new int[100];
    int i=0;

    do{
      A[i] = scanner.nextInt();
      B[i] = scanner.nextInt();
      C[i] = scanner.nextInt();
      i++;
    }while(!(A[i-1]==-1&&B[i-1]==-1&&C[i-1]==-1));

    for(int j=0;j<i-1;j++){
      if(A[j]==-1||B[j]==-1||A[j]+B[j]<30){System.out.println("F");}
      else if(A[j]+B[j]<50&&C[j]<50){System.out.println("D");}
      else if(A[j]+B[j]<65||C[j]>=50){System.out.println("C");}
      else if(A[j]+B[j]<80){System.out.println("B");}
      else{System.out.println("A");}
    }
  }
}


Measured memory_bytes: 26552
import java.util.*;

public class Main {

    public static void main(String... args) {

        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();
        a = a.toLowerCase();
        b = b.toLowerCase();
        c = c.toLowerCase();

        String[] alst = new String[a.length()];
        for (int i = 0; i < a.length(); i++) {
            alst[i] = String.valueOf(a.charAt(i));
        }
        List<String> aAr = new ArrayList<String>(Arrays.asList(alst));
        String[] blst = new String[b.length()];
        for (int i = 0; i < b.length(); i++) {
            blst[i] = String.valueOf(b.charAt(i));
        }
        List<String> bAr = new ArrayList<String>(Arrays.asList(blst));
        String[] clst = new String[c.length()];
        for (int i = 0; i < c.length(); i++) {
            clst[i] = String.valueOf(c.charAt(i));
        }
        List<String> cAr = new ArrayList<String>(Arrays.asList(clst));

        String winner = null;
        String str = null;
        int i = 0;
        while (true) {
            if (i==0) {
                str = aAr.get(0);
                aAr.remove(0);
            } else {
                if ( str.equals("a")) {
                    str = aAr.get(0);
                    aAr.remove(aAr.get(0));
                } else if ( str.equals("b")) {
                    str = bAr.get(0);
                    bAr.remove(0);
                } else if ( str.equals("c")) {
                    str = cAr.get(0);
                    cAr.remove(0);
                }
            }
            i++;
            if (str.equals("a")) {
                if (aAr.isEmpty()) {
                    winner = "A";
                    break;
                }
            } else if (str.equals("b")) {
                if (bAr.isEmpty()) {
                    winner = "B";
                    break;
                }
            } else if (str.equals("c")) {
                if (cAr.isEmpty()) {
                    winner = "C";
                    break;
                }
            }
        }


        System.out.println(winner);
    }

}

Measured memory_bytes: 8660
import sys

X = [0,0,0]

n = int(input())
A = [int(x) for x in input().split()]

res = 1
for a in A:
    res = res*X.count(a) % 1000000007
    if X.count(a):
        X[X.index(a)] += 1
    else:
        print(0)
        sys.exit(0)
print(res)


Measured memory_bytes: 14396
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

map<long long, int> prime_fact(long long n) {
  map<long long, int> res;
  for (long long i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n] = 1;
  return res;
}

int main() {
  ll A, B;
  cin >> A >> B;
  map<ll, int> mp = prime_fact(gcd(A, B));
  mp[1] = 1;
  cout << mp.size() << endl;
  return 0;
}

Measured memory_bytes: 256
m,d = list(map(int, input().split()))

def check(month,day):
	day_str = str(day)
	if len(day_str) < 2:
		return 0
	else:
		day1 = int(day_str[1])
		day10 = int(day_str[0])
		if day1 >= 2 and day10 >= 2 and month == day1 * day10:
			return 1
		else:
			return 0

cnt = 0
for i in range(1,m+1):
	for j in range(1,d+1):
		cnt += check(i,j)

print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a,b,c;
  cin>>a>>b>>c;
  if(a>b) swap(a,b);
  if(a<c && b>c){
    cout<<"Yes"<<'\n';
  }
  else cout<<"No"<<'\n';
  return 0;
}


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

char s[101];

int main(){
	scanf("%s",s);
	if(strlen(s)<4) {printf("No"); return 0;}
	if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I') printf("Yes");
	else printf("No");
}

Measured memory_bytes: 128
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

N=II()
As=LI()

DIG_CUM = [[0]*60 for _ in range(N+1)]

for i in range(N):
    for s in range(60):
        DIG_CUM[i+1][s] = DIG_CUM[i][s] + ((As[i] >> s) & 1)

# for arr in DIG_CUM:
#     print(arr)
POW2 = [1]
for i in range(60): POW2.append(POW2[i]*2%DVSR)

res = 0
for i in range(N-1):
    for s in range(60):
        coef = DIG_CUM[N][s] - DIG_CUM[i+1][s]
        if (As[i] >> s) & 1: coef = N - i - 1 - coef
        res += coef * POW2[s]
    res %= DVSR
print(res)


Measured memory_bytes: 202840