akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <tuple>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <assert.h>

using namespace std;

int64_t value(string& s, int64_t op, int64_t len)
{
  vector<string> ss;
  string x = string(1, s[0]);
  for (int64_t i = 0; i < len; i++) {
    if ((op >> i) & 1) {
      ss.push_back(x);
      x = string(1, s[i + 1]);
    } else {
      x += string(1, s[i + 1]);
    }
  }
  
  if (x != "") {
      ss.push_back(x);
  }

  int64_t sum = 0;
  for (int i = 0; i < ss.size(); i++) {
    //    cout << ss[i] << ", ";
    sum += (int64_t)stoll(ss[i]);
  }
  //  cout << endl;

  return sum;
}

int64_t sum(string& s)
{
  int64_t n = 0;
  int64_t len = s.length() - 1;
  for (int64_t i = 0; i < (1 << len); i++) {
    //    cout << "op " << i << endl;
    n += value(s, i, len);
  }
  return n;
}

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

  cout << sum(s) << endl;
  
  return 0;
}


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

int main() {
    long long N;
    cin >> N;
    long long best = N - 1;

    for (long long a = 1; a * a <= N; a++)
        if (N % a == 0)
            best = min(best, a + N / a - 2);

    cout << best << '\n';
}


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

using namespace std;

int main() {
    int n;
  	vector<int> v;
  	cin >> n;
    
  	if (n == 1) {
      	cout << "Yes" << endl;
      	return 0;
    }
  	
  	int tmp;
  	for (int i = 0; i < n; i++) {
      	cin >> tmp;
      	v.push_back(tmp);
    }
  	
  	reverse(v.begin(), v.end());
  	
  	for (int i = 1; i < n; i++) {
      	if (v[i] - v[i - 1] == 1) {
          	v[i]--;
        } else if (v[i] - v[i - 1] >= 2) {
         	cout << "No" << endl;
          	return 0;
        }
    }
  
  	cout << "Yes" << endl;
  
    return 0;
}

Measured memory_bytes: 892
N,M=gets.split.map &:to_i
list=Array.new(M,0)
N.times{
    ans=gets.split.map &:to_i
    ans[0].times{|i|
        list[ans[i+1]-1]+=1
    }
}
c=0
M.times{|m|
    if list[m]==N then
        c+=1
    end
}
p c

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

int main() {
  int n, sum = 0;
  cin >> n;

  long int c = 0;

  for (int i = 1; i <= n; i++) {
    if (!(i % 3 == 0 || i % 5 == 0)) c += i;
  }

  cout << c << endl;
}


Measured memory_bytes: 3636
import java.util.*;
public class Main{   
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int[][] c = new int[3][3];
      for(int i = 0;i < 3;i++){
      	for(int j = 0;j < 3;j++){
        	c[i][j]=sc.nextInt();
        }
      }
      if(c[1][1]==c[0][1]+c[1][0]-c[0][0]&&c[1][2]==c[1][0]+c[0][2]-c[0][0]&&c[2][1]==c[2][0]+c[0][1]-c[0][0]&&c[2][2]==c[2][0]+c[0][2]-c[0][0])System.out.println("Yes");
      else System.out.println("No");
    }
    public static int lcm(int x, int y){
      return x*y/gcd(x,y);
    }
    public static int gcd(int x, int y){
      if(x < y)return gcd(y,x);
      if(y==0)return x;
      return gcd(y,x%y);
    }
}

Measured memory_bytes: 22612
#include<cstdio>
#include<functional>
#include<algorithm>
#define Rint register int
using namespace std;
typedef long long LL;
const int N = 100003;
int n, fa[N], siz[N], head[N], to[N], nxt[N];
LL sum[N];
struct Node {
	LL val;
	int pos;
	inline Node(LL _val = 0, int _pos = 0): val(_val), pos(_pos){}
	inline bool operator < (const Node &o) const {return val > o.val;}
} a[N];
LL ans;
inline void add(int a, int b){
	static int cnt = 0;
	to[++ cnt] = b; nxt[cnt] = head[a]; head[a] = cnt;
}
inline void dfs(int x, int d){
	ans += d;
	for(Rint i = head[x];i;i = nxt[i])
		dfs(to[i], d + 1);
}
int main(){
	scanf("%d", &n);
	for(Rint i = 1;i <= n;i ++){
		scanf("%lld", &a[i].val);
		a[i].pos = i;
		siz[i] = 1;
	}
	sort(a + 1, a + n + 1);
	for(Rint i = 1;i <= n;i ++) sum[i] = a[i].val;
	for(Rint i = 1;i < n;i ++){
		int pos = lower_bound(sum + 1, sum + n + 1, sum[i] - n + (siz[i] << 1), greater<LL>()) - sum;
		if(sum[pos] != sum[i] - n + (siz[i] << 1) || pos == i){
			puts("-1");
			return 0;
		}
		fa[a[i].pos] = a[pos].pos; siz[pos] += siz[i]; add(pos, i);
	}
	dfs(n, 0);
	if(ans == a[n].val){
		for(Rint i = 1;i <= n;i ++)
			if(fa[i]) printf("%d %d\n", i, fa[i]);
		return 0;
	}
	puts("-1");
}

Measured memory_bytes: 6784
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
#include<cstdlib>
#include<ctime>
#include<vector>
#include<map>
using namespace std;

int main(){
//srandom((unsigned long)time(NULL));

long long w,a,b;
cin>>w>>a>>b;
if(abs(a-b)<=w){
    cout<<0<<endl;
    return 0;
}

cout<<min(abs(a-b-w),abs(b-a-w))<<endl;


return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

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

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n;
  cin >> n;

  ll sum = 0;
  ll keta = 1;
  ll v = 26;

  while (sum + v < n) {
    sum += v;
    v *= 26;
    keta++;
  }
  n -= sum;

  string a(keta, 'a');

  n--;
  ll i = 0;
  while (n) {
    ll v = n % 26;
    n /= 26;
    a[i++] += v;
  }

  reverse(all(a));
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 3648
N = int(input())
S = input()

d = {"W" : 0, "E" : 0}
for i in range(N):
    d[S[i]] += 1

t = {"W" : 0, "E" : 0}
ans = 300000
for i in range(N):
    if S[i] == "W":
        ans = min(ans,t["W"] + d["E"] - t["E"])
    else:
        ans = min(ans,t["W"] + d["E"] - t["E"] - 1)
    t[S[i]] += 1
print(ans)
        


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

int main()
{

int N;
cin>>N;
for(int i=1;i<=9;i++)
{
	int temp=i*100+i*10+i;
	if(temp>=N)
	{
		cout<<temp<<endl;
		break;
	}
}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include<string>
#include<cstring>
using namespace std;
int main()
{
	long long x;
	cin >> x;
	long long a = 2;
	for (int i = 0; i < x; i++)
	{
		a = (a + 1) * 2;
	}
	cout << a;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
    #include <filesystem>
    namespace fs = std::filesystem;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
int cnt[5];
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path __p = __FILE__;
        fs::path __input, __output;
        __input = __output = __p.parent_path();
        __input += string("/input/") + string(__p.stem()) + string(".txt");
        __output += string("/output/") + string(__p.stem()) + string(".txt");
        freopen(__input.c_str(), "r", stdin);
        freopen(__output.c_str(), "w", stdout);
    #endif
    cin >> N;
    memset(cnt,0,sizeof(cnt));
    for (int i = 0; i < N; i++)
    {
        ll a; cin >> a;
        if(a%2!=0) cnt[1]++;
        else if(a%4==0) cnt[4]++;
        else cnt[2]++;
    }
}

bool solve(){
    if(N%2==0){
        if(cnt[1]<=cnt[4]) return true;
        else return false;
    }
    else
    {
        if(cnt[1]<=cnt[4]) return true;
        else {
            if((cnt[1]-1)==cnt[4] && cnt[2]==0) return true;
            else return false;
        }        
    }
    
    return 0;
}   

int main()
{
    input();
    cout << (solve() ? "Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 256
length_of_input = int(input())

playlist = []
for i in range(length_of_input):
    current_line_list = input().split()
    playlist.append({"title": current_line_list[0], "length": int(current_line_list[1])})

last_awake_title = input()

duration_of_sleep = 0
sleeping_flag = False

for music_obj in playlist:
    if sleeping_flag:
        duration_of_sleep += music_obj["length"]
    else:
        if music_obj["title"] == last_awake_title:
            sleeping_flag = True

print(duration_of_sleep)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
signed main(){
	int a,b;
	cin>>a>>b;
	cout<<a*b/2<<endl;
}

Measured memory_bytes: 256
a = gets.to_i
b= gets
k=1
ans=0

array =  b.split(" ").map(&:to_i)

for num in 0..a-1
  if array[num]==k
    k+=1
    ans+=1
  end
end

if ans==0
  ans=a+1
end

puts a-ans
  
  

Measured memory_bytes: 15364
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cstdlib>
#include <cctype>
#define ll long long
#define PI 3.14159265358979323846
using namespace std;
int dist(int a,int b,int c,int d){
	return abs(a-c)+abs(b-d);
}
int main(){
	int n,m;
	cin>>n>>m;
	int *a=new int[n];
	int *b=new int[n];
	int *c=new int[m];
	int *d=new int[m];
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
	}
	for(int j=0;j<m;j++){
		cin>>c[j]>>d[j];
	}
	int min=100000;
	int index;
	for(int i=0;i<n;i++){
		min=10000000000;
		for(int j=0;j<m;j++){
//			cout<<a[i]<<" "<<b[i]<<" "<<c[j]<<" "<<d[j]<<endl;
//			cout<<"123."<<dist(a[i],b[i],c[j],d[j])<<endl;
			if(dist(a[i],b[i],c[j],d[j])<min){
				min=dist(a[i],b[i],c[j],d[j]);
				index=j+1;
//				cout<<"index:"<<index<<endl;
			}
		}
		cout<<index<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
#
#
# @stop_watch
def solve(N, XYs):
    ans = 0
    for i in range(2 ** N):
        for j in range(N):
            if (i >> j) & 1:
                for x, y in XYs[j + 1]:
                    if ((i >> (x - 1)) & 1) ^ y:
                        break
                else:
                    continue
                break
        else:
            ans = max(ans, bin(i).count('1'))
    print(ans)


if __name__ == '__main__':
    N = int(input())
    XYs = [[] for _ in range(N + 1)]
    for i in range(N):
        Ai = int(input())
        for _ in range(Ai):
            XYs[i + 1].append([int(i) for i in input().split()])
    # N = 15
    # XYs = [[] for _ in range(N + 1)]
    # for i in range(N):
    #     for j in range(15):
    #         if i == j:
    #             continue
    #         XYs[i + 1].append([j + 1, 1])
    # print(N)
    # for i in range(len(XYs)):
    #     print(i, XYs[i])
    solve(N, XYs)


Measured memory_bytes: 9196
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
using namespace std;

bool exist(vector<string> v, string s)
{
    bool exist = false;
    for (int i = 0; i < v.size(); i++)
    {
        if(v[i] == s) exist = true;
    }

    if(exist) return true;
    else return false;
}

int main()
{
    int n = 0;
    string s;
    vector<string> v;
    int rule = true;

    cin >> n;
    cin >> s;
    v.push_back(s);

    for (int i = 1; i < n; i++)
    {
        cin >> s;
        // cout << "s == " << s << endl;
        // cout << "v[i-1] = " << v[i - 1] << endl;
        if(exist(v,s) || (v[i-1].back() != s[0])) rule = false;
        v.push_back(s);
    }

    if(rule) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
N=int(input())
S=[]
dict={}

for n in range(N):
  S.append(input())

S.sort()

for n in range(N):
  if n!=0 and S[n]==S[n-1]:
    dict[S[n]]+=1
  else:
    dict[S[n]]=1
    
MAX=max(dict.values())
S2=[]

for k,v in dict.items():
  if v==MAX:
    S2.append(k)

S2.sort()
for s2 in S2:
  print(s2)
    


Measured memory_bytes: 35216
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var abcde = new int[5];
            for (var i = 0; i < abcde.Length; i++)
            {
                abcde[i] = int.Parse(Console.ReadLine());
            }
            abcde = abcde.OrderByDescending(x => (x - 1) % 10).ToArray();
            var sum = 0;
            for (var i = 0; i < abcde.Length; i++)
            {
                sum += abcde[i];
                if (i < abcde.Length - 1)
                {
                    var mod = (abcde[i] % 10);
                    sum += (mod > 0 ? 10 - mod : 0);
                }
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 13396
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
	
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		
		if (n < 1000) {
			System.out.println("ABC");
		}
		else if (n >= 1000) {
			System.out.println("ABD");
		}
	
	}
}

Measured memory_bytes: 23124
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner scanner =new Scanner(System.in);
		int N = scanner.nextInt();
		long ans = 0;
		
		for (int i = 1; i <= N; i++) {
			ans += (N-1) / i;
		}


		System.out.println(ans);
		scanner.close();
	}

}


Measured memory_bytes: 27224
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String args[]) {
		int[] coins = new int[] {500, 100, 50, 10, 5, 1};
		while(true) {
			int money = 1000 - sc.nextInt();
			if(money == 1000) break;
			int ans = 0;
			while(money > 0) {
				for(int k : coins) {
					if(money >= k) {
						money -= k;
						ans++;
						break;
					}
				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 12000
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace abc_060_C
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            long ans = 0;
            for(int i = 0; i < n[0]-1; i++)
            {
                while (true)
                {
                    if (i >= n[0] - 1) { break; }
                    if (a[i] + n[1] > a[1+i]) { ans += a[i+1]-a[i]; }
                    else { ans += n[1]; break; }
                    i++;
                }
            }
            Console.WriteLine(ans+n[1]);
            Console.ReadLine(); }
    }
}

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


int main() {
 int N;
  cin >> N;
 vector<int> A(N);
 int sum = 0;
 for(int i = 0; i < N; i++){
 cin >> A.at(i);
 sum += A.at(i);
 }
 int ans =0;
 for(int i = 0; i < N; i++){
 if(sum <= 2*A.at(i)){
 ans+=1;
 }
 }
 if(ans >= 1){
 cout << "No";
 }else{
 cout << "Yes";
 }
}


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

using namespace std;
typedef long long ll;

const int N=300005;
const ll inf=1e14;

int n,v[N],Q; 
ll sum[N],f[N],g[N],x[N],y[N],a[N];
int qu[N],tp;

inline int calc(ll*g,int j,int k){return (2*(g[j]-g[k])/(j-k)+j+k-1)/2;}
inline ll range(int n){return (ll)n*(n+1)>>1;}
inline int minlen(int l,ll v){return (v-range(l+1))/l+1;}
inline int cmp1(int i,int j){return minlen(i-j,y[j]-y[i]);}
inline int cmp2(int i,int j){return minlen(j-i,x[j]-x[i]);}
void make(ll*dp){
	qu[tp=1]=0;
	for(int i=1;i<=n;i++){
		while(tp>1&&calc(dp,qu[tp],qu[tp-1])<i)qu[tp--]=0;
		sum[i]=sum[i-1]+v[i];
		dp[i]=max(max(dp[i-1]+v[i],sum[i]),dp[qu[tp]]+range(i-qu[tp]));
		while(tp>1&&calc(dp,i,qu[tp])>=calc(dp,qu[tp],qu[tp-1]))qu[tp--]=0;
		qu[++tp]=i;
	}
	for(int i=1;i<=n;i++)dp[i]-=sum[i];
}

void solve(int l,int r){
	if(l>r)return;
	int m=(l+r)>>1;
	ll mx;
	mx=-inf;while(tp)qu[tp--]=0;
	for(int i=m;i<=r;i++){
		while(tp>1&&cmp1(i,qu[tp])<=cmp1(qu[tp],qu[tp-1]))qu[tp--]=0;
		qu[++tp]=i;
	}
	for(int i=l;i<=m;i++){
		while(tp>1&&cmp1(qu[tp],qu[tp-1])>qu[tp-1]-i)qu[tp--]=0;
		mx=max(mx,x[i]+y[qu[tp]]+range(qu[tp]-i+1));
		a[i]=max(a[i],mx);
	}
	mx=-inf;while(tp)qu[tp--]=0;
	for(int i=m;i>=l;i--){
		while(tp>1&&cmp2(i,qu[tp])<=cmp2(qu[tp],qu[tp-1]))qu[tp--]=0;
		qu[++tp]=i;
	}
	for(int i=r;i>=m;i--){
		while(tp>1&&cmp2(qu[tp],qu[tp-1])>i-qu[tp-1])qu[tp--]=0;
		mx=max(mx,x[qu[tp]]+y[i]+range(i-qu[tp]+1));
		a[i]=max(a[i],mx);
	}
	solve(l,m-1),solve(m+1,r);
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&v[i]);
	make(f);
	for(int i=1;i<=n/2;i++)swap(v[i],v[n-i+1]);
	make(g);
	for(int i=1;i<=n/2;i++)swap(v[i],v[n-i+1]),swap(g[i],g[n-i+1]);
	for(int i=1;i<=n;i++)sum[i]=sum[i-1]+v[i];
	for(int i=1;i<=n;i++)x[i]=f[i-1]+sum[i-1],y[i]=g[i+1]-sum[i],a[i]=-inf;
	solve(1,n);
	scanf("%d",&Q);
	while(Q--){
		int p,c;
		scanf("%d%d",&p,&c);
		ll res=max(f[p-1]+g[p+1],a[p]+v[p]-c);
		printf("%lld\n",res);
	}
	return 0;
}

Measured memory_bytes: 17792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main(){
  int n;
  string s;
  cin>>n>>s;
  int ans=1;
  for(int i;i<n-1;i++){
    if(s[i]!=s[i+1]){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define LLI long long int
#define pii pair<int,int>
#define fst first
#define sec second
#define ULTRA 2134567890
#define de(x) if(x!=0 && MODE==x)
#define MODE 0
using namespace std;

bool prime[1000007] ={};
bool v[1000007] = {};

int main()
{
    int i,j;
    LLI N;

    for( i=2; i <= 1000000; i++)
    {
        prime[i] = 1;
    }

    for( i=2; i <= 1000000; i++)
    {
        if( prime[i])
        {
            for( j=2; i*j <= 1000000; j++)
                prime[i*j] = 0;
        }
    }

    scanf("%lld", &N);

    int ans = 0;
    for( i=2; (LLI) i * i <= N; i++)
    {
        if( !prime[i])
            continue;
        v[i] = 1;

        if( N % i == 0)
        {
            for( j=i; N % j == 0; j*=i)
            {
                N /= j;
                de(1) printf("N = %lld\n", N);
                ans++;
            }

            while( N % i == 0)
                N /= i;
        }
    }

    if( N > 1)
        ans++;

    printf("%d\n", ans);

    return 0;
}

//
//          ___ ___  __________  __________
//         /////\  \/\   ______\/\\\\\\\\\\\  Code by ~Ice Tea~ of
//        //// \ \  \ \  \_____/\ \\\\_____/      New Empire of CHSH ...
//       ////   \ \  \ \  \      \ \\\\\\\\\\\
//      ////__   \ \  \ \  \      \ \\\\_____/
//     ///////\   \ \  \ \  \______\ \\\\_______   ________
//    ////____/    \ \__\ \___   ___\ \\\\\\\\\\\ _\  ___  \_
//   /__/           \/__/\/__/\  \__/\ \\\\_____//\  .\_/\_  \
//                           \ \  \   \ \\\\\\\\\\\\  \_\/_\  \
// ... with the AC Power of   \ \  \   \ \\\\_____/ \   _____  \
//   The Great Tsundere Doggy. \ \  \   \ \\\\     \ \  \  \ \  \
//                              \ \__\   \ \\\\\\\\\\ \__\  \ \__\
//                               \/__/    \/________/\/__/   \/__/
//


Measured memory_bytes: 5712
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: chars,
    }
    if n[0..3].iter().all(|c| c == &n[0]) ||
       n[1..4].iter().all(|c| c == &n[1]) {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
N=int(input())
xy=[list(map(int,input().split()))for _ in range(N)]
xy1=[x+y for x,y in xy]
xy2=[-x+y for x,y in xy]
ans1=max(xy1)-min(xy1)
ans2=max(xy2)-min(xy2)
print(max(ans1,ans2))

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

int main() {
  int a[3];

  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);

  int cnt = 0;
  int tmp = a[2] - a[1];
  cnt += tmp;
  a[0] += tmp;

  tmp = a[2] - a[0];
  if(tmp % 2 == 0) cnt += tmp/2;
  else cnt += tmp/2 + 2;
  cout << cnt << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
 
int main(void)
{
    int ginkou;
    double year;
    int bank_num;
    int syurui;
    double nenri;
    double max;
    int max_bank;
    double money[100];
    int i;
     
    while (1)
    {
        scanf("%d", &ginkou);
         
        if (ginkou == 0){
            break;
        }
         
        scanf("%lf", &year);
         
        memset(money, 0, sizeof(money));
        max = 0;
        for (i = 0; i < ginkou; i++){
            scanf("%d%lf%d", &bank_num, &nenri, &syurui);
             
            if (syurui == 1){
                money[i] = 1.00 + year * (nenri / 100);
            }
            else {
                money[i] = pow(1.00 + (nenri / 100), year);
            }
             
            if (money[i] > max){
                max = money[i];
                max_bank = bank_num;
            }
        }
         
        printf("%d\n", max_bank);
    }
     
    return (0);
}

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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef map<int, int> mpii;
typedef set<int> seti;

const int mxN = 2e5, iinf = 1e9 + 10, inf = 1e18 + iinf + 10, mod = 1000000007;
const ld pi = 4.0 * atanl(1.0), prec = .000001;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(c) c.begin(), c.end()
#define rall(c) c.end(), c.begin()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)

int n, m, t, a[mxN];

void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }

int main() {
  fast();
  cin >> n;
  n == 1 ? cout << 0 : cout << 1;

  return 0;
}



Measured memory_bytes: 3636
def resolve():
	n, k = map(int, input().split())
	a = list(map(int, input().split()))
	rec = [True]*(n+2)
	now = 0
	stp = [1]

	while rec[now]:
		rec[now] = False
		now = a[now] - 1
		stp.append(now+1)
	before_loop = stp.index(now+1)
	loop = stp[before_loop:-1]
	if k <= (before_loop + 1):
		print(stp[k])
	else:
		r = (k - before_loop) % len(loop)
		print(loop[r])
resolve()

Measured memory_bytes: 32380
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder.Contest.C
{
	static class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			var cin = new Scanner();

			int x = cin.NextInt();
			int n = cin.NextInt();
			if (n != 0)
			{
				var p = cin.ArrayInt(n);
				int ans = int.MaxValue;
                for (int i = 0; i <= 101; i++)
                {
                    if (!p.Contains(i))
                    {
						if (Math.Abs(x - ans) > Math.Abs(x - i)) ans = i;
                    }
                }
                Console.WriteLine(ans);
			}
            else
            {
                Console.WriteLine(x);
            }

			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

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

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

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

		public int NextInt()
		{
			return int.Parse(Next());
		}

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

		public long NextLong()
		{
			return long.Parse(Next());
		}

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

		public double NextDouble()
		{
			return double.Parse(Next());
		}

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

Measured memory_bytes: 27860
#include<bits/stdc++.h>
using namespace std;
#define fori(i,a,n) for(i=a;i<=n;i++)
#define ford(i,n,a) for(i=n;i>=a;i--)
typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned long long ull;
ll n,m,i;
int main()
{
	cin>>n>>m;
	while (n!=0)
	{
		i++;
		n/=m;
	}
	cout<<i<<endl;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int h,w;
  cin >> h >> w;
  vector<vector<char>> pur(h,vector<char>(w));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> pur[i][j];
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if((i%2&&j!=w-1)||j==0){
        cout << "#";
      }else{
        cout << pur[i][j];
      }
    }
    cout << endl;
  }
  cout << endl;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if((i%2==0&&j!=0)||j==w-1){
        cout << "#";
      }else{
        cout << pur[i][j];
      }
    }
    cout << endl;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define print(x) cout << x << endl;
#define input(x) cin >> x;

int main()
{
    int a, b;
    cin >> a >> b;
    cout << ((a * b) % 2 == 0 ? "Even" : "Odd") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main ()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(c!=0 || a!=0)
	{
		c=c-b;
		a=a-d;
		if(c<=0)
		{
			cout<<"Yes"; break;
		}
		else if(a<=0)
		{
			cout<<"No"; break;
		}
		else
		{
			continue;
		}
	}
	return 0;
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long



int32_t main() {

    int t, x; cin >> t >> x;
    cout << setprecision(11) << (double)t/(double)x << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<algorithm>
#include<complex>
#include<cstdlib>
#include<cctype>

#define DBG cout << '!' << endl;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cout << v[i] << ' ';cout << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cout << v[a][b] << ' ';cout << endl;}cout << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	ll q,h,s,d;
	ll n;
	ll ans = 0;
	cin >> q >> h >> s >> d >> n;
	
	h = min(h,q*2);
	s = min(s,h*2);
	d = min(d,s*2);
	
	ans += n / 2 * d;
	n = n % 2;
	if(n) ans += s;
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;

vll memokai(200010,-1);

ll kai(ll n){
    if(memokai[n]!=-1)return memokai[n];
    else memokai[n]=kai(n-1)*n%P;
    return memokai[n];
}

ll modinv(ll a) {
    ll b = P, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= P;
    if (u < 0) u += P;
    return u;
}

int root(pair<int,int> s, pair<int,int> g){
    //圧縮
    int t=min(s.first,g.first);
    s.first-=t;
    g.first-=t;
    t=min(s.second,g.second);
    s.second-=t;
    g.second-=t;
    ll a=kai(g.second+g.first);
    a%=P;
    // cout<<a<<endl;
    ll b=kai(g.first)*kai(g.second)%P;
    ll res=a*modinv(b)%P;
    return res;
}

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

    ll ans=0;
    memokai[0]=1;
    memokai[1]=1;
    int h,w,a,b;
    cin>>h>>w>>a>>b;
    for(int i=0;i<w-b;i++){
        ll up=root(mp(0,0),mp(h-a-1,b+i));
        ll down=root(mp(h-a,b+i),mp(h-1,w-1));
        ans+=up*down%P;
        // cout<<up<<" "<<down<<endl;
        ans%=P;
    }
    fin(ans);

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 6656
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll n,k;
	cin>>n>>k;
	vector<ll> cost(n);
	vector<ll> dp(n,-1);
	for(ll i = 0;i<n;i++)
	{
		cin>>cost[i];
	}
	dp[0] = 0;
	for(ll i = 0;i<n;i++)
	{
		for(ll j = 1;j<=k;j++)
		{
			if((i+j) < n)
			{
				if(dp[i+j] == -1)
					dp[i+j]=(dp[i]+abs(cost[i+j]-cost[i]));
				else
					dp[i+j] = min(dp[i+j],dp[i]+abs(cost[i+j]-cost[i]));

			}
		}
	}
	cout<<dp[n-1]<<'\n';
}
  	


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

int main() {
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	if (s.at(0) == s.at(1) && s.at(2) == s.at(3) && s.at(1) != s.at(2))cout << "Yes" << endl;
	else cout << "No" << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
#include <iomanip>

using namespace std;
#define int long long

signed main(){
    string S;
    int K;
    cin >> S >> K;
    
    int keta = S.length();
    
    int cnt = 0;
    for(int i=0;i<min(keta,K);i++){
        if(S[i]=='1'){
            cnt++;
        }
    }
    
    if(cnt == K){
        cout << 1 << endl;
        return 0;
    }
    
    int i = 0;
    while(i<S.length()){
        if(S[i]=='1'){
            i++;
        }else{
            cout << S[i] << endl;
            return 0;
        }
    }
    return 0;
}


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

int main(void) {
	int N;
	cin >> N;
	vector<int>W = vector<int>(N);
	for (int i = 0; i < N; i++)cin >> W[i];

	int min,S1,S2;
	min = 20000;
	for (int i = 0; i < N; i++) {
		S1 = S2 = 0;
		for (int j = 0; j < i; j++) {
			S1 += W[j];
		}
		for (int j = i; j < N; j++) {
			S2 += W[j];
		}
		if (abs(S1 - S2) < min)min = abs(S1 - S2);
	}

	cout << min << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int dx[4]={-1,1,0,0},dy[4]={0,0,-1,1};
typedef long long ll;
const double eps=1e-16;
const int mod=1e9+7;
const int N=500005;
int n,m,head[N],now=0,S,T;
int tmpS[N],tmpT[N];
ll pathS[N],pathT[N];
using namespace std;

struct node
{
	int t,w,next;
}adj[N<<1];
void add(int s,int t,int w)
{
	adj[++now]=(node){t,w,head[s]};
	head[s]=now;
}
struct que
{
	int s;
	ll len;
};
bool operator<(que a,que b){return a.len>b.len;}
priority_queue<que> Q;
void dij(int st,ll *path,int *tmp)
{
	int i,s,t,w;
	for (i=1;i<=n;i++) path[i]=(1ll<<60);
	path[st]=0,tmp[st]=1;Q.push((que){st,0});
	que fr;
	while (!Q.empty())
	{
		fr=Q.top(),Q.pop();
		if (fr.len!=path[fr.s]) continue;
		s=fr.s;
		for (i=head[s];i;i=adj[i].next)
		{
			t=adj[i].t,w=adj[i].w;
			if (path[t]>path[s]+w)
			{
				path[t]=path[s]+w,tmp[t]=tmp[s];
				Q.push((que){t,path[t]});
			}
			else if (path[t]==path[s]+w) tmp[t]=(tmp[s]+tmp[t])%mod;
		}
	}
}
inline int read()
{
	char c;int x;
	while (c=getchar(),c<'0' || c>'9');x=c^'0';
	while (c=getchar(),c>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x;
}
void write(int x)
{
	if (x==0) return;
	write(x/10);
	putchar((x%10)+'0');
}
//void upd(int& x,int y){if (x==-1) x=y;else x=max(x,y);}

int main()
{
	#ifdef Kay
		freopen ("code.in","r",stdin);
		freopen ("code.out","w",stdout);
	#endif
	scanf ("%d %d %d %d",&n,&m,&S,&T);
	int i,s,t,w;
	for (i=1;i<=m;i++)
	{
		scanf ("%d %d %d",&s,&t,&w);
		add(s,t,w),add(t,s,w);
	}
	dij(S,pathS,tmpS),dij(T,pathT,tmpT);
	//printf ("%lld %d\n",pathS[T],tmpS[T]);
	int ans=(ll)tmpS[T]*tmpS[T]%mod;
	int tmp=0;
	if (!(pathS[T]&1))
	{
		for (i=1;i<=n;i++)
		if ((pathS[i]<<1)==pathS[T])
		{
			int x=(ll)tmpS[i]*tmpT[i]%mod;
			x=(ll)x*x%mod;
			tmp=(tmp+x)%mod;
		}
	}
	for (s=1;s<=n;s++)
	for (i=head[s];i;i=adj[i].next)
	if (s<adj[i].t)
	{
		t=adj[i].t,w=adj[i].w;
		if (pathS[s]==pathS[t]) continue;
		int u=s,v=t;
		if (pathS[u]>pathS[v]) swap(u,v);
		if (pathS[u]+pathT[v]+adj[i].w!=pathS[T]) continue;
		if (pathS[u]*2<pathS[T] && pathS[v]*2>pathS[T])
		{
			int x=(ll)tmpS[u]*tmpT[v]%mod;
			x=(ll)x*x%mod;
			tmp=(tmp+x)%mod;
		}
	}
	tmp=mod-tmp;
	ans=(ans+tmp)%mod;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 22384
#include<cstdio>
const int N=505;
int n,go[N][N];
void Solve(int l,int r,int id) {
	if(l==r) return ;
	int mid=(l+r)/2;
	for(int i=l;i<=mid;i++)
		for(int j=mid+1;j<=r;j++)
			go[i][j]=id;
	Solve(l,mid,id+1);
	Solve(mid+1,r,id+1);
}
void Print() {
	for(int i=1;i<n;i++) {
		for(int j=i+1;j<n;j++)
			printf("%d ",go[i][j]);
		printf("%d\n",go[i][n]);
	}
}
int main() {
	scanf("%d",&n);
	Solve(1,n,1);
	Print();
	return 0;
}

Measured memory_bytes: 1408
K = int(input())

N = 50
res = [i - K for i in range(N)]
p,q = divmod(K, N)
for i in range(N):
    if i < q:
        res[i] += (p + 1) * (N + 1)
    else:
        res[i] += p * (N + 1)
print(N)
print(*res)

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#define REP(i, n) for(int i = 0; i < n; i++)
template<class T> inline void chmin(T& a, T b) {if (a>b) a=b; }
template<class T> inline void chmax(T& a, T b) {if (a<b) a=b; }
using namespace std;
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e9;


ll N;
int main() { 
    cin >> N;

    ll ct = 0;
    if (N>1) {
        REP(i, N-1) ct += (i+1);
    }
    cout << ct << endl;

    
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++) 
#define FOR(i,ini,n) for(int i=(ini);i<(n);i++)

using namespace std;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;
	while(cin >> n >> k){
		int ans = 0;
		REP(i,n){
			int a;
			cin >> a;
			ans += min(a,k-a) * 2;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<ii> vii;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define fr(be, en) for(int i = be; i <= en; i++) 
ll mod = LLONG_MAX;
ll power(ll a, ll b)
{
	if(b == 0) return 1;
	ll ans = power(a, b/2);
	ans = (ans*ans)%mod;
	if(b%2) ans*=a;
	return ans%mod;
}
ll mul(ll a,ll n, ll mod)
{
	ll ret;
	if(n==0) return 0;
	ret = mul(a,n/2, mod);
	ret = (ret+ret)%mod;
	if(n%2)	ret=(ret+a)%mod;
	return ret;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cout.tie(NULL);
	cin.tie(NULL);
	int n, m, k;
	cin >> n >> m >> k;
	ll sum = 0;
	vi a(n);
	vi b(m);
	fr(1, n) cin >> a[i - 1];
	fr(1, m) cin >> b[i - 1];
	int be = 0, end = 0;
	while(end < n)
	{
		if(sum + a[end] <= k)
		{
			sum += a[end];
			end++;
		}
		else break;
	}
	int ans = end;
	while(be < m)
	{
		if(b[be] + sum <= k)
		{
			sum += b[be];
			be++;
		}
		else 
		{
			end--;
			if(end >= 0) sum -= a[end];
			else break;
		}
		ans = max(ans, end + be);
	}
	cout << ans;
}

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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

using ll    = long long;
using vll   = vector<ll>;
using pll   = pair<ll,ll>;
using ld    = long double;

const ll mod = (ll)1e9 + 7;

void solve() {
	ll n,k;
	cin>>n>>k;
	ll A[n];for(int i=0;i<n;i++) cin>>A[i];
	sort(A,A+n);
	cout<<accumulate(A,A+k,0LL)<<"\n";
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;
//	pre();
//	ll t;cin>>t;while (t--)
		solve();
}


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

int main()
{
  int m[10];
  for(int i=0;i<10;i++){
    cin>>m[i];
    m[i]=-m[i];
  }
  sort(m,m+10);
  for(int i=0;i<3;i++)cout<<-m[i]<<endl;
  return 0;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)

int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  rep(i, 0, N) {
    cin >> H[i];
  }
  bool flag = true;
  int max = 0;
  rep(i, 0, N) {
    if (H[i] > max) {
      H[i]--;
      max = H[i];
    } else if (H[i] < max) {
      flag = false;
      break;
    }
  }
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
};


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

#include <string>

int main(){
    int n;cin >> n;
    string s,t;cin >> s >> t;
    for(int i=0; i<n; i++){
        cout << s.at(i) << t.at(i);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 3520
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const double INF = 1e9;

struct Point{
    double x,y,z;
};

using Vector = Point;
using Line = pair<Point,Point>;

double sq(double z){
    return z*z;
}

double size(Vector v){
    return sqrt(sq(v.x) + sq(v.y) + sq(v.z));
}

double Dot(Point a, Point b){
    return a.x*b.x + a.y*b.y + a.z*b.z;
}

Vector Cross(Point a, Point b){
    return Vector({a.y*b.z-b.y*a.z, a.z*b.x-b.z*a.x, a.x*b.y-b.x*a.y});
}

double dist(Point a, Point b){
    Vector v({a.x-b.x, a.y-b.y, a.z-b.z});
    return size(v);
}

double distLP(Line l, Point p){
    Vector u({l.fi.x-l.se.x, l.fi.y-l.se.y, l.fi.z-l.se.z});
    double usz = size(u);
    u.x /= usz;
    u.y /= usz;
    u.z /= usz;

    Vector a({p.x-l.fi.x, p.y-l.fi.y, p.z-l.fi.z});
    double sw = Dot(a,u);
    Vector w({sw*u.x, sw*u.y, sw*u.z});

    Point h({l.fi.x+w.x, l.fi.y+w.y, l.fi.z+w.z});
    return dist(p,h);
}

double distLL(Line l, Line m){
    Vector vl({l.fi.x-l.se.x, l.fi.y-l.se.y, l.fi.z-l.se.z});
    Vector vm({m.fi.x-m.se.x, m.fi.y-m.se.y, m.fi.z-m.se.z});

    Vector s({l.fi.x-m.fi.x, l.fi.y-m.fi.y, l.fi.z-m.fi.z});
    Vector t = Cross(vl,vm);
    return abs(Dot(s,t))/size(t);
}

Point READ(){
    double x,y,z;
    cin >>x >>y >>z;
    return {x,y,z};
}

int main(){
    int n;
    while(cin >>n,n){
        Point s = READ(), g = READ();
        vector<Line> l(n);
        rep(i,n){
            l[i].fi = READ();
            l[i].se = READ();
        }

        vector<vector<double>> d(n+2, vector<double>(n+2,INF));

        d[n][n+1] = d[n+1][n] = dist(s,g);
        rep(i,n){
            d[i][n] = d[n][i] = distLP(l[i],s);
            d[i][n+1] = d[n+1][i] = distLP(l[i],g);
        }
        rep(i,n)rep(j,i) d[i][j] = d[j][i] = distLL(l[i], l[j]);

        // rep(i,n+2){
        //     rep(j,n+2) printf(" %.4f", d[i][j]);
        //     printf("\n");
        // }

        rep(k,n+2)rep(i,n+2)rep(j,n+2) d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
        printf("%.10f\n", d[n][n+1]);
    }
    return 0;
}



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

A,B,C = map(int, input().split())
K = int(input())

for i in range(0,K):
    if (A >= B):
        B *= 2
        continue

    if (B >= C):
        C *= 2
        continue

if (A < B and B < C) :
    print("Yes")
else:
    print("No")



Measured memory_bytes: 9200
#include <iostream>
#include <string>
#include <vector>
#include <ios>
#include <iomanip>
#include <stack>
#include <queue>
#include <algorithm>

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

using namespace std;

bool cmp(pair<int,int> &a, pair<int,int> &b){
  return (a.second != b.second) ? a.second < b.second : a.first < b.first;
}
const int INF = 100000000;

int main(){
  int n,m;
  cin >> n >> m;

  vector< pair<int,int> > hope(m);
  vector<bool> realized(m);

  REP(i,m){
    int start,end;
    cin >> start >> end;
    hope[i] = pair<int,int>(start,end);
  }

  sort(hope.begin(),hope.end(),cmp);

  int ans = 0;
  REP(i,m){
    if (realized[i] == false) {
      int end = hope[i].second;
      for (int j = i + 1; j < m; j++) {
        if (hope[j].first < end) {
          realized[j] = true;
        }
      }
      ans++;
    }
  }

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

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

int main() {

  int A, B, C; cin >> A >> B >> C;
  if (B == C) {
    cout << A << endl;
  }
  else if (C == A) {
    cout << B << endl;
  }
  else {
    cout << C << endl;
  }
    
}


Measured memory_bytes: 256