akhauriyash/Code-Regression huggingface dataset:
#import numpy as np

    
##################################################################

if __name__ == "__main__":
    Input1 = [input() for i in range(2)]
    N,K = list(map(int,Input1[0].split()))
    h = list(map(int,Input1[1].split()))

    A = [h[i]>=K for i in range(N)]
    print(sum(A))
    #print(''.join(map(str,S[i])))
    


Measured memory_bytes: 12268
N, M = gets.chomp.split(" ").map(&:to_i)
a = Hash.new{|h, k| h[k] = Array.new}
M.times{
  p, s = gets.chomp.split(" ")
  if s == 'AC' then
    if a[p].empty? then
      a[p] << 'AC'
    elsif a[p][-1] == 'WA' then
      a[p] << 'AC'
    end
  else
    if a[p].empty? then
      a[p] << 'WA'
    elsif a[p][-1] == 'WA' then
      a[p] << 'WA'
    end
  end
}

ans, pen = [0, 0]
a.each{|k, v|
  if v[-1] == 'AC' then
    ans += 1
    pen += (v.size - 1)
  end
}

printf("#{ans} #{pen}\n")


Measured memory_bytes: 30588
#include <iostream>
#include<string>
#include<vector>
using namespace std;
int main(void){
string a,b,c;
cin>>a>>b>>c;
if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0])cout<<"YES"<<endl;
else cout<<"NO"<<endl;
return 0;
}

Measured memory_bytes: 256
#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 n;
    cin >> n;
    vector<ll> b(n + 1, INF);
    REP(i, n - 1){
        cin >> b[i + 1];
    }
    ll ans = 0;
    REP(i, n){
        ans += min(b[i], b[i + 1]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
from math import atan2, degrees

a, b, x = map(int, input().split())

if a * a * b / 2 >= x:
    c = 2 * x / a / b
    print(degrees(atan2(b, c)))
else:
    c = 2 * x / a / a - b
    print(degrees(atan2(b - c, a)))


Measured memory_bytes: 9384
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 08/22/20 18:13:53
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int h,w,m; cin>>h>>w>>m;
  vector<pair<int,int>> hr(h), vr(w);
  for (int i = 0; i < h; i++)
    hr[i].second = i;
  for (int i = 0; i < w; i++)
    vr[i].second = i;
  set<pair<int,int>> bs;
  for (int i = 0; i < m; i++) {
    int hi, wi; cin>>hi>>wi; hi--; wi--;
    hr[hi].first++;
    vr[wi].first++;
    bs.insert({hi, wi});
  }
  sort(hr.rbegin(), hr.rend());
  sort(vr.rbegin(), vr.rend());
  int ans = hr[0].first + vr[0].first - 1;
  for (int i = 0; i < h and hr[i].first == hr[0].first; i++) {
    for (int j = 0; j < w and vr[j].first == vr[0].first; j++) {
      if (bs.count({hr[i].second, vr[j].second}) == 0) {
        ans++;
        i = h;
        j = w;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 21940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public class State
{

    public struct AB
    {
        public int A;
        public int B;

        public AB(int a,int b)
        {
            this.A = a;
            this.B = b;

        }
    }

    public static void Main()
    {
        int N, M;
        var split = Console.ReadLine().Split().Select(int.Parse).ToArray();
        N = split[0];
        M = split[1];
        AB[] ab = new AB[N];
        for (long i = 0; i < N; i++)
        {
            split = Console.ReadLine().Split().Select(int.Parse).ToArray();

            ab[i] = new AB(split[0], split[1]);
        }
        Array.Sort(ab,comparer);
        long store = 0;
        int need = M;
        int[] buy = new int[N];

        while (need >0)
        {
            if (ab[store].B <= need)
            {
                buy[store] = ab[store].B;
                need -= ab[store].B;
                store++;
            }
            else
            {
                buy[store] = need;
                break;
            }
        }
        long pay = 0;
        for (int i = 0; i < N; i++)
        {
            if (buy[i] == 0) break;
            long temp = ab[i].A;
            temp *= buy[i];
            pay += temp;
        }
        Console.WriteLine(pay);

    }

    public static int comparer(AB a,AB b)
    {
        return a.A.CompareTo(b.A);
    }



}



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

#define INF 1e9
#define LLINF 1e18
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (c >= a && c <= b) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int64_t INF = 1LL << 60;
//const int INF = 1 << 29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    int N, K, R, S, P;
    string T;
    cin >> N >> K >> R >> S >> P >> T;
    int count = 0;
    rep(i, 0, N){
        if (T.at(i) == 's'){
            if (i >= K && T.at(i - K) == 's') T.at(i) = 'x';
            else count += R;
        }
        if (T.at(i) == 'p'){
            if (i >= K && T.at(i - K) == 'p') T.at(i) = 'x';
            else count += S;
        }
        if (T.at(i) == 'r'){
            if (i >= K && T.at(i - K) == 'r') T.at(i) = 'x';
            else count += P;
        }
    }
    cout << count << endl;
}

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

public class Main {

	public static void main(String[] args) {
        FastScanner in = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int d = in.nextInt(), t = in.nextInt() , s = in.nextInt();
        if(d/s<=t) {
        	if(d/s==t&&d%s!=0) out.println("No");
        	else out.println("Yes");
        }
        else out.println("No");
        out.flush();
	}
	
	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		
		String next() {
			while(!st.hasMoreTokens())
				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());
		}
		
		int[] readArray(int n) {
			int a[] = new int[n];
			for(int i=0;i<n;i++) a[i] = nextInt();
			return a;
		}
		
		long[] readArray(int n,long x) {
			long a[] = new long[n];
			for(int i=0;i<n;i++) a[i] = nextLong();
			return a;
		}
		
	}
	
	static boolean arrayEquals(char a[], char b[]) {
		int n = a.length;
		boolean verdict = true;
		for(int i=0;i<n;i++) {
			if(a[i]!=b[i]) {
				verdict = false;break;
			}
		}
		return verdict;
	}
	
	static long lcm(long a, long b) {
		return (a*b)/gcd(a,b);
	}
	
	static long gcd(long a, long b) {
		if(b==0) return a;
		else return gcd(b,a%b);
	}
}











Measured memory_bytes: 25420
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	long long n; cin >> n;
	long long ans = 0;
	for (long long i = 1; i <= n; i++) {
		if ((i % 3 != 0) and (i % 5 != 0)) ans += i;
	}
	cout << ans;
}

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

int main() {
	long long a, b, c, d, e;
	long long N;
	cin >> N >> a >> b >> c >> d >> e;
	long long minMove;
	//a~eの最小値をとる
	minMove = min({ a, b, c, d, e });

	long long ans;
	ans = (N + minMove - 1) / minMove + 4;
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Point[] point = new Point[n];
        int[] index = new int[n - 1];
        for (int i = 0; i < n; i++) {
            point[i] = new Point();
        }
        
        // 自分に子を割り当てる
        for (int i = 0; i < n - 1; i++) {
            int p = sc.nextInt() - 1;
            int q = sc.nextInt() - 1;
            index[i] = q;   // 出力順を記憶する
            
            point[p].child.add(q);
        }
        
        // 自分の子を若い色から塗る
        for (int i = 0; i < n; i++) {
            int nowColor = 1;
            int myColor = 0;
            if (i != 0) {
                myColor = point[i].color;
            }
            
            for (Integer children : point[i].child) {
                if (nowColor == myColor) {
                    nowColor++;
                }
                
                point[children].color = nowColor;
                nowColor++;
            }
        }
        
        // 必要な最小色数を出力
        int max = 0;
        for (Point p : point) {
            max = Math.max(max, p.color);
        }
        System.out.println(max);
        
        // 子の色を出力順に出力
        for (int i = 0; i < n - 1; i++) {
            System.out.println(point[index[i]].color);
        }
        
    }
    
    public static class Point {
        int color;
        List<Integer> child;
        
        Point() {
            this.child = new ArrayList<Integer>();
        }
    }
}


Measured memory_bytes: 100236
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int sum = 0;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            int s = sc.nextInt();
            sum += s;
            if (s % 10 != 0 && s < min) {
                min = s;
            }
        }

        if (sum % 10 != 0) {
            System.out.println(sum);
        } else {
            sum -= min;
            if (sum < 0) {
                System.out.println(0);
            } else {
                System.out.println(sum);
            }
        }
    }
}


Measured memory_bytes: 23764
#pragma GCC optimize ("O2")
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"

#define DEBUG 0
#define dd if (DEBUG)

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

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, A) for (auto & a : A)
#define all(a) (a).begin (), (a).end ()
#define rall(a) (a).rbegin (), (a).rend ()
#define sz(a) (int) (a).size ()
#define szl(a) (int) (a).length ()
#define FASTIO cin.sync_with_stdio (0); cin.tie (0); cin.exceptions (cin.failbit);

typedef long long ll;
typedef pair <int, int> pii;
#define f first
#define s second
#define mp(a, b) make_pair((a), (b))
typedef vector <int> vi;
typedef vector <vi> mi;
typedef vector <ll> vll;
typedef vector <vll> mll;
#define pb(a) push_back ((a))

const ll MOD = 1e+9+7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int INFi = 0x3f3f3f3f;
const ll MAXN = 1e+6+7;

int main ()
{
    FASTIO;
    int i, j, n;
    string s, t;
    cin >> s >> t;
    mi dp (szl(s) + 7, vi (szl (t) + 7));
    for (i = 0; i <= szl (s); i++)
    {
        for (j = 0; j <= szl (t); j++)
        {
            if (i == 0 || j == 0)
                dp[i][j] = 0;
        
            else if (s[i - 1] == t[j - 1])
                dp[i][j] = dp[i - 1][j - 1] + 1;
        
            else
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }
    dd for (i = 0; i <= szl (s); i++) {
        if (i <= 0)
            for (j = 1, cout << "  "; j <= szl (t); j++)
                cout << t[j - 1] << ' ';
        else
            for (j = 1, cout << s[i - 1] << ' '; j <= szl (t); j++)
                cout << dp[i][j] << ' ';
        cout << '\n';}
    dd cout << '\n';
    string out;
    for (i = szl (s), j = szl (t), n = dp[i][j]; n != 0;)
    {
        for (; j >= 0 && n == dp[i][j]; --j);
        ++j;
        dd printf ("%c %d ", t[j - 1], j);
        for (; i >= 0 && n == dp[i][j]; --i);
        ++i;
        dd printf ("%c %d\n", s[i - 1], i);
        out += s[i - 1];
        --i;
        n = dp[i][j];
    }
    for (i = szl (out) - 1; i >= 0; i--)
        cout << out [i];
    cout << '\n';

    return 0;
}



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

int main(){
	int a1,a2,a3,in;
	a1=a2=a3=0;
	
	for(int i=0;i<10;i++){
		cin>>in;
		if(in>a1){
			a3=a2;
			a2=a1;
			a1=in;
		}else if(in>a2){
			a3=a2;
			a2=in;
		}else if(in>a3){
			a3=in;
		}
	}
	cout<<a1<<endl<<a2<<endl<<a3<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int ,int> pi;
typedef pair<ll ,ll> pl;
typedef map<ll ,ll> ml;
#define modulo 1000000007
#define maxN 10000001
#define PI 3.14159265
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

void solve()
{ 
    char c;
    cin >> c;
    if(isupper(c))cout << "A" << endl;
    else cout << "a" << endl;
}

int main()
{

    fast;
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3644
n, m = map(int,input().split())
sa = set()
sb = set()
for i in range(m):
  a, b = map(int,input().split())
  if a == 1:
    sb.add(b)
  if b == n:
    sa.add(a)
print("IMPOSSIBLE" if len(sa&sb)==0 else "POSSIBLE")

Measured memory_bytes: 18892
# agc006_a.py
N = int(input())
S = list(input())
T = list(input())
ans = N*2
for i in range(N):
    # print(i,S[N-1-i:] , T[:i+1])
    if S[N-1-i:] == T[:i+1]:
        # print("find")
        ans = N*2-(i+1)
print(ans)


Measured memory_bytes: 3060
import collections
s = raw_input()
t = raw_input()
sb = s + s
h = {chr(ord('a') + i):-1 for i in range(26)}
dp = []
for j in range(len(sb)-1,-1,-1):
	dp.append({k:h[k] for k in h})
	h[sb[j]] = j
special = h
dp = dp[::-1]
i = -1
j = 0
c = 0
while(j < len(t)):
	ha = dp[i] if i >= 0 else special
	letter = t[j]
	if ha[letter] != -1:
		i = ha[letter]
		j += 1
	else:
		j = -1
		break

	if i >= len(s):
		i %= len(s)
		c+=1

print (c * len(s) + i + 1) if j != -1 else -1



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

int main(){
  int n, ans=100000, sum, a, b;
  cin >> n;
  
  for(int i = 0; i <= n; i++){
    a = i;
    b = n - i;
    sum = 0;
    while(a){
      sum += a % 6;
      a /= 6;
    }
    while(b){
      sum += b % 9;
      b /= 9;
    }
    if(ans > sum) ans = sum;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
#define ll long long int
#define mod 1000000007
#define adjSize 100000
#define MAX 1000000000
#ifdef FASTIO
#endif
/*
	Coded by Archit Shinde
*/
bool prime[(ll)1e7+1]; 
 
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}
 
unordered_set<ll> primeFactors(int n)  
{  
    // Print the number of 2s that divide n  
    unordered_set<ll> result;
    if(n%2==0){
    	result.insert(2);
    	while(n%2==0){
    		n=n/2;
    	} 
    }
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        if(n%i==0){
        	result.insert(i);
        	while(n%i==0){
        		n=n/i;
        	}
        }
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
    	result.insert(n);
    return result;
}  

vector<ll> printDivisors(int n) 
{ 
    // Note that this loop runs till square root 
    vector<ll> div;
    for (int i=1; i<=sqrt(n); i++) 
    { 
        if (n%i == 0) 
        { 
            // If divisors are equal, print only one 
            if (n/i == i && i%2 != 0 && i != 1){
                div.push_back(i);
            }
  
            else // Otherwise print both 
            {
            	if(i%2!=0)
                	div.push_back(i);
                if((n/i) %2!=0)	
                	div.push_back(n/i);

            }
        } 
    }
    //sort(div.begin(), div.end());
    return div;
} 

unordered_set<ll> SieveOfEratosthenes(ll n) 
{ 
	unordered_set<ll> u;
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        {  
            for (ll i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    for (ll p=2; p<=n; p++) 
       if (prime[p]) 
          u.insert(p);
    return u;
}

ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
}

ll product(ll num, ll result[], ll size){
	ll m = 0;
	ll i = 0;
	ll ans;
	for(i = 0; i<size; i++){
		ans = num*result[i]+m;
		m = ans/10;
		result[i] = ans%10;
	}
	while(m!=0){
		result[size] = m%10;
		m /= 10;
		size++;
	}
	return size;
}
void factorial(ll n){
	ll result[159];
	result[0] = 1;
	ll i, size = 1;
	for(i = 2; i<=n; i++){
		size = product(i, result, size);
	}
	for(i = size-1; i>=0; i--){
		cout<<result[i];
	}
}


int main()
{
	ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	ll t;
	cin>>t;
	map<string, ll> cnt;
	while(t--){
		string str;
		cin>>str;
		cnt[str]++;
	}
	cout<<"AC x "<<cnt["AC"]<<endl;
	cout<<"WA x "<<cnt["WA"]<<endl;
	cout<<"TLE x "<<cnt["TLE"]<<endl;
	cout<<"RE x "<<cnt["RE"]<<endl;
	return 0;
}



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

int main(){
    Int N, A, B; cin >> N >> A >> B;

    Int ans = (N/ (A+B)) * A, r = N % (A+B);

    ans += min(r, A);

    cout << ans << endl;
}


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

int main() {
    int ans, n;
    string s;
    cin >> s;
    ans = n = s.size();
    REP(i,n-1){
        if(s[i]!=s[i+1]){
            ans = min(ans, max(i+1,n-i-1));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;


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

    int H,A;
    cin >> H >> A;
    cout << (H-1)/A+1 << endl;

    

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int a, b; cin >> a >> b;
  if ((a + b) % 2 == 1) {
    cout << "IMPOSSIBLE" << endl;
  } else {
    cout << (a + b) / 2 << endl;
  }
}


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

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    if (b - a + 1 <= 2 * k) {
        for (int i = a; i <= b; i++) {
            cout << i << endl;
        }
    } else {
        for (int i = a; i < a + k; i++) {
            cout << i << endl;
        }
        for (int i = b - k + 1; i <= b; i++) {
            cout << i << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
    int n, m, ans=0;
    cin >> n >> m;
    int swi[(1<<n)][n];
    for(int bit = 0; bit < (1<<n); bit++){
        for(int i = 0; i < n; i++){
            if(bit & (1<<i)){
                swi[bit][i]=1;
            }
            else swi[bit][i]=0;
        }
    }
    vector<int> k(m), p(m);
    vector<vector<int>> s(m, vector<int>(n));
    for(int i = 0; i < m; i++){
        cin >> k.at(i);
        s[i].resize(k.at(i));
        for(int j = 0; j < k.at(i); j++){
            cin >> s[i].at(j);
        }
    }
    for(int i = 0; i < m; i++)cin >> p.at(i);

    for(int bit = 0; bit < (1<<n); bit++){
        for(int i = 0; i < m; i++){
            int sum=0;
            for(int j = 0; j < k.at(i); j++){
                sum += swi[bit][s[i][j]-1];
            }
            if(sum % 2 != p.at(i))break;
            if(i == m-1)ans++;
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
n = int(input())
A = sorted(list(map(int,input().split())))
for i in range(n):
    if A[i]*2>A[-1]:
        ind = i
        break
ind -= 1
a = A[ind]
b = A[-1]-A[ind+1]
if a>=b:
    print(A[-1],a)
else:
    print(A[-1],A[ind+1])


Measured memory_bytes: 86032
#include <stdio.h>

int main()
{
    int n = 0; // main number
    int front = 0;
    int i = 0;
    int total = 0;
    
    // using the gauss method.
    
    scanf("%d",&n);
    int back = n;
    
    if (n%2 == 0)
    {
        for (i=1;i<(n/2);i++)
        {
            front = front + i;
            back = back - i;
            
            if (front != back)
            {
                total = total + 1;
            }
            else if (front + back == n)
            {
                total = total + 1;
            }
        }
    }
    
    else
    {
        for (i=1;i<=(n/2);i++)
        {
            front = front + i;
            back = back - i;
            
            if (front != back)
            {
                total = total + 1;
            }
            else if (front + back == n)
            {
                total = total + 1;
            }
        }
    }
    
    printf("%d",total);
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main() 
{
  long long result = 0;
  int R,G,B,N;
  cin >> R >> G >> B >> N;
  for(int r = 0; R*r <= N; r++)
  {
    for(int g = 0; R*r + G*g <= N; g++)
    {
      int n = N-(R*r+G*g);
      if(n%B==0){result++;}
    }
  }
  cout << result;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
l = max(A)+1
li = [0]*(l)
A.sort()

for a in A:
  if li[a] == 0:
    li[a] = 1
    for i in range(a*2, l, a):
      li[i] = 2
  elif li[a] == 1:
    li[a] = 2
print(li.count(1))


Measured memory_bytes: 32324
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        if (x-r >= 0 && x+r <= W && y-r>=0 && y+r <=H) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26276
#include <bits/stdc++.h>
using namespace std;
int main(void){

    static const double pi = 3.141592653589793;
    int A, B, H, M;
    cin >> A >> B >> H >> M;
    
    double posB = 360*M/60.0;
    double posA = 360*(60*H+M)/720.0;
    double AtoB = abs(posA - posB);
    double dist;
   
    if(AtoB > 180){
        AtoB = 360 - AtoB;
        dist = sqrt(A*A+B*B-2*A*B*cos(pi*(AtoB)/180));
    }else if(AtoB == 180){
        dist = A + B;
    }else{
        dist = sqrt(A*A+B*B-2*A*B*cos(pi*(AtoB)/180));
    }
    
    cout << setprecision(20) << dist << endl;
    
}


Measured memory_bytes: 4224
Sa = list(input())
Sb = list(input())
Sc = list(input())
S = [Sa, Sb, Sc]

player = ['A','B','C']
card = ['a','b','c']
turn = 0

while(1):
    if len(S[turn]) == 0:
        print(player[turn])
        break
    else:
        position = S[turn].pop(0)
        turn = card.index(position)

Measured memory_bytes: 3064
using System;
class ProgramC
    {
        static void Main(string[] args)
        {
            
            //入力
            string[] s = Console.ReadLine().Split(' ');
            long n = long.Parse(s[0]);
            long k = long.Parse(s[1]);
          
            n %= k;
            
            Console.WriteLine(Math.Min(k - n, n));
            
        } 
    }

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define int long long
#define double long double
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define INF 1e18
#define porc 1000000007
#define ff first
#define ss second
#define ll long long
#define td(v) v.begin(),v.end()
#define tdr(v) v.rbegin(),v.rend()
using namespace std;
bool cmd(pair<int,int> a, pair<int,int> b){
    return a.second<b.second;
}
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int exp(int a, int b,int M){
    int result = 1;
    while (b > 0){
        if (b & 1)
            result = (result*a)%M;
 
        b >>= 1;
        a = (a*a)%M;
    }
    return result;
}
main(){
    string a,b;
    cin>>a;
    b=a;
    reverse(td(b));
    int res=0;
    for(int i=0;i<b.size()/2;i++){
        if(a[i]!=b[i]){
            res++;
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#define Rep(i,a) for(int i = 0; i < (a); i++)
#define rep(i,a,b) for(int i = (a); i <= (b); i++)//(a)!
#define dep(i,a,b) for(int i = (a); i >= (b); i--)
#define ab(a) ((a) > 0 ? (a) : -(a))
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
int main() {
	int n; scanf("%d",&n); int a; scanf("%d",&a);
	int mn = 1; LL ans = a - 1;
	rep(i,2,n) {
		int a; scanf("%d",&a);
		if (a == mn + 1) mn++;
		else if (a > mn + 1) ans += (a - 1) / (mn + 1);
	}
	cout <<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define x first
#define y second
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define pbb pair<bool,bool>
#define mp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define xmod (ll)(1e9+7) 
#define hmod 1286031825167LL
using namespace std;

int n,x,p[20005];
int main(){	
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i=1;i<=n;i++){
    	cin >> x;
    	p[x]=i;
	}
	for (int i=1;i<=n;i++){
		cout << i*50000 << " ";
	}
	cout << "\n";
	for (int i=1;i<=n;i++){
		cout << (n-i)*50000+p[i] << " ";
	}
	cout << "\n";
    return 0;
}	

Measured memory_bytes: 3704
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Food {
	String name;
	int w;
	int s;

	public Food(String name, int w, int s) {
		this.name = name;
		this.w = w;
		this.s = s;
	}

}

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	public void run() {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if(n==0)
				break;
			int max = 0;
			List<Food> list = new ArrayList<Food>();
			for (int i = 0; i < n; i++) {
				String l = scanner.next();
				int a = scanner.nextInt();
				int b = scanner.nextInt();
				list.add(new Food(l, a, b));
				max += a;
			}
			for (int i = 0; i < n; i++) {
				int l = 0;
				int k = 0;
				for (int j = 0; j < n; j++) {
					int m = max - list.get(j).w;
					int ss = list.get(j).s;
					if (m <= ss) {
						if (list.get(j).w > k) {
							k = list.get(j).w;
							l = j;
						}
					}
				}
				max -= list.get(l).w;
				System.out.println(list.get(l).name);
				list.get(l).s = -10;
				list.get(l).w = 0;
			}
		}
	}

}

Measured memory_bytes: 20504
#include <bits/stdc++.h>
#define LL long long
#define maxn 200005
using namespace std;
map<int ,int> mp;
int main()
{
   char ch[60];
   cin>>ch;
   if(ch[2]==ch[3]&&ch[4]==ch[5])
    cout<<"Yes"<<endl;
   else
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

const ll MOD = 1e9 + 7;

const int MAXN = 210000;

int n;

int a[MAXN];
ll dp[MAXN];

void add(ll &a, ll b) {
	a = (a + b) % MOD;
}

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	dp[a[0]] = 1;
	for (int i = 0; i < n; ++i) {
		if (a[i] != a[i + 1]) {
			add(dp[a[i + 1]], dp[a[i]]);
		}
	}
	cout << dp[0] << "\n";
	return 0;
}




Measured memory_bytes: 2560
#include <iostream>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
void trace(int A[], int N){
    for (int i = 0; i < N - 1; i++)
    {
        cout << A[i] << " ";
    }
    cout << A[N - 1] << endl;
    
}

int main() {
    int n;
    int a;
    cin >> n;

    int array[100];
    REP(i, n){
        cin >> a;
        array[i] = a;
    }
    trace(array, n);
    for(int i = 1; i < (int)(n); i++){
        int v = array[i];
        int j = i - 1;
        while (j >= 0 && array[j] > v){
            array[j+1] = array[j];
            j--;
        }
        array[j+1] = v;
        trace(array, n);
    }

}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

signed main()
{
	IO_OP;
	
	int n, lcnt = 0, rcnt = 0;
	cin >> n;
	V<pi> pos, zero, neg;
	for(int i = 0; i < n; i++) {
		string s;
		cin >> s;
		int need = 0, psum = 0;
		for(char c:s) {
			if(c == '(') lcnt++, psum++;
			else rcnt++, psum--;
			need = max(need, -psum);
		}
		if(psum > 0) pos.EB(need, psum);
		else if(psum == 0) zero.EB(need, psum);
		else {
			reverse(ALL(s))	;
			int need = 0, psum = 0;
			for(char c:s) {
				if(c == ')') psum++;
				else psum--;
				need = max(need, -psum);
			}
			neg.EB(need, psum);
		}
	}
	if(lcnt != rcnt) {
		cout << "No" << endl;
		return 0;
	}
	{
		sort(ALL(pos));
		int lb = 0;
		multiset<pi> s;
		int psum = 0;
		for(int i = 0; i < pos.size(); i++) {
			while(lb < pos.size() && pos[lb].F <= psum) {
				s.insert({pos[lb].S, pos[lb].F});
				lb++;
			}
			if(s.empty()) {
				cout << "No" << endl;
				return 0;
			}
			pi p = *s.rbegin();
			psum += p.F;
			s.erase(s.lower_bound(p));
		}
		for(pi p:zero) {
			if(p.F > psum) {
				cout << "No" << endl;
				return 0;
			}
		}

	}
	{
		sort(ALL(neg));
		int lb = 0;
		multiset<pi> s;
		int psum = 0;
		for(int i = 0; i < neg.size(); i++) {
			while(lb < neg.size() && neg[lb].F <= psum) {
				s.insert({neg[lb].S, neg[lb].F});
				lb++;
			}
			if(s.empty()) {
				cout << "No" << endl;
				return 0;
			}
			pi p = *s.rbegin();
			psum += p.F;
			s.erase(s.lower_bound(p));
		}
	}
	cout << "Yes" << endl;
}





Measured memory_bytes: 34280
package main

import "fmt"

func od(n int) int{
	return 3*n+1
}

func ev(n int) int{
	return n/2
}

func main() {
	var s int
	fmt.Scan(&s)
	m := make(map[int]int)
	m[s]++
	var tmp,cnt int
	cnt=1
	tmp=s
	for m[tmp]<=1 {
		if tmp%2==0 {
			tmp = ev(tmp)
		} else {
			tmp = od(tmp)
		}
		m[tmp]++
		cnt++
	}
	fmt.Println(cnt)
}

Measured memory_bytes: 512
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 文字列の入力
		String s = sc.next();
		String sun = "SUN";
		String mon = "MON";
		String tue = "TUE";
		String wed = "WED";
		String thu = "THU";
		String fri = "FRI";
		String sat = "SAT";
		// 出力
		if( s.equals(sat)) {
			System.out.println("1");
		} else if( s.equals(fri) ) {
			System.out.println("2");
		} else if( s.equals(thu) ) {
			System.out.println("3");
		} else if( s.equals(wed) ) {
			System.out.println("4");
		} else if( s.equals(tue) ) {
			System.out.println("5");
		} else if( s.equals(mon) ) {
			System.out.println("6");
		} else {
			System.out.println("7");
		}
	}
}


Measured memory_bytes: 21844
import numpy as np


n, d = map(int ,input().split())
x = []
sq = [i**2 for i in range(200)]
for i in range(n):
    x.append(list(map(int, input().split())))
x = np.array(x)
count = 0
for i in range(n):
    for j in range(i+1, n):
        if sum((x[i]-x[j])**2) in sq:
            count += 1
print(count)


Measured memory_bytes: 13132
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define Cout(s) cout << s << endl;
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 1ll << 60;
ll MOD = 1e9 + 7;

P f(int x)
{
    int a = x % 10;
    int b = 0;

    while (x)
    {
        b = x;
        x /= 10;
    }
    return P(a, b);
}

int main()
{

    ll h;
    cin >> h;

    ll cnt = 0;
    ll now = h;

    ll fact = 1;
    while (now > 1ll)
    {
        cnt++;
        now = now / 2ll;

        if (now != 1ll)
            fact += pow(2, cnt); // * 2ll;
    }
    cnt++;

    ll ans = pow(2, cnt) - 1;
    Cout(ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

const int V = 100000;

ll w[100], v[100], dp[101][100001];

int main() {
    int n, W;
    cin >> n >> W;
    for(int i=0;i<n;++i) cin >> w[i] >> v[i];

    fill(dp[0], dp[100]+100001, 1LL<<60);
    dp[0][0] = 0;
    for(int i=0;i<n;++i) {
        for(int vi=0;vi<=V;++vi) {
            if(dp[i][vi] == (1LL << 60)) continue;
            dp[i+1][vi] = min(dp[i+1][vi], dp[i][vi]);
            if(dp[i][vi]+w[i] <= W) dp[i+1][vi+v[i]] = min(dp[i+1][vi+v[i]], dp[i][vi]+w[i]);
        }
    }
    
    int ans = 0;
    for(int vi=V;vi>=0;--vi) {
        if(dp[n][vi] == (1LL << 60)) continue;
        ans = vi;
        break;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 79104
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;

void main() {
	auto N = split(readln())[0].to!int();
	auto L = split(readln()).map!(x => to!int(x));
	auto sum = reduce!("a + b")(L);
	
	foreach (i; 0 .. N) {
		if (sum-L[i] <= L[i] ) { writeln("No"); return; }
	}
	
	writeln("Yes");
} 

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


int main() {
    long long n, k;
    cin >> n >> k;
    bool ans = true;
        long long x = n - (n/k)*k;
        long long y = ((n/k)+1)*k - n;
        if(x > y) n = y; else n = x;      
    cout << n << endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
 
int main(void) {
    string s;
    cin >> s;
 
    int n = s.length();
    int mask = 0;
    int ans = n;
    unordered_map<int, int> dp;
    dp[0] = 0;
    for (int i = 0; i < n; ++ i) {
        mask ^= 1<<(s[i] - 'a');
        if (dp.find(mask) != end(dp)) ans = dp[mask];
        else ans = n;
 
        for (int j = 0; j < 26; ++ j) if (dp.find(mask ^ (1<<j)) != end(dp)) {
            ans = min(ans, dp[mask ^ (1<<j)] + 1);
        }
        if (dp.find(mask) == end(dp)) dp[mask] = ans;
        else if (dp[mask] > ans) dp[mask] = ans;
    }
    if (ans == 0) ++ ans;
    cout << ans << endl;
 
    return 0;
}

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

using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using ll = long long int;
using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>;
using vd = vector<double>; using vvd = vector<vd>; using vvvd = vector<vvd>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using cdouble = complex<double>;

const double eps = 1e-7;
#define Loop(i, n) for(int i = 0; i < int(n); i++)
#define Loopll(i, n) for(ll i = 0; i < ll(n); i++)
#define Loop1(i, n) for(int i = 1; i <= int(n); i++)
#define Loopll1(i, n) for(ll i = 1; i <= ll(n); i++)
#define Loopr(i, n) for(int i = int(n) - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = ll(n) - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = int(n); i >= 1; i--)
#define Looprll1(i, n) for(ll i = ll(n); i >= 1; i--)
#define Foreach(buf, container) for(auto buf : container)
#define Loopdiag(i, j, h, w, sum) for(int i = ((sum) >= (h) ? (h) - 1 : (sum)), j = (sum) - i; i >= 0 && j < (w); i--, j++)
#define Loopdiagr(i, j, h, w, sum) for(int j = ((sum) >= (w) ? (w) - 1 : (sum)), i = (sum) - j; j >= 0 && i < (h); j--, i++)
#define Loopdiagsym(i, j, h, w, gap) for (int i = ((gap) >= 0 ? (gap) : 0), j = i - (gap); i < (h) && j < (w); i++, j++)
#define Loopdiagsymr(i, j, h, w, gap) for (int i = ((gap) > (h) - (w) - 1 ? (h) - 1 : (w) - 1 + (gap)), j = i - (gap); i >= 0 && j >= 0; i--, j--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(ex_i, vector.size()) { cout << vector[ex_i] << " "; } cout << endl;
#define printmx(matrix) Loop(ex_i, matrix.size()) { Loop(ex_j, matrix[ex_i].size()) { cout << matrix[ex_i][ex_j] << " "; } cout << endl; }
#define quickio() ios::sync_with_stdio(false); cin.tie(0);
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
#define Comp(type_t) bool operator<(const type_t &another) const
#define fst first
#define snd second
#define INF INFINITY
bool feq(double x, double y) { return abs(x - y) <= eps; }
bool inrange(ll x, ll t) { return x >= 0 && x < t; }
bool inrange(vll xs, ll t) { Foreach(x, xs) if (!(x >= 0 && x < t)) return false; return true; }
int ceillog2(ll x) { int ret = 0;	x--; while (x > 0) { ret++; x >>= 1; } return ret; }
ll rndf(double x) { return (ll)(x + (x >= 0 ? 0.5 : -0.5)); }
ll floorsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (m * m <= x ? 0 : -1); }
ll ceilsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (x <= m * m ? 0 : 1); }
ll rnddiv(ll a, ll b) { return (a / b + (a % b * 2 >= b ? 1 : 0)); }
ll ceildiv(ll a, ll b) { return (a / b + (a % b == 0 ? 0 : 1)); }
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }

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

int main() {
	int n, l; cin >> n >> l;
	int m = l;
	int M = l + n - 1;
	int sum = 0;
	Loop(i, n) {
		sum += l + i;
	}
	if (m <= 0 && 0 <= M) {
		cout << sum - 0 << endl;
	}
	else if (M < 0) {
		cout << sum - M << endl;
	}
	else {
		cout << sum - m << endl;
	}
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
keta = len(str(N))
if keta == 1:
    print(N)
    sys.exit()
ans = {}
for i in [1,2,3,4,5,6,7,8,9]:
    for j in [1,2,3,4,5,6,7,8,9]:
        ans[(i, j)] = 0
for i in range(1, N+1):
    maxdigit = int(str(i)[0])
    mindigit = int(str(i)[-1])
    if mindigit != 0:
        ans[(maxdigit, mindigit)] += 1
cnt = 0
for i in range(1, 10):
    for j in range(1, 10):
        if i == j:
            cnt += ans[(i, i)] ** 2
        else:
            cnt += ans[(i, j)] * ans[(j, i)] * 2
            ans[(i, j)] = 0
            ans[(j, i)] = 0
print(cnt)

        

    

Measured memory_bytes: 40556
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <numeric>

//#include <map>

using namespace std;

int main()
{
	char ch[1200];
	memset(ch, 0, sizeof(ch));

	string st;
	getline(cin, st);
	strcpy(ch, st.c_str());
	char* pch = ch;

	while ( *pch )
	{
		if (*pch >= 'a' && *pch <= 'z')
		{
			*pch -= 0x20;;
		}
		else if (*pch >= 'A' && *pch <= 'Z')
		{
			*pch += 0x20;
		}
		pch++;
	}

	cout << ch << endl;

	return 0;
}

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

int main(){
    int n,ans=0,mae=0;
    cin>>n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n-1);
    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-1;i++){
        cin>>c[i];
    }
    for(int i=0;i<n;i++){
        if(mae==a[i]-1){
            ans+=c[a[i-1]-1];
        }
        ans+=b[a[i]-1];
        mae=a[i];
    }
    cout<<ans;
} 


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

int a[5] = {5,7,5,7,7};

int main(){
    int n;
    while(cin >> n, n){
        int w[n];
        string s;
        for(int i = 0; i < n; i++){
            cin >> s;
            w[i] = s.length();
        }
        
        int ans;

        for(int i = 0; i < n; i++){
            int pos = 0, tmplen = 0;
            for(int j = i; j < n; j++){
                if(tmplen < a[pos]) tmplen += w[j];
                if(tmplen > a[pos]) break;
                if(tmplen == a[pos])    pos++, tmplen = 0;
                if(pos == 5){
                    ans = i;
                    break;
                }
            }
            if(pos == 5)    break;
        }

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


Measured memory_bytes: 3188
#include <iostream>
using namespace std;
#include<string.h>
#include<set>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include <cstdio>
#include <cstdlib>
#include<stack>
#include<vector>
long long  a[51000000];
long long  n,a1,b1;
long  panduan(long long  zhi)
{
    long long  t=b1*zhi;
    long long  add=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]-t>0)
        {
            if((a[i]-t)%(a1-b1)==0)
                add+=(a[i]-t)/(a1-b1);
            else
                add+=(a[i]-t)/(a1-b1)+1;
        }
    }
    //cout<<zhi<<"_"<<add<<endl;
    return add<=zhi;
}
int  main()
{
    cin>>n>>a1>>b1;
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    long long  kaishi=0,jieshu=1e9;
    long long  mid;
    //cout<<panduan(3)<<"_"<<endl;
    int t;
    while(kaishi<jieshu-1)
    {
        //cout<<kaishi<<"_"<<jieshu<<endl;
        mid=(jieshu+kaishi)>>1;
        if(panduan(mid))
        {
            jieshu=mid;
            t=mid;
        }
        else
            kaishi=mid;
    }
    cout<<jieshu<<endl;
    return 0;
}

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

#define int long long int
#define double long double
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define endl "\n"

const int N = 105;
int a[N];
unordered_map<int, int>m;

int check(int y)
{
	int ans = 0;
	for (auto x : m)
	{
		int val = (x.ff - y) * (x.ff - y);
		ans += x.ss * val;

	}
	return ans;
}

int32_t main()
{
	IOS;
	int n;
	cin >> n;
	int sum = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		m[a[i]]++;
	}
	for (auto x : m)
		sum += x.ff;
	int y = sum / (int)m.size();
	int res = 2e9;
	for (int i = y - 105; i <= y + 105; i++)
	{
		res = min(res, check(i));
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256