akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
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 int Weight;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

typedef long long ll;

struct M {
  int v, p;
  M(int v, int p) : v(v), p(p) {}
  M(){}
};

// Â§ÀÈµ
ll knapsack(vector<int> v, vector<int> w, int W) {
  ll dp[W+1];
  memset(dp,0,sizeof(dp));
  REP(i,v.size())
    for(int j=w[i]; j <= W; ++j) 
      dp[j] = max(dp[j], dp[j-w[i]] + v[i]);
  return dp[W];
}

int main() {
  int n,m,w,t;
  cin >> n >> m >> w >> t;
  map<string, M> ma;
  vector<int> kati0, weight0;
  REP(i,m) {
    string s;
    int v,p;
    cin >> s>>v>>p;
    ma[s] = M(v,p);
    kati0.push_back(v);
    weight0.push_back(p);
  }
  int l[n],x[n],y[n];
  vector<string> r[n];
  vector<int> q[n];
  REP(i,n) {
    cin >> l[i]>>x[i]>>y[i];
    REP(j,l[i]) {
      string a;
      int b;
      cin >> a >> b;
      r[i].push_back(a);
      q[i].push_back(b);
    }
  }
  int dis[n];                // (0,0)©çÌ£
  Matrix g(n, Array(n, INF));
  REP(i,n) {
    REP(j,n) {
      g[i][j] = abs((x[i]-x[j])) + abs(y[i]-y[j]);
    }
    dis[i] = abs(x[i]) + abs(y[i]);
  }


  vector<int> v, time;
  
  for (int S=1; S<(1<<n); ++S) {
    int size = 0;
    vector<int> perm;
    REP(i,n) if (S>>i&1) perm.push_back(i);
    // ÅZn~gÂHvZ
    int mincost = INF;
    do {
      int cost = dis[perm[0]];
      REP(i,perm.size()-1) {
        cost += g[perm[i]][perm[i+1]];
      }
      cost += dis[perm[perm.size()-1]];
      mincost = min(mincost, cost);
    } while(next_permutation(ALL(perm)));
//    cout << "mincost = " << mincost << endl;

    // ÅåvvZ@ibvTbNâè
    vector<int> kati, weight;
    REP(i,perm.size()) {
      REP(j,l[perm[i]]) {
        kati.push_back(ma[r[perm[i]][j]].p-q[perm[i]][j]);
        weight.push_back(ma[r[perm[i]][j]].v);
      }
    }
    // FOR(it, kati)
    //   cout << *it << " ";
    // cout << endl;
    // FOR(it, weight)
    //   cout << *it << " ";
    // cout << endl;

    int maxkati = knapsack(kati, weight, w);
//    cout << "maxkati = " << maxkati << endl;

    v.push_back(maxkati);
    time.push_back(mincost);
  }
  cout << knapsack(v, time, t) << endl;
}

Measured memory_bytes: 1032
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

#define mod 1000000007

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; }

int N,now=0;

int main(){
    cin>>N;
    long long a[N],ans[2];
    rep(i,N)cin>>a[i];
    sort(a,a+N,greater<long long>());
    rep(i,N){
        if(a[i]==a[i+1]){
            ans[now]=a[i];
            now++;
            if(now==2){
                printf("%llu\n",ans[0]*ans[1]);
                return 0;
            }
            i++;
        }
    }
    out(0);
}

Measured memory_bytes: 1024
"use strict";

class Dice {
    /**
     *    +--+
     *    |0 |
     * +--+--+--+--+
     * |3 |1 |2 |4 |
     * +--+--+--+--+
     *    |5 |
     *    +--+
     */
    constructor(stat) {
        this.stat = stat;
    }

    fix(top, front) {
        switch (this.stat.indexOf(top)) {
            case 1: this.rot_ns(1); break;
            case 2: this.rot_we(1); break;
            case 3: this.rot_we(-1); break;
            case 4: this.rot_ns(-1); break;
            case 5: this.rot_ns(2); break;
        }
        while (this.stat[1] !== front) {
            this.rot(1);
        }
    }

    rot(val) {
        if (val < 0) val += 4 * Math.floor(-val / 4) + 4;
        const old_i = [1, 2, 4, 3];
        const new_i = [val, val + 1, val + 2, val + 3].map(elt => old_i[elt % 4]);
        [this.stat[old_i[0]], this.stat[old_i[1]], this.stat[old_i[2]], this.stat[old_i[3]]] =
            [this.stat[new_i[0]], this.stat[new_i[1]], this.stat[new_i[2]], this.stat[new_i[3]]];
    }

    rot_ns(val) {
        if (val < 0) val += 4 * Math.floor(-val / 4) + 4;
        const old_i = [0, 1, 5, 4];
        const new_i = [val, val + 1, val + 2, val + 3].map(elt => old_i[elt % 4]);
        [this.stat[old_i[0]], this.stat[old_i[1]], this.stat[old_i[2]], this.stat[old_i[3]]] =
            [this.stat[new_i[0]], this.stat[new_i[1]], this.stat[new_i[2]], this.stat[new_i[3]]];
    }

    rot_we(val) {
        if (val < 0) val += 4 * Math.floor(-val / 4) + 4;
        const old_i = [0, 2, 5, 3];
        const new_i = [val, val + 1, val + 2, val + 3].map(elt => old_i[elt % 4]);
        [this.stat[old_i[0]], this.stat[old_i[1]], this.stat[old_i[2]], this.stat[old_i[3]]] =
            [this.stat[new_i[0]], this.stat[new_i[1]], this.stat[new_i[2]], this.stat[new_i[3]]];
    }
}


new Promise(function (resolve, reject) {
    let content = "";
    process.stdin.on("data", chunk => { content += chunk; });
    process.stdin.on("end", () => { resolve([content, process.stdout]); });
}).then(function([cin, cout]) {
    const [init, n, ...data] = cin.split("\n");
    const dice = new Dice(init.split(" "));
    for (const [t, f] of data.slice(0, parseInt(n)).map(elt => elt.split(" "))) {
        dice.fix(t, f);
        cout.write(`${dice.stat[2]}\n`);
    }
});



Measured memory_bytes: 15352
n = int(input())
h = list(map(int,input().split()))
dp = [0] * n
dp[1] = abs(h[1] - h[0])
for i in range(2,n):
    dp[i] = min(abs(dp[i-1] + abs(h[i] - h[i-1])), dp[i-2] + abs(h[i] - h[i-2]))
print(dp[-1])

Measured memory_bytes: 13928
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))

s = []

if n % 2 == 0:
    x = a[0]
    for i in range(1, n):
        x = x ^ a[i]

    for i in range(n):
        s.append(x ^ a[i])

else:
    x = a[0]
    for i in range(1, n-1):
        x = x ^ a[i]

    for i in range(n-1):
        s.append(x ^ a[i])

    #最後だけ
    y = a[1]
    for i in range(1, n):
        y = y ^ a[i]

    s.append(y ^ a[n-1])

t = list(map(str, s))

print(" ".join(t))



Measured memory_bytes: 43532
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long int;
const ll MOD = 1e9 + 7;

vector<string> dfs(string s, ll depth, vector<char> symbol)
{
    vector<string> ret;
    if (depth == 0)
    {
        ret.push_back(s);
        return ret;
    }

    for (ll i = 0; i < symbol.size(); i++)
    {
        auto vec = dfs(s + symbol[i], depth - 1, symbol);
        for (auto &&e : vec)
        {
            ret.push_back(e);
        }
    }
    return ret;
}

int main()
{
  ll A, B, T;
  cin >> A >> B >> T;
  cout << (T / A * B) << endl;
}

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

int main(){
    using namespace std;

    int n, x;
    vector<int> l;

    cin >> n >> x;
    int input = 0;
    l.emplace_back(0);
    for(int i = 0; i < n; i++){
        cin >> input;
        l.emplace_back(input);
    }

    int bound = 0;
    int d = 0;
    int i = 0;
    while(i < (n+1)){
        d += l[i++];
        if(d <= x) bound++;
    }
    /* for(int i = 0; i < (n + 1); i++){
        if(i >= 2){
            d = d + l[i-1];
            if(((d + l[i-1]) >= x) bound++;
        }
        if(i == 1){
            d = l[i]; bound++;
        }
        if(i == 0){
            d = 0; bound++;
        }
    }
    */
   cout << bound;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>


int main() {
	std::string s;
	long long k;

	std::cin >> s >> k;

	if (k == 1) {
		std::cout << s[0] << std::endl;
		return 0;
	}

	for (size_t i = 0; i < s.length(); i++)
	{
		if (s[i] != '1' || i == k - 1) {
			std::cout << s[i] << std::endl;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 200200;
set<pii> blocked;
int H, W, n;
int a[N];

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

	scanf("%d%d%d", &H, &W, &n);
	for (int i = 0; i < n; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		x--;y--;
		blocked.insert(mp(x, y));
	}
	a[0] = 0;
	for (int i = 1; i < H; i++) {
		a[i] = a[i - 1];
		if (blocked.count(mp(i, a[i] + 1)) == 0) a[i]++;
	}
	int ans = H;
	for (pii t : blocked) {
		int x = t.first, y = t.second;
		if (x == 0) continue;
		if (a[x - 1] >= y)
			ans = min(ans, x);
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 10368
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

int k, x;
int main(void) {
    int i, d;
    cin >> k >> x;
    if (k == 1) {
        cout << x << endl;
        return 0;
    }
    d = k - 1;
    for (i = x - d; i <= x + d; i++) {
        cout << i << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
class Program
{
    static void Main()
    {
        var s = Console.ReadLine();
        int n = s.Length;
        long ans = 0;
        for (int i = 1; i <= n; i++)
        {
            for (int j = 0; i + j <= n; j++)
            {
                int term = 2;
                if (j == 0) term--;
                if (i + j == n) term--;
                ans += long.Parse(s.Substring(j, i)) * (long)Math.Pow(2, n - i - term);
            }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

// 1-indexedのBIT
template <typename T>
struct BIT {
    vector<T> array;
    const int N;

    // 0として初期化
    BIT(int _N) : array(_N + 1, 0), N(_N) {}

    // 左からi番目にxを加える
    void add(int i, T x){
        int lsb;
        while(i <= N){
            array[i] += x;
            lsb = i & (-i);
            i += lsb;
        }
    }

    //左からi番目までのSUMを得る
    T getSUM1(int i){
        T ret = 0;
        int lsb;
        while(i >= 1){
            ret += array[i];
            lsb = i & (-i);
            i -= lsb;
        }
        return ret;
    }

    //左からi番目からj番目のSUMを得る
    T getSUM(int i, int j){
        return getSUM1(j) - getSUM1(i-1);
    }
};

int main(){
    ll N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }
    BIT<int> bit(2000);
    int M = 0;
    int S = 0;
    for (int i = 0; i < N; i++) {
        M += bit.getSUM(A[i]+1, 2000);
        bit.add(A[i], 1);
    }
    for (int i = 0; i < N; i++) {
        S += bit.getSUM(1, A[i] - 1);
    }

    ll ans = 0;
    ans = M * K % MOD;
    ll tmp = S * K % MOD;
    tmp = tmp * (K-1) % MOD;
    tmp = tmp * ((MOD+1) / 2) % MOD;
    ans = (ans + tmp) % MOD;
    printf("%lld\n", ans);


}


Measured memory_bytes: 3652
from sys import stdin,stdout
import math
from collections import deque,defaultdict
from math import ceil,floor,inf,sqrt,factorial,gcd,log2
from copy import deepcopy
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
mod=1000000007
arr=iia()
n=len(arr)
for i in range(n):
    if arr[i]==0:
        print(i+1)
        break


Measured memory_bytes: 9492
n = int(input())
s = input()
ans = 0
for i in range(1000):
    index = 0
    i = str(i)
    if len(i) < 2:
        i = "00"+i
    elif len(i) < 3:
        i = "0"+i
    for j in s:
        if i[index] == j:
            index += 1
        if index == 3:
            ans += 1
            break
print(ans)

Measured memory_bytes: 40940
# -*- coding utf-8 -*-
import fractions

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

lcm = int(C * D / fractions.gcd(C, D))

a_cd = (A - 1) // (lcm)
b_cd = B // (lcm)

a_c = (A - 1) // C
a_d = (A - 1) // D
b_c = B // C
b_d = B // D

a = a_c + a_d - a_cd
b = b_c + b_d - b_cd

print(B - A + 1 - (b - a))


Measured memory_bytes: 5344
N = int(input())
a = [int(input()) for _ in range(N)]
if sum(a)  % 10 != 0:
  print (sum(a))
else:
  t = 101
  for i in a:
    if i % 10 != 0:
      t = min(t, i)
  print (sum(a)-t if t != 101 else 0)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
#define ll long long int
int main(){
    ll a, b, ans=-1;
    cin>>a>>b;
    ll w[a], v[a], dp[a][b+1];
    for (ll i=0; i<a; i++){
        for (ll j=0; j<=b; j++){
            dp[i][j]=-1;
        }
    }
    for (ll i=0; i<a; i++){
        cin>>w[i]>>v[i];
        dp[i][w[i]]=v[i];
    }
    for (ll i=0; i<a-1; i++){
        for (ll j=0; j<=b; j++){
            if (dp[i][j]==-1) continue;
            dp[i+1][j]=max(dp[i+1][j], dp[i][j]);
            if (j+w[i+1]>b) continue;
            dp[i+1][j+w[i+1]]=max(dp[i+1][j+w[i+1]], dp[i][j]+v[i+1]);
        }
    }
    for (ll j=1; j<=b; j++) ans=max(ans, dp[a-1][j]);
    cout<<ans<<endl;
}

Measured memory_bytes: 78336
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		java.util.Scanner sc = new java.util.Scanner(System.in);

		char[] abc = "abcdefghijklmnopqrstuvwxyz".toCharArray();

		int[] count = new int[abc.length];

		while ( sc.hasNextLine() ) {
			String data = sc.nextLine();

			for (int i=0; i < abc.length; i++) {
				String alfabet_i_th = String.valueOf( abc[i] );

				for (int j=0; j < data.length(); j++) {
					String alfabetInData = data.substring(j, j+1);

					if ( alfabet_i_th.equalsIgnoreCase( alfabetInData ) ) {
						count[i] ++;
					}

				}

			}
		}

		for ( int i=0; i < abc.length; i++) {
			System.out.println( abc[i] + " : " + count[i]);
		}
	}

}

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

int main(){
  int k,x;
  cin >> k >> x;
  for(int i=x-k+1;i<=x+k-1;i++){
    if(-1000000<=i && i<=1000000){cout << i << " ";}
  }
}

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

struct edge { int to, cap, rev; };
vector<edge>X[100009]; bool used[100009]; string S[200]; int H, W;

class Max_Flow {
public:
	void add_edge(int u, int v, int w) {
		X[u].push_back(edge{ v, w, (int)X[v].size() });
		X[v].push_back(edge{ u, 0, (int)X[u].size() - 1 });
	}
	int dfs(int s, int t, int f) {
		if (s == t) return f;
		used[s] = true;
		for (int i = 0; i < X[s].size(); i++) {
			if (used[X[s][i].to] == true || X[s][i].cap == 0) continue;
			int d = min(X[s][i].cap, dfs(X[s][i].to, t, min(f, X[s][i].cap)));
			if (d <= 0) continue;
			X[s][i].cap -= d;
			X[X[s][i].to][X[s][i].rev].cap += d;
			return d;
		}
		return 0;
	}
	int max_flow(int p, int q) {
		int sum = 0;
		while (true) {
			for (int i = 0; i <= 220; i++) used[i] = false;
			int D = dfs(p, q, (1 << 30));
			if (D == 0) break;
			sum += D;
			if (D >= 205) return 1000000007;
		}
		return sum;
	}
};

int main() {
	cin >> H >> W;
	for (int i = 0; i < H; i++) cin >> S[i];
	int sx = 0, gx = 0; Max_Flow X;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (S[i][j] == 'S') { X.add_edge(i, j + H, 1000000007); X.add_edge(j + H, i, 1000000007); sx = i; }
			if (S[i][j] == 'T') { X.add_edge(i, j + H, 1000000007); X.add_edge(j + H, i, 1000000007); gx = i; }
			if (S[i][j] == 'o') { X.add_edge(i, j + H, 1); X.add_edge(j + H, i, 1); }
		}
	}
	int ret = X.max_flow(sx, gx);
	if (ret >= 100000) ret = -1;
	cout << ret << endl;
	return 0;
}

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

int n, q, x, y, t;
long long a[100000];

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

	for (int i = 0; i < n; i++)
		a[i] = 0x7FFFFFFF;

	for (int i = 0; i < q; i++) {
		cin >> t;

		if (t == 0) {
			cin >> x >> y;
			a[x] = y;
		}
		else if (t == 1) {
			cin >> x >> y;
			long long m = 0x7FFFFFFF;

			for (int j = x; j <= y; j++)
				m = min(m, a[j]);
			
			cout << m << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3824
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<queue>
#include<vector>
#define ll long long
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define inf 0x3f3f3f3f
#define mod 1000000007
#define eps 1e-18
inline ll read()
{
    ll tmp=0; char c=getchar(),f=1;
    for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
    for(;'0'<=c&&c<='9';c=getchar())tmp=(tmp<<3)+(tmp<<1)+c-'0';
    return tmp*f;
}
using namespace std;
int a[100010],b[100010];
int n;
int main()
{
	int i;
	n=read();
	for(i=1;i<=n;i++)a[i]=read(),b[i]=read();
	ll sum=0,mn=inf;
	for(i=1;i<=n;i++){
		sum+=a[i];
		if(a[i]>b[i])mn=min(mn,b[i]);
	}
	if(mn==inf)printf("0\n");
	else printf("%lld\n",sum-mn);
	return 0;
}

Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DCardEater solver = new DCardEater();
        solver.solve(1, in, out);
        out.close();
    }

    static class DCardEater {
        static final int MAX = 100_000;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] count = new int[MAX + 1];

            for (int i = 0; i < n; i++) {
                count[in.nextInt()]++;
            }

            int answer = 0;
            for (int i = 1; i <= MAX; i++) {
                if (count[i] > 0) {
                    answer++;
                }
            }

            if (answer % 2 == 0)
                answer--;

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 34272
#include <atcoder/all>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define LL long long

int n,q;


LL op(LL a, LL b) {
    return max(a, b);
}

LL e() {
    return (LL)(-1e9);
}

int main(){
    cin>>n>>q;
    vector<LL> a(n);
    REP(i,n)cin>>a[i];
    auto seg = atcoder::segtree<LL,op,e>(a);
    REP(i,q){
        LL t,x,v;
        cin>>t>>x>>v;
        if(t==1){
            seg.set((int)x-1,v);
        }else if(t==2){
            cout<<seg.prod((int)x-1, (int)v)<<endl;
        }else{
            auto bs = [v](LL l){return l<v;};
            cout<<1+seg.max_right((int)x-1,bs)<<endl;
        }
    }
}

Measured memory_bytes: 8700
// Adjacency list implementation of Dinic's blocking flow algorithm.
// This is very fast in practice, and only loses to push-relabel flow.
//
// Running time:
//     O(|V|^2 |E|)
//
// INPUT:
//     - graph, constructed using AddEdge()
//     - source
//     - sink
//
// OUTPUT:
//     - maximum flow value
//     - To obtain the actual flow values, look at all edges with
//       capacity > 0 (zero capacity edges are residual edges).

#include <bits/stdc++.h>

using namespace std;

const int INF = 2000000000;

struct Edge {
  int from, to, cap, flow, index;
  Edge(int from, int to, int cap, int flow, int index) :
    from(from), to(to), cap(cap), flow(flow), index(index) {}
};

struct Dinic {
  int N;
  vector<vector<Edge> > G;
  vector<Edge *> dad;
  vector<int> Q;

  Dinic(int N) : N(N), G(N), dad(N), Q(N) {}

  void AddEdge(int from, int to, int cap) {
    G[from].push_back(Edge(from, to, cap, 0, G[to].size()));
    if (from == to) G[from].back().index++;
    G[to].push_back(Edge(to, from, 0, 0, G[from].size() - 1));
  }

  long long BlockingFlow(int s, int t) {
    fill(dad.begin(), dad.end(), (Edge *) NULL);
    dad[s] = &G[0][0] - 1;

    int head = 0, tail = 0;
    Q[tail++] = s;
    while (head < tail) {
      int x = Q[head++];
      for (int i = 0; i < G[x].size(); i++) {
	Edge &e = G[x][i];
	if (!dad[e.to] && e.cap - e.flow > 0) {
	  dad[e.to] = &G[x][i];
	  Q[tail++] = e.to;
	}
      }
    }
    if (!dad[t]) return 0;

    long long totflow = 0;
    for (int i = 0; i < G[t].size(); i++) {
      Edge *start = &G[G[t][i].to][G[t][i].index];
      int amt = INF;
      for (Edge *e = start; amt && e != dad[s]; e = dad[e->from]) {
	if (!e) { amt = 0; break; }
	amt = min(amt, e->cap - e->flow);
      }
      if (amt == 0) continue;
      for (Edge *e = start; amt && e != dad[s]; e = dad[e->from]) {
	e->flow += amt;
	G[e->to][e->index].flow -= amt;
      }
      totflow += amt;
    }
    return totflow;
  }

  long long GetMaxFlow(int s, int t) {
    long long totflow = 0;
    while (long long flow = BlockingFlow(s, t))
      totflow += flow;
    return totflow;
  }
};


int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  #ifdef Larra
  freopen("in","r",stdin);
  freopen("out","w",stdout);
  #endif
  int n, m;
  cin>>n>>m;
  Dinic netw(n);
  for(int i = 0; i < m; i++){
    int a, b, c;
    cin>>a>>b>>c;
    netw.AddEdge(a, b, c);
  }
  cout<<netw.GetMaxFlow(0, n-1)<<"\n";
}

Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
string coffe(string s)
{
    if(s[2]==s[3]&&s[4]==s[5])
        return "Yes";
    else
        return "No";
}
int main()
{
    string s,res;
    getline(cin,s);
    res = coffe(s);
    cout<<res;
    return 0;
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    int n;cin>>n;

    VPLL arm(n);
    REP(i,n){
        LL x,l;cin>>x>>l;
        arm[i].first = x+l;
        arm[i].second = x-l;
    }
    SORT_ASC(arm);

    int result = 0;
    LL now = -INF_LL;
    REP(i,n){
        if(arm[i].second >= now){
            result++;
            now = arm[i].first;
        }
    }
    cout<<result<<endl;
    
    return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

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

int a, b , c , x ,y;

int main() {
  cin >> a >> b >> c >> x >> y;
  int total = 0;
  if (a + b > c * 2) {
    if (x > y) {
      if (a > c * 2) {
        total = c * x * 2;
      }
      else {
      	total = c * y * 2+ a * (x - y);
      }
    } else {
      if ( b > c * 2) {
        total = c * y * 2;
      } else {
        total = c * x * 2+ b * (y - x);
      }
    }
  } else {
   total = a * x + b * y; 
  }
  cout << total;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
 
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int S = sc.nextInt();
	int h = S / 3600;
	int m = (S % 3600) / 60;
	int s = (S % 3600) % 60;
	System.out.println(h + ":" + m + ":" + s);
    }
 
}


Measured memory_bytes: 26408
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        long ans = 0;
        long a = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'W') {
                ans += (i - a);
                a++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 26680
import java.util.Scanner;

public class Main {
	static int numerators[] = new int[100];

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		int lcm = getLcm(a);
		calcNumerators(a, n, lcm);
		int sum = java.util.Arrays.stream(numerators).sum();
		double ans = (double) lcm / sum;
		System.out.println(ans);
	}

	static void calcNumerators(int a[], int n, int lcm) {
		for (int i = 0; i < n; i++) {
			numerators[i] = lcm / a[i];
		}
	}

	static int getLcm(int m, int n) {
		return m * n / getGcd(m, n);
	}

	static int getLcm(int a[]) {
		final int len = a.length;
		if (len == 1)
			return a[0];

		int l = getLcm(a[0], a[1]);
		for (int i = 1; i < len - 1; i++) {
			l = getLcm(l, a[i + 1]);
		}
		return l;
	}

	static int getGcd(int a, int b) {
		int temp;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return b;
	}

}


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

int main(){
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    int left , right , bottom, top;
    left = x - r;
    right = x + r;
    bottom = y - r;
    top = y + r;
    
    if (left < 0 || bottom < 0 || right > W || top > H){ cout << "No" << endl;}
    else {cout << "Yes" << endl;}
    return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll num = 998244353;

//繰り返し二乗法
ll ex(ll x,ll n){
    if(n==0)return 1;
    else if(n%2==1)return ex(x,n-1)*x%num;
    else return ex(x*x%num,n/2)%num;
};

int main(){
    ll n;
    cin >> n;
    vector<ll> d(n);
    unordered_map<ll,ll> mp;
    ll ans = 1;
    ll mx = 0;
    for(ll i = 0; i < n; i++){
        cin >> d[i];
        if(d[i] > mx) mx = d[i];
    }
    for(ll i = 0; i < n; i++) mp[d[i]]++;
    for(ll i = 1; i < mx; i++){
        ans *= ex(mp[i],mp[i+1]);
        ans %= num;
    }
    if(d[0] != 0 || mp[0] > 1) ans = 0;
    cout << ans << endl;
}

Measured memory_bytes: 5156
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2007
#include <iostream>
using namespace std;

int main(){

  for(int i=0,bill;cin>>bill,bill;++i){
    if(i>0) cout << endl;
    int c10,c50,c100,c500;
    cin>>c10>>c50>>c100>>c500;
    int sum = 500*c500+100*c100+50*c50+10*c10;
    sum -= bill;

    c500 -= sum/500;
    sum-= (sum/500)*500;
    c100 -= sum/100;
    sum-= (sum/100)*100;
    c50 -= sum/50;
    sum-= (sum/50)*50;
    c10 -= sum/10;
    sum-= (sum/10)*10;

    if(c10>0) cout << 10 << " " << c10 << endl;
    if(c50>0) cout << 50 << " " << c50 << endl;
    if(c100>0) cout << 100 << " " << c100 << endl;
    if(c500>0) cout << 500 << " " << c500 << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
from collections import deque
import sys
input = sys.stdin.readline

INF = float('inf')

def bfsMinCosts(adjList, vSt):
    numV = len(adjList)
    costs = [INF] * numV
    costs[vSt] = 0
    Q = deque([vSt])
    while Q:
        vNow = Q.popleft()
        cNow = costs[vNow]
        for v2 in adjList[vNow]:
            if costs[v2] == INF:
                costs[v2] = cNow + 1
                Q.append(v2)
    return costs

N, M = map(int, input().split())
adjL = [[] for _ in range(3*N)]
for _ in range(M):
    u, v = map(int, input().split())
    u, v = u-1, v-1
    adjL[3*u+0].append(3*v+1)
    adjL[3*u+1].append(3*v+2)
    adjL[3*u+2].append(3*v+0)

S, T = map(int, input().split())
S, T = S-1, T-1

costs = bfsMinCosts(adjL, 3*S+0)

if costs[3*T+0] == INF:
    print(-1)
else:
    print(costs[3*T+0]//3)


Measured memory_bytes: 60164
using System;
using System.Collections.Generic;

class Program
{
    static List<Tuple<int, int>>[] g;

    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());

        g = new List<Tuple<int, int>>[n];
        for (int i = 0; i < n; i++)
            g[i] = new List<Tuple<int, int>>();

        for (int i = 0; i < n - 1; i++)
        {
            var uvw = Console.ReadLine().Split();
            var u = int.Parse(uvw[0]) - 1;
            var v = int.Parse(uvw[1]) - 1;
            var w = int.Parse(uvw[2]);

            g[u].Add(Tuple.Create(v, w));
            g[v].Add(Tuple.Create(u, w));
        }

        var ans = new int[n];
        dfs(0, -1, 0, ans);

        for (int i = 0; i < n; i++)
        {
            Console.WriteLine(ans[i]);
        }
    }

    static void dfs(int x, int p, int c, int[] ans)
    {
        ans[x] = c;
        for (int i = 0; i < g[x].Count; i++)
        {
            if (g[x][i].Item1 == p) continue;
            dfs(g[x][i].Item1, x, (c + g[x][i].Item2) % 2, ans);
        }
    }
}


Measured memory_bytes: 37048
n, k = map(int,input().split())

divnum = 10**9+7

pTri =[[1]]
rowNum = 2000

def comb(n,m):
    if (n >= m):
        return pTri[n][m]
    return 0

for i in range(1,rowNum):
    ls = [1]
    for j in range(1,i):
        ls.append(pTri[i-1][j-1] + pTri[i-1][j])
    ls.append(1)
    pTri.append(ls)

for i in range(1,k+1):
        print(comb(k-1, i-1) % divnum * comb(n-k+1, i) % divnum)


Measured memory_bytes: 341608
#include<stdio.h>

#define MAX 100
#define NIL -1
#define WHITE 0
#define GREY 1
#define BLACK 2
#define INF (1<<21)

int n;
int in[MAX][MAX],color[MAX],p[MAX],d[MAX];

int main(){
  
  int i,j;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    
    for(j=0;j<n;j++) scanf(" %d",&in[i][j]);
  }
  
  printf("%d\n",prim());
  
  return 0;
}

int prim(){
  
  int i,temp,min,sum=0;
  
  for(i=0;i<n;i++){
    color[i]=WHITE;
    p[i]=NIL;
    d[i]=INF;
  }
  
  d[0]=0;
  
  while(1){
    
    min=INF;
    temp=NIL;
    
    for(i=0;i<n;i++){
      
      if(color[i]!=BLACK && d[i]<min){
	
        min=d[i];
        temp=i;
      }
    }
    
    if(temp==NIL) break;
    
    color[temp]=BLACK;
    
    for(i=0;i<n;i++){
      
      if(color[i]!=BLACK && in[temp][i]!=NIL){
	
	if(d[i]>in[temp][i]){
	  d[i]=in[temp][i];
	  p[i]=temp;
	  color[i]=GREY;
	}
      }
    }
  }
  
  for(i=0;i<n;i++){
    if(p[i]!=NIL) sum+=in[i][p[i]];
  }
  return sum;
}



Measured memory_bytes: 2052
h, w = map(int, input().split())
a = [[c for c in input()] for i in range(h)]

ah, aw = [0] * h, [0] * w
for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            ah[i] = aw[j] = True
ans = ''
for i in range(h):
    for j in range(w):
        if ah[i] and aw[j]:
            ans += a[i][j]
    if ah[i]:
        ans += '\n'
print(ans)


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

int main(){
  int n,d;
  cin >> n >> d;
  int dis[n][d];
  for(int i = 0; i < n; i++){
    for(int j = 0; j < d; j++){
      cin >> dis[i][j];
    }
  }
  int ans = 0;
  for(int i = 0; i < n; i++){
    for(int j = i+1; j < n; j++){
      int count = 0;
      for(int p = 0; p < d; p++){
        int cnt = abs(dis[i][p] - dis[j][p]);
        count += cnt * cnt;
      }
      bool flag = false;
      for(int k = 0; k <= count; k++){
        if(k * k == count){
          flag = true;
        }
      }
      if(flag) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int n;
    cin >> n;
    Vi a(n);
    ll xsum=0;
    rp(i,n){
        cin >> a[i];
        xsum^=a[i];
    }
    Vi ans;
    rp(i,n){
        ans.pb(xsum^a[i]);
    }
    for(auto an:ans){
        princ(an);
    }
    cout << endl;
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 6884
#include<iostream>
using namespace std;
int main(){
  long N, k, ans;
  long A[5];
  cin >> N;
  k = N;
  for (int i = 0; i < 5; ++i){
    cin >> A[i];
    if(k > A[i])  k = A[i];  
   }
 if(k == N) ans = 5;
 else ans = (N + k - 1)/k + 4;
  cout << ans << endl;
    return 0;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

void solve(){
    int n,d;
    cin >> n >> d;
    map<int,vector<pii>> m;
    rep(i,0,n){
        int x,y,b;
        cin >> x >> y >> b;
        m[b].push_back(make_pair(x,y));
    }
    
    vector<int> v1[2],v2[2],ds; //上,右、下、左
    for(auto it=m.begin(); it!=m.end(); ++it){
        ds.push_back(it->first);
        int a=0,b=0,c=inf,d=inf;
        vector<pii> &tmp=it->second;
        rep(i,0,tmp.size()){
            a=max(a,tmp[i].second);
            b=max(b,tmp[i].first);
            c=min(c,tmp[i].second);
            d=min(d,tmp[i].first);
        }
        v1[0].push_back(a);
        v1[1].push_back(b);
        v2[0].push_back(c);
        v2[1].push_back(d);
    }
    
    ll ans=0,s=0;
    priority_queue<ll,vector<ll>> q1[2],del1[2];
    priority_queue<ll,vector<ll>,greater<ll>> q2[2],del2[2];
    rep(t,0,ds.size()){
        rep(i,0,2) q1[i].push(v1[i][t]);
        rep(i,0,2) q2[i].push(v2[i][t]);
        while(ds[t]-ds[s]>d){
            rep(i,0,2) del1[i].push(v1[i][s]);
            rep(i,0,2) del2[i].push(v2[i][s]);
            ++s;
        }
        rep(i,0,2){
            while(!q1[i].empty() and !del1[i].empty() and q1[i].top()==del1[i].top()){
                q1[i].pop();
                del1[i].pop();
            }
            while(!q2[i].empty() and !del2[i].empty() and q2[i].top()==del2[i].top()){
                q2[i].pop();
                del2[i].pop();
            }
        }
        ans=max(ans,(q1[0].top()-q2[0].top())*(q1[1].top()-q2[1].top()));
    }
    
    cout << ans << endl;
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 39796
#include <stdio.h>
int main(void){
   double x1,y1,x2,y2,x3,y3,xp,yp;
   double xab,yab,xbc,ybc,xca,yca;
   double xap,yap,xbp,ybp,xcp,ycp;
   double z1,z2,z3;
   
   while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)!=EOF){
       xab=x2-x1,yab=y2-y1;
       xap=xp-x1,yap=yp-y1;
       z1=(xab*yap)-(yab*xap);
       
       xbc=x3-x2,ybc=y3-y2;
       xbp=xp-x2,ybp=yp-y2;
       z2=(xbc*ybp)-(ybc*xbp);
       
       xca=x1-x3,yca=y1-y3;
       xcp=xp-x3,ycp=yp-y3;
       z3=(xca*ycp)-(yca*xcp);
       
       if((z1<0&&z2<0&&z3<0) || (z1>0&&z2>0&&z3>0)){
           printf("YES\n");
       }else{
           printf("NO\n");
       }
   }
   
   return 0;
    
}



Measured memory_bytes: 2064
#include <bits/stdc++.h>
using namespace std;
int n,K,vis[10];
int main()
{
    scanf("%d%d",&n,&K);
    for (int i=1;i<=K;++i) {
        int x;scanf("%d",&x);
        vis[x]=1;
    }
    for (int i=n;;++i) {
        int t=i,f=0;
        while (t) {
            if (vis[t%10]) {
                f=1;
                break;
            }
            t/=10;
        }
        if (!f) return 0*printf("%d\n",i);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    int n;
    in(n);
    vector<int> vec(n);
    in(vec);
    int ans=0;
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            for(int k=j+1;k<n;k++){
                if(vec[i]==vec[j]||vec[i]==vec[k]||vec[j]==vec[k])continue;
                if(vec[i]<vec[j]+vec[k]
                &&vec[j]<vec[i]+vec[k]
                &&vec[k]<vec[j]+vec[i]
                )ans++;
            }
        }
    }
    out(ans);
}

Measured memory_bytes: 3788
#include <stdio.h>
#include <math.h>
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)
#define all(c) begin(c),end(c)
#define vmax(c) *max_element(all(c))
#define vmin(c) *min_element(all(c))
 
template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const long long INF = 0x3f3f3f3f3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9; 

// 多次元配列を作る
// vector<vi> my_vector(n, vi(m, 0));

// 多次元配列の dump
// for (vi v : my_vector) {
//     cout << v;
// }

int solve() {
    int a, b, k;
    cin >> a >> b >> k;

    int cnt = 0;
    RREP(i, 101){
        if (i > 0) {
            if(a % i == 0 && b % i == 0) {
                // cout << i << "," << cnt << endl;
                ++cnt;
            }

            if (k == cnt) {
                return i;
            }
        }
    }
    return 0;
}

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

    int res = solve();
    cout << res;
    return 0;
}


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

int main()
{
    int N, K;
    cin >> N >> K;
    if (N <= K){
        cout << 0 << endl;
    } else {
        vector<int> H(N);
      
        long ans = 0;
        rep(i, N) {
            cin >> H[i];
            ans += H[i];
        }

        sort(H.begin(), H.end(), greater<int>());
        rep(i, K) {
            //   cout << H[0] << " ";
            //H.erase(H.begin());
            ans -= H[i];
        }
        //   cout << endl;
        /*rep(i, N - K) {
            //   cout << H[i] << " ";
            ans += H[i];
        }*/
        cout << ans << endl;
    }
    return 0;
}


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

#define NMAX 100000

using namespace std;

//ifstream fin("f.in");
//ofstream fout("f.out");

vector<int> graph[NMAX];
vector<int> weights[NMAX];
bool visited[NMAX];
int colours[NMAX];
int nodes;

void DFS(int node, int cost)
{
    visited[node] = 1;
    if(cost == 1) colours[node] = 1;
    for(int i = 0; i < graph[node].size(); i++)
        if(!visited[graph[node][i]])
            DFS(graph[node][i], (cost + weights[node][i]) % 2);
}

int main()
{
    int a, b, w;
    cin >> nodes;
    for(int i = 0; i < nodes - 1; i++)
    {
        cin >> a >> b >> w;
        a--;
        b--;
        w = w % 2;
        graph[a].push_back(b);
        graph[b].push_back(a);
        weights[a].push_back(w);
        weights[b].push_back(w);
    }
    DFS(0, 0);
    for(int i = 0; i < nodes; i++)
        cout << colours[i] << '\n';
    return 0;
}


Measured memory_bytes: 13696
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  import std.math;

  int n, d; rd(n, d);
  auto t=new long[](n);
  auto f=new long[](n);
  foreach(i; 0..n) rd(t[i], f[i]);

  long sm=0, pos=1, tm=0, m=0;
  foreach(i; 0..n){
    if(tm+(pos-1)+(f[i]-1)<=t[i]){
      sm+=m*(pos-1);
      m=1;
    }else if(tm+abs(pos-f[i])<=t[i] && m<d){
      // sm+=m*abs(pos-f[i]);
      sm+=m*abs(t[i]-tm);
      m++;
    }else{
      writeln(-1);
      return;
    }
    pos=f[i]; tm=t[i];
  }

  writeln(sm+m*(pos-1));
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}

Measured memory_bytes: 4732
#include<bits/stdc++.h>
using namespace std;
int main(){
    int c=0;
    string s;
    string t;
        cin >> s;
        cin >> t;
    for(int i=0;i<3;i++){
        if(s.at(i)==t.at(i))
        c++;
    }
    cout << c << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;

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

	int correct = 0;
	for (int i = 0; i < 3; i++) {
		if (s[i] == t[i])correct++;
	}

	cout << correct;
    return 0;
}

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

int N,id;
double Max,T,H,A;
int main()
{
	cin >> N >> T >> A;
	Max = 2e9;
	for(int i = 1; i <= N; i++){
		cin >> H;
		double res = fabs(A - T + H * 0.006);
		if(res < Max){
			Max = res;
			id = i;
		}
	}
	cout << id << endl;
	return 0;
}

Measured memory_bytes: 256
a, b = map(int, raw_input().split())
s = raw_input()
flag = False
for i in range(0, a+b+1):
	if s[i] == '-':
		if i == a:
			flag = True
		else:
			flag = False
			break
if flag:
	print 'Yes'
else:
	print 'No'

Measured memory_bytes: 2568
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
a.sort()
check = [True] * (a[-1] + 1)
cnt = Counter(a)

for i in range(n):
    if check[a[i]] == False:continue
    for j in range(a[i], a[-1] + 1, a[i]):
        if j == a[i]:continue
        check[j] = False

ans = 0
for i in range(n):
    if check[a[i]] and cnt[a[i]] == 1:ans += 1

print(ans)


Measured memory_bytes: 133140
#include<iostream>

using namespace std;
int main()
{
    int n;
    cin>>n;int m,p=0;
    while(n>0){
      m = n%10;
      n = n/10;
      if(m==7){
         p=1;
         break;
      }
    }
    if(p==1){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }


    return 0;
}


Measured memory_bytes: 3576