akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

int main(void)
{
	char str[201], tmp[201];
	int i, h, n, slen;
	while (1) {
		gets(str);
		slen = strlen(str);
		if (strcmp(str, "-") == 0)
			break;
		scanf("%d", &n);
		for(i = 0; i < n; i++)
		{
			memset(tmp, 0, sizeof(tmp));
			scanf("%d", &h);
			
			strcpy(tmp, &str[h]);
			strncat(tmp, str, h);
			tmp[slen] = '\0';
			strcpy(str, tmp);
		}
		printf("%s\n", str);
		getchar();
	}
	return 0;
}

Measured memory_bytes: 600
import sys

##sys.stdin = open("in.txt","r")
cin = sys.stdin
##sys.stdout = open("out.txt","w")
cout = sys.stdout

def solve():
    N, A, B = map(int,cin.readline().split())
    X = list(map(int, cin.readline().split()))
    cnt = 0
    for i in range(1,N):
        cnt += min((X[i]-X[i-1])*A , B)
    print(cnt)

if __name__=="__main__":
    solve()


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

int sum10(int n) {
  int a,b,c,d,e;
  a = n/10000;
  n = n%10000;
  b = n/1000;
  n = n%1000;
  c = n/100;
  n = n%100;
  d = n/10;
  n = n%10;
  e = n;
  return a+b+c+d+e;
}
  

int main() {
  int n;
  cin >> n;
  int a, b;
  cin >> a >> b;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (a <= sum10(i) && sum10(i) <= b) {ans+= i;}
  }
  cout << ans << endl;
}
    
  
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using in = int64_t;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
double n;//,x,y,z;
  cin>>n;//>>x >> y>> z;
  in nn = (in)n;
  
//vector<int> a(n);
 // rep(i,n) cin>>a.at(i);
  
  double root = sqrt(n);
  in rooot = (in)root;
  for(in i =rooot;i>0;i--){
  if(nn%i==0){
  cout <<(i-1)+(nn/i-1);
    break;
  }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int r;
    cin>>r;
    if(r<1200){
        cout<<"ABC"<<endl;
    }else if(r>=2800){
        cout<<"AGC"<<endl;
    }else{
        cout<<"ARC"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	N = inputInt()
	A = inputList()

	dis = {}
	for i, val in enumerate(A):
		dis[val] = i+1

	#print(dis)
	ans = []
	for i in range(1,N+1):
		ans.append(dis[i])

	print(*ans)


if __name__ == "__main__":
	main()


Measured memory_bytes: 68268
#include <iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<string>
#include <queue>
#include <stack>
#include <cstring>
#include <map>
using namespace std;
typedef long long ll;
int ind[1001];
vector<int> v[1001];
int d[1001];
int e[1001];
bool c[1001];
int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	int n; cin >> n;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j < n; j++) {
			int x; cin >> x;
			v[i].push_back(x);
		}
		d[i] = v[i][0];
		e[i] = 1;
	}
	int ans = 0;
	while (1) {
		bool f = false;
		memset(c, false, sizeof(c));
		for (int i = 1; i <= n; i++) {
			if (c[i] || c[d[i]])continue;
			if (e[i] == n)continue;
			int x = d[i];
			int y = d[d[i]];
			if (x == d[i] && y == i) {
				f = true;
				c[x] = true; c[i] = true;
				if (e[i] <= n - 2)
					d[i] = v[i][e[i]];
				if (e[x] <= n - 2)
					d[x] = v[x][e[x]];
				e[i] += 1; e[x] += 1;
			}
		}
		if (!f)break;
		ans += 1;
	}
	for (int i = 1; i <= n; i++) {
		if (e[i] != n) {
			cout << -1 << '\n'; return 0;
		}
	}
	cout << ans << '\n';	
}

Measured memory_bytes: 4352
s = str(input())
n = int(input())


for i in range(n):
    let = list(map(str,input().split()))
    if let[0] == "replace":
        s = s[:int(let[1])] + let[3] + s[int(let[2])+1:]
        
    elif let[0] == "reverse":
        ss = s[int(let[1]):int(let[2])+1]
        s = s[:int(let[1])] + ss[::-1] + s[int(let[2])+1:] 
        
    elif let[0] == "print":
        print(s[int(let[1]):int(let[2])+1])


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


int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int e_num = 0;
    for (int i = 0; i < N; i++) {
        if (S.at(i) == 'E')  e_num++;
    }

    int min;
    if (S.at(0) == 'E') min = e_num - 1;
    else min = e_num;

    int x = min;
    for (int i = 1; i < N; i++) {
        if (S.at(i) == 'E' && S.at(i - 1) == 'E') {
            x--;
            if (min > x) min = x;
        }
        if (S.at(i) == 'W' && S.at(i - 1) == 'W') {
            x++;
        }
    }
    cout << min << endl;
}

Measured memory_bytes: 3876
# Tenka1 Programmer Beginner Contest 2018: B – Exchange
A, B, K = [int(i) for i in input().split()]

for i in range(1, K + 1):
    if i % 2 == 1:
        A = (A - 1) // 2 if A % 2 == 1 else A // 2
        B += A
    else:
        B = (B - 1) // 2 if B % 2 == 1 else B // 2
        A += B

print(A, B)

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


int main(){
	int N;
	cin>>N;
	string S;
	int A_cnt = 0;
	int B_cnt = 0;
	int A_B_cnt = 0;
	long long ans = (long long)0;
	for(int i=0;i<N;i++){
		cin>>S;
		for(int j=0;j<S.size()-1;j++){
			if(S[j]=='A'&&S[j+1]=='B')ans++;
		}
		if(S[0]=='B')B_cnt++;
		if(S[S.size()-1]=='A')A_cnt++;
		if(S[0]=='B'&&S[S.size()-1]=='A')A_B_cnt++;
	}
	
	A_cnt-=A_B_cnt;
	B_cnt-=A_B_cnt;
	
	
	if(A_B_cnt!=0){
		ans+=A_B_cnt-1;
		if(A_cnt>0){
			ans++;
			A_cnt--;
		}
		if(B_cnt>0){
			ans++;
			B_cnt--;
		}
	}
	ans+=min(A_cnt,B_cnt);

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int f(int n){
  int x=1;
  for(int i=1;i<=n;i++){
    x*=i;
  }
  return x;
}
int count(vector<int> a,int N){
  int x=0;
  if(N==1)
    return 1;
  vector<int> v(N-1);
  x+=f(N-1)*(a.at(0)-1);
  for(int i=0;i<N-1;i++){
    if(a.at(i+1)<a.at(0))
      v.at(i)=a.at(i+1);
    else v.at(i)=a.at(i+1)-1;
  }
  x+=count(v,N-1);
  return x;
}
int main(){
  int N;
  cin>>N;
  vector<int> b(N),c(N);
  for(int i=0;i<N;i++){
    cin>>b.at(i);
  }
  for(int i=0;i<N;i++){
    cin>>c.at(i);
  }
  cout<<abs(count(b,N)-count(c,N))<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env ruby
n = STDIN.readline.strip.split(' ').map(&:to_i)
k = STDIN.readline.strip.to_i
k.times do 
  _, i = n.each_with_index.max
  n[i] *= 2
end
def sum(a)
  a.inject(0){|sum, e|  sum += e}
end
puts sum(n)


Measured memory_bytes: 1788
n=int(input())
L=list(map(int,input().split()))
a=0
for i in range(n-2):
    if L[i]<L[i+1]:
        if L[i+1]<L[i+2]:
            a = a+1
    if L[i]>L[i+1]:
        if L[i+1]>L[i+2]:
            a = a+1
print(a)

Measured memory_bytes: 3060
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す
//1:数値へ変換 2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字に分割 7:1文字に分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main() {
  var N = myconv(next(),1);
  var list = myconv(next(),4);
  var max = 0;
  for(var i = 0; i < N; i++){
    max += list[i];
  }
  var mae = 0;
  var output = Math.pow(10,15);
  for(var i = 0; i < N - 1; i++){
    mae += list[i];
    var ato = max - mae;
    output = Math.min(output,Math.abs(mae - ato));
  }
  myout(output);
}

Measured memory_bytes: 33732
#include<bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define lint long long
#define ll long long
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define vl vector<long long>
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mod 1000000007
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
long long INF = 1e10;

int main(){
    int n; cin >> n;
    vector<pii> red(n),blue(n);
    vector<bool> ured(n);
    rep(n){cin>>red[i].second>>red[i].first; ured[i]=false;}
    rep(n){cin>>blue[i].first>>blue[i].second;}
    int cnt = 0;
    sort(all(red)),sort(all(blue)),reverse(all(red));
    rep(n){
        int x = blue[i].first,y = blue[i].second;
        int j;bool chk = false;
        //debug(x);debug(y);
        for(j=0;j<n;j++){
            int xr = red[j].second,yr = red[j].first;
            /*debug(xr);
            debug(yr);
            debug(xr < x);
            debug(yr < y);
            debug(!ured[j]);*/
            if(xr<x&&yr<y&&!ured[j]){
                chk = true;
                ured[j] = true;
                break;
            }
        }
        if(chk) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 384
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
bool DEBUG = 0; void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void main(string[] args){ args ~= ["", ""]; string cmd = args[1]; if(cmd == "-debug") DEBUG = 1;
if(cmd == "-gen") gen; else if(cmd == "-jury") jury; else solve; } 
void print(){ writeln(""); } void print(T)(T t){ writeln(t); } void print(T, A ...)(T t, A a){ std.stdio.write(t, " "), print(a); }
string unsplit(T)(T xs){ return xs.array.to!(string[]).join(" "); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
T lowerTo(T)(ref T x, T y){ if(x > y) x = y; return x; } T raiseTo(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //
void gen(){}
void jury(){}
void solve(){
  
  long n = scan!long, x = scan!long, m = scan!long;
  
  long r = n % (m - 1);
  long a = x;
  long[] sums = [0]; // sums[i]: sum of 0 <= _ < i
  int[long] ixs; // ixs[a1]: last index where a = a1
  foreach(long i; 0 .. m + 10){
    sums ~= sums[$ - 1] + a;
    log("i:", i, "a:", a, "sum:", sums, "ixs:", ixs);
    if(a in ixs){
      long len = i - ixs[a];
      long value = sums[i + 1] - sums[ixs[a] + 1];
      long amt = (n - ixs[a]) / len;
      long ans = sums[n - len * amt] + value * amt;
      log("len:", len, "value:", value, "amt:", amt, "ans:", ans);
      ans.print;
      return;
    }
    else ixs[a] = i.to!int;
  	a = (a * a) % m;
  }
}


Measured memory_bytes: 7088
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	string s,t; cin >> s >> t;
	ll n = s.size(), m = t.size();
	vector<vector<pair<ll,pair<pair<ll,ll>,pair<ll,ll> > > > > dp(n+1, vector<pair<ll,pair<pair<ll,ll>,pair<ll,ll> > > >(m+1));
	for(ll i = 1; i <= n; i++) for(ll j = 1; j <= m; j++){
		if(s[i-1] == t[j-1]){
			dp[i][j].first = dp[i-1][j-1].first + 1;
			dp[i][j].second.second.first = i, dp[i][j].second.second.second = j;
			dp[i][j].second.first.first = dp[i-1][j-1].second.second.first, dp[i][j].second.first.second = dp[i-1][j-1].second.second.second;
		}
		else if(dp[i-1][j].first > dp[i][j-1].first) dp[i][j] = dp[i-1][j];
		else dp[i][j] = dp[i][j-1];
	}
	string res;
	for(ll i = dp[n][m].second.second.first, j = dp[n][m].second.second.second; i != 0; tie(i,j) = dp[i][j].second.first){
		res = s[i-1] + res;
	}
	cout << res << endl;
}

Measured memory_bytes: 352256
import java.util.Scanner;

//Area of Polygons
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int Case = 1;
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			double a[][] = new double[n][2];
			for(int i=0;i<n;i++){
				a[i][0] = sc.nextDouble();
				a[i][1] = sc.nextDouble();
			}
			double area = 0;
			for(int i=0;i<n-1;i++)area+=(a[i][0]*a[i+1][1]-a[i][1]*a[i+1][0])/2;
			area+=(a[n-1][0]*a[0][1]-a[n-1][1]*a[0][0])/2;
			System.out.printf("%d %.1f\n", Case++, -area);
		}
	}
}

Measured memory_bytes: 13000
def solve():
    data = read();
    result = think(data)
    write(result)


def read():
    return read_line()


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_float(n):
    return list(map(lambda x: float(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(data):
    if data == 'Sunny':
        return 'Cloudy'
    if data == 'Cloudy':
        return 'Rainy'
    if data == 'Rainy':
        return 'Sunny'


def write(result):
    print(result)


if __name__ == '__main__':
    # import doctest
    # doctest.testmod()
    # import sys
    # sys.setrecursionlimit(10000)
    solve()


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

using namespace std;
long long x[10000010], y[10000010];
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i < (n)i++)
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
#define pii pair<int, int>
#define int long long
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

signed main()
{

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

   string s;
   cin >> s;

   if (s.size() == 2)
      cout << s << '\n';
   else
   {
      rv(s);
      cout << s << '\n';
   }
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
using namespace std;

int imos[30][100100];
int imos2[100100];

int main() {
        int n, cnt;
        scanf("%d%d", &n, &cnt);
        for (int i = 0; i < n; i ++) {
                int s, t, c;
                scanf("%d%d%d", &s, &t, &c);
                c --;
                imos[c][s] ++;
                imos[c][t] --;
        }
        for (int i = 0; i < cnt; i ++) {
                for (int j = 1; j < 100100; j ++) {
                        imos[i][j] += imos[i][j - 1];
                }
        }
        for (int i = 0; i < cnt; i ++) {
                for (int j = 0; j < 100100 - 1; j ++) {
                        if (imos[i][j] == 0 && imos[i][j + 1] == 1) {
                                imos2[j] ++;
                        } else if (imos[i][j] == 1 && imos[i][j + 1] == 0) {
                                imos2[j + 1] --;
                        }
                }
        }
        int ans = 0;
        for (int i = 1; i < 100100; i ++) imos2[i] += imos2[i - 1];
        for (int i = 0; i < 100100; i ++) {
                ans = max(ans, imos2[i]);
        }
        printf("%d\n", ans);
        return 0;
}



Measured memory_bytes: 12416
#
import sys
import math
import numpy as np
import itertools

# いくつか入力
n,q = (int(i) for i in input().split())  
# 文字列をリストに
s = list(input())

# n行複数列の数をリストに
td = [[i for i in input().split()] for i in range(q)] 


hidari = 0
migi   = n-1

for i in range(q-1,-1,-1):
    if td[i][0] == s[hidari] and td[i][1] == 'L':
        hidari += 1
        if hidari == n:
            print("0")
            exit()
    elif hidari >0:
        if td[i][0] == s[hidari-1] and td[i][1] == 'R' :
            hidari -= 1

for i in range(q-1,-1,-1):
    if td[i][0] == s[migi] and td[i][1] == 'R':
        migi -= 1
        if migi == -1:
            print("0")
            exit()
    elif migi <n-1:
        if td[i][0] == s[migi+1] and td[i][1] == 'L' :
            migi += 1

if migi < hidari:
    print("0")
else:
    print(migi-hidari+1)

#print(migi,hidari)



Measured memory_bytes: 37140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N;
	cin >> N;

	co(N * N * N);

	Would you please return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
	#ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int a,b;
    char c;
    cin>>a>>c>>b;
    cout<<((c=='+')?a+b:a-b);
    return 0;
}

Measured memory_bytes: 3532
#include <bits/stdc++.h>
#include <vector>       // ヘッダファイルインクルード
#include <iostream>
#include <algorithm>
using namespace std;


int main() {
int N;
int a[110];
int s = 0;
cin>>N;
  for (int i=0;i<N;i++){
    cin>>a[i];}
  sort(a,a+N,greater<int>());

  for (int i=0;i<N;i++){
  if (a[i]!=a[i+1]) s++;
  }
cout<<s<<endl;

}

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

  #define vi vector<int>
  #define all(v) v.begin(),v.end()
  #define ll long long int
  #define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define D1(x) {cerr<<" [" <<#x<<": "<<x<<"]";cout << endl;}
  #define D2(x) {cerr<<" [" <<#x<<": ";for(auto it:x)cerr<<it<< " ";cerr<<"] ";cout << endl;}

  const ll MOD=1e9+7;

  void solve(){
     ll a;
     cin >> a;
     cout << a + a*a + a*a*a;
  }


  int main(){
    IOS
       solve();
       cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying

Measured memory_bytes: 3772
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
typedef long long LL;
using namespace std;
int N,W;
LL swa[105],swb[105],swc[105],swd[105];
LL sva[105],svb[105],svc[105],svd[105];
struct good
{
	int w,v;
};
good s[105],a[105],b[105],c[105],d[105];
bool cmp(good xx,good yy){ return xx.v>yy.v; }
inline LL max(LL aa,LL bb){ return aa>bb?aa:bb; }
int main()
{
	while(scanf("%d%d",&N,&W)!=EOF)
	{
		LL ans=0;
		int A=0,B=0,C=0,D=0;
		for(int i=1;i<=N;i++)
		{
			scanf("%d%d",&s[i].w,&s[i].v);
			if(s[i].w==s[1].w) a[++A]=s[i];
			if(s[i].w==s[1].w+1) b[++B]=s[i];
			if(s[i].w==s[1].w+2) c[++C]=s[i];
			if(s[i].w==s[1].w+3) d[++D]=s[i];
		}
		sort(a+1,a+A+1,cmp);
		sort(b+1,b+B+1,cmp);
		sort(c+1,c+C+1,cmp);
		sort(d+1,d+D+1,cmp);
		swa[0]=swb[0]=swc[0]=swd[0]=0;
		sva[0]=svb[0]=svc[0]=svd[0]=0;
		for(int i=1;i<=A;i++)
		{
			swa[i]=swa[i-1]+a[i].w;
			sva[i]=sva[i-1]+a[i].v;
		}
		for(int i=1;i<=B;i++)
		{
			swb[i]=swb[i-1]+b[i].w;
			svb[i]=svb[i-1]+b[i].v;
		}
		for(int i=1;i<=C;i++)
		{
			swc[i]=swc[i-1]+c[i].w;
			svc[i]=svc[i-1]+c[i].v;
		}
		for(int i=1;i<=D;i++)
		{
			swd[i]=swd[i-1]+d[i].w;
			svd[i]=svd[i-1]+d[i].v;
		}
		for(int i=0;i<=A;i++)
			for(int j=0;j<=B;j++)
				for(int k=0;k<=C;k++)
					for(int l=0;l<=D;l++)
					{
						LL noww=swa[i]+swb[j]+swc[k]+swd[l];
						if(noww<=(LL)W) ans=max(sva[i]+svb[j]+svc[k]+svd[l],ans);
					}
		printf("%lld\n",ans);
	}
	return 0;
}


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

char f,g;
bool flag;
///vector < int > v,va,vb;
int arr[sz],brr[sz],crr[sz];



int main(){

    int n,m, i,j,k, x=0,y=0,z=0, a,b,c;

    cin>>n>>m;
    n--;
    m--;
    cout<<n*m<<endl;

    return 0;



}

Measured memory_bytes: 3588
def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    from collections import defaultdict
    count = defaultdict(int)
    for a in A:
        count[a] += 1

    for i in range(1, N+1):
        print(count[i])


if __name__ == '__main__':
    main()


Measured memory_bytes: 36208
A = Array.new
b = Array.new
n, m = gets.split.map(&:to_i)
n.times do 
    A << gets.split.map(&:to_i)
end
m.times do
    b << gets.to_i
 end
 
A.each do |is|
  j = 0
  sum = 0
  is.each do |i|
    sum += i * b[j]
    j += 1
  end
  puts sum
end

Measured memory_bytes: 6128
def resolve():
    H, W = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(H)]

    ans = []
    # 横走査
    for i in range(H):
        for j in range(W - 1):
            if AB[i][j] % 2:
                AB[i][j] -= 1
                AB[i][j + 1] += 1
                ans.append((i, j, i, j + 1))

    # 最後の列を走査
    for i in range(H - 1):
        if AB[i][W - 1] % 2:
            AB[i][W - 1] -= 1
            AB[i + 1][W - 1] += 1
            ans.append((i, W - 1, i + 1, W - 1))

    print(len(ans))
    for (a, b, c, d) in ans:
        print(a + 1, b + 1, c + 1, d + 1)


if __name__ == "__main__":
    resolve()

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

int main(){
    int k, t;
    cin >> k >> t;
    vector<int> a(t);
    rep(i,t) cin >> a[i];
    sort(a.begin(),a.end());
    int amax = a[a.size()-1];
    if(amax <= k/2) cout << 0 << endl;
    else cout << (amax-1)-(k-amax) << endl;
}

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

#define pb push_back
#define mp make_pair
#define taskname "A"

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;
int a[maxn];
int n;
map<int,int> mmap;
int dp[1<<15];
bool f[1<<15];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    cin >> n;
    for(int i = 1 ; i < n ; ++i){
        int u , v , c;cin >> u >> v >> c;
        a[u] ^= c;a[v] ^= c;
    }
    vector<int> val;
    for(int i = 0 ; i < n ; ++i){
        mmap[a[i]]++;
    }
    for(int i = 1 ; i < 16 ; ++i){
        if(mmap[i] & 1)val.pb(i);
        n -= mmap[i] / 2;
    }
    n -= mmap[0];
    memset(dp,-123,sizeof dp);dp[0] = 0;
    for(int i = 0 ; i < (1 << val.size()) ; ++i){
        int cur = 0;
        for(int j = 0 ; j < val.size() ; ++j){
            if(i & (1 << j)){
                cur ^= val[j];
            }
        }
        if(cur == 0)f[i] = 1;
        for(int j = i ; j > 0 ; j = (j - 1) & i){
            if(f[j])dp[i] = max(dp[i],dp[i ^ j]+1);
        }
    }
    cout << n  - dp[(1<<val.size())-1];
}


Measured memory_bytes: 768
#include<iostream>
using namespace std;
int N,A[100005],B[100005];
long long ans=0;
int main(void){
	cin>>N;
	for(int i=0;i<=N;i++)cin>>A[i];
	for(int i=0;i<N;i++)cin>>B[i];
	for(int i=0;i<N;i++){
		if(B[i]>=A[i]){
			ans+=A[i]+min(A[i+1],B[i]-A[i]);
			A[i+1]-=min(A[i+1],B[i]-A[i]);
		}
		else ans+=B[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define REP(n) for(int i = 0; i < n; i++)
#define all(p) p.begin(), p.end()
#define count_1(p) __builtin_popcountll(p)
#define count_0(p) __builtin_ctzll(p)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
template<class X=int>inline X min(X a,X b,X c){return min(min(a,b),c);}
template<class X=int>inline X min(X a,X b,X c,X d){return min(min(a,b,c),d);}
template<class X=int> inline X max(X a,X b,X c){return max(max(a,b),c);}
template<class X=int> inline X max(X a,X b,X c,X d){return max(max(a,b,c),d);}
template<class X=int> inline X mid(X s,X e){return (s+(e-s)/2);}
template<class X=int> inline X len(X s,X e){return (e-s+1);}
const int MOD = 1e9 + 7;
const int INF = 987654321;
const bool TESTCASES = 0;
const bool CODEJAM = 0;

void solve() {
	int n;
	cin >> n;
	vector<int> A = vector<int>(n);
	REP(n) cin >> A[i];
	vector<int> dp = vector<int>(n);
	dp[0] = 0;
	dp[1] = abs(A[1] - A[0]);
	for(int i = 2; i < n; i++) {
		dp[i] = min(dp[i - 1] + abs(A[i] - A[i - 1]), dp[i - 2] + abs(A[i] - A[i - 2]));
	}
	cout << dp[n - 1] << "\n";
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int T = 1;
	if(TESTCASES) cin >> T;
	for(int t = 1; t <= T; t++) {
		if(CODEJAM) cout << "Case #" << t << ": ";
		solve();
	}
	return 0;
}


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

	int main(){
		
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);
	
		// #ifndef ONLINE_JUDGE
		// freopen("input.txt", "r", stdin);
		// freopen("output.txt", "w", stdout);
		// #endif

		// int n,W;
		// cin >> n >> W;
		// long long int w[n+1],v[n+1],dp[n+1][10000];
		// for(int i=0;i<n;i++){
		// 	cin >> w[i+1] >> v[i+1];
		// }
		// memset(dp,0,sizeof(dp));
		// for(int i=1;i<=n;i++){
		// 	for(int j=0;j<=W;j++){
		// 		dp[i][j]=dp[i-1][j];
		// 		if(j>=w[i]){
		// 			dp[i][j]=max(dp[i][j],v[i]+dp[i-1][j-w[i]]);
		// 		}
		// 	}
		// }
		// cout << dp[n][W];
		
		int n;
		cin >> n;
		double a[n],h[n],t[n],dp[n][n+1];
		memset(dp,0,sizeof(dp));
		for(int i=0;i<n;i++) cin >> a[i];
		h[0]=a[0];
		t[0]=1-a[0];
		for(int i=1;i<n;i++){
			h[i]=a[i]*h[i-1];
			t[i]=(1-a[i])*t[i-1];
		}
		for(int i=0;i<n;i++){
			if(i==0){
				dp[i][1]=a[0];
				dp[i][0]=(1-a[0]);
				continue;
			}
			for(int j=0;j<=n;j++){
				if(j==0){
					dp[i][j]=t[i];
				}
				else{
					if(i>0){
						dp[i][j]=a[i]*dp[i-1][j-1]+(1-a[i])*dp[i-1][j];
					}
				}
			}
		}
		double ans=0;
		for(int i=(n+1)/2;i<=n;i++) ans+=dp[n-1][i];
		cout << fixed << setprecision(10) << ans;


	
	
		
	
	}


Measured memory_bytes: 70656
#include<bits/stdc++.h>
#include<iomanip>
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mxn 1000005
#define mod 1000000007
#define ld long double
#define pb push_back
#define inf 1e18
#define fi first
#define se second
typedef long long int ll;
int bit[130][8];
using  namespace std;
int main(void){
	#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	fast;
	ll n,i;
	string s;
	cin>>n>>s;
	ll st[n+1][2];
	memset(st,0,sizeof st);
	for(i=0;i<n;i++){
		if(s[i]=='W'){
			st[i+1][0]=st[i][0]+1;
			st[i+1][1]=st[i][1];
		}
		else{
			st[i+1][0]=st[i][0];
			st[i+1][1]=st[i][1]+1;
		}
	}
	ll ans=n;
	for(i=0;i<=n;i++){
		ll o1=min(st[i][0],st[n][1]-st[i][1]);
		ll o2=max(st[i][0],st[n][1]-st[i][1]);
		ans=min(ans,max(o1,o2));
	}
	cout<<ans;
}


Measured memory_bytes: 6792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtcoderTemplateForCSharp
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var sides = Console.ReadLine()
                .Split(' ')
                .Select(int.Parse);

            var sortedSides = sides.OrderBy(side => side);

            // 実装1（愚直に。遅いと思ったらこっちのほうが速かった。もう一度動かしてみたら逆転したので誤差ですね。）
            if (sortedSides.Last() < sortedSides.Sum() - sortedSides.Last())
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

            // 実装2（こっちのほうが効率がいいかも？実際はこっちのほうが遅かった。範囲を足し合わせる処理があるから？もう一度動かしてみたら逆転したので誤差ですね。）
            //if (sortedSides.Last() < sortedSides.Take(sortedSides.Count() - 1).Sum())
            //{
            //    Console.WriteLine("Yes");
            //}
            //else
            //{
            //    Console.WriteLine("No");
            //}
        }
    }
}


Measured memory_bytes: 13396
///******* In the name of Allah *******///

#include <bits/stdc++.h>
using namespace std;

//long int ar[10013];
//long int gcd(long int a, long int b)
//{
//    if(b==0)
//        return a;
//    return gcd(b,a%b);
//}
//void sieve()
//{
//    long long int i,j,k = 0;
//    memset(ar,0,sizeof(ar));+
//    ar[1] = 1;
//    for(i=2; i<=713; i++)
//    {
//        if(ar[i]==0)
//        {
//            for(j=i+i; j<=713; j+=i)
//            {
//                ar[j] = 1;
//            }
//        }
//    }
//}

void Ok()
{
    long long  int a[200013],b,c,d,e,f,g,h,t,i,j,k,l,m,n,Min,Max;
    long long int ans_1,ans_2,ans_3,cnt_1,cnt_2,cnt_3,flag_1,flag_2,flag_3,temp,sum;
    double aa,bb,cc,dd,ee,ff,gg;
    char aaa[13],bbb,ccc,ddd;
    string spc,in,store;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    cnt_1 = 0;
    Max = a[1];
    for(i=2;i<=n;i++)
    {
        if(a[i]<Max)
        {
            cnt_1 += (Max - a[i]);
        }
        else
            Max = max(Max,a[i]);
    }
    cout<<cnt_1<<endl;

    return;
}

int main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    Ok();

    return 0;
}


Measured memory_bytes: 5216
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = new Date();
  Main();
  var end = new Date() - start;
  
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}


//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var N = nextInt();
	var list = nextIntArray();
	list.sort(function(a,b){
		return b - a;
	});
	var output = 0;
	var last = 0;
	for(var i = 0; i < Math.ceil(N / 2); i++){
		if(i == 0){
			output += list[i];
		}else{
			output += list[i] * 2;
			last = list[i];
		}
	}
	if(N % 2 == 1){
		output -= last;
	}
	myout(output);
}


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

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

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

int main() {
	int a, b;
	cin >> a >> b;
	for (int i = b-a+1;i < a+b-1;i++) {
		cout << i << " ";
	}
	cout << a+b-1 << endl;
}


Measured memory_bytes: 256
s = [ str( input() ) ]
q = int( input() )
query = []
rev_flag_k = 0
for _ in range( q ):
    query_i = list( input().split() )
    query.append( query_i )
    if query_i[ 0 ] == "1":
        rev_flag_k += 1

top = []
rev_flag = 0
for query_i in query:
    t = query_i[ 0 ]
    if t == "1":
        rev_flag += 1
    else:
        f = query_i[ 1 ]
        c = query_i[ 2 ]
        if f == "1" and rev_flag % 2 == 1:
            s.append( str( c ) )
        elif f == "2" and rev_flag % 2 == 0:
            s.append( str( c ) )
        else:
            top.append( str( c ) )
s = "".join( top )[::-1] + "".join( s )
if rev_flag_k % 2 == 1:
    s = s[::-1]

print( s )

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

/* #pragma */
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int GCD(int a,int b){return b?GCD(b,a%b):a;}
long long GCD(long long a, long long b){return b ? GCD(b, a%b) : a;}
int LCM(int a, int b){return a * b / GCD(a, b);}
long long LCM(long long a, long long b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const double EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right

//#define int ll
//#define int long long

//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//chcp 65001

signed main()
{
	int n; cin >> n;
	int mcnt{};//int cnt{};
	vector<int> a(n);
	for(int i = 0, i_len = n; i < i_len; ++i) cin >> a[i];

	map<int, int> mp;
	for(const auto &i: a){
		++mp[i];
		++mp[i+1];
		++mp[i-1];
	}

	for(const auto &i: mp){
		amax(mcnt, i.second);
	}

	cout << mcnt << endl;
	return 0;
}
// 各Aiに対し、Ai, Ai+1, Ai-1の操作後となる整数をカウントする
// 重複が答え　→　mapのバケット法か配列のバケット法
// array[重複してほしい数]
// ++array[i] == 重複した数


//	sort(a.begin(), a.end());
/*	auto func = [&]{
		return a[i]+1 == x || a[i] == x || a[i]-1 == x;
	};
	for (size_t i = 0; i < n; i++)
	{
		cnt = count_if(a.begin(), a.end(), );
		amax(mcnt, cnt);
	}
*/
/*	for(auto i = 0; i < n; ++i){
		int x = a[i];
		for(auto j = 0; j < n; ++j){
			if(a[j]+1== x || a[j] == x || a[j]-1 == x){
				++cnt;
			}
		}
		amax(mcnt, cnt);cnt = 0;
	}
*/

Measured memory_bytes: 5120
#include <iostream>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int x1,x2,x3;
    if(a < b){
        if(a < c){
            x1 = a;
            if(b < c){
                x2 = b;
                x3 = c;
            }else{
                x2 = c;
                x3 = b;
            }
        }else{
            x1 = c;
            x2 = a;
            x3 = b;
        }
    }else{
       if(b < c){
            x1 = b;
            if(a < c){
                x2 = a;
                x3 = c;
            }else{
                x2 = c;
                x3 = a;
            }
        }else{
            x1 = c;
            x2 = b;
            x3 = a;
        } 
    }
    cout << x1 <<" "<<x2<<" "<<x3<<endl;
    return 0;
}


Measured memory_bytes: 3112
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

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

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

//xy??§?¨???§?????±???????????¢?´¢
void dfs(int x, int y) {
	static const int MAX_X = 1, MAX_Y = 1;

	/* ?????? */

	//?§????4?????????????????????
	int dx[4] = { 1,0,-1,0 };
	int dy[4] = { 0,1,0,-1 };
	//?§????4???????????¢?´¢
	for (int i = 0; i < 4; i++) {
		int nx = x + dx[i], ny = y + dy[i];
		if (0 <= nx&&nx < MAX_X && 0 <= ny&&ny < MAX_Y) {
			dfs(nx, ny);
		}
	}
}

//xy??§?¨???§??????????????¢?´¢
//???????????¢
int bfs(int sx, int sy, int gx, int gy) {
	static const int MAX_X = 1, MAX_Y = 1;

	queue<pii> Q;
	Q.push(pii(sx, sy));

	//???????????¢
	int d[MAX_X][MAX_Y];
	memset(d, 0x3f, sizeof(d));

	//?§????4?????????????????????
	int dx[4] = { 1,0,-1,0 };
	int dy[4] = { 0,1,0,-1 };
	for (pii u; !Q.empty();) {
		u = Q.front(); Q.pop();
		//??´??????????????¢?´¢????????????
		if (u == pii(gx, gy))break;
		//?§????4???????????¢?´¢
		for (int i = 0; i < 4; i++) {
			int nx = u.first + dx[i], ny = u.second + dy[i];
			if (0 <= nx&&nx < MAX_X && 0 <= ny&&ny < MAX_Y) {
				//??¢?´¢???????£???°???
				if (d[nx][ny] != INF)continue;
				d[nx][ny] = d[sx][sy] + 1;
				Q.push(pii(nx, ny));
			}
		}
	}

	return d[gx][gy];
}

#define MAX 200
#define O 100

int main() {
	bool m[MAX][MAX]; //?????????
	int d[MAX][MAX];
	for (int t, n; cin >> t >> n&&t;) {
		memset(m, false, sizeof(m));
		memset(d, 0x3f, sizeof(d));
		for (int i = 0; i < n; i++) {
			int x, y;
			cin >> x >> y;
			x += O; y += O;
			m[x][y] = true;
		}
		int sx, sy; cin >> sx >> sy;
		sx += O; sy += O;

		queue<pii> Q;
		Q.push(pii(sx, sy));
		d[sx][sy] = 0;

		//?§????6?????????????????????
		int dx[6] = { 1,1,0,-1,-1,0 };
		int dy[6] = { 0,1,1,0,-1,-1 };
		for (pii u; !Q.empty();) {
			u = Q.front(); Q.pop();
			if (d[u.first][u.second] == t)continue;
			//?§????6???????????¢?´¢
			for (int i = 0; i < 6; i++) {
				int nx = u.first + dx[i], ny = u.second + dy[i];
				if (0 <= nx&&nx < MAX && 0 <= ny&&ny < MAX) {
					//?????????????£???°???
					if (m[nx][ny])continue;
					//??¢?´¢???????£???°???
					if (d[nx][ny] != INF)continue;
					d[nx][ny] = d[u.first][u.second] + 1;
					Q.push(pii(nx, ny));
				}
			}
		}

		int cnt = 0;
		for (int x = 0; x < MAX; x++) {
			for (int y = 0; y < MAX; y++) {
				if (d[x][y] <= t)cnt++;
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 1420
import sys
S=input()
N=len(S)
S1=list(S[0:(N-1)//2])
S2=list(S[(N+3)//2-1:])
S=list(S)
S.pop(N//2)
if(len(S1)%2==1):
    S1.pop(len(S1)//2)

if(len(S2)%2==1):
    S2.pop(len(S2)//2)

for i,s in enumerate(S):
    if(s!=S[-1-i]):
        print('No')
        sys.exit()

for i,s in enumerate(S1):
    if(s!=S1[-1-i]):
        print('No')
        sys.exit()

for i,s in enumerate(S2):
    if(s!=S2[-1-i]):
        print('No')
        sys.exit()
        
print('Yes')

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

int main(){
    int x, a, b;
    cin >> x >> a >> b;
    int A = abs(a - x);
    int B = abs(b - x);
    if(A > B) cout << 'B' << endl;
    else cout << 'A' << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
int f[305][305][305],n,k;
char s[305];
inline int dfs(int l,int r,int k){
  if (l==r) return 1; if (l>r) return 0;
  if (f[l][r][k]) return f[l][r][k];
  f[l][r][k]=std::max(dfs(l+1,r,k),dfs(l,r-1,k));
  if (s[l]==s[r]) f[l][r][k]=std::max(f[l][r][k],dfs(l+1,r-1,k)+2);
  else if (k) f[l][r][k]=std::max(f[l][r][k],dfs(l+1,r-1,k-1)+2);
  return f[l][r][k];
}
int main(){
  std::cin>>s>>k,n=strlen(s);
  std::cout<<dfs(0,n-1,k); return 0;
}


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

int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0; n>i; i++)
		cin>>a.at(i);
	long long sum=0,cntp=0;
	for(int i=0; i<n; i++){
    	sum = sum+a.at(i);
    	if(i%2==0)
			if(sum<=0){
				cntp = cntp+1-sum;
				sum=1;
			}
    	if(i%2==1)
			if(sum>=0){
				cntp = cntp+sum+1;
				sum=-1;
			}
	}
	long long cntm = 0;
	sum = 0;
	for(int i=0; i<n; i++){
    	sum = sum+a.at(i);
    	if(i%2==1)
			if(sum<=0){
				cntm = cntm+1-sum;
				sum=1;
			}
    	if(i%2==0)
			if(sum>=0){
				cntm = cntm+sum+1;
				sum=-1;
			}
	}
	cout << min(cntm,cntp) << endl;
 }

Measured memory_bytes: 640
#include<stdio.h>
int main(){
	char b[5][5];
	int i,f;
	while(scanf("%s",b[0])){
		if(b[0][0]=='0')break;f=0;
		scanf("%s%s",b[1],b[2]);
		for(i=0;i<3;i++){
			if(b[i][0]!='+' && b[i][0]==b[i][1] && b[i][1]==b[i][2]){
				printf("%c",b[i][0]);
				f++;break;}
			else if(b[0][i]!='+' && b[0][i]==b[1][i] && b[1][i]==b[2][i]){
				printf("%c",b[0][i]);
				f++;break;}
		}
		if(b[1][1]!='+'){
			if(b[0][0]==b[1][1] && b[1][1]==b[2][2]){
				printf("%c",b[1][1]);f++;}
			else if(b[2][0]==b[1][1] && b[1][1]==b[0][2]){
				printf("%c",b[1][1]);f++;}
		}
		if(f==0)printf("NA");
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  vector<char> a;
  vector<int> b(26);
  for(char moji='a'; moji<='z'; ++moji) {
    a.push_back(moji);
  }
  for (int i = 0; i < 26; i++) {
    b[i] = 0;
  }
  vector<char>::iterator itr;
  for (int i = 0; i < S.length(); i++) {
    itr = find(a.begin(), a.end(), S[i]);
    size_t index = distance(a.begin(), itr);
    
    b[index]++;
  }
  
  for (int i = 0; i < 26; i++) {
    if (b[i] == 0) {
      cout << a[i] << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}

Measured memory_bytes: 3752
import java.util.*;
public class Main {
	public static void main(String[] args){
      	
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		if (N==1 && M==1) {
			System.out.println(0);
		} else {
			System.out.println((N*(N-1)/2)+(M*(M-1)/2));
		}
		
			
		
		
      	sc.close();
    }
		
		
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;


int main(){

    int x1,x2,x3,x4,x5;

    cin >> x1 >> x2 >> x3 >> x4 >> x5;
    
    if(x1==0) cout << 1 << endl;
    if(x2==0) cout << 2 << endl;
    if(x3==0) cout << 3 << endl;
    if(x4==0) cout << 4 << endl;
    if(x5==0) cout << 5 << endl;

    return 0;
}


Measured memory_bytes: 3672
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

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

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

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

    string a, b;
    cin >> a >> b;

    if (a.size() > b.size()) {
        cout << "GREATER" << endl;
    } else if (a.size() < b.size()) {
        cout << "LESS" << endl;
    } else {
        int ro = a.size();
        for (int i = 0; i < ro; i++) {
            if (a[i] > b[i]) {
                cout << "GREATER" << endl;
                break;
            } else if (a[i] < b[i]) {
                cout << "LESS" << endl;
                break;
            } else {
                if (i != ro - 1) {
                    continue;
                } else {
                    cout << "EQUAL" << endl;
                }
            }
        }
    }

    return 0;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  int n, k;
  cin >> n >> k;
  vi p(n);
  rep(i,n) cin >> p[i];
  vector<double> v(n);
  rep(i,n) {
    ll tmp = 0;
    rep(j,p[i]+1) tmp += j;
    v[i] = double(tmp)/double(p[i]);
  }
  double ans = -1;
  double now = 0;
  rep(i,k) now += v[i]; 
  ans = max(ans, now);
  for(int i = 1; i <= n-k; i++) {    
    now -= v[i-1];
    now += v[i+k-1];
    ans = max(ans ,now);
  }
  //rep(i,n) {
    //cout << v[i] << endl;
  //}
  printf("%.10lf", ans);
}

Measured memory_bytes: 2560
n,m = list(map(int,input().split()))
h = list(map(int,input().split()))
a = []
h1 = list(range(len(h)))


for i in range(m):
    a.append(list(map(int,input().split())))

for i in a:
    if h[i[0]-1] < h[i[1]-1]:
        h1[i[0]-1] = "*"
    elif h[i[0]-1] > h[i[1]-1]:
        h1[i[1]-1] = "*"
    else:
        h1[i[0]-1] = "*"
        h1[i[1]-1] = "*"

print(n - h1.count("*"))


        

Measured memory_bytes: 35320