akhauriyash/Code-Regression huggingface dataset:
package main

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

const (
	maxBufsize = 1000000
)

func inputs(lines int, rdr *bufio.Reader) []string {
	var strSlice []string

	//rdr := bufio.NewReaderSize(os.Stdin, maxBufsize)

	for i := 0; i < lines; i++ {

		line := ReadLine(rdr)
		strSlice = append(strSlice, line)

	}

	return strSlice
}

// ReadLine is to read long line
func ReadLine(rdr *bufio.Reader) string {
	buf := make([]byte, 0, maxBufsize)
	for {
		l, p, e := rdr.ReadLine()

		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}

	return string(buf)
}

func main() {

	rdr := bufio.NewReaderSize(os.Stdin, maxBufsize)
	line0 := inputs(1, rdr)

	tmp := strings.Split(line0[0], " ")
	//N, _ := strconv.Atoi(tmp[0])
	M, _ := strconv.Atoi(tmp[1])
	Q, _ := strconv.Atoi(tmp[2])

	lineq := inputs(Q, rdr)

	arrQ := make([][]int, Q+1)
	for i := 0; i < Q+1; i++ {
		arrQ[i] = make([]int, 4)
	}

	for i := 0; i < Q; i++ {
		tmpq := strings.Split(lineq[i], " ")

		a, _ := strconv.Atoi(tmpq[0])
		b, _ := strconv.Atoi(tmpq[1])
		c, _ := strconv.Atoi(tmpq[2])
		d, _ := strconv.Atoi(tmpq[3])

		arrQ[i+1][0] = a
		arrQ[i+1][1] = b
		arrQ[i+1][2] = c
		arrQ[i+1][3] = d
	}

	ans := 0
	for i1 := 1; i1 < M+1; i1++ {
		for i2 := i1; i2 < M+1; i2++ {
			for i3 := i2; i3 < M+1; i3++ {
				for i4 := i3; i4 < M+1; i4++ {
					for i5 := i4; i5 < M+1; i5++ {
						for i6 := i5; i6 < M+1; i6++ {
							for i7 := i6; i7 < M+1; i7++ {
								for i8 := i7; i8 < M+1; i8++ {
									for i9 := i8; i9 < M+1; i9++ {
										for i10 := i9; i10 < M+1; i10++ {
											tmp := 0
											tmpArr := []int{0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10}
											for j := 1; j < Q+1; j++ {
												A := arrQ[j][0]
												B := arrQ[j][1]
												C := arrQ[j][2]
												D := arrQ[j][3]
												if tmpArr[B]-tmpArr[A] == C {
													tmp += D
												}
											}

											ans = int(math.Max(float64(ans), float64(tmp)))

										}
									}
								}
							}
						}
					}
				}
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 6152
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        string S = Console.ReadLine();
        int cnt = 0;

        while(true)
        {
            if(0 <= S.IndexOf("ABC"))
            {
                cnt++;
                S = S.Substring(S.IndexOf("ABC") + 2);
            }
            else
            {
                break;
            }
        }

        Console.WriteLine(cnt.ToString());
    }
}

Measured memory_bytes: 13280
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int X; cin >> X;
    int ans = 0;
    if(X >= 1 && X <= 3)
    {
        cout << 1 << endl;
    }
    else
    {
        for(int i = 2; i < sqrt(X); i++)
        {
            int cnt = i;
            while(cnt <= X)
            {
                cnt *= i;
                if(cnt <= X && ans < cnt)
                {
                    ans = cnt;
                }
            }
        }
        cout << ans << endl;
    }
}

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

using namespace std;

class Edge {
public:
    int u, v, cost;
    Edge() {}
    Edge(int _u, int _v, int _cost) {
        u = _u;
        v = _v;
        cost = _cost;
    }

    bool operator<(const Edge& e) const {
        return cost < e.cost;
    }
};

class UnionFind {
public:
    int n;
    vector<int> parent_nodes, rank;
    UnionFind() {}
    UnionFind(int _n) {
        n = _n;
        // all node is same rank
        for (int i = 0; i < n; ++i) {
            parent_nodes.push_back(i);
            rank.push_back(0);
        }
    }

    int find(int v) {
        if(parent_nodes[v] == v) return v; // return root.
        return parent_nodes[v] = find(parent_nodes[v]); // compress path
    }

    // unite sets
    void unite(int x, int y) {
        x = find(x);
        y = find(y);

        if (x == y){
            return;
        }

        if (rank[x] < rank[y]) {
            parent_nodes[x] = y;
        } else {
            parent_nodes[y] = x;
            if (rank[x] == rank[y]) {
                ++rank[x];
            }
        }

        return;
    }

    // validation of same set
    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

int kruskal(int n_vertex, int n_edge, vector<Edge> edges) {
    int costs = 0;
    sort(edges.begin(), edges.end());
    UnionFind uf = UnionFind(n_vertex);

    for (int i = 0; i < n_edge; ++i) {
        if(!uf.same(edges[i].u, edges[i].v)) {
            uf.unite(edges[i].u, edges[i].v);
            costs += edges[i].cost;
        }
    }

    return costs;
}


int main()
{
    int n, m, a, b, cost, result;
    vector<Edge> edges;
    while(cin>>n>>m) {
        if(n == 0 && m == 0) {
            break;
        }
        for (int i = 0; i < m; ++i) {
            cin >> a >> b >> cost;
            edges.push_back(Edge(a, b, cost));
        }

        result = kruskal(n, m, edges);
        cout << result << endl;
        edges.clear();
    }
    return 0;
}

Measured memory_bytes: 3028
#include "bits/stdc++.h"
using namespace std;

int main() {
	string S;
	while (cin >> S) {
		if (S == "#") return 0;
		int Y, M, D;
		cin >> Y >> M >> D;
		if (Y <= 30 || (Y == 31 && M <= 4)) cout << S << ' ' << Y << ' ' << M << ' ' << D << endl;
		else cout << "? " << Y - 30 << ' ' << M << ' ' << D << endl;
	}
}


Measured memory_bytes: 3232
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           ll                          long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;

inline ll bigmod(ll B,ll P){ll R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline ll ad(ll x,ll y){ll ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll sub(ll x,ll y){ll ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll gun(ll x,ll y){ll ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}

int pre[M+2],suf[M+2];
int a[M+4];
 main()

{
    fast
    int n;
    cin>>n;
    f(i,1,n)cin>>a[i];
    f(i,1,n)
    {
        pre[i]=__gcd(pre[i-1],a[i]);
    }
    rf(i,n,1)
    {
        suf[i]=__gcd(suf[i+1],a[i]);
    }
    int ses=1;
    f(i,1,n)
    {
        ses=max(ses,__gcd(suf[i+1],pre[i-1]));
    }
    cout<<ses<<endl;
    return 0;

}





































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

int main()
{
  	int h,w;
  
 	cin >> h >> w;
  
  	while(h != 0 || w != 0){
      for(int i = 0;i < h;i++){
     	 for(int j = 0;j < w/2;j++){
           if(i % 2)
             cout << ".#";
           else
             cout << "#.";
         }
        if(w % 2){
          if(i % 2)
            cout << '.';
          else
            cout << '#';
        }
        cout << endl;
      }
      cout << endl;
      
      cin >> h >> w;
    }
 	
    
}


Measured memory_bytes: 3100
#include <iostream>
 
using namespace std;
int arr[10000];
int main(){
	int n, x;
  cin >> n >> x;
  for(int i=0;i<n;i++){
  	cin >> arr[i];
  }
  int ans = 1;
  int cur = 0;
  int i=0;
  while(cur <= x && i != n){
  	cur += arr[i];
    i++;
    if(cur <= x){
      ans++;
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define endl "\n"
typedef long long ll;
#define traceV(v) for(auto x:v)cout<<x<<" ";cout<<endl
#define traceM(mp) for(auto x:mp)cout<<x.first<<" "<<x.second<<endl

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

  int N; cin>>N;

  int res = 0;
  reps(i,1, N+1) {
    int v = i, cnt = 0;
    while(v) {
      v/=10;
      ++cnt;
    }
    if(cnt%2==1) ++res;
  }

  cout << res <<endl;

  return 0;
}


Measured memory_bytes: 256
S = input()

if "keyence" in S:
    if S[0:7] == "keyence" or S[-7:] == "keyence":
        print("YES")
    else:
        print("NO")
    exit()

s = "keyence"

for i in range(1,len(s)):
    if S[:i] == s[:i] and S[-(7-i):] == s[-(7-i):]:
        print("YES")
        exit()
print("NO")


Measured memory_bytes: 3060
#include <queue>
#include <cctype>
#include <iostream>
#include <string>

using namespace std;

struct PS {
	string name;
	unsigned int t;
};

int main()
{
	unsigned int n, s, t = 0;
	queue<PS> ps;

	cin >> n >> s;

	for (unsigned int i = 0; i < n; ++i) {
		PS x;
		cin >> x.name >> x.t;
		ps.push(x);
	}

	while ( ! ps.empty()) {
		PS x;
		x = ps.front();
		ps.pop();

		if (x.t <= s) {
			t += x.t;
			cout << x.name << " " << t << endl;
		} else {
			t += s;
			x.t -= s;
			ps.push(x);
		}
	}

	return 0;
}



Measured memory_bytes: 6304
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef boost::multiprecision::cpp_int bigint;

const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VI a(n);
	rep(i,n) cin >>a[i];
	bigint bs = 1 , ans =0;
	rep(i, n) bs = boost::math::lcm(bs, bigint(a[i]));
	//dbg(bs);
	bigint tg = bs-1;
	rep(i, n) ans += tg % a[i];
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 256
N = int(input())
s = {}
for i in range(N):
  a = input()
  if a in s:
    s[a] += 1
  else:
    s[a] = 1
M = int(input())
t = {}
for i in range(M):
  b = input()
  if b in t:
    t[b] += 1
  else:
    t[b] = 1
ans = 0
for p in s:
  if p in t:
    m = s[p] - t[p]
  else:
    m = s[p]
  if m > ans:
    ans = m
print(ans)
  


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
#include <cstring>
#include <iomanip>
#include<queue>
#include<set>
#include<stack>
#include<fstream>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1844674407370955161
typedef long long int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007


int main()
{
	int x[5];

	REP(i,0,5){
		cin>>x[i];
		if(x[i]==0){
			cout<<i+1<<endl;
		}
	}

	return 0;
	
}

Measured memory_bytes: 3592
using System.Collections.Generic;
using System.Linq;
using System;

public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        getAns(n, a);
    }
    static void getAns(int n, int[] a)
    {
        var ans = new List<int>();
        var m1p = -1;
        var m2c = 0;
        var m2p = -1;

        for (int i = 0; i < n; i++)
        {
            if (a[i] == 2) ans.Add(i + 1);
            else if (a[i] == -1)
            {
                if (m1p == -1) { m1p = i + 1; ans.Add(m1p); }
            }
            else if (a[i] == -2)
            {
                m2p = i + 1;
                ans.Add(m2p);
                m2c++;
            }
        }
        if (m2c % 2 == 0 && m1p != -1) ans.Remove(m1p);
        if (m2c % 2 != 0 && m1p == -1) ans.Remove(m2p);
        if (ans.Count() == 0) { Console.WriteLine(0); return; }
        else
        {
            Console.WriteLine(ans.Count());
            Console.WriteLine(string.Join("\n", ans));
        }
    }
}


Measured memory_bytes: 20188
a=[]
for i in 0..4
  a[i]=gets.chomp.to_i
end
k=gets.chomp.to_i

t=true
for i in 0..4
  for j in 0..4
    if (a[i]-a[j]).abs > k
      puts ":("
      t=false
      break
    end
  end
  break unless t
end

if t
  puts "Yay!"
end

Measured memory_bytes: 1788
import numpy as np

def make_divisors(n):
        divisors = []
        for i in range(1, int(n**0.5)+1):
                if n % i == 0:
                        divisors.append(i)
                        if i != n // i:
                                divisors.append(n//i)
        # divisors.sort()
        return divisors

S = int(input())
ans = []
x1y2 = int(np.sqrt(S))
if x1y2 > (10**9)-10000:
    x1y2 = 10**9
rem = S - x1y2 ** 2
if rem == 0:
        x2 = 0
        y1 = 0
elif rem == 1:
        x2 = 1
        y1 = -1
elif rem < 0:
        comb = make_divisors(-rem) 
        x2 = comb[-1]
        y1 = abs(rem // x2)
        print(0)
        print(0)
        print(x1y2)
        print(y1)
        print(x2)
        print(x1y2)
        exit()
else:
        comb = make_divisors(rem) 
        x2 = comb[-1]
        y1 = -(rem // x2)
print(0)
print(-y1)
print(x1y2)
print(0)
print(x2)
print(x1y2 - y1)



Measured memory_bytes: 22072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll h,w;
	cin>>h>>w;
	char ch[22][22];
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			cin>>ch[i][j];
		}
	}
	ll dx[4]={1,0,-1,0};
	ll dy[4]={0,1,0,-1};
	ll ans=0;
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			if(ch[i][j]=='#'){
				continue;
			}
			queue<pair<ll,ll>>q;
			q.push(make_pair(i,j));
			ll cnt[22][22];
			for(ll i=0;i<h;i++){
				for(ll j=0;j<w;j++){
					cnt[i][j]=-1;
				}
			}
			cnt[i][j]=0;
			while(q.size()!=0){
				ll nowx=q.front().first;
				ll nowy=q.front().second;
				q.pop();
				for(ll i=0;i<4;i++){
					ll nexx=nowx+dx[i];
					ll nexy=nowy+dy[i];
					if(ch[nexx][nexy]=='#'||cnt[nexx][nexy]!=-1){
						continue;
					}
					cnt[nexx][nexy]=cnt[nowx][nowy]+1;
					ans=max(ans,cnt[nexx][nexy]);
					q.push(make_pair(nexx,nexy));
				}
			}
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
int main(void){
    int x,y;
while(1){
    scanf("%d%d",&x,&y);
if(x==0&&y==0){
        break;
    }else if(x<y){
        printf("%d %d\n",x,y);
    }else if(y<x){
        printf("%d %d\n",y,x);
    }else {
        printf("%d %d\n",x,y);
    }
}

return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
string s,t;
  cin>>s>>t;
  int a,b;
  cin>>a>>b;
  string u;
  cin>>u;
  if(u==s){
    a -=1;
  }
  else{
    b -=1;
  }
  cout<<a<<" "<<b<<endl;


}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int i,j;
int k[1002],n,m,a[204],b[204];

int main(){
	scanf("%d",&n);
	for(i=1;i<=n*2;i++)a[i]=i,b[i]=i;
	scanf("%d",&m);
	for(i=0;i<m;i++)scanf("%d",&k[i]);
	
	for(i=0;i<m;i++){
		if(k[i]==0){
			for(j=1;j<=n*2;j++){
				if(j%2==1)b[j]=a[(j+1)/2];
				else b[j]=a[n+j/2];
			}
			for(j=1;j<=n*2;j++)a[j]=b[j];
		}else{
			for(j=1;j<=n*2;j++){
				if(j<=n*2-k[i])b[j]=a[k[i]+j];
				else b[j]=a[j-n*2+k[i]];
			}
			for(j=1;j<=n*2;j++)a[j]=b[j];
		}
	}
	
	for(i=1;i<=n*2;i++)printf("%d\n",a[i]);
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<queue>
#include<cstdint>
#include<algorithm>
using namespace std;

const int MAX = 100000;
const int64_t INF = 4611686018427387903; // 2^62-1、使わない辺とかに用いる

typedef struct node {
	int myID; // ユニークID, まぁデバッグ用？
	vector<pair<int, int> > edge; // 移動辺
	vector<int64_t> costs; // 確定したコスト
	bool done; // 確定ノードか否か
	int64_t cost; // 現時点のコスト
	
	bool operator<(const node& a) const {
		return cost > a.cost;
	}
} Node;

typedef class dijkstra {
	private:
		int N; // 頂点数
		vector<Node> node;
		void init(int s);
	public:
		dijkstra(int n);
		void addEdge(int n, int m, int cost);
		void calc(int s);
		int64_t getCost(int s, int t);
} Dijkstra;

/**
 * 頂点数を渡してください、初期化します。
 * @param n 頂点の数
 */
dijkstra::dijkstra(int n) {
	N = n;
	node.resize(n);
	for (int i = 0;i < N;i ++) {
		node[i].edge.clear();
		node[i].myID = i;
	}
}

/**
 * 頂点nと頂点mの間にcostの重み付き無向辺を作ります。
 * @param n 行く側の頂点
 * @param m 向かう側の頂点
 * @param cost 移動コスト
 */
void dijkstra::addEdge(int n, int m, int cost) {
	node[n].edge.push_back(make_pair(m, cost));
	node[m].edge.push_back(make_pair(n, cost));
}

void dijkstra::init(int s) {
	for (int i = 0;i < N;i ++) {
		node[i].done = false;
		node[i].cost = INF;
	}
	node[s].cost = 0;
}
/**
 * ダイクストラ法を実行します。O(VlogE)です。
 */
void dijkstra::calc(int s) {
	init(s);
	priority_queue<Node> que; // コスト、頂点
	que.push(node[s]);
	
	Node check;
	while(!que.empty()) {
		check = que.top();
		que.pop();
		
		if (check.done) continue;
		check.done = true;
		for (int i = 0;i < check.edge.size();i ++) {
			if (check.cost + check.edge[i].second < node[check.edge[i].first].cost) { // より近い経路発見！
				node[check.edge[i].first].cost = check.cost + check.edge[i].second;
				que.push(node[check.edge[i].first]);
			}
		}
	}
	node[s].costs.resize(N);
	for (int i = 0;i < N;i ++) node[s].costs[i] = node[i].cost;
}

/**
 * 頂点sから頂点tへ行くまでの最短コストを返します。
 * @param s 始点となる頂点
 * @param t 終点となる頂点
 * @return sからtまでの最短コスト
 */
int64_t dijkstra::getCost(int s, int t) {
	return node[s].costs[t];
}

int main() {
	int n, m, s, t, u, v, a, b;
	cin >> n >> m >> s >> t;
	
	int64_t snuke = 1000000000000000; // 持ち金
	Dijkstra map1(n), map2(n);
	for (int i = 0;i < m;i ++) {
		cin >> u >> v >> a >> b;
		map1.addEdge(u - 1, v - 1, a);
		map2.addEdge(u - 1, v - 1, b);
	}
	map1.calc(s - 1);
	map2.calc(t - 1);
	
	static pair<int64_t, int> cost[MAX];
	for (int i = 0;i < n;i ++) { // iは両替を行う都市
		cost[i] = make_pair(map1.getCost(s - 1, i) + map2.getCost(t - 1, i), i);
	}
	
	sort(cost, cost+n);
	
	int read = 0;
	for (int i = 0;i < n;i ++) {
		while(cost[read].second < i) read ++; // その両替所は存在しない！
		
		cout << snuke - cost[read].first << endl;
	}
	
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

さて、下準備
まず、都市sから他の全ての都市への円を用いた最短経路を出す
次に、その全ての都市から都市tへのスヌークを用いた最短経路を出す 逆に出せば良いのよ、tからね

最後に、どの都市で両替したら良いかを最終スヌークが多い順にソートして持っておこう

さて、この時i年目について高速に求めてみよう
と言っても、答えはソートした奴を上から見て、両替所が存在していればそれが答え

DijkstraでO(nlog(m))、ソートにO(nlog(n))、上から見てくのO(n)だしO(nlog(m))かなぁ(O(max(n,m))=O(m)なので)
*/

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main(){
  set<int>st;
  rep(i, 0, 3){
     int a;
     cin >> a;
     st.insert(a);
  }
  cout << st.size() << endl;
}

Measured memory_bytes: 3608
N = int(input())
L = list(map(int,input().split()))
L.sort()
ans = 0
for b in range(N):
    l = b + 1
    r = l
    for a in range(b):
        maxL = L[a] + L[b]
        while r<N and L[r]<maxL: r += 1
        ans += max(0, r-l)
print(ans)

Measured memory_bytes: 3188
#include<stdio.h>
#include<stdlib.h>
int x[100005]={},dp[100005][20],lg[20]={1}; //倍增
int main()
{
	int n,m,q,a,b,temp,ans,d,last,k;
	scanf("%d",&n); last=n;
	for(int i=1;i<=n;i++) scanf("%d",&x[i]);
	scanf("%d %d",&m,&q);
	for(int i=1;i<20;i++) lg[i]=lg[i-1]*2; //准备好2的幂
	for(int i=n;dp[1][0]==0;i--){ //预处理走一步的情况
		d=x[i]-m; //极限距离
		if(x[last]<d) continue; //本次结果和上一次一样 没必要搜索
		for(int j=last;j>=1&&x[j]>=d;j--,last--)
			dp[j][0]=i;
	}
	for(int j=1;j<=16;j++) //一次走65536步是可能的 走2^17是不可能的
		for(int i=1;i<=n;i++)
			dp[i][j]=dp[dp[i][j-1]][j-1]; //核心算法：在i点走2^j步等效于在i点走2^(j-1)步后再走2^(j-1)步！
	while(q>0){
		q--; ans=0;
		scanf("%d %d",&a,&b);
		if(a>b){ //a到b和b到a等效
			temp=a;
			a=b;
			b=temp;
		}
		while(dp[a][0]<b){
			for(k=0;k<=16;k++) //大步流星
				if(dp[a][k]>=b)
					break;
			ans+=lg[k-1];
			a=dp[a][k-1];
		}
		printf("%d\n",ans+1);
	}
	return 0;
}

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

using namespace std;

int N, M;
vector<int> ItemInfo, PersonInfo;

void solve() {
	int curValue;
	int total[1000];

	memset(total, 0, sizeof(total));
	for (int i = 0; i < M; ++i) {
		curValue = PersonInfo[i];
		for (int j = 0; j < N; ++j) {
			if (ItemInfo[j] <= curValue) {
				//cout << "=" << j + 1 << endl;
				++total[j];
				break;
			}
		}
	}

	cout << max_element(total, total + N) - total + 1 << endl;
}

int main() {
	int num;

	cin >> N >> M;
	for (int i = 0; i < N; ++i) {
		cin >> num;
		ItemInfo.push_back(num);
	}
	for (int i = 0; i < M; ++i) {
		cin >> num;
		PersonInfo.push_back(num);
	}
	solve();

	return 0;
}


Measured memory_bytes: 3176
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    
    int res = 0;
    
    for(int i = 0; i < N; i++){
        res += a[i] - 1;
    }
    
    cout << res << endl;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int MAXW = 7, W = 5;

int main()
{
	int m; cin >> m;
	while( m -- )
	{
		int tile[MAXW][MAXW] = {};
		int w[MAXW][MAXW] = {};
		int dp[MAXW][MAXW] = {};
		rep(j,W)rep(i,W) cin >> tile[i+1][j+1];

		rep(j,W)rep(i,W) w[i+1][j+1] = (w[i][j+1] + 1) * tile[i+1][j+1];

		//rep(j,W){ rep(i,W) cout << w[i+1][j+1] << " "; cout << endl;}

		int width = 0;
		rep(j,W)rep(i,W)
		{
			width = 5;
			for(int k = 0; j - k >= 0;k++)
			{
				width = min(width, w[i+1][j+1 - k]);
				dp[i][j] = max(dp[i][j], width * (k + 1));
			}
		}
		int ans = 0;
		rep(j,W)rep(i,W) ans = max(ans, dp[i][j]);
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define  pb  push_back
int main(){
    int tmp;
    int n;cin>>n;
    vector<int> a;
    vector<int> b;
    vector<int> c;
    int a_n;cin>>a_n;for(int i = 0; a_n > i; i++)cin>>tmp,a.pb(tmp);sort(a.begin(),a.end());
    int b_n;cin>>b_n;for(int i = 0; b_n > i; i++)cin>>tmp,b.pb(tmp);sort(b.begin(),b.end());
    int c_n;cin>>c_n;for(int i = 0; c_n > i; i++)cin>>tmp,c.pb(tmp);sort(c.begin(),c.end());
    int nwa = 0;
    int nwb = 0;
    int nwc = 0;
    bool bla,blb,blc;
    int ans = 0;
    for(int i = 1; n >= i; i++){
        bla = false;
        blb = false;
        blc = false;
        if(!a.empty()&&a[nwa]==i){
            bla = true;
            nwa++;
        }
        if(!b.empty()&&b[nwb]==i){
            blb = true;
            nwb++;
        }
        if(!c.empty()&&c[nwc]==i){
            blc = true;
            nwc++;
        }
        //cout << (bla?"a":"b") << " " << (blb?"a":"b") << " " << (blc?"a":"b") << endl;
        if((!bla && blc) || (blb && blc))ans++;
    }
    cout << ans << endl;
    
}



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

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int INF = pow(2,29);
const int MOD = 1000000007;

int main() {
  string s; cin >> s;
  int l = s.length();

  vector<int> pos;
  rep(i, l-1) {
    if (i==0 && s[i]=='0') { cout << -1 << endl; return 0; }
    if (s[i]!=s[l-2-i]) { cout << -1 << endl; return 0; }
    if (s[i]=='1') pos.push_back(i+1);
  }
  if (s[l-1]=='0') pos.push_back(l);
  else { cout << -1 << endl; return 0; }

  rep(i, pos.size()-1) {
    for (int j=pos[i]; j<pos[i+1]; j++) {
      cout << j << " " << pos[i+1] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 2040
#include <iostream>

//??´??°???3?????\??£????????????,3??§??????????????????????????¨???

void call(int n){
  for(int i = 1; i <= n;i++){
    int x = i;
    if (x % 3 == 0){
      std::cout << " " << i;
      continue;
    }
    while(x){
      if(x % 10 == 3){
	std::cout << " " << i;
	break;
      }
      x /= 10;
    }
  }
  std::cout << std::endl;
}
  
int main(){
  
  int n;
  //?????°??????
  while(std::cin >> n){ 
    call(n);
  }
  return 0;
}

Measured memory_bytes: 1160
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    let mut a:Vec<u64> = (0..3).map(|_| read()).collect();
    a.sort();
    let k:u64 = read();

    println!("{}", a[0]+a[1]+a[2]*(2 as u64).pow(k as u32));

}


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


int main()
{
 string str;
 
 cin>>str;
 if(str.compare("abc")==0 or str.compare("acb")==0 or str.compare("bac")==0 or str.compare("bca")==0 or str.compare("cab")==0 or str.compare("cba")==0)
 { cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ll_s long
#define mod 1000000007
#define forn(i,start,lim) for(ll i=start;i<lim;i++)
#define forn_d(i,start,lim) for(ll i=start;i>=lim;i--)
#define f first
#define s second
#define pb push_back
#define pf push_front
#define mp make_pair
#define debug1(a) cout<<"------\n"<<#a<<" = "<<a<<endl<<"------"<<endl
#define debug2(a,b) cout<<"--------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<endl<<"--------------"<<endl
#define debug3(a,b,c) cout<<"----------------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<" ; "<<#c<<" = "<<c<<endl<<"----------------------"<<endl
#define sz(a) (ll)(a.size())
#define debug4(a) cout<<"chu "<<a<<endl
#define endl "\n"

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  ll n,m;
  cin>>n>>m;
  if(n>m)
    swap(n,m);
  while(m){
    cout<<n;
    m--;
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define MOD (long long int)(998244353)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}


int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  ll n,k,q;cin>>n>>k>>q;
  vector<ll> A(n);
  rep(i,n){
    cin>>A[i];
  }
  ll ans = LINF;
  rep(i,n){
    ll minA = A[i];
    ll ok = 1e12+3;
    ll ng = minA - 1;
    while(ok - ng >= 2){
      ll mid = (ok + ng) / 2;
      ll sum = 0;
      ll count = 0, count_min = 0;
      rep(j,n){
        if(A[j] >= minA){
          count++;
          if(A[j] <= mid){
            count_min++;
          }
        }else{
          sum += max(0ll, min(count - k + 1, count_min));
          count = 0;
          count_min = 0;
        }
      }
      sum += max(0ll, min(count - k + 1, count_min));
      if(sum >= q){
        ok = mid;
      }else{
        ng = mid;
      }
    }

    chmin(ans, ok - minA);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
int n, m, l, a[100][100], b[100][100];
int main() {
	scanf("%d%d%d", &n, &m, &l);
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			scanf("%d", &a[i][j]);
		}
	}
	for(int i = 0; i < m; i++) {
		for(int j = 0; j < l; j++) {
			scanf("%d", &b[i][j]);
		}
	}
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < l; j++) {
			long long ret = 0;
			for(int k = 0; k < m; k++) ret += a[i][k] * b[k][j];
			if(j) printf(" ");
			printf("%lld", ret);
		}
		printf("\n");
	}
	return 0;
}

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

using namespace std;

int
main(void){
	int n, k;
	cin >> n >> k;
	vector<int> vec(n);
	for(int i = 0; i < n; i++)
		cin >> vec[i];
	int ans = INT_MAX;
	for(int i = 0; i < n - k + 1; i++){
		ans = min(ans, vec[i + k - 1] - vec[i] + (int)min(fabs(vec[i]), fabs(vec[i + k - 1])));
	}
	cout << ans;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
  ll n,x,tmp,cnt=0;
  cin >> n >> x;
  int a[n+1];
  for(int i=0;i<n;i++){
    cin >> a[i+1];
  }
  a[0]=0;
  for(int i=1;i<=n;i++){
    tmp=a[i]+a[i-1];
    if(tmp>=x){
      cnt += tmp-x;
      a[i] -= (tmp-x);
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;
 
    int main(){
      int n;
      cin >> n;
      int c[n-1],s[n-1],f[n-1];
      rep(i,n-1){
        cin >> c[i] >> s[i] >> f[i];
      }
      rep(i,n-1){
        int t=0;
        int pos=i;
        while(pos<n){
          while(pos!=n-1 && (s[pos]>t || t%(f[pos])!=0)){
            t++;
          }
          if(pos<n-1)t+=c[pos];
          pos++;
        }
        cout << t << endl;
      }
      cout << 0 << endl;
      return 0;}

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

typedef long long LL;
typedef pair<int, int> II;

const int MAXN = (int) 1e5 + 10;
int n, k;
priority_queue<II> pq;

LL Sum(priority_queue<II> pq, int lim) {
    LL ans = 0;
    while (pq.size()) {
        if (pq.top().first <= lim) ans += pq.top().second;
        pq.pop();
    }
    return ans;
}

void Print(priority_queue<II> pq, int k) {
    cout << k << endl;
    while (pq.size()) {
        int x = pq.top().first;
        int y = pq.top().second;
        pq.pop();
        cout << "   " << x << " " << y << endl;
    }
}

LL Solve(int k) {
    if (k == 0) return Sum(pq, 0);
    int h = 29; while ((k >> h & 1) == 0) h--;
    while (pq.size() && pq.top().first >= (1 << (h + 1))) pq.pop();
    // Print(pq, k);
    LL ans = Sum(pq, (1 << h) - 1);
    while (pq.size() && pq.top().first >= (1 << h)) {
        II x = pq.top(); pq.pop();
        pq.push(II(x.first - (1 << h), x.second));
    }
    return max(ans, Solve(k - (1 << h)));
}

int main() {
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; ++i) {
        int x, y; scanf("%d%d", &x, &y);
        pq.push(II(x, y));
    }
    printf("%lld\n", Solve(k));
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll N,X;
ll x[200010];
ll sum[200010];

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

  cin>>N>>X;
  rep(i,N)cin>>x[i];
  reverse(x,x+N);
  rep(i,N)sum[i+1]=sum[i]+x[i];
  __int128 res=1e22;
  repl(k,1,N+1){
    __int128 crt=0;
    for(ll i=0;i<N;i+=k){
      ll j=i/k;
      __int128 s=sum[min(N,i+k)]-sum[i];
      if(i==0)crt+=s*5;
      else crt+=s*(2*j+3);
    }
    __int128 add=X;
    add*=(N+k);
    minch(res,crt+add);
  }
  string ans;
  while(res>0){
    ans+=(char)('0'+res%10); res/=10;
  }
  reverse(all(ans));
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3328
def divisors(N):
    U = int(N ** 0.5)
    res = []
    *_, = (res.extend([i, N // i]) for i in range(1, U) if N % i == 0)
    if N % U == 0:
        res.append(U)
    res.sort()
    return res

N, M = map(int, input().split())
print(max(d for d in divisors(M) if d * N <= M))


Measured memory_bytes: 3060
#include<iostream>
#include<set>
using namespace std;
int N;
long K;
long A[1<<17],B[1<<17],C[1<<17];
main()
{
	cin>>N>>K;
	set<int>L,R;
	for(int i=0;i<N;i++)L.insert(K+i),R.insert(K+N+i);
	for(int i=0;i<N;i++)
	{
		C[i]=K+2*N+N-i-1;
		if(i%2==0)
		{
			set<int>::iterator it=R.end();
			it--;
			B[i]=*it;
			R.erase(it);
			it=L.lower_bound(C[i]-B[i]);
			if(it==L.end())it--;
			if(*it+B[i]<=C[i])
			{
				A[i]=*it;
				L.erase(it);
			}
			else
			{
				cout<<-1<<endl;
				return 0;
			}
		}
		else
		{
			set<int>::iterator it=L.end();
			it--;
			A[i]=*it;
			L.erase(it);
			it=R.lower_bound(C[i]-A[i]);
			if(it==R.end())it--;
			if(A[i]+*it<=C[i])
			{
				B[i]=*it;
				R.erase(it);
			}
			else
			{
				cout<<-1<<endl;
				return 0;
			}
		}
	}
	for(int i=0;i<N;i++)cout<<A[i]<<" "<<B[i]<<" "<<C[i]<<"\n";
}


Measured memory_bytes: 13952
//         Jai Saraswati Maa       Om Namah Shivaay        Jai Bhawani
// You have to work hard and keep coding till you get correct output never quit! :-)
// May the force be with you
// Ganpatai Bappa Morya! Mangal Murti Morya!
#include<bits/stdc++.h>
#define sc(x) scanf("%d",&x);
#define scc(x,y) scanf(" %d %d",&x,&y);
#define sccc(x,y,z) scanf("%d %d %d",&x,&y,&z);
#define sl(x) scanf("%lld",&x);
#define sll(x,y) scanf("%lld %lld",&x,&y);
#define slll(x,y,z) scanf("%lld %lld %lld",&x,&y,&z);
#define pf(x) printf("%d",x);
#define pfn(x) printf("%d\n",x);
#define pl(x) printf("%lld",x);
#define pln(x) printf("%lld\n",x);
#define st(s) scanf("%s",s);
using namespace std;
int main()
{
    int k,i,j,c=0;
    sc(k)
    for(i=1;i<=k;i=i+1)
    {
        for(j=i+1;j<=k;j=j+2)
           c++;
    }
    pfn(c)
 return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>

int main()
{
    int N;
    scanf("%d", &N);
    int A[N];
    for(int i=0; i<N; i++)
        scanf("%d", &A[i]);
    int count_minus=0;
    int flag_zero=0;
    long min_abs = abs(A[0]);
    long sum_abs = 0;

    for(int i=0; i<N; i++){
        if(A[i] < 0) count_minus++;
        else if(A[i] == 0) flag_zero=1;
        if(abs(A[i]) < min_abs) min_abs = abs(A[i]);
        sum_abs += abs(A[i]);
    }
    long r = (count_minus%2 == 1 && flag_zero==0) ? sum_abs - min_abs * 2 : sum_abs;
    printf("%ld\n", r);
    return 0;
}


Measured memory_bytes: 512
x,y = list(map(int, input().split()))

if (x+y) % 3 != 0:
    print(0)
    exit()

a = (2*x - y) // 3
b = (2*y - x) // 3

if a < 0 or b < 0:
    # (x,y) = (1,5)とかは無理
    print(0)
    exit()
    
MOD = 10**9+7
def fact(x):
    f = 1
    for i in range(2, x+1):
        f *= i
        f %= MOD
    return f

def fact_inv(x):
    return pow(fact(x), MOD-2, MOD)

ans = fact(a+b) * fact_inv(a) * fact_inv(b) % MOD

print(ans)

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

int main(){
	string s;
	cin >> s;
	
	if(s == "Sunny") cout << "Cloudy" << endl;
	else if(s == "Cloudy") cout << "Rainy" << endl;
	else cout << "Sunny" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int N;
	scanf("%d", &N);
	int p[N + 1];
	int i = 1;
	while (i <= N)
		scanf("%d", &p[i++]);
	i = 1;
	int ans = 0;
	int min = p[1];
	int j;
	while (i <= N)
	{
		if (min >= p[i])
		{
			min = p[i];
			ans++;
		}
		i++;
	}
	printf("%d\n",ans);
	return (0);
}


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

int main() {
    string str;
    string sub;
    int number = 0;
    int shuffle = 0;
    int i;

    while (1) 
    {
        cin >> str;                     //文字列入力
        if (str == "-") break;

 
        cin >> number;                   //回数入力

        for (i = 0; i < number; i++) 
        {
            cin >> shuffle;                //末尾に移動する先頭からの要素数
            sub = str.substr(0, shuffle);  //先頭から入力した数値を抽出
            
            str.erase(str.begin(), str.begin() + shuffle);
            str = str + sub;
        }
        cout << str << "\n";
    }
    return 0;
}


Measured memory_bytes: 3176
//BadWaper gg
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#define inf 1e9
#define eps 1e-6
#define mp make_pair
#define fr first
#define sd second
#define N 21
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
int n,m,k;
int p[N][N],q[N][N];
char s[N][N];
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read(),m=read(),k=read();
	for(register int i=1;i<=n;i++)
	{
		scanf("%s",s[i]+1);
		for(register int j=1;j<=m;j++)if(s[i][j]=='.')p[i][j]=0;else p[i][j]=1;
	}
	int ans=0;
	for(register int S=0;S<(1<<n);S++)
	{
		for(register int T=0;T<(1<<m);T++)
		{
			for(register int i=1;i<=n;i++)
			{
				for(register int j=1;j<=m;j++)q[i][j]=p[i][j];
			}
			for(register int i=1;i<=n;i++)
			{
				if((S>>(i-1))&1)
				{
					for(register int j=1;j<=m;j++)q[i][j]=2;
				}
			}
			for(register int j=1;j<=m;j++)
			{
				if((T>>(j-1))&1)
				{
					for(register int i=1;i<=n;i++)q[i][j]=2;
				}
			}
			int v=0;
			for(register int i=1;i<=n;i++)for(register int j=1;j<=m;j++)if(q[i][j]==1)v++;
			if(v==k)ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}


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

public class Main {

    static BufferedReader br;
    static StringTokenizer st;

    public enum EventType {
        INSERT,
        DELETE,
        QUERY
    }

    public static class Event {
        final long time;
        final EventType type;
        final long x;

        public Event(final long time, final EventType type, final long x) {
            this.time = time;
            this.type = type;
            this.x = x;
        }
    }

    public static void main(final String[] args) throws Exception {
        br = new BufferedReader(new InputStreamReader(System.in));

        long N;
        N = readLong();
        long Q;
        Q = readLong();
        final List<Event> events = new ArrayList<>();
        for(int i = 0 ; i < N ; i++){
            long S = readLong();
            long T = readLong();
            long X = readLong();

            events.add(new Event(S - X, EventType.INSERT, X));
            events.add(new Event(T - X, EventType.DELETE, X));
        }

        for(int i = 0 ; i < Q ; i++){
            final long D = readLong();
            events.add(new Event(D, EventType.QUERY, i));
        }

        final Solver solver = new Solver();
        solver.solve(Q, events);
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }

    static long readLong() throws IOException {
        return Long.parseLong(next());
    }
}

class Solver {
    public void solve(long Q, List<Main.Event> events) {
        events.sort(Comparator.comparingLong(e -> e.time));

        long[] ANS = new long[(int)(Q)];
        final TreeSet<Long> blocks = new TreeSet<>();

        for (final Main.Event event : events) {
            switch (event.type) {
                case INSERT:
                    blocks.add(event.x);
                    break;
                case DELETE:
                    blocks.remove(event.x);
                    break;
                case QUERY:
                    ANS[(int) event.x] = blocks.isEmpty() ? -1 : blocks.first();
                    break;
            }
        }

        for (final long ans : ANS) {
            System.out.println(ans);
        }
    }
}



Measured memory_bytes: 108592
using System;
public class tiisai
{
    public static int asd(int a)
    {
        int b = 0;
        for(int i=a-1;i>=0; )
        {
            for(int j=2;j< i; )
            {
                if (i % j == 0)
                {
                    goto stop;
                }
                if (j == 2)
                {
                    j++;
                }
                else
                {
                    j += 2;
                }
            }
            b = i;
            break;
            stop:;
            if (i % 2 == 0)
            {
                i--;
            }
            else
            {
                i -= 2;
            }
        }
        return b;
     }
}
public class ookii
{
    public static int sdf(int a)
    {
        int b = 0,i=a+1;
        for(;;)
        {
            for (int j = 2; j < i;)
            {
                if (i % j == 0)
                {
                    goto stop;
                }
                if (j == 2)
                {
                    j++;
                }
                else
                {
                    j += 2;
                }
            }
            b = i;
            break;
        stop:;
            if (i % 2 == 0)
            {
                i++;
            }
            else
            {
                i += 2;
            }
        }
        return b;
    }
}
class aoj
{
    static void Main()
    {
        int[,] g = new int[50, 2];
        int i = 0;
        while (true)
        {
            string a = Console.ReadLine();
            if (String.IsNullOrEmpty(a)) break;
            int b = int.Parse(a);
            tiisai tiisai = new tiisai();
            int e = tiisai.asd(b);
            ookii ookii = new ookii();
            int f = ookii.sdf(b);
            g[i, 0] = e;
            g[i, 1] = f;
            i++;
        }
        for(int j=0;j< i; j++)
        {
            Console.WriteLine("{0} {1}", g[j, 0], g[j, 1]);
        }
    }
}

Measured memory_bytes: 9144
#include <iostream>
#include <cmath>
#include <string>
#include <vector>

int main()
{
  int N, K;
  std::cin >> N >> K;
  std::vector< int > vx(N, 0);

  int ans = 0;
  for (int i = 0; i < N; i++) {
    std::cin >> vx[i];
    ans += std::min(vx[i], (int)std::fabs(vx[i] - K)) * 2;
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
bool checkBridge(int a) {
    int tmp = a;
    // aを2進数表記したときに1が連続した部分がある -> false
    // else true
    vector<int> b;
    while (tmp > 0) {
        b.push_back(tmp % 2);
        tmp /= 2;
    }
    int l = b.size();
    for (int i = 0; i < (l-1); i++) {
        if (b[i] == 1 && b[i+1] == 1) return false;
    }
    return true;
}
/* main */
int main(){
    int H, W, K;
    cin >> H >> W >> K;
    if (W == 1) {
        cout << 1 << '\n';
        return 0;
    }

    vector<ll> dp1(W), dp2(W);
    // init
    dp1[0] = 1LL;
    // calc
    for (int h = 0; h < H; h++) {
        fill(dp2.begin(), dp2.end(), 0);
        for (int b = 0; b < (1 << (W-1)); b++) { // 橋のかけ方
            // 連続した橋がかかってないか
            if (checkBridge(b) == false) continue;
            // b = 0 0 1 0
            //    | | |-| |
            //    0 1 2 3 4
            for (int i = 0; i < W-1; i++) {
                if ((b>>i) % 2) {
                    dp2[i] += dp1[i+1]; dp2[i] %= mod;
                    dp2[i+1] += dp1[i]; dp2[i+1] %= mod;
                    i++;
                }
                else {
                    dp2[i] += dp1[i]; dp2[i] %= mod;
                }
            }
            // 右端の棒の処理
            if ((b >> (W-2)) % 2 == 0) dp2[W-1] += dp1[W-1], dp2[W-1] %= mod;
        }
        swap(dp1, dp2);
    }
    cout << dp1[K-1] << '\n';
}


Measured memory_bytes: 3596