akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
  int N, S = 0, j = 1;
  cin >> N;
  
  while (j <= N){
    S = S + (N%(j*10)/j);
    j *= 10;
  }
  
  int R = N % S;
  if (R == 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}
    

Measured memory_bytes: 256
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N, K := sc.nextInt(), sc.nextInt()
	nums := make([]int, int(1e+5))
	for i := 0; i < N; i++ {
		a, b := sc.nextInt()-1, sc.nextInt()
		nums[a] += b
	}
	total := 0
	ans := 0
	for n, count := range nums {
		total += count
		if K <= total {
			ans = n + 1
			break
		}
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


Measured memory_bytes: 3072
#include <iostream>
using namespace std;
int main()
{
	int n, X, Y, W, H, N, x, y, i;
	cin >> n;
	for (; n > 0; n--)
	{
		cin >> X >> Y >> W >> H >> N;
		for (i = 0; N > 0; N--)
		{
			cin >> x >> y;
			if ((X <= x && x <= X+W) && (Y <= y && y <= Y+H))
				i++;
		}
		cout << i << endl;
	}
}

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

bool flag;
int n;

int main() {
  cin >> n;
  
  for (int i = 1; i <= 9; i++)
  	for (int j = 1; j <= 9; j++)
  		if (i * j == n)
  			flag = true;
  if (flag)
    	cout << "Yes" << '\n';
 else
   cout << "No" << '\n';
  return 0; 
}

Measured memory_bytes: 256
def cmb(n,r,mod):
  if r<0 or r>n:
    return 0
  r=min(r,n-r)
  return g1[n]*g2[r]*g2[n-r]%mod
 
n,m,k=map(int,input().split())
mod=10**9+7
 
g1=[1,1]
g2=[1,1]
inverse=[0,1]
 
for i in range(2,n*m):
  g1.append((g1[-1]*i)%mod)
  inverse.append((-inverse[mod%i]*(mod//i))%mod)
  g2.append((g2[-1]*inverse[-1])%mod)

c=cmb(n*m-2,k-2,mod)
ans=0
for i in range(n):
  ans+=((n-i)*m*m*i*c)%mod
  ans%=mod
for i in range(m):
  ans+=((m-i)*n*n*i*c)%mod
  ans%=mod
print(ans%mod)

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

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

  x -= a;
  while (true) {
    if (x - b >= 0) {
      x -= b;
    } else {
      break;
    }
  }
  cout << x << endl;
}

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

using namespace std;

int main(void) {
    long n;
    cin >> n;

    auto idx = [&](int x, int y) {
        int t = min(x, y);
        int s = max(x, y);
        return t*n + s;
    };

    vector<vector<long>> a(n, vector<long>(n-1));
    for(auto &x: a)
        for(auto &y: x)
            cin >> y, y--;

    vector<int> out(n*n);
    vector<vector<int>> G(n*n), rG(n*n);
    vector<long> dis(n*n);

    for(int i=0; i<n; i++)
        for(int j=0; j<n-1-1; j++) {
            int s = idx(i, a[i][j]);
            int t = idx(i, a[i][j+1]);
            G[s].push_back(t);
            rG[t].push_back(s);
            out[s]++;
        }

    queue<int> q;
    for(int i=0; i<n*n; i++)
        if(!out[i]) q.push(i);

    while(!q.empty()) {
        int i = q.front(); q.pop();

        long r = -1;
        for(int f: G[i])
            r = max(r, dis[f]);
        dis[i] = r+1;

        for(int p: rG[i])
            if(!--out[p]) q.push(p);
    }

    for(int i=0; i<n*n; i++)
        if(out[i]) {
            cout << -1 << endl;
            return 0;
        }

    long r = 0;
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
            r = max(r, dis[idx(i, j)]);
    cout << r+1 << endl;
    return 0;
}


Measured memory_bytes: 99968
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int X;
    int K ;
    cin >> X;
    //Xto360nosaishoukoubasisu
    int ans;
    for(int i=1;i <= 180;i++){
        ans =i*360;
        if(ans%X==0){
            break;
        }
    }
    cout << ans/X<<endl;
    
}


Measured memory_bytes: 3620
package main
import "fmt"
import "sort"
func main(){
    // Your code here!
    var n int
    fmt.Scan(&n)
    t := make([]int, n)
    var k int
    fmt.Scan(&k)
    for i := 0; i < n; i++ {
        fmt.Scan(&t[i])
    }
    sort.Ints(t)
    
    fi := len(t) - k -1
    var sum int64
    sum = 0
    for i := fi; i >= 0; i--{
        sum = sum + int64(t[i])
    }
    fmt.Println(sum)
}

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

int main()
{
    int X, N, atai, M=0,M2=0;
    cin >> X >> N;
    vector<int> p(N + 1);
    bool dekita = false;
    p.at(0) = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> p.at(i);
    }
    if (p.at(0) == 0)
    {
        dekita = true;
        atai = X;
    }
    sort(p.rbegin(), p.rend());

    for (int i = 0; i <= 100; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (X - i == p.at(j))
            {
                M = j;
            }
            if (X + i == p.at(j))
            {
                M2 = j;
            }
        }
            if(dekita==true)
            {
                cout << atai << endl;
                break;
            }
            else if (X - i != p.at(M)&&X-i!=p.at(M2))
            {
                atai = X - i;
                cout << atai << endl;
                break;
            }
            else if (X + i != p.at(M)&&X+i!=p.at(M2))
            {
                atai = X + i;
                cout << atai << endl;
                break;
            }
    }
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

using namespace std;

int main(){

    int a,b;
    string s;
    cin >> a >> b;
    cin >> s;

    bool ans = true;

    for(int i = 0; i < a; i++){
        if(s[i] == '-'){
            ans = false;
            break;
        }
    }

    if(s[a] != '-') ans = false;

    if(ans){
        for(int i = a + 1; i < a + b + 1; i++){
            if(s[i] == '-'){
                ans = false;
                break;
            }
        }
    }

    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define vi vector<int>
#define mod 1000000007
#define tc(t) 			int t;cin >> t;while(t--)
#define for0(i , n)		for(int i=0;i<n;i++)
#define loop(i , a, b)	for(int i=a;i<=b;i++)
#define endl '\n'


signed main() {

	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
#ifndef ONLINE_JUDGE
	freopen("input.txt" , "r" , stdin);
	freopen("output.txt" , "w" , stdout);
#endif

	int n,w;
	cin >> n >> w;
	int wt[n],val[n];

	for(int i=0;i<n;i++){
		cin >> wt[i] >> val[i];
	}

	int dp[n+1][w+1];

	for(int i=0;i<=n;i++){
		for(int j=0;j<=w;j++){
			if(i==0||j==0){
				dp[i][j] = 0;
			}else if(wt[i-1] <= j){
				dp[i][j] = max(dp[i-1][j],val[i-1]+dp[i-1][j-wt[i-1]]);
			}else{
				dp[i][j] = dp[i-1][j];
			}
		}
	}

	cout << dp[n][w] << endl;
	return 0;
}

Measured memory_bytes: 82424
import collections
n = int(input())
a = list(map(int, input().split()))
s = collections.Counter(a)
c = []
for i in s.keys():
	if s[i] >= 2:
		c.append(i)
c.sort(reverse=  True)
if len(c) < 2:
	print (0)
else:
	if s[c[0]] >= 4:
		print (c[0]**2)
	else:
		print (c[0]*c[1])

Measured memory_bytes: 18600
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int n;
	cin >> n;
	vector<int>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	map<int, int> map;
	int ans = 0;
	rep(i, n) {
		ans += map[i - a[i]];
		map[i + a[i]]++;
	}
	print(ans);
}

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

int main() {
    char c;
    string res;
    cin >> c;
    if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') res = "vowel";
    else res = "consonant";
    cout << res << endl;
}


Measured memory_bytes: 256
def main():
    N = input()
    N = int(N[len(N) - 1])
    ans = ""
    if N in {2, 4, 5, 7, 9}:
        ans = "hon"
    elif N in {0, 1, 6, 8}:
        ans = "pon"
    else:
        ans = "bon"
    print(ans)
    return


main()


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

int main() {
    int k;
    cin >> k;
    map<int,int> m;
    int d = 7;
    int x = 7;
    ll cnt = 1;
    while(true){
        x %= k;
        if(m[x] > 0){
            cout << -1 << endl;
            return 0;
        }
        m[x]++;
        if(x == 0){
            cout << cnt << endl;
            return 0;
        }
        x = x*10 + 7;
        cnt++;
        
        // cout << x << endl;
    }

    
    return 0;
}

Measured memory_bytes: 50424
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define pb push_back 
#define mp make_pair
typedef long long ll;



int main(){
	int n,q; cin>>n>>q;
	string s; cin>>s;
	
	int memo[n+5];
	memo[0]=0;
	
	for(int i=1;i<n;i++){
		memo[i]=memo[i-1];
		if(s[i]=='C' && s[i-1]=='A') memo[i]++;
	}
	
	while(q--){
		int l,r; cin>>l>>r;
		l--; r--;
		int answer=memo[r]-memo[l];
		cout<<answer<<"\n";
	}
			
	return 0;
}


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

int main(){
	int a,b;
	cin >> a >> b;
	for(int i=0;i<=10000000;i++){
		if(floor((double)i*0.08)==a and floor((double)i*0.1)==b)
			return cout << i << '\n',0;
	
	}
	cout << "-1\n";
}

Measured memory_bytes: 256
nums = STDIN.gets.chomp.split('').map(&:to_i).reverse
sum = 0

nums.each_with_index do |num, i|
  if nums[i + 1].nil?
    sum += num
    break
  end

  if num != 9
    nums[i + 1] -= 1
  end
  sum += 9
end

puts sum


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if (s[2] == s[3] and s[4] == s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    String S = sc.next();
      char[] ss =S.toCharArray();

	if(ss[K-1]=='A'){
      ss[K-1]='a';
    }else if(ss[K-1] =='B'){
      ss[K-1]='b';
    }else{
      ss[K-1]='c';
}
      System.out.println(String.valueOf(ss));
}
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
// #define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin); freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp(pair < pii, int > a, pair < pii, int > b)//true for a before b
{
	if(a.F.F/300 < b.F.F/300)
		return 1;
	if(a.F.F/300 > b.F.F/300)
		return 0;
	if(a.F.S < b.F.S)
		return 1;
	if(a.F.S > b.F.S)
		return 0;
	if(a.F <= b.F)
		return 1;
	return 0;
}

const int N = (1e5) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 2*550;
const int SQRT = BUCK+9;



void solve()
{
	int a, b, ans = 0;
	cin >> a >> b;
	if(a <= 5)
		ans = 0;
	else if(a <= 12)
		ans = b/2;
	else
		ans = b;
	cout << ans << '\n';
	return;
}

int main()
{
	sws;
	clock_t clk;
	clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	int t = 1, cs;
	cout << fixed << setprecision(9);
	// cin >> t;
	fo(cs,1,t+1)
	{
		// cout << "Case #" << cs << ": ";
		solve();
	}
	// Code ends here

	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
 int main(){
   string S;
   cin >> S;
   int cnt = 0;
   for (int i = 0; i<4 ;i++) {
     if (S.at(i) == '+'){
       cnt++;
     }
     else {
       cnt--;
     }
   }
   cout << cnt << endl;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long N,D;
  long c=0;
 cin>>N>>D;
  long a,b;
  for(int i=0;i<N;i++){
  cin>>a>>b;
     
    if(a*a+b*b<=D*D){
    c++;
     // cout<<a*a+b*b<<endl;
  //    cout<<d[i][0];
    }
  }
  cout <<c<<endl;
  
}


Measured memory_bytes: 3584
#include <iostream>
using namespace std;
int main(){

  int n,k,w[100000],i;

  cin>>n>>k;
  for(i=0;i<n;i++) cin>>w[i];

  long long l=0,r=100000*10000,m;
  while(r-l>1){
    m=(l+r)/2;
    int cnt=0;
    for(int j=0;j<k;j++){
      long long s=0;
      while(s+w[cnt]<=m){
        s+=w[cnt];
        cnt++;
        if(cnt==n) break;
      }
      if(cnt==n) break;
    }

    if(cnt>=n) r=m;
    else l=m;
  }
  cout<<r<<endl;

  return 0;

}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

ll x[60], y[60];

int main() {
   int n, k;
   cin >> n >> k;
   rep (i, n) {
      cin >> x[i] >> y[i];
   }

   ll ans = 1LL << 62;
   rep (xi, n) {
      rep (xj, n) {
         rep (yi, n) {
            rep (yj, n) {
               if (x[xi] <= x[xj] && y[yi] <= y[yj]) {
                  int cnt = 0;
                  rep (p, n) {
                     if (x[p] >= x[xi] && x[p] <= x[xj] && y[p] >= y[yi] && y[p] <= y[yj]) {
                        cnt++;
                     }
                  }
                  if (cnt >= k) {
                     ans = min(ans, (x[xj] - x[xi]) * (y[yj] - y[yi]));
                  }
               }
            }
         }
      }
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
import heapq
INF = float("inf")
MOD = 10**9 + 7
sys.setrecursionlimit(10**7)
# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def mi(): return map(int, input().split())
def ii(): return int(input())
###template###


X = ii()

for t in range(1, 1000000):
  if (t**2 + t) // 2 >= X:
    print(t)
    exit()




Measured memory_bytes: 38768
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

const int MAX_N=1<<17;
const ll INF=(1ll<<31)-1;
ll dat[2*MAX_N-1];
pint dat2[2*MAX_N-1];
int N;
//RMQ
void init(int n_){
    N=1;
    while(N<n_) N*=2;
    //rep(i,2*N-1) dat[i]=INF;
    rep(i,2*N-1) dat2[i]=mp(-1,INF);
}
void update(int k,ll a){
    k+=N-1;
    dat[k]=a;
    while(k>0){
        k=(k-1)/2;
        dat[k]=min(dat[k*2+1],dat[k*2+2]);
    }
}
//range [a,b)
ll query(int a,int b,int k,int l,int r){
    if(r<=a||b<=l) return INF;
    if(a<=l&&r<=b) return dat[k];
    else{
        ll vl=query(a,b,k*2+1,l,(l+r)/2);
        ll vr=query(a,b,k*2+2,(l+r)/2,r);
        return min(vl,vr);
    }
}
//RUQ
//range [a,b)
void r_update(int a,int b,pint x,int k,int l,int r){
    if(r<=a||b<=l) return;
    if(a<=l&&r<=b){
        dat2[k]=x;return;
    }
    else{
        r_update(a,b,x,k*2+1,l,(l+r)/2);
        r_update(a,b,x,k*2+2,(l+r)/2,r);
    }
}
ll r_query(int i){
    i+=N-1;
    pint res=dat2[i];
    while(i>0){
        i=(i-1)/2;
        res=max(res,dat2[i]);
    }
    return res.second;
}

int main(){
    //int n,q,c,x,y;
    int n,q,c,s,t,x;
    cin>>n>>q;
    init(n);
    rep(i,q){
        cin>>c;
        //if(c==0) update(x,y);
        if(c==0){
            cin>>s>>t>>x;
            r_update(s,t+1,mp(i,x),0,0,N);
        }
        else{
            ll ans;
            cin>>x;
            //ans=query(x,y+1,0,0,N);
            ans=r_query(x);
            cout<<ans<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 5112
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define modn 1000000007

#define SZ 100005
using namespace std;
int main()
{
    ll n;
    cin>>n;
    if(n%2 == 0) cout<<n<<endl;
    else cout<<n*2LL<<endl;
    return 0;
}

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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

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

  // 全部ばらばら
  int val1 = a * x + b * y;
  // Aをできる限りABで
  int val2 = c * 2 * x + b * max(0, y - x);
  // Bをできる限りABで
  int val3 = c * 2 * y + a * max(0, x - y);
  cout << min(min(val1, val2), val3) << endl;

  return 0;
}


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

using namespace std;

int main() {
    for(int C = 1; ; ++C) {
        int N, W;
        cin >> N >> W;
        if(!N && !W) break;

        vector<int> ws(N);
        for(int i = 0; i < N; ++i) cin >> ws[i];

        vector<vector<int> > sv(N, vector<int>(N, 0));
        for(int i = 0; i < N; ++i) {
            int sum = 0;
            for(int j = i; j < N; ++j) {
                sum += ws[j];
                sv[i][j] = sum;
            }
        }
        vector<vector<int> > cv(N, vector<int>(N, 0));
        for(int i = 0; i < N; ++i) {
            int sum = 0;
            for(int j = i; j < N; ++j) {
                sum += ws[j];
                cv[i][j] = abs(sum-W);
            }
        }

        vector<int> dp(N, INT_MAX);
        dp[0] = cv[0][0];
        for(int i = 1; i < N-1; ++i) {
            dp[i] = cv[0][i];
            for(int j = 0; j < i; ++j) {
                dp[i] = min(dp[i], dp[j]+cv[j+1][i]);
            }
        }
        dp[N-1] = max(0, sv[0][N-1]-W);
        for(int i = 0; i < N-1; ++i) dp[N-1] = min(dp[N-1], dp[i] + max(0, sv[i+1][N-1]-W));

        cout << "Case " << C << ": " << dp[N-1] << endl;
    }
    return 0;
}

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

using namespace std;

int main() {
  string s;
  cin >> s;
  int n = s.length();
  s = '0' + s;
  bool ok = true;
  if (s[1] == '0' || s[n] == '1') ok = false;
  for (int i = 1; i < n; i++) {
    if (s[i] != s[n - i]) ok = false;
  }
  if (!ok) {
    cout << "-1\n";
    return 0;
  }

  int center = 1;
  vector< pair<int,int> > res;
  for (int i = 1; i < n; i++) {
    if (s[i] == '1') {
      res.emplace_back(center, i + 1);
      center = i + 1;
    }
    else {
      res.emplace_back(center, i + 1);
    }
  }
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    tie(u, v) = res[i];
    cout << u << ' ' << v << '\n';
  }
  return 0;
}

Measured memory_bytes: 2416
#include<bits/stdc++.h>
//#include<tr1::unordered_map>
#define rep(i,a,n) for(int i=a;i<=n;++i)
#define per(i,a,n) for(int i=n;i>=a;--i)
#define pb push_back
#define fi first
#define se second
#define io std::ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
const int  maxn=1e5+50;
ll gcd(ll a,ll b)
{
    return b?gcd(b,a%b):a;
}
ll qpow(ll a,ll n)
{
    ll r=1%P;
    for (a%=P; n; a=a*a%P,n>>=1)if(n&1)r=r*a%P;
    return r;
}
bool cmp(int a,int b)
{
  return a>b;
}
ll mp[65][65];
ll ans;
void fen(ll x)
{   ll ans2=0;
    ll ans5=0;
    while(x%5==0)
    {
      x/=5;
      ans5++;
    }
    while(x%2==0)
    {
      x/=2;
      ans2++;
    }
    for(int i=0;i<=64;i++)
      for(int j=0;j<=64;j++)
      {
        if(ans2+i>=18&&ans5+j>=18)
           ans+=mp[i][j];
      }
    mp[ans2][ans5]++;
}
int main()
{  io;
   int n;
   cin>>n;
   for(int i=1;i<=n;i++)
   {
     double x;
     cin>>x;
     ll y=llround(x*=1000000000.0);
     fen(y);
   }
   cout<<ans<<endl;
}


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

using namespace std;

using ll = long long;


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

    ll x, y, z, k;
    cin >> x >> y >> z >> k;

    vector<ll> a(x), b(y), c(z);
    for (int i = 0; i < x; ++i) cin >> a[i];
    for (int i = 0; i < y; ++i) cin >> b[i];
    for (int i = 0; i < z; ++i) cin >> c[i];

    vector<ll> ab;
    ab.reserve(x * y);
    for (int i = 0; i < x; ++i)
        for (int j = 0; j < y; ++j)
            ab.push_back(a[i] + b[j]);
    sort(ab.begin(), ab.end(), greater<ll>());

    vector<ll> abc;
    abc.reserve(min(k, x * y));
    for (int i = 0; i < min(k, x * y); ++i) {
        for (int j = 0; j < z; ++j) {
            abc.push_back(ab[i] + c[j]);
        }
    }
    sort(abc.begin(), abc.end(), greater<ll>());
    for (int i = 0; i < k; ++i)
        cout << abc[i] << '\n';

    return 0;
}


Measured memory_bytes: 34216
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  ll n,W;
  cin>>n>>W;
  vecll dp(W+1, 0);
  for(auto&& i:irange(0l,n)) {
    ll w,v;
    cin>>w>>v;
    vecll tmp = dp;
    for(auto&& j:irange(0l,W+1)) {
      if (j + w <= W) {
        tmp[j+w] = max(tmp[j+w], dp[j] + v);
      }
    }
    swap(dp, tmp);
  }
  cout<<*boost::max_element(dp)<<endl;
  return 0;
}


Measured memory_bytes: 1804
#include<stdio.h>
#include<math.h>
int Sosu(int N){
  int i=3;
if(N==2)return 1;
if(N<2 || N%2==0)return 0;
while(i<=sqrt(N)){
  if(N%i==0)return 0;
  i=i+2;
}
return 1;
}
int main(void){
int N;
int n,i;
int S=0;
while(1){
scanf("%d",&n);
if(n>=1 && n<=10000)break;
}
for(i=0 ; i<n ; i++){
  while(1){
  scanf("%d",&N);
  if(N>=2 && N<=100000000)break;
  }
  S+=Sosu(N);
}
printf("%d\n",S);
return 0;
}


Measured memory_bytes: 2124
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include <functional>
#include <limits>


using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

class BIT{
	vector<int> bit;
	
public:
	
	BIT(){
	}
	
	BIT(int size){
		init(size);
	}
	
	void init(int size){
		bit.clear();
		bit.resize(size+1);
	}
	
	int sum(int i){
		int s = 0;
		while(i > 0){
			s += bit[i];
			i -= i & -i;
		}
		return s;
	}

	void add(int i , int x){
		while(i < bit.size()){
			bit[i] += x;
			i += i & -i;
		}
	}

	int lower_bound(int w){
		if(w <= 0) return 0;
		int x = 0, t = 1;
		while(t*2 < bit.size()) t *= 2;
		
		for(int k = t; k > 0; k /= 2){
			if(x + k < bit.size() && bit[x + k] < w){
				w -= bit[x + k];
				x += k;
			}
		}
		return x + 1;
	}
};


signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, Q;
	string S;
	vector<BIT> bit(26);
	
	cin>>N;
	cin>>S;
	cin>>Q;
	
	for(int i = 0; i < 26; i++){
		bit[i].init(N+10);
	}
	
	for(int i = 0; i < N; i++){
		bit[S[i] - 'a'].add(i+1, 1);
	}
	
	for(int i = 0; i < Q; i++){
		int a, b;
		
		cin>>a>>b;
		
		
		if(a == 1) {
			char c;
			
			cin>>c;
			
			bit[S[b-1] - 'a'].add(b, -1);
			bit[c - 'a'].add(b, 1);
			S[b-1] = c;
			
		} else {
			int r;
			cin>>r;
			
			int con = 0;
			for(int j = 0; j < 26; j++){
				if(bit[j].sum(r) - bit[j].sum(b-1) >= 1) con++;
			}
			
			cout<<con<<endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 102556
using System;
namespace ABC173.Problems
{
    class D
    {
        static void Main()
        {
            long n = long.Parse(Console.ReadLine());
            string[] s = Console.ReadLine().Split(' ');
            long[] a = new long[n];
            for (long j = 0; j < n; j++) {
                a[j] = long.Parse(s[j]);
            }
            Array.Sort(a);
            long res = a[n-1];
            long i = n - 2;
            int two = 0;
            for (long cnt = 0; cnt < n - 2; cnt++) {
                res += a[i];
                two++;
                if (two == 2) {
                    two = 0;
                    i--;
                }
            }
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 47060
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int get_maxabs_index(vector<int> &a) {
    int maxidx = 0;
    int maxabs = 0;
    for (int i = 0; i < a.size(); i++) {
        if (abs(a[i]) > maxabs) {
            maxidx = i;
            maxabs = abs(a[i]);
        }
    }
    return maxidx;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<pair<int, int>> ans;

    int maxidx = get_maxabs_index(a);

    if (a[maxidx] == 0) {
        cout << 0 << endl;
    }
    else {
        bool lr = (a[maxidx] > 0);
        for (int i = 0; i < n; i++) {
            if (i != maxidx) {
                ans.push_back(make_pair(maxidx, i));
                a[i] += a[maxidx];
            }
        }

        if (lr) {

            for (int i = 0; i < n - 1; i++) {
                if (a[i] > a[i + 1]) {
                    ans.push_back(make_pair(i, i + 1));
                    a[i + 1] += a[i];
                }
            }
        }
        else {
            for (int i = n - 1; i >= 1; i--) {
                if (a[i] < a[i - 1]) {
                    ans.push_back(make_pair(i, i - 1));
                    a[i - 1] += a[i];
                }
            }
        }
        cout << ans.size() << endl;
        for (auto t : ans) {
            cout << t.first + 1 << " " << t.second + 1 << endl;
        }
    }



    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll N, M;
  cin >> N >> M;
  ll a[3][N];
  REP(i, N) {
    REP(j, 3) { cin >> a[j][i]; }
  }
  ll ans = 0;
  for (ll bit = 0; bit < (1 << 3); ++bit) {
    ll b[N];
    REP(i, N) {
      ll tmp = 0;
      REP(j, 3) {
        if (bit & (1 << j)) {
          tmp += a[j][i];
        } else {
          tmp -= a[j][i];
        }
      }
      b[i] = tmp;
    }
    sort(b, b + N, greater<ll>());
    ll sum = 0;
    REP(i, M) { sum += b[i]; }
    ans = max(ans, sum);
  }
  cout << ans;
  return 0;
}

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

int main(){
    ll s;
    cin>>s;
    vector<ll> a(10000000);
    a[0]=s;
    ll ans;
    for(ll i=0;i<100000000;++i){
        if(a[i]%2==0){
            a[i+1]=a[i]/2;
        }else{
            a[i+1]=3*a[i]+1;
        }
        for(ll j=0;j<i+1;++j){
            if(a[j]==a[i+1]){
                ans=i+1;
                cout<<ans+1<<endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 78336
#include<stdio.h>
#include<string.h>
#include<math.h>
int a,s,d[1001],f[1001],g[1001][1001],h,i,j,z,x;
int main(void)
{
	x=1;
	while(1){
		scanf("%d",&a);
		if(a==0)	break;
		scanf("%d",&s);
		for(i=0;i<s;i++)
			scanf("%d,%d",&d[i],&f[i]);
		for(i=0;i<=s;i++){
			for(j=0;j<=a;j++)
				g[i][j]=-1;
		}
		g[0][0]=0;
		for(i=0;i<=s;i++){
			for(j=0;j<=a;j++){
				if(g[i][j]!=-1){
					if(g[i][j]>g[i+1][j])
						g[i+1][j]=g[i][j];
					if(j+f[i]<=a){
						if(g[i][j]+d[i]>g[i+1][j+f[i]])
							g[i+1][j+f[i]]=g[i][j]+d[i];
					}
				}
			}
		}
		h=0;
		z=0;
		for(i=0;i<=a;i++){
			if(h<g[s][i]){
				h=g[s][i];
				z=i;
			}
		}
		printf("Case %d:\n",x);
		printf("%d\n%d\n",h,z);
		x++;
	}
	return 0;
}

Measured memory_bytes: 6476
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second
using namespace std;


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


ll power(ll a,ll b,ll p)
{

    ll res = 1; // Initialize result
    // Update a if it is more than
    // or equal to mod

    a %= p;

    while(b)
    {
    // If b is odd, multiply a with result
    if (b & 1)
    res = (res * a)%p;

    // Here we assume that doing a*a
    // doesn't cause overflow
    a = (a * a) % p;
    b >>= 1; // b = b / 2

    }

    return res;
}

struct UnionFind{
 
 int num;
 vector<int> rank , parent;
  
  UnionFind()
  { }

  UnionFind(int n) : rank(n,1) , parent(n,0)
  {
       num = n; 

       iota(parent.begin() , parent.end() , 0); 
  }

  int find(int x)
  {
     if(x==parent[x])
     return x;

     parent[x] = find(parent[x]);
     return parent[x];
  }

  bool same(int x , int y){
      return find(x)==find(y);
  }

  void unite(int x , int y){
     
     int x_rep = find(x);
     int y_rep = find(y);

     if(x_rep==y_rep)
     return;

     if(rank[x_rep] < rank[y_rep])
     swap(x_rep,y_rep);

     rank[x_rep]+=rank[y_rep];

     parent[y_rep]=x_rep;

     num--;
  }

  int size(int x )
  {
      return rank[find(x)];
  }

  int count() const{
      return num;
  }
};

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int n,m;
    cin>>n>>m;

    UnionFind uf(n);

    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;

        a--;
        b--;

        uf.unite(a,b);
    }

    cout<<uf.count() - 1<<endl;

    return 0;
}

Measured memory_bytes: 3860
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    vl a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    ll ret = 0;
    while (true) {
        ll k = 0;
        vl b(n);
        for (int i = 0; i < n; ++i) {
            b[i] = a[i] / n;
            k += b[i];
        }
        ret += k;
        for (int i = 0; i < n; ++i) {
            a[i] = a[i] % n + k - b[i];
        }
        bool ok = true;
        for (int i = 0; i < n; ++i) {
            if (a[i] >= n) {
                ok = false;
                break;
            }
        }
        if (ok)
            break;
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>      // std::swap
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 200000000000;
struct edge {int to,cost;};
typedef std::pair<int,int> P;

    ll N;
    ll A[1000],temp,ans=1;
    bool f=false;
    ll gcd(ll x, ll y)
    {
        ll r;

        // ユーグリッドの互除法
        while((r = x % y) != 0) // yで割り切れるまでループ
        {
            x = y;
            y = r;
        }
        return y;
    }
    ll lcm(ll a,ll b){
         return (a/gcd(a,b))*b;
    }

int main(){
    ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N){
        cin>>A[i];
        if(i==0)continue;
        if(A[i-1]!=A[i])f=true;
    }
    if(!f){cout<<A[0];return 0;}
    REP(i,N){
        if(i==0)continue;
        else if(i==1)temp=lcm(A[0],A[1]);
        else temp=lcm(temp,A[i]);
    }
    cout<<temp;
    return 0;
}


Measured memory_bytes: 256
from itertools import product
from itertools import accumulate as acc

N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))
# N, K = 5000, 10**9
# P = list(range(1, N+1))
# C = list(range(N, -1, -1))
# # print(len(P), len(C))

P = [p-1 for p in P]

visited = [0]*N
g = []
for i in range(N):
    if visited[i]:
        continue
    g.append([])
    # print(g)
    while visited[i] == 0:
        g[-1].append(i)
        visited[i] = 1
        i = P[i]
c = [[C[g_j] for g_j in g_i] for g_i in g]
c_acc = [[0]+list(acc(c_i*2)) for c_i in c]
c_sum = [sum(c_i) for c_i in c]
c_len = [len(c_i) for c_i in c]

max_num = -(10**18)
for i, g_i in enumerate(g):
    for j, start in enumerate(g_i):
        for k, end in enumerate(g_i*2):
            if not (j < k):
                continue
            cost = k-j
            score = c_acc[i][k+1] - c_acc[i][j+1]
            if c_sum[i] > 0:
                count = (K-cost)//c_len[i]
                cost += c_len[i]*count
                score += c_sum[i]*count
            if 1 <= cost <= K:
                max_num = max(max_num, score)
            # print((j, k), score)

print(max_num)

Measured memory_bytes: 71724
#include<bits/stdc++.h>
using namespace std;
multiset<int>S;
int i,n,m,ans;

struct s
{
  int a,b;
}A[234234];

bool cmp(s t1,s t2)
{
  if(t1.a!=t2.a) return t1.a<t2.a;
  else return t1.b>t2.b;
}

int main()
{int i,j;
  scanf("%d%d",&n,&m);
  for(i=1;i<=n;i++) scanf("%d%d",&A[i].a,&A[i].b);
  sort(A+1,A+1+n,cmp);
  j=1;
  for(i=m-1;i>=0;i--)
    {
	  while(m-A[j].a==i && j<=n) S.insert(A[j].b),j++;
	  if(S.size()) ans+=(*(--S.end())),S.erase(--S.end());
	}
cout<<ans<<endl;
} 

Measured memory_bytes: 5632
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int n,i;
    scanf("%d",&n);
    //配列用変数の用意
    int a[n];
    
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=n-1;0<=i;i--){
        printf("%d",a[i]);
        if(i!=0){
            printf(" ");
        }
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2100
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int n;
    cin >> n;

    vs32 ans(26, (int)1e9);
    string s;
    rep (i, n)
    {
        cin >> s;
        vs32 temp(26, 0);
        rep (i, s.size())
        {
            ++temp[s[i] - 'a'];
        }
        rep (i, 26)
        {
            ans[i] = MIN(ans[i], temp[i]);
        }
    }

    string t = "";
    rep (i, 26)
    {
        t += string(ans[i], (char)('a' + (char)i));
    }
    cout << t << "\n";
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    ll N;
    cin >> N;
    ll a, b, c;
    vvint graph(N);
    map<pair<int, int>, ll> cost;
    rep(i, N - 1)
    {
        cin >> a >> b >> c;
        a--;
        b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
        cost[{a, b}] = c;
        cost[{b, a}] = c;
    }
    ll Q, K;
    cin >> Q >> K;
    K--;
    vll dist(N, INF);
    dist[K] = 0;
    queue<ll> q;
    q.push(K);
    while (!q.empty())
    {
        ll now = q.front();
        q.pop();
        for (ll i : graph[now])
        {
            if (dist[i] == INF)
            {
                dist[i] = dist[now] + cost[{i, now}];
                q.push(i);
            }
        }
    }
    ll x, y;
    rep(i, Q)
    {
        cin >> x >> y;
        x--;
        y--;
        cout << dist[x] + dist[y] << '\n';
    }
    return 0;
}

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

const int mod = 1e9 + 7;
const int MN = 111;

int exp(int x, int n) {
    int ret = 1;
    while(n) {
        if(n & 1) ret = 1LL * ret * x % mod;
        x = 1LL * x * x % mod;
        n >>= 1;
    }
    return ret;
}

int N;
int H[MN], mnp[MN][MN];

int cc[MN][MN][MN][2];
int dp(int l, int r, int p, int t) {
    if(l > r) return 1;
    int &ret = cc[l][r][p][t];
    if(ret != -1) return ret;

    ret = 0;
    int h = p == N? 1 : H[p];
    int x = mnp[l][r];
    int d = H[x] - h;
    if(t) {
        ret += 1LL * dp(l, x - 1, x, 1) * dp(x + 1, r, x, 1) % mod * 2 % mod;
        ret %= mod;
        ret += 1LL * dp(l, x - 1, x, 0) * dp(x + 1, r, x, 0) % mod * (exp(2, d) + mod - 1) % mod * 2 % mod;
        ret %= mod;
    }
    else {
        ret += 1LL * dp(l, x - 1, x, 0) * dp(x + 1, r, x, 0) % mod * exp(2, d) % mod;
        ret %= mod;
    }

    //cout << l << ' ' << r << ' ' << p << ' ' << t << ' ' << ret << endl;

    return ret;
}

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

    for(int i = 0; i < N; i++) {
        scanf("%d", &H[i]);
    }

    for(int i = 0; i < N; i++) {
        int mn = 2e9, p = -1;
        for(int j = i; j < N; j++) {
            if(mn > H[j]) mn = H[j], p = j;
            mnp[i][j] = p;
        }
    }

    memset(cc, -1, sizeof(cc));
    printf("%d", dp(0, N - 1, N, 1));
}


Measured memory_bytes: 11008
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end() 

using namespace std;



int main(){

    //nが奇数なら報告される数は偶数,nが偶数なら報告は奇数になる
    //また報告される数は0を除いて2回ずつ現れるはず
    //答えは矛盾していなければ2の(n/2)乗を除算したものになる

    int n;
    cin >> n;

    map<int,int> m;

    rep(i,n){
        int tmp;
        cin >> tmp;

        m[tmp]++;
    }

    ll ans = 1;

    if(n % 2 == 1){
        for(int i = 0; i <= n - 1; i = i + 2){
            if(i == 0){
                if(m[i] != 1){
                    ans = 0;
                    break;
                }
            }else{
                if(m[i] != 2){
                    ans = 0;
                    break;
                }else{
                    ans = ans * 2 % MODN;
                }
            }
        }
    }else{
        for(int i = 1; i <= n - 1; i = i + 2){
            if(m[i] != 2){
                ans = 0;
                break;
            }else{
                ans = ans * 2 % MODN;
            }
        }

    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3200
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<10;i++){
        for(int j=1;j<10;j++){
            if(i*j==n){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}


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

using namespace std;

int type(int n) {
  if (n >= 3200) {
    return 9;
  }
  for (int i = 1; i < 9; i++) {
    if (n < 400 * i) {
      return i;
    }
  }
}

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);

  for (int i = 0; i < n; i++) {
    cin >> vec[i];
  }

  int ans = 0;
  int free = 0;
  set<int> S;

  for (int i = 0; i < n; i++) {
    int color = type(vec[i]);
    if (color == 9) {
      free++;
    } else {
      S.emplace(color);
    }
  }

  if (S.size() == 0) {
    cout << 1 << " ";
    cout << free << endl;
  } else {
    cout << S.size() << " ";
    cout << S.size() + free << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

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

    void solve() {
        try (Scanner in = new Scanner(System.in)) {
            int n = in.nextInt();
            int c = in.nextInt();
            int k = in.nextInt();
            int t[] = new int[n];
            for (int i = 0; i < n; ++i) {
                t[i] = in.nextInt();
            }
            Arrays.sort(t);
            int x = 0, a = 0, b = 0;
            for (int i = 0; i < n; ++i) {
                if (a == 0 || b < t[i]) {
                    x++;
                    a = c - 1;
                    b = t[i] + k;
                } else {
                    a -= 1;
                }
            }
            System.out.println(x);
        }
    }

    void tr(Object... o) {
        System.err.println(Arrays.deepToString(o));
    }
}


Measured memory_bytes: 50376
#include<bits/stdc++.h>
#define inf INT_MAX
#define sc(a) scanf("%d",&a)
#define scc(a,b) scanf("%d %d",&a,&b)
#define sccc(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pf(a) printf("%d",a)
#define pff(a,b) printf("%d %d",a,b)
#define pfff(a,b,c) printf("%d %d %d",a,b,c)
#define pb(a) push_back(a)
#define em empty()
#define fr front()
#define cl clear()
#define sz size()
#define mp(a,b) make_pair(a,b)
#define fri(b) freopen(b,"r",stdin)
#define fro(b) freopen(b,"w",stdout)
/*
ID: uslusam1
TASK: test
LANG: C++
*/
using namespace std;

int main(){
	//	fri(".in");
	//	fro(".out");
	int n;
	cin>>n;
	string st;
	cin>>st;
	for(int i=0;i<st.size();i++){
		int k=st[i]-'A'+1;
		k+=n;
	 	k%=26;
		if(k==0){
			k=26;
		}	
		k+=(int)'A'-1;
		cout<<(char)k;
	}	

	return 0;
}



Measured memory_bytes: 256