akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;


int main()
{
    int A, B, H, M;
    cin >> A >> B >> H >> M;

    auto minAngle = [](int min) -> double {
        return M_PI * (min / 30.);
    };

    auto hourAngle = [](int hour, int min) -> double {
        return M_PI * (hour / 6. + min / 360.);
    };

    double hourX = A * sin(hourAngle(H, M));
    double hourY = A * cos(hourAngle(H, M));
    double minX = B * sin(minAngle(M));
    double minY = B * cos(minAngle(M));
    double disX = abs(hourX - minX);
    double disY = abs(hourY - minY);

    char out[100];
    snprintf(out, 100, "%20.20f", sqrt(disX * disX + disY * disY));
    cout << out << endl;

    return 0;
}

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

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string S1 = S;
            string S2 = S;
            string[] strArray = {"dreamer","dream","eraser","erase"};
            string[] strArray2 = {"eraser","erase","dreamer","dream"};

            foreach(string str in strArray){
                S1 = S1.Replace(str,"");
            }
            foreach(string str in strArray2){
                S2 = S2.Replace(str,"");
            }
            if(S1==""||S2=="") Console.WriteLine("YES");
            else Console.WriteLine("NO");
        }
    }
}


Measured memory_bytes: 13140
#include<stdio.h>
int main(){
	int a, b;
	// 値の入力
	scanf("%d %d",&a,&b);
	// 偶奇の判定
	if((a * b) % 2 == 1){
		printf("Odd");
	} else {
		printf("Even");
	}
	return 0;
}


Measured memory_bytes: 128
"""考え方
以下の2種類の配列を用意する。（いずれも、サイズは（1,N）)
1.どこに赤い玉がある可能性があるか
2.どこに何個玉があるか
"""

N,M = map(int, input().split())
red = [0]+[1]+[0]*(N)
num = [1]*(N+2)

for m in range(M):
  x,y = map(int, input().split())
  
  ## 1.xがredの配列にHitするかを確認
  if red[x] > 0:
    ## 1-1.拡散する
    red[y] = 1
    
  ## 1-2.玉の個数の調整
  num[x] -= 1
  num[y] += 1
  
  ## 1-3.感染状態の更新
  if red[x] > 0:
    if num[x] == 0:
      red[x] = 0
    
ans = len([True for r in red if r > 0])
print(ans)
  

Measured memory_bytes: 5348
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = n; i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
	ll n;
	cin >> n;
	ll t = 0, u = 1;
	int cnt = 0;
	while (t < n) 
	{
		u *= 26;
		t += u;
		cnt++;
	}
	ll k = n - (t-u);
	string ans  = "";
	k--;
	rep(i, cnt)
	{
		ll q = k / 26;
		int r = k % 26;
		ans = char('a'+r) + ans;
		k = q;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define ll long long
#define vi vector<int>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

int N, A[3][105], ans, buff = 0;

void solve(){
    rep(i,N-2){
        buff = buff + A[0][i+1] - A[1][i];
        ans = max(ans, buff);
    }
    cout << ans << endl;
}

int main(){
    cin >> N;
    rep(i,N) cin >> A[0][i];
    rep(i,N){ 
        cin >> A[1][i];
        buff += A[1][i];
    }

    buff += A[0][0];
    ans = buff;

    solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000
 
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;
 
int n,m,ans; string str;
 
int a[15][1005];
int solve(){
    int k; cin>>n>>m>>k;
    char a[n][m];
    rep(i,0,n-1) rep(j,0,m-1) cin>>a[i][j];
    ans=1e9;
    rep(i,0,(1<<n)-1){
        int s=0;
        vi v;
        v.pb(0);
        rep(j,0,n-1){
            if(i&(1<<j)) v.pb(j+1);
        }
        v.pb(n);
        int s1=sz(v)-1;
        vi v1(s1,0);
        rep(j,0,m-1){
            vi temp(s1,0);
            rep(l,0,s1-1){
                rep(l1,v[l]+1,v[l+1]){
                    temp[l]+=(a[l1-1][j]=='1');
                }
                v1[l]+=temp[l];
            }
            rep(l,0,s1-1){
                if(v1[l]>k){
                    if(j==0) s=1e9;
                    else{
                        v1=temp; s++;
                    }
                    break;
                }
            }
            rep(l,0,s1-1){
                if(v1[l]>k){
                    s=1e9;
                    break;
                }
            }
            if(s==1e9) break;
        }
        // cout<<ans<<"\n";
        // cout<<s<<" "<<sz(v)-2<<"\n";
        ans=min(ans,s+sz(v)-2);
    }
    cout<<ans;
    return 0;
}
 
signed main() {
    ios::sync_with_stdio(0);
    //std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

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

using namespace std;
typedef long long unsigned int ll;

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

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))




int main(void){
    int n; cin >> n;
    int k; cin >> k;
    vector <int> d;
    int j;
    REP(i, n){
        cin >> j;
        d.push_back(j);
    }
    int max_score = 0;
    vector <int> r_section;
    REP(ir, min(k, n)+1){
        vector <int> rl_section = r_section;
        REP(il, min(k, n)-ir+1){
            sort(rl_section.begin(), rl_section.end());
            int score = 0;
            REP(ij, rl_section.size()){
                if (rl_section[ij] < 0 and ij < k-ir-il){
                    continue;
                }
                score += rl_section[ij];
            }
            max_score = max(max_score, score);
            if (il < k-ir){
                rl_section.push_back(d[il]);
            }
        }
        if (ir < k) {
            r_section.push_back(d[n-ir-1]);
        }
    }
    cout << max_score << endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

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

Measured memory_bytes: 3584
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  	int k;
  cin>>k;
  cout<<a[k-1]<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;

int main(){
	int n;
	cin >> n;
	
	cout << n+n*n+n*n*n << endl;
	
	
	return 0;
}

Measured memory_bytes: 3592
import java.util.Scanner;

class Main {
    public static int[] revpos(int[] p,int[] q) {//pos 1 pos 2
        int[] vec = {0,0};
        for (int i = 0; i < vec.length; i++) {
            vec[i] = p[i] - q[i];
        }
        int tmp = 0;
        tmp = vec[0];
        vec[0] = vec[1];
        vec[1] = -tmp;
        int[] newpos = {0,0};
        for (int i = 0; i < newpos.length; i++) {
            newpos[i] = q[i] + vec[i];
        }
        return newpos;
    }
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int[] input = {0,0,0,0};
        for (int i = 0; i < input.length;i++) {
            input[i] = scan.nextInt(); // x_1,y_1,x_2,y_2
        }
        scan.close();
        int[][] position = {{0,0},{0,0},{0,0},{0,0}};
        position[0][0] = input[0];
        position[0][1] = input[1];
        position[1][0] = input[2];
        position[1][1] = input[3];
        position[2] = revpos(position[0],position[1]);
        position[3] = revpos(position[1], position[2]);
        if (position[0] == revpos(position[2], position[3])) {
            System.out.println("OK");
        }
        int[] output={0,0,0,0};
        output[0] = position[2][0];
        output[1] = position[2][1];
        output[2] = position[3][0];
        output[3] = position[3][1];
        for (int i : output) {
            System.out.println(i);
        }
    }
}

Measured memory_bytes: 35520
#include<bits/stdc++.h>
using lint=long long;
using real=long double;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n,m;std::cin>>n>>m;
    std::vector<std::vector<std::pair<lint,lint>>>g(n);
    while(m--){
        lint l,r,d;std::cin>>l>>r>>d;
        l--,r--;
        g.at(l).emplace_back(r,d);
        g.at(r).emplace_back(l,-d);
    }
    lint inf=std::numeric_limits<lint>::max();
    std::vector<lint>dist(n,inf),que;
    auto dfs=[&](auto&&f,lint x)->void{
        for(auto&&e:g.at(x)){
            lint y,w;std::tie(y,w)=e;
            if(dist.at(y)!=inf){
                if(dist.at(y)!=dist.at(x)+w){
                    std::cout<<"No"<<'\n';
                    exit(0);
                }
                continue;
            }
            dist.at(y)=dist.at(x)+w;
            f(f,y);
        }
    };
    for(lint s=0;s<n;s++){
        if(dist.at(s)!=inf)continue;
        dist.at(s)=0;
        dfs(dfs,s);
    }
    std::cout<<"Yes"<<'\n';
}


Measured memory_bytes: 16256
#include<stdio.h>
int main()
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
	if(a == b + c) printf("Yes");
	else if(b == a + c) printf("Yes");
	else if(c == a + b) printf("Yes");
	else printf("No");
	
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

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

#define REP(i, n) for(ll i = 0; i < n; i++)





















int main(){
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    cout << min(a, k) - max(0LL, k - a - b) << endl;
}


Measured memory_bytes: 3632
input1 =int(input())
L = list(map(int, input().split()))
count = 0
for i in range(1,input1-1):
    if (((L[i] < L[i+1] and L[i] > L[i-1])) or ((L[i] > L[i+1] and L[i] < L[i-1]))):
        count = count + 1
        
print(count)

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

public class Main {

  public static void main(String[] args) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String readStr = reader.readLine();
    char[] readStrChars = readStr.toCharArray();
    
    for (int i = 0; i < readStrChars.length; i++) {
      if (readStrChars[i] >= 'a' && readStrChars[i] <= 'z') {
        readStrChars[i] += 'A' - 'a';
      }
    }
    System.out.println(new String(readStrChars));
  }

}

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

int main() {
    string s;
    cin >> s;
    
    for (int i = 0; i < s.length(); i++) {
        if ((i % 2) == 1) {
            if ((s[i] != 'L') && (s[i] != 'U') && (s[i] != 'D')) {
                cout << "No" << endl;
                return 0;
            }
        }
        else {
            if ((s[i] != 'R') && (s[i] != 'U') && (s[i] != 'D')) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
/*********************************************JMD**********************************************/
//                                  |\  |     | |   |   /\                                   //
    //                              | \ |     | |---|  /--\                              //
        //                          |  \| |___| |   | /    \1999                     //
/*******************************************************************************************/
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define mem(x,val) memset(x,val,sizeof(x))
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define f(i,n) forr(i,0,n)
#define sz(x) ll((x).size())
#define all(x) ((x).begin(),(x).end())
#define asc(x) ((int)(x))
#define precision(x) cout<<fixed<<setprecision((x));

const ll mod=1e9 + 7;

/*******************************************************************************************/

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

    ll a[n];
    ll mm=INT_MAX,falg=0,s=0;
    f(i,n)
    {
        cin>>a[i],mm=min(mm,abs(a[i])),s+=abs(a[i]);
        if(a[i]<0) falg++;
    }

    if(falg%2) cout<<s-2*mm;
    else cout<<s;

    return;
}

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

    ll t=1;
    //cin>>t;
    clock_t launch=clock();

    while(t--)
    {
        solve();
    }

    clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
}


Measured memory_bytes: 1024
m = []
NX = list(int(i) for i in input().split())
for i in range(NX[0]):
     m.append(int(input()))

weight0 = 0
for i in range(NX[0]):
    weight0 += m[i]
rest = NX[1] - weight0
minimumfood = min(m)
ans = int(rest/minimumfood) + NX[0]
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <stdlib.h>
#define llint long long

using namespace std;

llint d;
llint beki[19];

llint get(llint n, llint k)
{
	return (beki[n-k] - beki[k]) / 9;
}
llint dfs(llint p, llint n, llint x)
{
	//cout << p << " " << n << " " << x << endl;
	if(p >= (n+1)/2){
		if(x == d){
			if(n%2 == 0) return 10;
			else return 1;
		}
		else return 0;
	}
	llint ret = 0;
	for(int i = -9; i <= 9; i++){
		llint y = x + get(n, p)*i;
		//cout << x << " " << get(n, p) << " " << y << endl;
		if(y < 0 || y/beki[p]%10 != d/beki[p]%10) continue;
		llint cnt = 10-abs(i);
		if(p == 0 && i >= 0) cnt--;
		ret += dfs(p+1, n, y) * cnt;
	}
	return ret;
}

int main(void)
{
	cin >> d;
	if(d % 9){
		cout << 0 << endl;
		return 0;
	}
	d /= 9;
	
	beki[0] = 1;
	for(int i = 1; i <= 18; i++) beki[i] = beki[i-1] * 10;
	
	llint ans = 0;
	for(int i = 1; i <= 18; i++) ans += dfs(0, i, 0);
	cout << ans << endl;
	
	return 0;
}

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

class Main {
    public static void main(String[] args) throws Exception {
        MyScanner in = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        String input = in.nextLine();
        int val = input.charAt(0);

        out.println((char) (val+1));

        out.close();
    }

    public static PrintWriter out;

    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
}

Measured memory_bytes: 21076
{-# LANGUAGE FlexibleContexts, RankNTypes #-}
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as M
import Data.Ord
import Data.Foldable
import Data.Function
import Debug.Trace
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import Control.Monad.ST

main :: IO ()
main = readLn >>= readContents . pred >>= printRes . solve 
    where
        printRes = mapM_ print

solve :: [[Int]] -> [Int]
solve uvws = V.toList $ V.create (VM.replicate n (0 :: Int) >>= search)
    where
        n = 1 + length uvws

        g = M.fromList . map (\g -> (fst $ head g, map snd g)) . groupBy ((==) `on` fst) . sortOn fst $ concatMap mf uvws
            where
                mf [u, v, w] = [(u - 1, (v - 1, even w)), (v - 1, (u - 1, even w))]

        search vs = vs <$ loop 0 0 0
            where
                loop p i v = mapM_ (\(j, w) -> VM.unsafeWrite vs j w >> loop i j w) cs
                    where
                        cs = map mf . filter (\(j, _) -> j /= p) $ g M.! i
                        mf (j, b)
                            | b = (j, v)
                            | otherwise = (j, 1 - v)
 

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 122364
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		boolean flag = false;
		
		for(int i=0; i<str.length(); i++) {
			for(int j=i; j<=str.length(); j++) {
				StringBuilder strs = new StringBuilder(str);
				if(strs.delete(i, j).toString().equals("keyence")) {
					flag = true;
					System.out.println("YES");
					return;
				}else {
					flag = false;
				}
			}
		}
		if(!flag) {
			System.out.println("NO");
		}
	}
}


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

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var N = sc.nextInt();
        var M = sc.nextInt();
        var dic = new Dictionary<int, int>();
        for (int i = 0; i < M*2; i++) {
            var a = sc.nextInt();
            if (dic.ContainsKey(a)) {
                dic[a]++;
            } else {
                dic.Add(a, 1);
            }
        }
        for (int i = 0; i < N; i++) {
            if (!dic.ContainsKey(i+1)) {
                WriteLine(0);
                continue;
            }
            WriteLine(dic[i+1]);
        }
    }
}



class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 13152
main=do
 n<-readLn
 a<-map read.words<$>getLine
 let x=length$filter((/=0).(`mod`2))a
 let z=length$filter((==0).(`mod`4))a
 let y=n-x-z
 putStrLn$if z+(if y>0 then 0 else 1)>=x then"Yes"else"No"

Measured memory_bytes: 33148
#include<bits/stdc++.h>
#define int long long 
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(a) a.begin(),a.end()
#define ld long double
#define ub upper_bound
#define lb lower_bound
#define pii pair<int,int>
using namespace std;
signed main(){
    fast;
    int n;
    cin>>n;
    cout<<(n+1)/2;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <regex>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include  <cassert>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define int ll
//const int INF = 100100100;
const int INF = (1LL << 32);
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;


static const int NMAX = 105;
static const int WMAX = 10005;
static const int DIAGONAL = 1;
static const int TOP = 0;

struct Item {
	int value, weight;
};

int N, W;
Item items[NMAX + 1];
int C[NMAX + 1][WMAX + 1], G[NMAX + 1][WMAX + 1];


void compute(int& maxValue, vector<int>& selection) {
	rep(i, W + 1) {
		C[0][i] = 0;
		G[0][i] = DIAGONAL;
	}
	FOR(i, 1, N + 1) C[i][0] = 0;

	FOR(i, 1, N + 1) {
		FOR(w, 1, W + 1) {
			C[i][w] = C[i - 1][w];
			G[i][w] = TOP;
			if (items[i].weight > w) continue;
			if (items[i].value + C[i - 1][w - items[i].weight] > C[i - 1][w]) {
				C[i][w] = items[i].value + C[i - 1][w - items[i].weight];
				G[i][w] = DIAGONAL;
			}
		}
	}
	maxValue = C[N][W];
	selection.clear();
	for (int i = N, w = W; i >= 1; i--) {
		if (G[i][w] == DIAGONAL) {
			selection.pb(i);
			w -= items[i].weight;
		}
	}
	reverse(ALL(selection));
}

void input() {
	cin >> N >> W;
	FOR(i, 1, N + 1) cin >> items[i].value >> items[i].weight;
}

signed main() {
	ios::sync_with_stdio(false);
	int maxValue;
	vector<int> selection;
	input();
	compute(maxValue, selection);
	//for (auto i : selection) {
	//	cout << i << ' ';
	//}
	//cout << endl;
	cout << maxValue << endl;
	return 0;
}


Measured memory_bytes: 18940
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        m: usize,
        v: usize,
        p: usize,
        mut a: [usize; n]
    }
    a.sort_by(|x, y| y.cmp(x));
    let mut t = 0;
    let mut f = true;
    for i in p - 1..n {
        if a[i] > a[n - 1] + m {
            f = false;
            break;
        } else {
            t += min(a[n - 1] + m - a[i], m);
        }
    }
    if f && t + (p - 1) * m >= v * m {
        println!("{}", n);
        return;
    }
    let mut l = a[n - 1];
    let mut r = 1000000000;
    while l + 1 < r {
        let mid = (l + r) / 2;
        let mut t = 0;
        let mut f = true;
        for i in p - 1..n {
            if a[i] > mid + m {
                f = false;
                break;
            } else {
                t += min(mid + m - a[i], m);
            }
        }
        if f && t + (p - 1) * m >= v * m {
            r = mid;
        } else {
            l = mid;
        }
    }
    let mut ans = 0;
    for i in 0..n {
        if a[i] >= r {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<stdlib.h>
#pragma warning(disable : 4996)
int main()
{
	int n = 0;
	int k = 0;
	int price[1000] = { 0 };
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%d", &price[i]);
	}
	
	int swap = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n - i - 1; j++) {
			if (price[j] > price[j + 1]) {
				swap = price[j];
				price[j] = price[j + 1];
				price[j + 1] = swap;
			}
		}
	}

	int total = 0;
	for (int i = 0; i < k; i++) {
		total = total + price[i];
	}
	printf("%d\n", total);

	system("pause");
	return 0;
}

Measured memory_bytes: 1724
import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,k = na()
mod = 10**9+7
dp = [1]*(k+1)

for i in range(k//2,0,-1):
    p = pow(k//i,n,mod)
    for j in range(2*i,k+1,i):
        p -= dp[j]
    dp[i] = p%mod

ans = 0

for k,v in enumerate(dp):
    ans += k*v
    ans %= mod

print(ans)

Measured memory_bytes: 11312
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void get() {}template<class H, class...T>void get(H&h, T&...t) { cin >> h; get(t...); }
template<class T>void geti(T&a) { for (auto&_ : a)cin >> _; }
template<class T>void getii(T&a) { for (auto&_ : a)geti(_); }
void put(string d) {}template<class H, class...T>void put(string d, H&h, T&...t) { cout << h; if (sizeof...(t))cout << d; put(d, t...); }
template<class T>void puti(T&a, string d = " ") { bool f = 1; for (auto&_ : a)cout << (exchange(f, 0) ? "" : d) << _; cout << endl; }
template<class T>void putii(T&a, string d = " ") { for (auto&_ : a)puti(_, d); }
#define dcl(...) ll __VA_ARGS__;get(__VA_ARGS__)
#define dclt(t,...) t __VA_ARGS__;get(__VA_ARGS__)


int main() {
    int n;
    cin >> n;
    vi v(n, 0);
    geti(v);
    int s = 0;
    rep(i, n-1) {
        rep(j,n-1-i) {
            if (v[j] > v[j + 1]) {
                s++;
                swap(v[j], v[j + 1]);
            }
        }
    }
    puti(v);
    cout << s << endl;
}



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

typedef pair<int, int> P;
const int inf = 10000000;
int H, W;
char maze[51][51];
int d[51][51];
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int sx, sy, gx, gy;

int bfs() {
  queue<P> que;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      d[i][j] = inf;
    }
  }
  que.push(P(sx, sy));
  d[sx][sy] = 1;
  while (que.size()) {
    P p = que.front(); que.pop(); 
    if (p.first == gx && p.second == gy) break;
    for (int i = 0; i < 4; i++) {
      int nx = p.first + dx[i], ny = p.second + dy[i];
      if (0 <= nx && nx < H && 0 <= ny && ny < W && maze[nx][ny] != '#'
          && d[nx][ny] == inf) {
        que.push(P(nx, ny));
        d[nx][ny] = d[p.first][p.second]+1;
      }
    }
  }
  return d[gx][gy];
}

int main() {
  cin >> H >> W;
  sx = 0; sy = 0; gx = H-1; gy = W-1;
  int count = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> maze[i][j];
      if (maze[i][j] == '.') count++;
    }
  }
  int ans = bfs();
  if (ans == inf) cout << -1 << endl;
  else cout << count - ans << endl;
}

Measured memory_bytes: 256
def io_tmp():
    global input
    import io, sys
    #f = io.StringIO(open(0).read())
    f = io.BytesIO(sys.stdin.buffer.read())
    input = f.readline

io_tmp()


from scipy.sparse.csgraph import floyd_warshall
import numpy as np

N, M, L = map(int, input().split())
graph = [[float("inf")] * N for _ in range(N)]
for _ in range(M):
    s, t, w = map(int, input().split())
    if w <= L:
        graph[s-1][t-1] = graph[t-1][s-1] = w
dist = floyd_warshall(graph, directed=False)
graph = dist <= L
#np.fill_diagonal(graph, 0)
#graph[dist > L] = 0
dist = floyd_warshall(graph, directed=False)
dist[np.isinf(dist)] = 0
#dist = dist.astype(int)

Q = int(input())
ans = []
for _ in range(Q):
    s, t = map(int, input().split())
    ans.append(int(dist[s-1][t-1]) - 1)
print(*ans, sep='\n')


Measured memory_bytes: 19772
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const int INF=1e+9;
const ll INFLL=1e+17;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  bool f=false;
  rep1(i,b){
    if(a*i%b==c){
      f=true;
      break;
    }
  }
  if(f) prin("YES");
  else prin("NO");

  return 0;
}



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

int main()
{
	bool visited[211] = { 0, };
	int X, N;
	cin >> X >> N;
	while (N--)
	{
		int tmp;
		cin >> tmp;
		visited[tmp] = true;
	}
	for (int i = 0;  ; i++)
	{
		if (X - i < 1 || !visited[X - i])
		{
			cout << X - i;
			break;
		}
		else if (!visited[X + i])
		{
			cout << X + i;
			break;
		}
	}
}

Measured memory_bytes: 3592
open Batteries
let () =
  let n = Scanf.scanf "%d " (fun a -> a) in
  let a_lst = Array.to_list @@ Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a)) in

  let rec aux res = function
      [] -> res
    | hd::tl -> 
      if hd mod 2 = 0 then
        let t = hd/2 in
        aux (res+1) (t::tl)
      else
        aux res tl 
  in

  Printf.printf "%d\n" @@
  aux 0 a_lst 


Measured memory_bytes: 5376
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	h, w := iScan(), iScan()
	s := SScan(h)
	ans := "Yes"
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if string(s[i][j]) == "#" {
				f := false
				if i > 0 {
					if string(s[i-1][j]) == "#" {
						f = true
					}
				}
				if i < h-1 {
					if string(s[i+1][j]) == "#" {
						f = true
					}
				}
				if j > 0 {
					if string(s[i][j-1]) == "#" {
						f = true
					}
				}
				if j < w-1 {
					if string(s[i][j+1]) == "#" {
						f = true
					}
				}
				if !f {
					ans = "No"
				}
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'
#define mp make_pair
#define pb push_back
#define mod 1000000007

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int a,b;
	int k;
	double k1;
	cin>>a>>b;
	k = (a+b)/2;
	k1 = (double)(a+b)/2;
	if(k==k1)
	  cout<<k;
	else
	  cout<<"IMPOSSIBLE";
return 0;
}




Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int t, h, m ;
	int a;
	

	scanf("%d", &t);

	h = t / 3600;
	t = t-h*3600;
	m = t / 60;
	t = t - m * 60;

	printf("%d:%d:%d\n", h,m,t);

	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using namespace std;
signed main(){
  int n,m;
  cin>>n>>m;
  vector<int> a(n);
  int sum;
  sum=0;
  rep(i,n){
    cin>>a[i];
    sum+=a[i];
  }
  sort(all(a));
  reverse(all(a));
  int ans;
  bool ted;
  ted = true;
  ans=0;
  rep(i,m){
    if(sum%(4*m)==0){
      if(a[i]<sum/(4*m)){
        ted=false;
        break;
      }
    }
    else if(sum%(4*m)!=0){
      if(a[i]<=sum/(4*m)){
        ted=false;
        break;
      }
    }
  }
  if(ted){
    cout<<"Yes"<<endl;
  }
  else if(!ted){
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
// Package main provides
//
// File:  b.go
// Author: ymiyamoto
//
// Created on Wed Dec  5 00:30:32 2018
//
package main

import "fmt"

var n int

func main() {
	fmt.Scan(&n)
	arr := make([]string, n)
	for i := range arr {
		fmt.Scan(&arr[i])
	}

	for i := range arr {
		for j := i + 1; j < len(arr); j++ {
			if arr[i] == arr[j] {
				fmt.Println("No")
				return
			}
		}

		if i+1 < len(arr) {
			if arr[i][len(arr[i])-1] != arr[i+1][0] {
				fmt.Println("No")
				return
			}
		}
	}

	fmt.Println("Yes")
}


Measured memory_bytes: 512
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<utility>
#include<functional>
#include<algorithm>
#include<bitset>
#include<ctime>
#include<cmath>
#include<cstdio>
#include<cstdlib>
using namespace std;
int dfs(int n, int count)
{
	if (n<6)
		return count+n;
	int a=0,b=0,c=0,d=0;
	while(1)
	{
		if(n<pow(9,a+1))
			break;
		++a;
	}
	while(true)
	{
		if(n<pow(6,b+1))
			break;
		++b;
	}
	c=dfs(n-pow(9,a),count+1);
	d=dfs(n-pow(6,b),count+1);
	return min(c,d);
}
int n;
int main()
{
	cin>>n;
	cout<<dfs(n,0);
	return 0;
}

Measured memory_bytes: 640
// amigos y no más
// dile a la jardinera que traigo flores
 
// += O(logn) ; + = O(n)
 
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#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
 
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define MOD 998244353LL
#define MOD1 1000000009LL
#define LIM 262150
#define FORN(i,j,n) for(int i=j; i<n;i++) 
#define FOR(i,n) FORN(i,0,n)
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll ;
typedef unsigned long long ull ;
typedef tree<int,int,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

string s,s1,s2;
int n;

bool checkPal(string s){
	for(int i=0; i<=s.size()/2;i++)
		if(s[i] != s[s.size()-1-i]) return false;
	
	return true;
}

int main() {
	fastio;
	cin>>s;
	n= s.size();
	
	s1 = s.substr(0,(n-1)/2);
	s2 = s.substr((n+1)/2);

	if(checkPal(s) && checkPal(s1) && checkPal(s2)){
		cout<<"Yes";
	}
	else cout<<"No";
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
#include <assert.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
set<int> oo;
char s[555555];
int n;
void upd(int t)
{
	bool u=(t>=0)&&(s[t]=='A')&&(s[t+1]=='B')&&s[t+2]=='C';
	if(u) oo.insert(t);
	else oo.erase(t);
}
int main()
{
	scanf("%s",s);
	n=strlen(s);
	vector<int> v;
	for(int j=0;j<n;++j)
	{
		if(s[j]=='A') v.pb(0);
		else if(s[j]=='B'&&s[j+1]=='C')
			v.pb(1),j+=1;
		else v.pb(2);
	}
	v.pb(2);
	ll ans=0,c=0;
	for(auto t:v)
	{
		if(t==0) ++c;
		else if(t==1) ans+=c;
		else c=0;
	}
	cout<<ans<<"\n";
}


Measured memory_bytes: 1656
#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using ll=long long;
using ld=long double;
#define inf INT_MAX  
const ll infll=1ll*inf*inf;
#define mode 998244353
#define mod 1000000007
const long double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define pb push_back
#define mp make_pair
#define ub upper_bound 
#define lb lower_bound 
#define far(i,a,b) for (ll i = a; i <= b; i++)
#define rev(i,a,b) for (ll i = a; i >= b; i--)
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define sz(a) int((a).size())
#define ftr(c,i) for(auto i = begin(c); i != end(c); i++)
#define rtr(c,i) for(auto i = rbegin(c); i != rend(c); i++)
#define pre(c,x) ((c).find(x) != (c).end())
#define cpre(c,x) (find(all(c),x) != (c).end())
#define mii map<int,int>
#define mll map<ll,ll>
#define vs vector<string>
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define vii vector<pii >
#define vll vector<pll >
#define vvl vector<vector<ll> >
#define vvi vector< vector<int > >
#define wh(t) while(t --)
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout <<(ll)(it-arr.begin()) << ')' <<  *it << ' '; cout << endl;
#define printii(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << it->ff<<' '<<it->ss << endl; cout << endl;
#define MID(i,j) ((i)+(j))/2
#define nl '\n' 
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
ll max(ll a,ll b) {return (a>b? a:b);}
ll min(ll a,ll b) {return (a>b? b:a);}
ll gcd(ll a,ll b) {return (b==0)? a:gcd(b,a%b); }
ll gcd(ll a,ll b,ll & x,ll & y) {
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    ll x1, y1;
    ll d = gcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}
ll modinv(ll a,ll b){
	ll x,y;
	gcd(a, b, x, y);
	return (x%b + b)%b;
}
ll ceiling(ll a,ll b){ 
        if(a%b==0) return a/b;
        else return a/b+1;
}
ll bpow(ll a,ll b,ll m){
	a%=m;
	ll res=1;
	while(b>0){
		if(b&1) res=(res*a)%m;
		b>>=1;
		a=a*a%m;
	}
	return res;
}
vvl mat_mul(vvl mat1,vvl mat2,ll mod1){
        vvl res(sz(mat1),vl(sz(mat2[0]),0));
        far(i,0,sz(mat1)-1){
                far(j,0,sz(mat2[0])-1){
                        far(k,0,sz(mat1[0])-1){
                                res[i][j]=(res[i][j]+(mat1[i][k]*mat2[k][j])%mod1)%mod1;          
                        }   
        }   
        }   
        return res;
}
vvl mat_exp(vvl mat,ll p,ll mod1){ 
        vvl res(sz(mat),vl(sz(mat[0]),0));
        far(i,0,sz(mat)-1) res[i][i]=1;
        while(p>0){
                if(p&1) res=mat_mul(res,mat,mod1);   
                mat=mat_mul(mat,mat,mod1);
                p>>=1;
        }   
        return res;
}
const int N=2*1e5+5;
ll n,m,q,t,k,x,y,z,ans;

int main()
{
	cin >> n >> t;
	far(i,0,n-1) x+=i+t;
	if(t<=-n) ans=n-1+t;
	else if(t>=1) ans=0+t;
	else ans=0;
	cout << x-ans << nl;
}


Measured memory_bytes: 256
n,target = map(int,input().split())

for i in range(n+1):
    for j in range(n+1):
            k=n-i-j
            if 10000*i + 5000*j + 1000*k == target and k>=0:
                print(i,j,k)
                exit()
print("-1 -1 -1")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define ai64(v) (v).begin(), (v).end()
#define eb emplace_back

struct mint{
    using i64 = int_fast64_t;
    i64 x;
    const i64 MOD = 1000000007;

    mint(const i64 y = (i64)0) noexcept : x(y) { if(x >= MOD) x %= MOD; }
    mint operator+() const noexcept {return x;}
    mint operator-() const noexcept {return -x;}

    mint operator+(const mint y) const noexcept {return (mint)*this += y; }
    mint operator-(const mint y) const noexcept {return (mint)*this -= y; }
    mint operator*(const mint y) const noexcept {return (mint)*this *= y;}
    mint operator/(const mint y) const noexcept {return (mint)*this /= y;}

    mint& operator+=(const mint y) noexcept {
        x += y.x; 
        if(x >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint y) noexcept {
        x -= y.x;
        if(x < 0) x += MOD;
        return *this;
    }
    mint& operator*=(const mint y) noexcept {
        x *= y.x;
        if(x >= MOD) x %= MOD;
        return *this;
    }
    mint& operator/=(mint y) noexcept {
        i64 exp = MOD - 2;
        while(exp){
            if(exp & 1) *this *= y;
            y *= y;
            exp /= 2;
        }
        return *this;
    }
    friend std::ostream& operator<< (std::ostream& os, const mint& m);
    friend std::istream& operator>> (std::istream& in, mint& m);
};
std::ostream& operator<<(std::ostream& os, const mint& m){
    os << m.x;
    return os;
}
std::istream& operator>> (std::istream& in, mint& m){
    in >> m.x; 
    if(m.x < 0) m.x += 1000000007;
    if(m.x >= 1000000007) m.x %= 1000000007;
    return in; 
}

mint comb(i64 n, i64 k) {
    mint res = 1;
    for(int i = 0; i < k; i++) {
        res *= mint(n-i) / mint(k-i);
    }
    return res;
};

mint POW(mint n, i64 k){
    mint res = 1;
    while(k){
        if(k&1) res *= n;
        n *= n;
        k >>= 1;
    }
    return res;
}

int main(){
    i64 N, A, B;
    cin >> N >> A >> B;
    cout << POW(mint(2), N) - 1 - comb(N, A) - comb(N, B) << endl;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))
x=list(range(n))
x[n-1]=0
#print(x)
i=n-2
j=1
y=[]
while i!=-1:
    j=1
    while j!=k+1 and j+i!=n:
        y.append(abs(a[i]-a[j+i])+x[j+i])
        #print(a[i])
        #print(a[j+i])
        j+=1

    #print(y)
    x[i]=min(y)
    #print(x)
    y=[]

    i-=1
print(x[0])

Measured memory_bytes: 52448
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  string a;
  cin >> a;
  if (a[0] == a[1] && a[1] == a[2])
    cout << "Yes" << endl;
  else if (a[1] == a[2] && a[2] == a[3])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define lld long double
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	lli n;
	cin>>n;
	set<string> ss;
	char before='1';

	REP(i,0,n){
		string s;
		cin>>s;

		if(ss.find(s)!=ss.end()){
			cout<<"No"<<endl;
			return 0;
		}
		if(before!='1' && before != s.at(0)){
			cout<<"No"<<endl;
			return 0;
		}

		ss.insert(s);
		before = s.at(s.size()-1);
	}
	cout<<"Yes"<<endl;

	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
ps = [input() for _ in range(m)]
p = [0] * m
s = [''] * m
for i in range(m):
  x, y = ps[i].split()
  p[i] = int(x)
  s[i] = y
ac_flag = [0]*n # AC出したかどうかのflag
ac_count = 0
wa_count = [0]*n
for j in range(m):
  if ac_flag[p[j]-1] == 1:
    continue
  if s[j] == 'AC':
    ac_flag[p[j]-1] = 1
    ac_count+=1
  if s[j] == 'WA':
    wa_count[p[j]-1] += 1
true_wa_count=0
for k in range(n):
  if ac_flag[k] == 1:
    true_wa_count+=wa_count[k]
print(ac_count,true_wa_count)

Measured memory_bytes: 22040