akhauriyash/Code-Regression huggingface dataset:
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t;
int cev;
string s;
vector<int> v;

int main(void){
	scanf("%d",&n);
	FOR{
		scanf("%d",&a[i]);
		b[i]=a[i];
	}
	sort(b+1,b+n+1);
	FOR{
		if(a[i]!=b[i])cev++;
	}
	if(cev>2){printf("NO\n");return 0;}
	printf("YES\n");
	return 0;
}


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

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    float ans;
    if(n%2==0){
    	ans=n/2;
	}else{
		ans=(n+1)/2;
	}
	ans=ans/n;
	cout<<fixed<<setprecision(6)<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
using static System.Math;
using System.Collections.Generic;
using System;

public class Hello
{
    public static int h, w;
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        h = int.Parse(line[0]);
        w = int.Parse(line[1]);
        var m = int.Parse(line[2]);
        var rs = new int[h];
        var cs = new int[w];
        var hs = new HashSet<long>();
        var rmax = 0; var cmax = 0;
        for (int i = 0; i < m; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            var x = int.Parse(line[0]) - 1;
            var y = int.Parse(line[1]) - 1;
            rs[x]++;
            rmax = Max(rmax, rs[x]);
            cs[y]++;
            cmax = Max(cmax, cs[y]);
            hs.Add(x * 1000000 + y);
        }
        getAns(rs, cs, hs, rmax, cmax);
    }
    static void getAns(int[] rs, int[] cs, HashSet<long> hs, int rmax, int cmax)
    {
        var clist = new List<int>();
        for (int i = 0; i < w; i++)
            if (cs[i] == cmax) clist.Add(i);
        for (int i = 0; i < h; i++)
            if (rs[i] == rmax)
            {
                foreach (var x in clist)
                {
                    var t = i * 1000000 + x;
                    if (!hs.Contains(t)) { Console.WriteLine(rmax + cmax); return; }
                }
            }
        Console.WriteLine(rmax + cmax - 1);
    }
}


Measured memory_bytes: 60856
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        string inpt = Reader.ReadLine();
        string ans = "=";
        if(inpt[0]>inpt[2]) {
            ans = ">";
        } else if(inpt[0]<inpt[2]) {
            ans = "<";
        }
        Console.WriteLine(ans);
    }

    public class Reader
    {
        private static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"




A B




";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 11092
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  ll a,b;
  cin >> a >> b;
  cout << max(a+b,max(a-b,a*b)) << endl;
  return 0;
}


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

int main() {
	int N = 0;
	cin >> N;
	vector<int> a(N,0);
	for (int i = 0; i < N; i++) cin >> a[i];
	sort(a.begin(), a.end(), greater<int>());
	int ans = 0;
	for (int i = 0; i < N; i += 2) {
		ans += a[i];
		if (i + 1 < N) ans -= a[i+1];
	}
	cout << ans;
}

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

void test(ll &a){
    a=3;
}

int main() {
    ll a,b;
    cin>>a>>b;
    if(abs(a-b)<=1){
        cout<<a+b<<endl;
    }else {
        cout<<2*max(a,b)-1<<endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  char s1[201],s2[201],p[101];
  char *ans;
  scanf("%s",s1);
  strcpy(s2,s1);
  strcat(s1,s2);
  scanf("%s",&p);
  ans = strstr(s1,p);
  if(ans != NULL){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 2108
def resolve():
    import itertools
    n = int(input())
    l = list(map(int, input().split()))
    l = sorted(l)
    ans = 0
    for a, b, c in itertools.combinations(range(1, n + 1), 3):
        x = l[a-1]
        y = l[b-1]
        z = l[c-1]
        if x != y and y != z and z != x and z < x + y:
            ans += 1
    print(ans)
resolve()

Measured memory_bytes: 9192
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			if(n == 0) break;
			int count = 0;
			long temp = 1;
			for(int i = n; i > 1; i--){
				temp *= i;
				if(temp > 1000000000) temp %= 1000000000;
				if(temp % 10 == 0){
					count++;
					temp /= 10;
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 25812
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i = (s);i<(int)(n);i++)

int main(){
    int n , d;
    cin >> n >> d;
    long long int x[n], y[n];
    double k;
    int sum = 0;
    rep(i,n){
        cin >> x[i] >> y[i];
        k = sqrt(x[i]*x[i] + y[i]*y[i]);
        if(k <= d)sum++;
    }
    cout << sum << endl;
}


Measured memory_bytes: 6712
from collections import Counter

N = int(input())
A = [int(x) for x in input().split()]
d = Counter(A)
Q = int(input())

def sum_from_counter(d):
  return sum(map(lambda k: k * d[k], d))

s = sum(map(lambda k: k * d[k], d))
for i in range(Q):
  B, C = [int(x) for x in input().split()]
  d[C] = d.get(C, 0) + d[B]
  s += (C - B) * d[B]
  d[B] = 0
  print(s)

Measured memory_bytes: 24008
H,W=map(int,input().split())
S = []
for _ in range(H):
  S.append(list(input()))
  
Left = [[0] * W for i in range(H)]
for i in range(H):
  cur=0
  for j in range(W):
    #cur=0
    if S[i][j]=='#':
      cur=0
    else:
      cur=cur+1
    Left[i][j]=cur
    
Right=[[0] * W for i in range(H)]
for i in range(H):
  cur=0
  for j in range(W-1,-1,-1):
    if S[i][j]=='#':
      cur=0
    else:
      cur+=1
      Right[i][j]=cur
      
Up=[[0] * W for i in range(H)]
for j in range(W):
  cur=0
  for i in range(H):
    if S[i][j]=='#':
      cur=0
    else:
      cur+=1
      Up[i][j]=cur
      
Down=[[0] * W for i in range(H)]
for j in range(W):
  cur=0
  for i in range(H-1,-1,-1):
    if S[i][j]=='#':
      cur=0
    else:
      cur+=1
      Down[i][j]=cur
      
res=0
for i in range(H):
  for j in range(W):
    if S[i][j]=='#':
      continue
    res=max(res,Left[i][j]+Right[i][j]+Up[i][j]+Down[i][j]-3)
print(res)

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

void input_vector(std::vector<int>& v) {
  int N;
  int temp;
  std::cin >> N;
  for(int i = 0; i < N; ++i) {
    std::cin >> temp;
    v.push_back(temp);
  }
}
    
void print_vector(std::vector<int> v) {
  for(int i = 0; i < v.size()-1; ++i) {
    std::cout << v[i] << " ";
  }
  std::cout << v[v.size()-1] << std::endl;
}

void insertionSort(std::vector<int>& A) {
  int v;
  print_vector(A);
  for(int i = 1; i < A.size(); ++i) {
    v = A[i];
    for(int j = i - 1; j >= 0; --j) {
      if( A[j] < v ) {
	break;
      }
      std::swap(A[j+1], A[j]);
    }
    print_vector(A);
  }
}

int main() {

  std::vector<int> A;

  input_vector(A);
  insertionSort(A);
  
  return 0;
}

Measured memory_bytes: 1220
#include<cstdio>
#include<cstring>
int main(){
    int n,ans=0,r;
    char s[11];
    scanf("%s %d",s,&n);
    r=strlen(s);
    for(int i=0;i<n;i++){
        char t[101];
        bool flag=false;
        scanf(" %s",t);
        int l=strlen(t);
        for(int j=0;j<l;j++){
            for(int k=0;k<r;k++){
                if(s[k]!=t[(j+k)%l]) break;
                if(k==r-1) flag=true;
            }
            if(flag) break;
        }
        if(flag) ans++;
    }
    printf("%d\n",ans);
    return 0;
}

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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

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

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    string str;
    cin >> str;

    for (char add = 'a'; add <= 'z'; add++) {
        if (str.find(add) == string::npos) {
            cout << str << add << endl;
            return 0;
        }
    }

    for (int i = str.size() - 1; i >= 0; i--) {
        int rep = -1;
        for (int j = i + 1; j < str.size(); j++) {
            if (str[j] > str[i]) {
                if (rep == -1) rep = j;
                else if (str[j] < str[rep])
                    rep = j;
            }
        }
        if (rep != -1) {
            swap(str[i], str[rep]);
            cout << str.substr(0, i + 1) << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <random>
#include <cassert>
#include <numeric>
#define ll long long int
#define LL unsigned long long
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;



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

    map<char,int> mp[n];
    string l;
    rep(i,n){
        string s; cin >> s;
        int m = s.size();
        rep(j,m){
            mp[i][s[j]]++;
        }
        l = s;
    }
    int t = l.size();
    string ans = "";
    vector<char> c(t);
    rep(i,t) c[i] = l[i];
    sort(c.begin(),c.end());
    c.erase(unique(c.begin(), c.end()), c.end());
    rep(i,c.size()){
        int ma = 1000;
        rep(j,n){
            ma = min(ma,mp[j][c[i]]);
        }
        rep(j,ma) ans += c[i];
    }
    cout << ans << endl;


}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
#define int long long int

vector<vector<int>> a(100001,vector<int>(3));
vector<vector<int>> dp(100001,vector<int>(3,-1));

int topDown(int n, int i, int last){
    if(i==n)
        return 0;

    if(last == -1)
        return max({
              a[i][0] + topDown(n,i+1,0)
            , a[i][1] + topDown(n,i+1,1)
            , a[i][2] + topDown(n,i+1,2)
        });

    if(dp[i][last]!=-1){
        return dp[i][last];
    }

    int mmax = 0;
    for(int j=0;j<3;j++){
        if(j==last)
            continue;
        mmax = max(mmax, a[i][j] + topDown(n,i+1,j));
    }
    return dp[i][last]=mmax;
}

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t,n,m,i,j,k,sum=0;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    cout<<topDown(n,0,-1)<<'\n';
    



    return 0;
}


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

using namespace std;

typedef long long ll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

int main() {
    int n,k,res = 0;
    string s;

    cin>>n>>k;
    cin>>s;

    int index = 0;
    bool is_zero = false;
    //int skip_num = 0;
    int used_k = 0;

    int maxcnt = 1;
    
    vector<int> v;
    
    v.push_back(index);
    while(index < s.length())
    {
        if (s.substr(index,1) == "0") 
        {
            if (used_k == k && !is_zero) 
            { 
                //DEBUG(index);
                //DEBUG(v[0]);
                maxcnt = max(maxcnt, index - v[0]);
                //index = v[0];
                used_k--;

                v.erase(v.begin());
            }


            if (!is_zero) 
                used_k++;
            
            is_zero = true;
        }

        if (s.substr(index,1) == "1") 
        {
            if (is_zero) 
            {
                v.push_back(index);
            }
            is_zero = false;
        }

        index++;
    }

    //DEBUG(index);
    //DEBUG(v[0]);
    maxcnt = max(maxcnt, index - v[0]);

    cout << maxcnt << endl;
    return 0;
}

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


int main(){
	double n,a,b,c,d,e;
	cin>>n>>a>>b>>c>>d>>e;

	double mn = min(a,b);
	mn = min(mn,c);
	mn = min(mn,d);
	mn = min(mn,e);

	if(n<mn){
		cout<<5;
	} else {
		ll res = (ll)(5+ceil((n-mn)/mn));
		cout<<res;
	}

}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); i--)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, n, 0)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main(void)
{
    string s;
    cin >> s;
    (((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])) ? puts("Yes") : puts("No"));
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}

	sc.Scan()
	x, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}

	var sum, cnt int = 0, 1

	for sc.Scan() {
		y, e := strconv.Atoi(sc.Text())
		if e != nil {
			panic(e)
		}
		sum += y
		if sum <= x {
			cnt++
		} else {
			fmt.Println(cnt)
			return
		}
		if cnt > n {
			fmt.Println(cnt)
			return
		}
	}
}

Measured memory_bytes: 640
from itertools import product
[N, M, X] = [int(i) for i in input().split()]
bk = [[int(i) for i in input().split()] for _ in range(N)]

ans = 12*10**5 + 1
for seq in product(range(2), repeat=N):
    S = [0]*(M+1)
    for i in range(N):
       for j in range(M+1):
           S[j] += seq[i]*bk[i][j]     
    if min(S[1:M+1]) >= X:
        ans = min(ans, S[0])

if ans == 12*10**5 + 1:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9152
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    int r;
    cin >> r;
    cout << (r*r*3) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void) {
    string s;
    int count = 0;

    cin >> s;

    for (int i; i<s.size(); i++) {
        if (s[i]=='o') {
            count += 1;
        }
    }

    cout << 700+count*100 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

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

int main() {
  int N;
  cin >> N;
  vector<int> l(N);

  rep(i, N){
    cin >> l[i];
  }
  sort(l.begin(), l.end());

  int ans = 0;
  int a, b, c;
  for(int i = N; i > 0; i--){
    a = l[i];
    for(int j = i-1; j >=0; j--){
      b = l[j];
      // 2分探索する
      int left = 0, right = j-1; // 配列 a の左端と右端
      if(right < left) continue;
      int key = abs(a-b), mid;
      while (right >= left) {
        // cout << right << " " << left << endl;
        mid = left + (right - left) / 2; // 区間の真ん中
        // if (l[mid] == key) return mid;
        if (l[mid] > key) right = mid - 1;
        else if (l[mid] <= key) left = mid + 1;
      }
      if(l[left] > key) ans+= j-left;
      // cout << l[left] << " : " << key << endl;
    }
  }
  
  cout << ans << endl;

}


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

using namespace std;

char S[202020];
int s;
int ans;

int main() {
	scanf("%s", S);
	for(int i = 0; S[i]; i++) {
		if(S[i] == 'S') s++;
		else {
			if(s) s--;
			else ans++;
		}
	}
	printf("%d\n", ans + s);
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>
using namespace::std;
int main(){
  int A;
  cin>>A;
  int *N=new int[A];

  for(int i=0;i<A;i++){
 cin>>N[i];
  }
  
  int Max=N[0];
  int SMax=0;
  int dM=0;
  
  for(int i=1;i<A;i++){
    if(Max<=N[i]){
      Max=N[i];
    }
  }
  for(int i=0;i<A;i++){
    if(!(Max==N[i])){
      if(SMax<N[i]){
        SMax=N[i];
      }
    }
  }
  for(int i=0;i<A;i++){
    if(Max==N[i]){
      dM++;
    }
  }
  for(int i=0;i<A;i++){
    if(dM>1){
      cout<<Max<<endl;
    }else if(N[i]==Max){
      cout<<SMax<<endl;
    }else{
      cout<<Max<<endl;
    }
  }
}



Measured memory_bytes: 2432
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <functional>
#include <cmath>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言
#define MOD 1000000007

void solve();

string w;
int a[26];

int main() {
  cin >> w;

  solve();

  return 0;
}

void solve() {
  int len = (int)(w.length());

  rep(i, len) {
    a['z'-w[i]] += 1;
  }

  rep(i, 26) {
    if(a[i]%2!=0) {
      cout << "No" << endl;
      return;
    }
  }

  cout << "Yes" << endl;
}


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

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


void solve5a(int a, int b) {
    REP(i,a) {
        REP(j,b) {
            cout << "#";
        }
        cout << endl;
    }
    cout << endl;
}

int main() {
    int a, b;
    while(cin >> a >> b, a+b) {
        solve5a(a, b);
    }
    return 0;
}

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

#define ASTART (1<<17)
int a[ASTART*2];

void add(int i,int x){
  i+=ASTART-1;
  a[i]+=x;
  while (i>0){
    i=(i-1)/2;
    a[i]=a[i*2+1]+a[i*2+2];
  }
}
long long getsum(int s,int t,int k,int l,int r){
  if (r<=s||l>=t)return 0;
  if (l>=s&&r<=t)return a[k];
  int m=(l+r)/2;
  return getsum(s,t,k*2+1,l,m)+getsum(s,t,k*2+2,m,r);
}

int main(){
  int n,q,com,x,y;
  for (int i=0;i<ASTART*2;i++)a[i]=0;
  cin >> n>>q;

  for (int i=0;i<q;i++){
    cin >> com >> x >> y;
    if (com==0) add(x,y);
    else cout << getsum(x,y+1,0,0,ASTART)<< endl;
  }

  return 0;
}

Measured memory_bytes: 4120
#include<iostream>
#include<math.h>

using namespace std;

int main(){
    int week, fraction;

    cin >> week;
        double debt = 100000;
        double const rate = 1.05;

        for (int i = 0; i < week; i++){
            debt = debt*rate;
            fraction = (int)debt % 1000;

            if (fraction > 0){
                debt = debt + 1000 - fraction;
            }
        }
        cout << (int)debt << endl;

    return 0;
}

Measured memory_bytes: 1160
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define MP make_pair
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()

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

	FOR(a, -1000, 1000){
		FOR(b, -1000, 1000){
			if(a * a * a * a * a - b * b * b * b * b == X){
				cout << a << " " << b << endl;
				return 0;
			}
		}
	}


	return 0;
}


Measured memory_bytes: 3164
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

typedef pair<int,int> pii;
int main() {
  int n,m;
  cin >> n >> m;
  vector<int> a(n);
  
  REP(i,n) {
    REP(j,m) {
      int b;
      cin >> b;
      a[i] += b;
    }
  }
  cout << *max_element(ALL(a)) << endl;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i, a, b)    for(int i = (a); i <= (int)(b); ++i)
#define per(i, a, b)    for(int i = (a); i >= (int)(b); --i)
#define debug(x)    cerr << #x << ' ' << x << endl;
using namespace std;
 
typedef long long ll;
const int MAXN = 2e5 + 7;
 
int main() {
    int n;
    cin >> n;
    map<string, ll> mp;
    rep(i, 1, n){
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }
    ll res = 0;
    for(auto i = mp.begin(); i != mp.end(); ++i){
        res += 1LL * ((*i).second - 1) * (*i).second / 2;
    }
    cout << res << endl;
    return 0;
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x3 = (y1 - y2) + x2;
    int y3 = -(x1 - x2) + y2;
    int x4 = -(y2 - y1) + x1;
    int y4 = (x2 - x1) + y1;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
    return 0;
}


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

Measured memory_bytes: 128
#include <iostream>
using namespace std;
#include<string.h>
#include<set>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include <cstdio>
#include <cstdlib>
#include<stack>
#include<vector>
long long  a[1100000];
int main()
{
    long long  n,m,k;
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    if(n==1)
        cout<<abs(k-a[1])<<endl;
    else
        cout<<max(abs(k-a[n]),abs(a[n]-a[n-1]))<<endl;
    return 0;
}


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

namespace ABC_C
{
    class C098
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            List<char> S = Console.ReadLine().ToCharArray().ToList();
            int countE = S.Count(x => x == 'E');

            int minTurn = int.MaxValue;
            int EtoW = countE;
            int WtoE = 0;
            for(int i = 0; i < N; i++)
            {
                if (S[i] == 'E') EtoW--;
                int numTurn = WtoE + EtoW;
                if (numTurn < minTurn) minTurn = numTurn;
                if (S[i] == 'W') WtoE++;
            }
            Console.WriteLine(minTurn);
        }
    }
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
//#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}


void solve(long long H, long long A){
    cout<<RUP(H,A)<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){
    long long H;
    scanf("%lld",&H);
    long long A;
    scanf("%lld",&A);
    solve(H, A);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acosl(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define MXN 200005
int main(){ 
    LL n,a,b;
    scanf("%lld %lld %lld",&n,&a,&b);
    if(a>b){
        printf("0\n");
    }
    else if(n==1){
        if(a!=b)printf("0\n");
        else printf("1\n");
    }
    else{
        LL Max=(n-1)*b+a,Min=(n-1)*a+b;
        printf("%lld\n",Max-Min+1);
    }
}
/**/

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

#define SZ(v) ((int)(v).size())
using ll = long long;

int main(void)
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	ll A, B, C, K;
	cin >> A >> B >> C >> K;
	ll ans(0);
	ans += min(A, K);
	K -= min(A, K);
	K -= min(K, B);
	ans -= min(C, K);
	cout << ans << endl;
}


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

int main(){
  double N, K;
  cin >> N >> K;
  double ans = 0;
  for(int i=1; i<=N; i++){
    int x = i;
    double y = 1/N;
    while(x < K){
      x *= 2;
      y /= 2.0;
    }
    ans += y;
  }
  cout << setprecision(15) << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int a[1000000];
int b[1000000];
int c[1000000];
int main(){

	int i, I, n;
	for(i=0;i<1000000;i++)
	{
		scanf("%d%d", &a[i], &b[i]);
		if(a[i]==0 && b[i]==0)
		{
			n=i;
			break;
		}
		c[i]=b[i]-a[i];
	}
	
	int sen[n];
	int gohyaku[i];
	int hyaku[n];
	
	for(i=0;i<n;i++)
	{
		sen[i]=0;
		gohyaku[i]=0;
		hyaku[i]=0;
	}
	
	for(i=0;i<n;i++)
	{
		for(I=0;I<10000000;I++)
		{
			if(c[i]-1000>=0)
			{
				c[i]=c[i]-1000;
				sen[i]++;
			}
			else
			{
			break;	
			}
		}
		for(I=0;I<10;I++)
		{
			if(c[i]-500>=0)
			{
				c[i]=c[i]-500;
				gohyaku[i]++;
			}
			else
			{
				break;
			}
		}
		for(I=0;I<10;I++)
		{	
		
			if(c[i]-100>=0)
			{
				c[i]=c[i]-100;
				hyaku[i]++;
			}
			else
			{
				break;
			}
		}
	}
	
	for(i=0;i<n;i++)
	{
		printf("%d %d %d\n", hyaku[i], gohyaku[i], sen[i]);
	}
	return 0;
}

Measured memory_bytes: 4708
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP2(i, a, b) for(int i = a;i <= b;i++)
#define REPR(i, a, b) for(int i = a; i >= b; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define PI 3.14159265358979323846
#define vi vector<int>
#define vll vector<ll>
#define vi2 vector<vector<int>>
#define eb emplace_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
using P = pair<ll,ll>;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
#define INT(name) int name;cin >> name;
#define VEC(type,name,n) vector<type> name(n);REP(i,n) cin >> name[i];

template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main()
{
  string S;
  cin >> S;
  S.push_back('S');
  int MAX = 0;
  int cnt = 0;
  REP(i,sz(S)){
    if(S[i]=='R'){
      cnt++;
    }else{
      MAX=max(MAX,cnt);
      cnt=0;
    }
  }

  cout << MAX << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//
//    #pragma GCC optimize("unroll-loops")
//    #pragma GCC optimize("Ofast")
//    #pragma GCC optimize("-O3")
//    #pragma GCC optimize("no-stack-protector")
//    #pragma GCC optimize("fast-math")

#define fi first
#define f first
#define se second
#define s second
#define vi_a vector<int>a;
#define p_b push_back
////////////////////////////////???????????????CHECK THIS OUT???????????????//////////////////////////////
#define ll long long
////////////////////////////////???????????????CHECK THIS OUT???????????????//////////////////////////////
#define ld long double
#define pll pair<ll,ll>
#define pii pair<int,int>
#define m_p make_pair
#define fast_io cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
#define all(x) x.begin(),x.end()
#define getfiles    ifstream cin("input.txt");ofstream cout("output.txt");
#define pw(x) (1ll << x)
#define sz(x) (ll)x.size()
#define endl "\n"
#define rall(x) x.rbegin(),x.rend()
#define len(a) (ll)a.size()
#define rep(x,l,r) for(ll x=l;x<r;x++)
//#define for(int i=0;i<n;i++) for(ll i=0;i<n;i++)
using namespace std;
//using namespace __gnu_pbds;
ld eps = (ld)1 / 1e6;
ll inf = 1e18, mod2 = 998244353, mod1 = 1e9 + 7;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//const ll to[5]={0,4,6,7,9};
//const ll N=2*1e5+1;
const ll R=1e4;
//const ll to[7]={1,2,3,1,3,2,1};
const ll tx[4]={0,0,-1,1};
const ll ty[4]={-1,1,0,0};
const char rev_to[4]={'E','W','N','S'};
const ll N=2*1e5+4;
ll n;
vector<ll>b,c,d,e;
ll mx=0;
ll m;
void brute(vector<ll>&a,ll indx,ll prev){
    if(indx==n){
        ll ans=0;
        for(ll i=0;i<sz(b);i++){
            if(a[c[i]]-a[b[i]]==d[i]){
                ans+=e[i];
            }
        }
        mx=max(mx,ans);
    }
    else{
        for(ll i=prev;i<=m;i++){
            a[indx]=i;
            brute(a,indx+1,i);
        }
    }
}
signed main(){
    fast_io;
    ll q;
    cin>>n>>m>>q;
    b.resize(q);
    c.resize(q);
    d.resize(q);
    e.resize(q);
    for(ll i=0;i<q;i++){
        cin>>b[i]>>c[i]>>d[i]>>e[i];
        c[i]--;
        b[i]--;
    }
    vector<ll>a(n);
    brute(a,0,1);
    cout<<mx;
    return 0;
}
/*
    n*(m+1)/2*m;
    если WA , то чекер говно, поэтому почекай l8 строчку

*/


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
const ll INF = 1e18;
const ld eps = 1e-4;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int d; cin >> d;
    int c[26];
    REP(i,26) cin >> c[i];
    int lsum = 0;
    REP(i,26) lsum += c[i];
    int v[d][26];
    REP(i,d)REP(j,26) cin >> v[i][j];
    V<> sol(d);
    V<> loss(26,0);
    REP(i,d){
        V<pair<ld,ll>> score(26,{0.0,0});
        REP(j,26) score[j] = {v[i][j] + loss[j] + c[j] * eps, j};
        sort(rall(score));
        int r = score[0].second;
        sol[i] = r;
        REP(j,26){
            if(j == r) loss[j] = 0;
            else loss[j] += c[j];
        }
    }
    REP(i,26) loss[i] = 0;
    ll nowres = 0;
    REP(i,d){
        nowres += v[i][sol[i]];
        REP(j,26){
            if(j == sol[i]) loss[j] = 0;
            else loss[j] += c[j];
            nowres -= loss[j];
        }
    }
    int Q = 246000;
    random_device rnd;
    int newi, newsol, old;
    ll newres;
    while(Q--){
        newi = rnd() % 365;
        newsol = rnd() % 26;
        if(sol[newi] == newsol) continue;
        old = sol[newi];
        sol[newi] = newsol;
        REP(i,26) loss[i] = 0;
        newres = 0;
        REP(i,d){
            newres += v[i][sol[i]];
            REP(j,26){
                if(j == sol[i]) loss[j] = 0;
                else loss[j] += c[j];
                newres -= loss[j];
            }
        }
        if(newres <= nowres) sol[newi] = old;
        else nowres = newres;
    }
    REP(i,d) cout << sol[i] + 1 << '\n';
}

Measured memory_bytes: 3716
/*
{

AuThOr Gwj
*/
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define R(a) cin>>a
#define R2(a,b) cin>>a>>b
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
/*}
*/
const int MAXN=100000+20;
int fa[MAXN],siz[MAXN],n,q;
LL m;
int root(int a){
	if(fa[a]==a) return a;
	return fa[a]=root(fa[a]);
}
void merge(int a,int b){
	int ra=root(a),rb=root(b);
	fa[ra]=rb;
}
int cnt=0,id[MAXN];
vector<int> g[MAXN];
void addedge(int u,int v){
	g[u].PB(v);
	g[v].PB(u);
}
void erasing(){
	rb(i,1,cnt){
		sort(ALL(g[i]));
		g[i].erase(unique(ALL(g[i])),g[i].end());
	}
}
int main(){
	fastio;
	R2(n,m);
	R(q);
	rb(i,1,n)
		fa[i]=i;
	vector<mp> cant; 
	rb(i,1,q){
		int a,b,c;
		R2(a,b);
		R(c);
		a++;
		b++;
		if(!c){
			merge(a,b);
		}
		else{
			cant.PB(II(a,b));
		}
	}
	rb(i,1,n){
		if(root(i)==i){
			id[i]=++cnt;
		}
	}
	for(mp it:cant){
		if(root(it.FIR)==root(it.SEC)){
			cout<<"No"<<endl;
			return 0;
		}
		addedge(id[root(it.FIR)],id[root(it.SEC)]);
	}
	erasing();
	if(cnt==2){
		if(!cant.empty()){
			cout<<"No\n";
		}
		else{
			if(m!=n-1){
				cout<<"No\n"; 
			} 
			else{
				cout<<"Yes\n";
			}
		}
		return 0;
	}
	if(cnt==1){
		cout<<(m==n-1? "Yes\n":"No\n");
		return 0;
	}    
	LL realm=0;
	m-=(n-cnt);
	rb(i,1,cnt)
		realm+=g[i].size();
	LL l,r;
	l=cnt;
	if(cant.empty()){
		l--;
	}
	r=1ll*cnt*(cnt-1)/2;
	if(m<=r&&m>=l){
		 cout<<"Yes\n";
	}
	else{
		cout<<"No\n";
	} 
	return 0;
}

/*
100000 99999 0
*/

Measured memory_bytes: 10492
import java.util.Scanner;

public class Main {

	private static Scanner sc;

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		sc = new Scanner(System.in);
		int a = sc.nextInt();
		int h = a/3600;
		int m = (a % 3600) / 60;
		int s = (a % 3600) % 60;
		
		System.out.println(h+":"+m+":"+s);
		
	}

}

Measured memory_bytes: 26260
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();
        int[][] dp = new int[s.length + 1][t.length + 1];

        for(int i = 1;i <= s.length;i++) {
            for(int j = 1;j <= t.length;j++) {
                if(s[i - 1] == t[j - 1]) dp[i][j] = dp[i - 1][j - 1] + 1;
                else if(dp[i - 1][j] >= dp[i][j - 1]) dp[i][j] = dp[i - 1][j];
                else dp[i][j] = dp[i][j - 1];
            }
        }

        int i = s.length;
        int j = t.length;
        String ans = "";
        while(i > 0 && j > 0) {
            if(dp[i][j] == dp[i - 1][j]) i--;
            else if(dp[i][j] == dp[i][j - 1]) j--;
            else {
                ans = s[i - 1] + ans;
                i--;
                j--;
            }
        }

        System.out.println(ans);
    }

}


Measured memory_bytes: 87244
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int f = N;
        int ans = 0;
        while(N != 0){
            ans += N % 10;
            N /= 10;
        }
        if(f % ans == 0){
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }
}


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

public class Main {
	public static void main(String args[]) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder builder = new StringBuilder();
		while(true){
			String data[] = reader.readLine().split(" ");
			int a= Integer.parseInt(data[0]);
			int b= Integer.parseInt(data[2]);
			
			if( data[1].equals("+") )
				builder.append(Integer.toString(a+b)).append("\n");
			else if( data[1].equals("-") )
				builder.append(Integer.toString(a-b)).append("\n");
			else if( data[1].equals("*") )
				builder.append(Integer.toString(a*b)).append("\n");
			else if( data[1].equals("/") )	
				builder.append(Integer.toString(a/b)).append("\n");
			else if( data[1].equals("?") )
				break;
		}
		System.out.print(builder);
	}
}

Measured memory_bytes: 16920
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n=I()
  l=LI()

  l.sort()

  ans=[]
  # +オンリー
  if l[0]>=0:
    a=l[0]
    for i in range(1,n-1):
      b=l[i]
      ans.append([a,b])
      a-=b
    ans.append([l[-1],a])

    print(l[-1]-a)
    for x in ans:
      print(x[0],x[1])

  # +と-がある
  elif l[0]<0 and l[-1]>=0:
    a=l[0] #最低
    b=l[-1] #最高

    for x in l[1:-1]:
      if x<=0:
        ans.append([b,x])
        b-=x
      else:
        ans.append([a,x])
        a-=x
    ans.append([b,a])

    print(b-a)
    for x in ans:
      print(x[0],x[1])

  # -オンリー
  else:
    l.reverse()
    a=l[0]
    for i in range(1,n-1):
      b=l[i]
      ans.append([a,b])
      a-=b
    ans.append([a,l[-1]])

    print(a-l[-1])
    for x in ans:
      print(x[0],x[1])

main()


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

using namespace std;

int main() {
  //freopen("date.in", "r", stdin);
  //freopen("date.out", "w", stdout);

  int n, a, b;
  scanf("%d%d%d", &n, &a, &b);
  printf("%d\n", min(b, a * n));
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] nums = new int[n];
		for(int i =0; i< n; i++) {
			nums[i] = sc.nextInt();
		}
		int cnt =0;
		for(int i = 0; i < nums.length - 2; i++) {
			if(nums[i+1] > nums[i] && nums[i+2] > nums[i+1] ) {
				cnt++;
			}else if(nums[i+1] < nums[i] && nums[i+2] < nums[i+1]) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}

}


Measured memory_bytes: 21844
#include <cstdio>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	string name;
	long long N, num = 1;
	scanf("%lld", &N);
	int len = 0;
	while (N >= num) N -= num, ++len, num *= 26;
	while (N != 0) {
		name = (char) ('a' + N % 26) + name;
		N /= 26;
	}
	while (name.size() != len) name = 'a' + name;
	printf("%s", name.c_str());
	return 0;
}


Measured memory_bytes: 3340
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;

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

const ll MAX_N = 2e5 + 10;
ll n;
ll fenSum[MAX_N];
ll cnt[MAX_N];
pii Query[MAX_N];

ll Arr[MAX_N];
ll ind;

ll Map (ll d) {
	return lower_bound(Arr, Arr + ind, d) - Arr + 1;
}

void upd (ll d) {
	ll tmp = d;
	for (; tmp < MAX_N; tmp += tmp & -tmp) {
		fenSum[tmp] += Arr[d - 1];
		cnt[tmp]++;
	}
}

ll getNum (ll d) {
	ll c = 0, pointer = 0;
	for (ll i = 20; ~i; i--)
		if ((pointer | (1 << i)) < MAX_N && c + cnt[pointer | (1 << i)] < d) {
			pointer |= (1 << i);
			c += cnt[pointer];
		}

	return pointer + 1;
}

ll getSum (ll d) {
	ll res = 0;
	for (; d; d -= d & -d)
		res += fenSum[d];

	return res;
}

ll getCnt (ll d) {
	ll res = 0;
	for (; d; d -= d & -d)
		res += cnt[d];

	return res;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for (ll i = 0; i < n; i++) {
		ll type;
		cin >> type;

		Query[i] = {-1, -1};
		if (type == 1) {
			ll a, b;
			cin >> a >> b;

			Query[i] = {a, b};
			Arr[ind++] = a;
		}
	}

	sort(Arr, Arr + ind);
	ind = unique(Arr, Arr + ind) - Arr;

	ll num = 0;
	ll val = 0;

	for (ll i = 0; i < n; i++) {
		if (Query[i].first != -1) {
			upd(Map(Query[i].first));
			val += Query[i].second;
			num++;
		}
		else {
			ll tmp = getNum((num + 1) / 2);
			ll calc = getCnt(tmp) * Arr[tmp - 1] - getSum(tmp);
			calc += (getSum(MAX_N - 1) - getSum(tmp)) - (num - getCnt(tmp)) * Arr[tmp - 1];
			cout << Arr[tmp - 1] << " " << val + calc << "\n";
		}
	}
	return 0;
}

Measured memory_bytes: 8832
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <set>
#include <queue>
#include <limits>
#include <deque>
#include <locale>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <bitset>
#include <map>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>
#include <cwchar>
#include <cwctype>
#define mp make_pair
#define fs first
#define se second
#define memset(a,t) memset(a,t,sizeof(a))
#define all(v) v.begin(),v.end()
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define MN 0LL
#define Mx 200000005
#define Mn -Mx
#define MX 20000000000000005
using namespace std;
int readint(){
	char c;
	while(c=getchar(),(c<'0'||c>'9')&&c!='-');
	bool flag=(c=='-');
	if(flag)c=getchar();
	int x=0;
	while(c>='0'&&c<='9'){
		x=x*10+c-48;
		c=getchar();
	}
	return flag?-x:x;
}
inline string tos(int x){
	string s;
	while(x) s=(char)(x%10+'0')+s,x/=10;
	return s;
}
map<int,int> cnave[200005];
int a[200005],b[200005];
inline int finda(int t){
	if(a[t]==t) return a[t];
	int x=finda(a[t]);
	a[t]=x;
	return x;
}
inline int findb(int t){
	if(b[t]==t) return b[t];
	int x=findb(b[t]);
	b[t]=x;
	return x;
}
int main(){
	ios_base::sync_with_stdio(false);
	int n,p,q,i,j,x,y;
	cin>>n>>p>>q;
	for(i=0;i<n;i++) a[i]=b[i]=i;
	while(p--){
		cin>>x>>y;
		a[finda(x-1)]=finda(y-1);
	}
	while(q--){
		cin>>x>>y;
		b[findb(x-1)]=findb(y-1);
	}
	for(i=0;i<n;i++){
		finda(i),findb(i);
		cnave[a[i]][b[i]]++;
	}
	for(i=0;i<n;i++) cout<<cnave[a[i]][b[i]]<<" ";
	cout<<endl;
	return 0;
}


Measured memory_bytes: 20096
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
typedef long long ll;
int main() {
//input
string s,t;
cin>>s>>t;
// cin>>n>>a>>b;

//compute

//output
	// printf("%ld",ans);
    cout<<t<<s;
	return 0;
}

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

int main() {
  int a1, a2, a3;
  vector<int> a = {0, 0, 0};
  for (int i=0; i<3; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  cout << a[2]-a[0];
  return 0;
}

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

int main() {
    ll n, m, l, r;
    std::vector<ll> ls, rs;
    cin >> n >> m;
    for (int i=0; i<m; ++i) {
        cin >> l >> r;
        ls.push_back(l);
        rs.push_back(r);
    }

    int minR = *std::min_element(rs.begin(), rs.end());
    int maxL = *std::max_element(ls.begin(), ls.end());
    
    cout << max(minR - maxL + 1, 0) << endl;
    return 0;
}

Measured memory_bytes: 2036