akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main() {
  int a, l, n, m, i, j;
  int s[100][100] = {0};
  
  scanf("%d", &n);
  
  for (i = 0; i < n; i++) {
    scanf("%d", &a);
    scanf("%d", &m);
    for (j = 0; j < m; j++) {
      scanf("%d", &l);
      s[i][l - 1] = 1;
    }
    for (j = 0; j < n; j++) {
      if (j == n - 1) {
        printf("%d", s[i][j]);
      } else {
      printf("%d ", s[i][j]);
      }
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 652
import java.util.*;
import java.io.PrintWriter;
import java.math.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		BigDecimal a=BigDecimal.valueOf(sc.nextLong());
		BigDecimal b=BigDecimal.valueOf(sc.nextDouble());
	
		System.out.println(a.multiply(b).longValue());
	}
}


Measured memory_bytes: 37972
#!/usr/bin/python2
# -*- coding: utf-8 -*-

import sys

def rl(proc=None):
    if proc is not None:
        return proc(sys.stdin.readline())
    else:
        return sys.stdin.readline().rstrip()

def srl(proc=None):
    if proc is not None:
        return map(proc, rl().split())
    else:
        return rl().split()

def main():
    rl()
    A = srl(int)
    p = 0
    c = 1
    ret = 0
    for x in A:
        if x == p:
            c += 1
        else:
            ret += c / 2
            p = x
            c = 1
    ret += c / 2
    print ret


if __name__ == '__main__':
    main()


Measured memory_bytes: 2568
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <numeric>
#include <functional>
#include <cstdlib>
#include <regex>
#include <list>
int main() {
	int a, b, c, d;
	std::cin >> a >> b >> c >> d;
	std::cout << std::min(a, b) + std::min(c, d) << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    char ai[105][20],bi[105][20];
    char su[20];
    scanf("%d",&a);getchar();
    for(int i=0;i<a;i++)
        scanf("%s",ai[i]);
    scanf("%d",&b);getchar();
    for(int i=0;i<b;i++)
        scanf("%s",bi[i]);
    int aum=0,bum=0,max1=0;
    for(int i=0;i<a;i++)
    {
         aum=0,bum=0;
         strcpy(su,ai[i]);
        for(int q=0;q<a;q++)
        {
            if(strcmp(su,ai[q])==0)
                aum++;
        }
        for(int j=0;j<b;j++)
        {

             if(strcmp(su,bi[j])==0)
                bum++;
        }
       int  ma=aum-bum;
        if(ma>max1)
            max1=ma;
    }
    printf("%d\n",max1);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int b, f, r, v;
	int n, i, j, k;
	int campus[5][4][11];

	for(i=1;i<5;i++){
		for(j=1;j<4;j++){
			for(k=1;k<11;k++) campus[i][j][k] = 0;
		}
	}

	scanf("%d", &n);
	for(i=0;i<n;i++){
		scanf("%d %d %d %d", &b, &f, &r, &v);
		campus[b][f][r]+=v;
	}

	for(i=1;i<5;i++){
		for(j=1;j<4;j++){
			for(k=1;k<11;k++){
				printf(" %d", campus[i][j][k]);
			}
			printf("\n");
		}
		if(i==4) break;
		else printf("####################\n");
	}

	return 0;
}



Measured memory_bytes: 2712
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        br.readLine();
        String[] in = br.readLine().split(" ");
        ArrayList<Integer> list = new ArrayList<Integer>();
        boolean[] color = {true, true, true, true, true, true, true, true};
        for(int i = 0; i < in.length; i++) {
            list.add(Integer.parseInt(in[i]));
        }
        int count = 0;
        int min = 0;
        int max = 0;
        for(int j = 0; j < list.size(); j++) {
            if(list.get(j) < 400 && color[0]){
                color[0] = false;
                count++;
            } else if(list.get(j) >= 400 && list.get(j) < 800 && color[1]) {
                color[1] = false;
                count++;
            } else if(list.get(j) >= 800 && list.get(j) < 1200 && color[2]) {
                color[2] = false;
                count++;
            } else if(list.get(j) >= 1200 && list.get(j) < 1600 && color[3]) {
                color[3] = false;
                count++;
            } else if(list.get(j) >= 1600 && list.get(j) < 2000 && color[4]) {
                color[4] = false;
                count++;
            } else if(list.get(j) >= 2000 && list.get(j) < 2400 && color[5]) {
                color[5] = false;
                count++;
            } else if(list.get(j) >= 2400 && list.get(j) < 2800 && color[6]) {
                color[6] = false;
                count++;
            } else if(list.get(j) >= 2800 && list.get(j) < 3200 && color[7]) {
                color[7] = false;
                count++;
            } else if(list.get(j) >= 3200) {
                max++;
            }
        }
        max = max + count;
        min = count;
        if(min == 0) {
            min++;
        }
        System.out.println(min + " " + max);
    }
}

Measured memory_bytes: 22484
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int n;
    n = sc.nextInt();

    int a[] = new int[n];
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }

    func(a);

    sc.close();
  }

  private static void func(int a[]) {// 選択ソート
    int minj, copy, times = 0;

    // 選択ソート
    for (int i = 0; i < a.length; i++) {
      minj = i;
      for (int j = i; j < a.length; j++) {// minj の探索
        if (a[j] < a[minj]) minj = j;
      }
      if (a[i] > a[minj]) {// 交換が行われた場合
        copy = a[minj];
        a[minj] = a[i];
        a[i] = copy;
        times++;
      }
    }

    // 回答
    for (int i = 0; i < a.length - 1; i++) {
      System.out.printf("%d ", a[i]);
    }
    System.out.printf("%d\n%d\n", a[a.length - 1], times);
  }
}



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

int main()
{
    int x;
    cin>>x;
    long long y=0;
    for(int i=1;i<=x;i++)
    {
        if(i%3==0||i%5==0) y+=0;
        else y+=i;
    }
    cout<<y;
    return 0;
}


Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
	final int INF = Integer.MAX_VALUE / 3;
	final int MAX_N = 200 + 1;
	final int MAX_M = 100000 + 1;
	final int MAX_R = 1000 + 1;

	void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			int n = scan.nextInt();
			int m = scan.nextInt();
			if (n + m == 0)
				break;
			int[][] l = new int[MAX_N][MAX_N];
			int[][] s = new int[MAX_N][MAX_N];

			for (int i = 0; i < MAX_N; i++)
				for (int j = 0; j < MAX_N; j++)
					l[i][j] = s[i][j] = INF;
			for (int i = 0; i < MAX_N; i++)
				l[i][i] = s[i][i] = 0;

			for (int i = 0; i < m; i++) {
				int to = scan.nextInt();
				int from = scan.nextInt();
				int dist = scan.nextInt();
				char sl = scan.next().charAt(0);
//				System.out.println(to + " " + from + " " + dist + " " + (sl == 'S'));
				if (sl == 'S')
					s[to][from] = s[from][to] = dist;
				else
					l[to][from] = l[from][to] = dist;
			}

			// WarshallFloyd
			for (int k = 1; k <= n; k++) for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) {
				l[i][j] = Math.min(l[i][j], l[i][k] + l[k][j]);
				s[i][j] = Math.min(s[i][j], s[i][k] + s[k][j]);
			}
//			for (int i = 1; i <= n; i++) {
//				for (int j = 1; j <= n; j++)
//					System.out.print((s[i][j] != INF ? s[i][j] : "x") + " ");
//				System.out.println();
//			}
//			for (int i = 1; i <= n; i++) {
//				for (int j = 1; j <= n; j++)
//					System.out.print((l[i][j] != INF ? l[i][j] : "x") + " ");
//				System.out.println();
//			}

			int r = scan.nextInt();
			int[] z = new int[MAX_R];
			for (int i = 0; i < r; i++)
				z[i] = scan.nextInt();

			// dp
			int[][] dp = new int[MAX_R][MAX_N];
			for (int i = 0; i < MAX_R; i++)
				for (int j = 0; j < MAX_N; j++)
					dp[i][j] = INF;

			dp[0][z[0]] = 0;

			for (int i = 0; i < r - 1; i++) {
				for (int j = 1; j <= n; j++) {
					if (dp[i][j] == INF)
						continue;
					dp[i + 1][j] = Math.min(dp[i + 1][j], dp[i][j] + l[z[i]][z[i + 1]]);
					for (int k = 1; k <= n; k++)
						dp[i + 1][k] = Math.min(dp[i + 1][k], dp[i][j] + l[z[i]][j] + s[j][k] + l[k][z[i + 1]]);
				}
			}

			int ans = INF;
			for (int i = 1; i <= n; i++)
				ans = Math.min(ans, dp[r - 1][i]);
			System.out.println(ans);
		}
	}

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



Measured memory_bytes: 82072
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define m_p			make_pair
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i =a, i>=b;i--)
#define sz(x)       (int)x.size()
#define F			first
#define S			second
#define debug(x)	for(int i=0;i<x;i++) cout<<"##########"<<endl
#define M			1000000007
#define ll			long long int
#define lMax		LLONG_MAX
#define pii 		pair<int ,int >
#define	all(a)		a.begin(), a.end()
#define vi 			vector<int> 
#define vii 		vector<pii>

// queue<int> , prefix_sum(a,a+n) , reverse(a,a+n) , priority_queue <int> max heap , priority_queue <int, vector<int>, greater<int> > min heap;
// == > != precedence gretaer then & , << precedence greater than <= == => , 
//int chk, cnt, fl, pos, in, src, tar, val, res. dummy;  fill (myvector.begin(),myvector.begin()+4,5), freq;

ll dp[101][100001];

void solve()
{
	ll n,W;
	cin>>n>>W;
	
	rep(i,0,101)
	{
		rep(j,1,100001)
		{
			dp[i][j]=100000000000;
		}
	}
//	rep(i,0,n+1)
//	{
//		rep(j,0,W+1)
//		{
//			cout<<dp[i][j]<<" ";
//		}
//		cout<<endl;
//	}
	ll v[n+1],w[n+1];
	rep(i,1,n+1) cin>>w[i]>>v[i];
	rep(i,1,n+1)
	{
		rep(j,1,100001)
		{
			if(j<v[i]) dp[i][j]=dp[i-1][j];
			else dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i]);
		}
	}
	
	ll ans=0;
	for(ll i=100000;i>=0;i--)
	{
		if(dp[n][i]<=W)
		{
			ans=max(ans,i);
		}
	}
	
//	rep(i,1,n+1)
//	{
//		rep(j,1,W+1)
//		{
//			cout<<dp[i][j]<<" ";
//		}
//		cout<<endl;
//	}
	cout<<ans<<endl;
}


signed main()
{
		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
		int t=1;
		while(t--)
		{
			solve();
		}
}

Measured memory_bytes: 79232
n = int(input())
s = list(str(input()))

ss = [0]*len(s)

for i in range(len(s)):
     if ord(s[i]) + n > 90:
          ss[i] = chr(ord(s[i]) + n - 26)
     else:
          ss[i] = chr(ord(s[i]) + n)
print(''.join(ss))



Measured memory_bytes: 3188
import sys
import itertools as it
L, R = map(int, input().split())
if R-L > 2017: print(0); sys.exit()

DL = L % 2019
DR = R % 2019
if DL > DR: print(0); sys.exit()

print(min(x*y%2019 for x,y in it.combinations(range(DL, DR+1), 2)))

Measured memory_bytes: 3060
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl
#define NL <<"\n"

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
//#undef NUIP
#ifdef NUIP
#include "../benri.h"
#else
#define out
#endif
#ifdef __cpp_init_captures
template<typename T>vector<T> table(int n, T v){ return vector<T>(n, v);}
template <class... Args> auto table(int n, Args... args){auto val = table(args...); return vector<decltype(val)>(n, move(val));}
#endif
const ll MOD=1e9+7; //998244353

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout<<fixed<<setprecision(0);
	ll cur;
	cin>>cur;
	array<ll,3> a,b;
	rep(i,3) cin>>a[i];
	rep(i,3) cin>>b[i];
	rep(_,2){
		vector<ll> dp(cur+1); iota(all(dp),0);
		dp[0]=0;
		rep(i,3)rep(j,cur+1-a[i]) MX(dp[j+a[i]],dp[j]+max(a[i],b[i]));
		cur=*max_element(all(dp));
		swap(a,b);
	}
	cout<<cur<<endl;
  return 0;
}


Measured memory_bytes: 195584
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <numeric>
#include <tuple>

using namespace std;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};


int main() {
	int n;
	cin >> n;
	vector<pair<int,int>> xs,ys;
	for (int i = 0; i < n; ++i) {
		int x, y;
		cin >> x >> y;
		xs.push_back(make_pair(x, i));
		ys.push_back(make_pair(y, i));
	}
	sort(xs.begin(), xs.end());
	sort(ys.begin(), ys.end());
	vector<tuple<int, int, int>> xdis,ydis;
	for (int i = 1; i < xs.size(); ++i) {
		int dis = abs(xs[i].first - xs[i - 1].first);
		xdis.push_back(make_tuple(dis,xs[i - 1].second, xs[i].second));
		dis = abs(ys[i].first - ys[i - 1].first);
		ydis.push_back(make_tuple(dis, ys[i - 1].second, ys[i].second));
	}
	sort(xdis.begin(), xdis.end());
	sort(ydis.begin(), ydis.end());
	UnionFind uf(n);
	int xcur, ycur;
	xcur = ycur = 0;
	int64_t sum = 0;
	while (true) {
		if (xcur == xdis.size() && ycur == ydis.size()) {
			break;
		}
		if (xcur == xdis.size()) {
			int dis = get<0>(ydis[ycur]);
			int src = get<1>(ydis[ycur]);
			int dst = get<2>(ydis[ycur]);
			if (!uf.findSet(src, dst)) {
				uf.unionSet(src, dst);
				sum += dis;
			}
			ycur++;
		}
		else if (ycur == ydis.size()) {
			int dis = get<0>(xdis[xcur]);
			int src = get<1>(xdis[xcur]);
			int dst = get<2>(xdis[xcur]);
			if (!uf.findSet(src, dst)) {
				uf.unionSet(src, dst);
				sum += dis;
			}
			xcur++;
		}
		else {
			int dis1 = get<0>(xdis[xcur]);
			int dis2 = get<0>(ydis[ycur]);
			if (dis1 < dis2) {
				int dis = get<0>(xdis[xcur]);
				int src = get<1>(xdis[xcur]);
				int dst = get<2>(xdis[xcur]);
				if (!uf.findSet(src, dst)) {
					uf.unionSet(src, dst);
					sum += dis;
				}
				xcur++;
			}
			else {
				int dis = get<0>(ydis[ycur]);
				int src = get<1>(ydis[ycur]);
				int dst = get<2>(ydis[ycur]);
				if (!uf.findSet(src, dst)) {
					uf.unionSet(src, dst);
					sum += dis;
				}
				ycur++;
			}
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 5480
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Blue ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,n) for(int i=a;i<n;++i)
typedef vector<int> vi;
typedef long long ll;
const int mod=1e9+7;
 
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

void solve(){
	string s;
	cin>>s;
	int i=0,j=sz(s)-1,cnt=0;
	while(i<j){
		if(s[i]!=s[j])cnt++;
		i++;
		j--;
	}
	cout<<cnt;
 
}
 
 
int main(){
	Blue;
	int test=1;
	//cin>>test;
	while(test--)
		solve();
	return 0;
}

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

//コピペ用
//		int[] ab = Array.ConvertAll(Console.ReadLine().Split(' '),i=>int.Parse(i));
//      int a = int.Parse(Console.ReadLine());

public class Job{
    public int a {get;set;}
    public int b {get;set;}
}
class Program
{
	static void Main(string[] args)
	{
		// スペース区切りの整数の入力
        string[] input = Console.ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int m = int.Parse(input[1]);
        var job = new List<Job>();

        for(int i=0;i<n;i++){
            string[] temp = Console.ReadLine().Split(' ');
            job.Add(new Job());
            job[i].a = int.Parse(temp[0]);
            job[i].b = int.Parse(temp[1]);
        }
        job.Sort((v,w)=>v.a-w.a);

        var q = new PriorityQueue<int,int>();
        int t=0;
        long sum=0;
        for(int i=0;i<=m;i++){
            //Console.WriteLine("i:"+i);
            for(;t<n && job[t].a <= i;t++){
                q.Add(-job[t].b,1);
            }
            //Console.WriteLine("q:"+q.Count);
            if(q.Count>0){
                sum -= q.Dequeue().Key;
            }
            //Console.WriteLine("sum:"+sum);
        }

        Console.WriteLine(sum);
        //Console.WriteLine(string.Join("\n",job.Select((v)=>v.a+","+v.b)));
    }
}




////////////////////////////////////////////////////
// キーの重複がOKな優先度付きキュー
/* 使い方
var p = new PriorityQueue<int, int>();
 
while (p.Count != 0)
{
    var kvpair = p.Dequeue();
    Console.WriteLine(kvpair.Key + ", " + kvpair.Value);
    ...
    p.Add(key, value);
}
*/
public class PriorityQueue<TKey, TValue>
{
    SortedDictionary<TKey, Queue<TValue>> dict = new SortedDictionary<TKey, Queue<TValue>>();
    int count = 0;
 
    public int Count
    {
        get
        {
            return count;
        }
    }
 
    public void Add(TKey key, TValue value)
    {
        if (!dict.ContainsKey(key))
        {
            dict[key] = new Queue<TValue>();
        }
 
        dict[key].Enqueue(value);
        count++;
    }
 
    public KeyValuePair<TKey, TValue> Dequeue()
    {
        var queue = dict.First();
        if (queue.Value.Count <= 1)
        {
            dict.Remove(queue.Key);
        }
        count--;
        return new KeyValuePair<TKey, TValue>(queue.Key, queue.Value.Dequeue());
    }
}
////////////////////////////////////////////////////

Measured memory_bytes: 26020
'use strict'

function main(input) {
  input = input.split('\n').map(v => v.split(' ').map(v => ~~v))

  const n = input[0][0] //shop.length
  const m = input[0][1] //M 本の栄養ドリンクを買い集める
  const shop = input.slice(1, -1) // 単価 + max
  shop.sort((a, b) => {
    return a[0] - b[0]
  })
  let cost = 0
  let total = 0

  for (let i in shop) {
    cost = cost + shop[i][0] * shop[i][1]
    total = total + shop[i][1]

    if (total == m) {
      console.log(cost)
      return
    } else if (total > m) {
      let sa = total - m
      cost -= sa * shop[i][0]
      console.log(cost)
      return
    } 
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define EPS (1e-7)
#define INF 1e9

typedef long long ll;
typedef pair<int,int>P;

int main(){
	int H,W;
	cin>>H>>W;
	string a[H];
	REP(i,H){
		cin>>a[i];
	}
	string ans="Possible";
	REP(i,H){
		REP(j,W){
			if(i+1<H && j+1<W){
				if(a[i+1][j]=='#' && a[i][j+1]=='#' && (a[i][j]=='#' || a[i+1][j+1]=='#')){
					ans="Impossible";
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np

n = int(input())
X = np.array([input().split() for _ in range(n)], np.int64)
dp = np.zeros((n + 1, 3), np.int64)
dp[0, 0] = dp[0, 1] = dp[0, 2] = 0
for i in range(n):
    for j in range(3):
        dp[i + 1, j] = X[i, j] + max(dp[i, k] for k in range(3) if j != k)
print(max(dp[n]))

Measured memory_bytes: 56196
#include<iostream>
#include<cstdio>
using namespace std ;
int main()  {
  double r,w,i;
  cin>>r;
  w=r*r*3.141592653589;
  i=2*r*3.141592653589;
  printf("%.6lf %.6lf\n", w,i); 
  
  return 0;
}

Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%lld",&x);
int main(){
    ll n, k, ans = 0;
    sc(n) sc(k)
    for (int i = k + 1; i <= n; i++){ 
        ans += (i - k) * (n / i);
        if (n % i >= k) ans += n % i - k + 1;
    }
    if (k == 0) ans -= n;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# define MOD 1000000000+7
using namespace std;

int main() {
	int n;
	cin >> n;
	long long ans = 1;
	for (int i = 1; i <= n; i++) {
		ans *= i;
		if (ans > MOD) {
			ans %= MOD;
		}
	}
	cout << ans << endl;
}

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

char s[114];

int main() {
  scanf("%s", s);
  int n = strlen(s);
  for (int i=0; i<=n-2; i++) {
    if (s[i] == 'A' &&  s[i+1] == 'C') {
      puts("Yes");
      return 0;
    }
  }
  puts("No");
}



Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<sys/time.h>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline int ri()
{
	register int x=0;register bool f=0;register char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=1;ch=getchar();}
	while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();};
	return f?-x:x;
}
void wi(int x)
{
	if(x<0)	x=-x,putchar('-');
	if(x>9)	wi(x/10);
	putchar('0'+x%10);
}

int main()
{
	int n=ri(),m=ri();
	wi((1<<m)*(1900*m+100*(n-m)));
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 10000000000000000;
const ll mod = 1000000007;
//printf("%.10f\n", n);
signed main() {
	ll n, m, a = 0, b = 0, cnt = 0, ans = 0; cin >> n;
	vector<ll> v(n);
	for (int h = 0; h < n; h++) { cin >> v[h]; ans += v[h]; }
	sort(v.begin(), v.end());
	cout << ans - (v[n - 1] / 2) << endl;
	cin >> n; return 0;
}

Measured memory_bytes: 256
s = input()
t = input()

dict_st = {}
dict_ts = {}

for x, y in zip(s, t):
    if x not in dict_st:
        dict_st[x] = y
    else:
        if dict_st[x] != y:
            print("No")
            break

    if y not in dict_ts:
        dict_ts[y] = x
    else:
        if dict_ts[y] != x:
            print("No")
            break
else:
    print("Yes")

Measured memory_bytes: 42060
n = int(input())
sp = []
for i in range(n):
    a,b= input().split(" ")
    sp.append([a,int(b),i+1])
sp.sort()

ans = []
t = []
for j in range(len(sp)):
    if j == len(sp) - 1:
        t.append(sp[j])
        t.reverse()
        ans.append(t)
        break
    if sp[j][0] == sp[j+1][0]:
        t.append(sp[j])
    else:
        t.append(sp[j])
        t.reverse()
        ans.append(t)
        t = []

for w in ans:
    for x,y,z in w:
        print(z)


Measured memory_bytes: 3064
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>


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

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;
#define int long long




//here begins your code
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  string S;
  cin >> S;
  if(S.length() % 2 != 0){
  	cout << "No" << endl;
  	return 0;
  }
  for(int i = 0; i < S.size(); i++){
  	if(i % 2 == 0){
  		if(S[i] == 'h'){
  			continue;
  		}
  		else{
  			cout << "No" << endl;
  			return 0;
  		}
  	}
  	else{
  		if(S[i] == 'i'){
  			continue;
  		}
  		else{
  			cout << "No" << endl;
  			return 0;
  		}
  	}
  }
  cout << "Yes" << endl;
  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

class Eratosthenes {
    vector<int> plist;

public:
    Eratosthenes(int sz)
        : plist(sz, -1) {
        for (int i = 2; i < sz; i++) {
            if (plist[i] == -1) {
                for (int j = i; j < sz; j += i) {
                    if (plist[j] == -1) {
                        plist[j] = i;
                    }
                }
            }
        }
    }
    bool isPrime(int n) {
        return plist[n] == n;
    }
    vector<int> factor(int n) {
        vector<int> res;
        while (n > 1) {
            res.push_back(plist[n]);
            n /= plist[n];
        }
        return res;
    }
};

#include <map>

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin, n;
    Eratosthenes pr(n + 1);
    ll ans = 0;
    REP(i, 1, n + 1) {
        auto v = pr.factor(i);
        map<int, int> m;
        for (auto vv : v) {
            m[vv]++;
        }
        ll t = 1;
        for (auto it : m) {
            t *= (it.second + 1);
        }
        ans += i * t;
    }
    print(ans);

    return 0;
}


Measured memory_bytes: 42264
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
#include <unordered_set>
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 2000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144
#define REP(a,b) for(long long a = 0;a < b;++a)
/*
unordered_set<long long> go;
int main() {
#define int long long
	long long n, x, d;
	cin >> n >> x >> d;
	long long ans = 0;
	for (long long i = 0; i <= n; ++i) {
		long long tmp = x * (2LL * i) + d * i * (i - 1LL) 
								- d * n * (n - 1LL) - x * n; //定数
		for (long long q = 0; q <= ((n-1) * i) - (2LL * i * (i-1LL)/2LL); ++q) {
			if (go.find(tmp) == go.end()) {
				ans++;
				go.insert(tmp);
			}
			tmp += 2LL * d;
		}
	}
	cout << ans << endl;
}
*/
map<long long, set<pair<long long, long long>>> go_itr;
int main() {
#define int long long
	long long n, x, d;
	cin >> n >> x >> d;
	if (d == 0) {
		if (x == 0) {
			cout << 1 << endl;
			return 0;
		}
		cout << n +1LL<< endl;
		return 0;
	}
	if (d < 0) {
		d *= -1LL;
		x *= -1LL;
	}
	long long ans = 0;
	for (long long i = 0; i <= n; ++i) {
		long long tmp = x * (2LL * i) + d * i * (i - 1LL)
			- d * n * (n - 1LL) - x * n; //定数
		long long itring = tmp % (2LL * d);
		itring += 2LL * d * 2LL;
		itring %= 2LL * d;
		long long left = tmp;
		long long right = tmp + 2LL * d * ((n - 1) * i - (2LL * i * (i - 1LL) / 2LL));
		auto q = go_itr[itring].lower_bound(make_pair(tmp, -LONG_INF));
		//[left,right]
		while (q != go_itr[itring].end()&&tmp <= right) {
			left = min(left, (*q).second);
			if (tmp < (*q).second) {
				if (right < (*q).second) {
					ans += (right - tmp) / (2LL * d) + 1LL;
					tmp = right + 2LL * d;
					break;
				}
				ans += ((*q).second - tmp) / (2LL * d);
			}
			tmp = (*q).first + 2LL * d;
			right = max(right, (*q).first);
			go_itr[itring].erase(q);
			q = go_itr[itring].lower_bound(make_pair(tmp, -LONG_INF));
		}
		if (tmp <= right) {
			ans += (right - tmp) / (2LL * d) + 1LL;
		}
		go_itr[itring].insert(make_pair(right, left));
		/*
		for (long long q = 0; q <= ((n - 1) * i) - (2LL * i * (i - 1LL) / 2LL); ++q) {
			if (go.find(tmp) == go.end()) {
				ans++;
				go.insert(tmp);
			}
			tmp += 2LL * d;
		}
		*/
	}
	cout << ans << endl;
}

Measured memory_bytes: 28416
#include<bits/stdc++.h>				//edit by thidailoc
using namespace std;				//team three wolves
typedef long long ll;
typedef vector<ll> vi;
#define fu(i,a,b)   for(ll i=a;i<b;i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define pb(i)	    push_back(i)
#define popb(i)     pop_back(i)
#define sc(a) 	    scanf("%lld",&a);
#define sc2(a,b)    scanf("%lld%lld",&a,&b)
#define pr(a)	    printf("%lld ",a)
#define pr2(a,b)    printf("%lld %lld",a,b)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)	lower_bound(a.begin(),a.end(),x) -a.begin()
#define all(x) 		(x).begin(), (x).end()
#define sz(a) 		(ll)a.size()
#define le			length()						
#define re 			return 	
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
double const eps = 1e-6;	//dung trong sai so
ll const Base=1e9+7;
ll arr[1000000],mark[1000000];

ll Solves(){
	//INPUT;
	ll n,k,cnt=0,ans=0,x;
	// PROCESSING IN HERE
	ll a,b,c;
	cin>>a>>b>>c;
//	
//	fu(i,1,200)mark[(a*i)%b]=1;
//	
//	fu(i,0,b){
//		if()
//	}
	if(c%__gcd(a,b)==0)cout<<"YES";
	else cout<<"NO";
	re 0;
}


int main(){
	Solves();
}

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

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};
ll Nagaemon1;
void swap(ll i,ll j){
  Nagaemon1=i;
  i=j;
  j=Nagaemon1;
}
int main(){
  ll n,m;
  cin >> n;
  vector<int> d(n);
  map<int,int>a,b;
  rep(i,n){
    cin >> d[i];
    a[d[i]]++;
  }
  cin >> m;
  vector<int> t(m);
  rep(i,m){
    cin >> t[i];
    b[t[i]]++;
  }
  rep(i,m){
    int x=t[i];
    if(a[x]<b[x]){
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
}

Measured memory_bytes: 20608
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define MOD 1000000007
void add(int &x,int y){x+=y;if(x>=MOD)x-=MOD;}
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int n,m,K,ans,Lim[22][22];
int f[2][22][1<<20],nxt[1<<20][22];
int main()
{
	n=read()-1;m=read();K=read();
	memset(Lim,-1,sizeof(Lim));
	for(int i=1;i<=K;++i)
	{
		int a=read(),b=read();
		Lim[a][b-1]=read();
	}
	int S=1<<n;
	for(int i=0;i<S;++i)
	{
		int v=-1;
		for(int j=n-1;~j;--j)
		{
			if(i&(1<<j))v=j;
			nxt[i][j]=v;
		}
	}
	f[0][n][0]=1;
	for(int i=1,nw=1,pw=0;i<=m;++i,nw^=1,pw^=1)
	{
		for(int j=0;j<S;++j)f[nw][0][j]=f[pw][n][j];
		memset(f[pw],0,sizeof(f[pw]));
		for(int j=0;j<n;++j)
			for(int k=0;k<S;++k)
				if(f[nw][j][k])
					for(int l=0;l<=1;++l)
					{
						if((~Lim[i][j])&&l!=Lim[i][j])continue;
						int t=(k>>j)&1;
						if(l==0&&t==1)continue;
						if(l==t)add(f[nw][j+1][k],f[nw][j][k]);
						else
						{
							int p=nxt[k][j];
							if(p==-1)add(f[nw][j+1][k+(1<<j)],f[nw][j][k]);
							else add(f[nw][j+1][k+(1<<j)-(1<<p)],f[nw][j][k]);
						}
					}
	}
	for(int i=0;i<S;++i)add(ans,f[m&1][n][i]);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 227584
#include <iostream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <limits>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#include <cmath>
#include <complex>

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

const int INFL = (int)1e9;
const ll INFLL = (ll)1e18;
const double INFD = numeric_limits<double>::infinity();
const double PI = 3.14159265358979323846;
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loopll(i, n) for(ll i = 0; i < (ll)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopll1(i, n) for(ll i = 1; i <= (ll)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = (ll)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define Looprll1(i, n) for(ll i = (ll)n; i >= 1; i--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(i, vector.size()) { cout << vector[i] << " "; } cout << endl;
#define printmx(matrix) Loop(i, matrix.size()) { Loop(j, matrix[i].size()) { cout << matrix[i][j] << " "; } cout << endl; }
#define rndf(d) (ll)((double)(d) + (d >= 0 ? 0.5 : -0.5))
#define floorsqrt(x) ((ll)sqrt((double)x) + ((ll)sqrt((double)x) * (ll)sqrt((double)x) <= (ll)(x) ? 0 : -1))
#define ceilsqrt(x) ((ll)sqrt((double)x) + ((ll)x <= (ll)sqrt((double)x) * (ll)sqrt((double)x) ? 0 : 1))
#define rnddiv(a, b) ((ll)(a) / (ll)(b) + ((ll)(a) % (ll)(b) * 2 >= (ll)(b) ? 1 : 0))
#define ceildiv(a, b) ((ll)(a) / (ll)(b) + ((ll)(a) % (ll)(b) == 0 ? 0 : 1))
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)

/*******************************************************/

int main() {
	map<int, int> mp;
	Loop(i, 3) {
		int x; cin >> x;
		mp[x]++;
	}
	cout << mp.size() << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
using namespace std;
typedef pair<int, int> P;

priority_queue<P> que[20];

int main()
{
    int n;
    cin >> n;
    int p[20];
    p[0] = 1;
    int s[300000];
    P pa[300000];
    bool maked[300000];
    fill(maked, maked + p[n], false);
    for(int i = 1; i < 20; i++) p[i] = p[i - 1] * 2;
    for(int i = 0; i < p[n]; i++){
        cin >> s[i];
        pa[i] = P(s[i], i);
    }
    sort(pa, pa + p[n], greater<P>());
    que[0].push(pa[0]);
    maked[0] = true;
    for(int i = 1; i <= n; i++){
        int j = 0;
        while(que[i - 1].size()){
            P nowp = que[i - 1].top();
            que[i - 1].pop();
            for(; j < p[n]; j++){
                if(!maked[j] && pa[j].first < nowp.first){
                    que[i].push(nowp);
                    que[i].push(pa[j]);
                    maked[j] = true;
                    break;
                }
            }
            if(j == p[n]) break;
        }
        if((int)que[i].size() != p[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 8372
results = {chr(c): 0 for c in range(ord('a'), ord('a')+26)}

while True:
    try:
        line = input()
    except EOFError:
        break
    for c in line:
        c_lowered = c.lower()
        if c_lowered in results:
            results[c_lowered] += 1


for key in range(ord('a'), ord('a')+26):
    key_str = chr(key)
    print(f'{key_str} : {results[key_str]}')


Measured memory_bytes: 5580
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,a[21],b[21],c[20],sum,i,x;
	scanf("%d",&n);
	for(i=1;i<=n;i++)	scanf("%d",&a[i]);
	for(i=1;i<=n;i++)	scanf("%d",&b[i]);
	for(i=1;i<=n-1;i++)	scanf("%d",&c[i]);	
	sum=0;
	for(i=1;i<=n;i++)	{
		x=a[i];		sum+=b[x];
	}
	for(i=1;i<=n-1;i++)	{
		if(a[i]+1==a[i+1])	sum+=c[a[i]];
	}
	printf("%d\n",sum);
	return 0;
}

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

public class Main {
	static PrintWriter out;
	static StringBuilder sb;
	static int mod = 998244353;
	static int inf = (int) 1e15;
	static ArrayList<Integer>[] ad;
	static int n, s;
	static int[][][] memo;
	static int[] a;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
         int n=sc.nextInt();
         int ans=n/500;
         ans=ans*1000;
         n=n%500;
         ans=ans+(n/5)*5;
         System.out.println(ans);
		out.close();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

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

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public int[] nextArrInt(int n) throws IOException {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextArrLong(int n) throws IOException {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}


Measured memory_bytes: 22484
#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define pb push_back
#define pii pair<int,int>
#define SZ(x) (int)x.size()
#ifdef __linux__
#define getchar getchar_unlocked
#endif
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
typedef long long LL;
using namespace std;
const int N=1010;
const int M=200010;
const int inf=0x3f3f3f3f;
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
#ifdef ztzshiwo
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
}
int n,m;
int x[M],y[M];
bool g[N][N],f[N][N];
int p[2][N];
vector<int>G[N];
inline void dfs(int u,int x,int f)
{
	if(p[f][u])return;
	p[f][u]=x;
	For(i,0,SZ(G[u])-1)dfs(G[u][i],x,f);
}
inline void Solve(int u)
{
	For(i,1,n)p[0][i]=p[1][i]=0;
	p[0][u]=p[1][u]=1;
	 For(i,0,SZ(G[u])-1)dfs(G[u][i],i+1,0);
	rFor(i,SZ(G[u])-1,0)dfs(G[u][i],i+1,1);
	For(i,1,n)g[u][i]=p[0][i]!=p[1][i],f[u][i]=p[0][i]||p[1][i];
}
int main()
{
	file();
	read(n),read(m);
	For(i,1,m)read(x[i]),read(y[i]),G[x[i]].pb(y[i]);
	For(i,1,n)Solve(i);
	For(i,1,m)printf("%s\n",g[x[i]][y[i]]^f[y[i]][x[i]]?"diff":"same");
	return 0;
}


Measured memory_bytes: 6272
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

bool ans = false;

string S;
string C[4] = {"dream", "dreamer", "erase", "eraser"};
char now[int(2e5)];

int DFS(int num){
  if (num == S.length()){
    string T = "";
    for (int i = 0; i < num; i++) T += now[i];
    if (S == T) ans = true;
    return 0;
  }

  for (int i = 0; i < 4; i++){
    if (num + C[i].length() > S.length()) continue;
    bool flag = true;
    for (int j = 0; j < C[i].length(); j++){
      if (S[num + j] != C[i][j]) flag = false;
      now[num + j] = C[i][j];
    }
    if (flag) DFS(num + C[i].length());
  }

  return 0;
}

int main(){
  cin >> S; DFS(0);
  if (ans) YES();
  else NO();

  return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 2000000000
typedef long long ll;
bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}
// 入力



int main() {
    ll N,cnt=0;
    
    cin >>N;
    vector<ll>L(N);
    rep(i,N){
        cin >> L[i];
    }
    sort(L.begin(), L.end());

    rep(i,N){
        for(int j = i+1;j<N; j++ ){
            cnt += lower_bound(L.begin()+j+1, L.end(), L[i] + L[j]) - L.begin() -j-1;
        }
    }




    cout << cnt << endl;
    
    
    return 0;
    

}

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

#define NMAX 51
#define WHITE 0
#define GRAY 1
#define BLACK 2

bool graph[NMAX + 1][NMAX + 1];
int color[NMAX + 1];
int n, m;

void dfs(int u) {
  int v;
  color[u] = GRAY;
  for (v = 1; v <= n; v++) {
    if (graph[u][v] != true || color[v] != WHITE) {
      continue;
    }
    dfs(v);
  }
  color[u] = BLACK;
  return;
}

void initialize_color() {
  int u;
  for (u = 1; u <= n; u++) {
    color[u] = WHITE;
  }
  return;
}

int solve(int a, int b) {
  int ans = 0;
  int u;
  graph[a][b] = false;
  graph[b][a] = false;
  initialize_color();
  dfs(1);

  for (u = 1; u <= n; u++) {
    if (color[u] != BLACK) {
      ans = 1;
    }
  }
  graph[a][b] = true;
  graph[b][a] = true;
  return ans;
}

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

  for (i = 1; i <= m; i++) {
    for (j = 1; j <= m; j++) {
      graph[i][j] = false;
    }
  }

  for (i = 1; i <= m; i++) {
    graph[a[i]][b[i]] = true;
    graph[b[i]][a[i]] = true;
  }

  for (i = 1; i <= m; i++) {
    ans += solve(a[i], b[i]);
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a = sorted(rl(), reverse=True)
print(a[0]*10 + a[1] + a[2])














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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

void solve();

int main(void){
    int W, H, N; cin >> W >> H >> N;
    pair<int, int> left_up, left_down, right_up, right_down;
    left_up.first = 0; left_up.second = H;
    left_down.first = 0; left_down.second = 0;
    right_up.first = W; right_up.second = H;
    right_down.first = W; right_down.second = 0;
    rep(i, N){
        int x, y, a;
        cin >> x >> y >> a;
        switch(a){
            case 1:
                left_up.first = max(left_up.first, x);
                left_down.first = left_up.first;
                break;
            case 2:
                right_up.first = min(right_up.first, x);
                right_down.first = right_up.first;
                break;
            case 3:
                left_down.second = max(left_down.second, y);
                right_down.second = left_down.second;
                break;
            case 4:
                left_up.second = min(left_up.second, y);
                right_up.second = left_up.second;
                break;
            default:
                break;
        }
    }
    if(right_up.first < left_up.first || right_up.second < right_down.second) cout << 0 << endl;
    else cout << (right_down.first - left_down.first)*(right_up.second - right_down.second) << endl;;
    return 0;
}

void solve(){}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=101101;
int a,b,c;
int main(){
	scanf("%d%d%d",&a,&b,&c);
	if (a==b&&b==c){
		printf("No\n");
		return 0;	
	}
	if (a==b||b==c||a==c)	printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007;
const ll INF=1LL<<60;

int main(){
    
    int N,W;cin>>N>>W;
    vector<pair<ll,ll>> S(N);
    ll dp[1000*N+3];//dp[i]はiの価値にするときの最小のWの合計、Wが与えられた時より小さい時の最大のiを求める
    for(int i=0;i<1000*N+3;i++){
        dp[i]=INF;
    }
    for(int i=0;i<N;i++){
        cin>>S[i].first>>S[i].second;
    }
    dp[0]=0;
    for(int i=0;i<N;i++){
        for(int j=i*1000;j>=0;j--){
            if(j==0||dp[j]!=INF) dp[j+S[i].second]=min(dp[j+S[i].second],dp[j]+S[i].first);
        }
    }
    ll ans=0;
    for(int i=0;i<1000*N+3;i++){
        if(dp[i]<=W) ans=i;
    }
    cout<<ans<<endl;
    }


Measured memory_bytes: 1024