akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
using namespace std;
const int maxn=8000;
int n, m;
int tot[2], a[2][16010];
bool f[2][16010];
char s[maxn];
int main()
{
	scanf("%s", s+1); scanf("%d%d", &n, &m);
	int len=strlen(s+1); int now=0; tot[0]=1;
	for(int i=1;i<=len;i++)
		if(s[i]=='T') now^=1, tot[now]++;
			else a[now][tot[now]]++;
	f[1][a[0][1]+maxn]=1;
	for(int i=2;i<=tot[0];i++)
	for(int j=0;j<=16000;j++)
	f[i&1][j]=(j-a[0][i]>=0?f[i&1^1][j-a[0][i]]:0)||(j+a[0][i]<=16000?f[i&1^1][j+a[0][i]]:0);
	if(!f[tot[0]&1][n+maxn]) return puts("No"), 0;
	memset(f, 0, sizeof(f)); f[0][maxn]=1;
	for(int i=1;i<=tot[1];i++)
	for(int j=0;j<=16000;j++)
	f[i&1][j]=(j-a[1][i]>=0?f[i&1^1][j-a[1][i]]:0)||(j+a[1][i]<=16000?f[i&1^1][j+a[1][i]]:0);
	if(!f[tot[1]&1][m+maxn]) return puts("No"), 0;
	puts("Yes");
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    private static Scanner sc=new Scanner(System.in);
    public static void main(String[] args){
        int n=sc.nextInt();
        int[] a=new int[n];
        for(int i=0;i<n;i++) a[i]=sc.nextInt();
        boolean flag=true;
        int counter=0;
        while(flag){
            flag=false;
            for(int j=n-1;j>=1;j--){
                if(a[j]<a[j-1]){
                    int t=a[j];
                    a[j]=a[j-1];
                    a[j-1]=t;
                    counter++;
                    flag=true;
                }
            }        
        }
        for(int i=0;i<=n-2;i++) System.out.printf("%d ",a[i]);
        System.out.println(a[n-1]);
        System.out.println(counter);
    }
}

Measured memory_bytes: 26420
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    while (true) {
        val x =scanner.nextInt()
        val y =scanner.nextInt()
        if (x == 0 && y == 0) break

        println(if (x < y) "${x} ${y}" else "${y} ${x}")
    }
}



Measured memory_bytes: 34056
using System;

namespace abc115
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var x = new int[n];
            var y = new int[n];
            var h = new int[n];
            for (int i = 0; i < n; i++)
            {
                var xyh = Console.ReadLine().Split();
                x[i] = int.Parse(xyh[0]);
                y[i] = int.Parse(xyh[1]);
                h[i] = int.Parse(xyh[2]);
            }

            for (int cx = 0; cx <= 100; cx++)
            {
                for (int cy = 0; cy <= 100; cy++)
                {
                    var ch = m1(cx, cy, x[0], y[0], h[0]);
                    for (int k = 1; k < n; k++)
                    {
                        var _ch = m1(cx, cy, x[k], y[k], h[k]);
                        ch = m2(ch, _ch);

                        if (ch.Item1 == -1) break;
                    }

                    if (ch.Item1 == 1)
                    {
                        Console.WriteLine($"{cx} {cy} {ch.Item2}");
                        return;
                    }
                }
            }
        }

        static Tuple<int, int> m2(Tuple<int, int> x, Tuple<int, int> y)
        {
            if (x.Item1 == -1) return x;

            if (x.Item1 == 0 && y.Item1 == 0)
            {
                return Tuple.Create(0, Math.Min(x.Item2, y.Item2));
            }
            if (x.Item1 == 0 && y.Item1 == 1)
            {
                if (y.Item2 <= x.Item2)
                {
                    return y;
                }
                else
                {
                    return Tuple.Create(-1, 0);
                }
            }
            if (x.Item1 == 1 && y.Item1 == 0)
            {
                if (x.Item2 <= y.Item2)
                {
                    return x;
                }
                else
                {
                    return Tuple.Create(-1, 0);
                }
            }
            if (x.Item1 == 1 && y.Item1 == 1)
            {
                if (x.Item2 == y.Item2)
                {
                    return x;
                }
                else
                {
                    return Tuple.Create(-1, 0);
                }
            }

            throw new Exception();
        }

        static Tuple<int, int> m1(int cx, int cy, int x, int y, int h)
        {
            var ch = h + Math.Abs(cx - x) + Math.Abs(cy - y);
            if (h == 0)
            {
                return Tuple.Create(0, ch);
            }
            else
            {
                return Tuple.Create(1, ch);
            }
        }
    }
}


Measured memory_bytes: 15272
n=int(input())
if n<10:
	kazu=n
else:
	if n<100:
		kazu=9
	else:
		if n<1000:
			kazu=n-90
		else:
			if n<10000:
				kazu=909
			else:
				if n<100000:
					kazu=n-9090
				else:kazu=90909
print(kazu)

Measured memory_bytes: 2940
#include <iostream>
#include <queue>
static const int MAX = 100;
static const int INFTY = (1<<21);
using namespace std;

enum Color {
  WHITE, GRAY, BLACK
};

int n;
int G[MAX][MAX];
int d[MAX];
Color color[MAX];


void bfs_init() {
  for (int i = 0; i < n; i++) {
    color[i] = WHITE;
    d[i] = INFTY;
  }
}

void bfs(int r) {
  bfs_init();
  queue<int> q;
  q.push(r);
  d[r] = 0;
  int u;
  while (!q.empty()) {
    u = q.front();
    q.pop();
    for (int v = 0; v < n; v++) {
      if (G[u][v] == 0) continue;
      if (d[v] != INFTY) continue;
      d[v] = d[u] + 1;
      q.push(v);
    }
  }
  for (int i = 0; i < n; i++) {
    cout << i+1 << " " << ((d[i]==INFTY) ? (-1):d[i]) << endl;
  }
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      G[i][j] = 0;
    }
  }
  for (int i = 0; i < n; i++) {
    int vi, out_v_num;
    cin >> vi;
    cin >> out_v_num;
    for (int j = 0; j < out_v_num; j++) {
      int out_vi;
      cin >> out_vi;
      G[vi-1][out_vi-1] = 1;
    }
  }
  bfs_init();
  bfs(0);
  return 0;
}



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

const int MOD = 1000000007;

template<typename T> T combination(T N, T K) {
	if (N < K) return 0;
	if (N == K || K == 0) return 1;
	vector<T> v(N, 1);
	T prev1 = 1, prev2 = 1; // prev1 = n−1Ck−1, prev2 = n−1Ck

	for (T n = 2; n <= N; n++) {
		prev1 = 1;
		T k = 1;
		while (k < n && k <= K) {
			prev2 = v[k];
			v[k++] = (prev1 + prev2) % MOD; // 余りを答えるように要求された時用
			prev1 = prev2;
		}
	}
	return v[K];
}

// numを素因数分解してprime_factorに結果を格納する
template<typename T> void prime_factorization(T num, std::vector<std::pair<T, T>>& prime_factor) {
	using namespace std;
	T L = static_cast<T>(ceil(sqrt(num))), i = 0;
	prime_factor = vector<pair<T, T>>(L, make_pair(0, 0));
	for (T x = 2; x <= L; x++) {
		while (num % x == 0) {
			if (prime_factor[i].first) prime_factor[i].second++;
			else prime_factor[i] = make_pair(x, 1);
			num /= x;
		}
		if (num == 1) break;
		if (prime_factor[i].first) i++;
	}
	if (num > 1) prime_factor[i] = make_pair(num, 1);
}

signed main()
{
	using ULL = unsigned long long;
	ULL N, M;
	cin >> N >> M;

	// Mを素因数分解
	vector<pair<ULL, ULL>> prime;
	prime_factorization(M, prime);

	// 素因数ごとに重複組合せで振り分け
	ULL comb = 1;
	for (auto& p : prime) {
		if (p.first == 0) break;
		comb = (comb * combination(p.second + N - 1, p.second)) % MOD;
	}

	cout << comb << endl;
	return 0;
}

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

int n, pos;
vector<int> pre, in, post;

void rec(int l, int r)
{
    if (l >= r)
        return;
    int root = pre[pos++];
    int m = distance(in.begin(), find(in.begin(), in.end(), root));
    rec(l, m);
    rec(m + 1, r);
    post.push_back(root);
}

void solve()
{
    pos = 0;
    rec(0, pre.size());
    for (int i = 0; i < n; i++)
    {
        if (i)
            cout << " ";
        cout << post[i];
    }
    cout << endl;
}

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

    for (int i = 0; i < n; i++)
    {
        cin >> k;
        pre.push_back(k);
    }

    for (int i = 0; i < n; i++)
    {
        cin >> k;
        in.push_back(k);
    }

    solve();

    return 0;
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  rep(i,N) cin>>A[i];
  sort(all(A));
  cout<<A[N/2]-A[N/2-1]<<endl;
}

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

using namespace std;

int ar[200010];

int main()
{
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> ar[i];
    }
    int a = 0, b = n - 1;
    for(int i = n - 1; i >= 0; i-= 2) {
        cout << ar[i] << ' ';
    }
    int i;
    if(n % 2 == 0)
        i = 0;
    else
        i = 1;
    for(i; i < n; i+= 2) {
        cout << ar[i] << ' ';
    }


	return 0;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()

signed 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){
    int t=0;
    for(int j=i;j<N-1;j++){
      if(t<S[j]) t=S[j];
      if(t%F[j]!=0){
        int h=t/F[j]+1;
        t=F[j]*h;
      }
      //t=(t+F[j]-1)/F[j];
      t+=C[j];
      //cout << i << " " << j << " " <<  t << endl;
    }
    cout << t << endl;
  }
  return 0;
}


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

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

    map<string, int> mp;
    rep(i,n) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }

    ll ans = 0;
    for (auto m : mp) {
        if (m.second < 2) continue;
        ans += (ll) m.second * (m.second - 1) / 2;
    }

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

Measured memory_bytes: 11376
#include <bits/stdc++.h>
using namespace std;
int main () {
  vector<int> A(5);
  for(int i = 0; i < 5; i++) {
    cin >> A.at(i);
    if(A.at(i) == 0) {
      cout << i + 1;
    }
  }
}

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

namespace A_Frog_2
{
    class Program
    {
        static void Main(string[] args)
        {
            var l1 = Console.ReadLine().Split(' ');
            var N = int.Parse(l1[0]);
            var K = int.Parse(l1[1]);
            
            var hi = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            
            var costs = new long[N];
            costs[0] = 0;

            for(int i = 1;i <= K;i++)
            {
                costs[i] = Math.Abs(hi[0]-hi[i]);
                if(i==N-1) break;
            }

            for(int i = K+1;i<=N-1;i++)
            {
                costs[i] = long.MaxValue;
                for(int j= 1;j<=K;j++)
                {
                    costs[i] = Math.Min(costs[i],costs[i-j]+Math.Abs(hi[i]-hi[i-j]));
                }
            }

            Console.WriteLine(costs[N-1]);
        }
    }
}


Measured memory_bytes: 18784
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 19 22:03:19 2020

@author: liang
"""

N, X, M = map(int,input().split())
mod_set = {X}
mod_lis = [X]
A = [0]*(10**6+1)
A[0] = X
flag = False
#for i in range(1,N):
i = 1
for i in range(1,min(10**6,N)):
    tmp = A[i-1]**2%M
    if tmp in mod_set:
        flag = True
        break
    A[i] = tmp
    mod_set.add(tmp)
    mod_lis.append(tmp)

if flag:
    j = mod_lis.index(tmp)
else:
    j = i
T = i - j
ans = 0
if T != 0:  
    #print("A")
    ans += sum(mod_lis[:j])
    T_sum = sum(mod_lis[j:])
    """
    【切り捨て演算は必ず()をつけて先に計算】
    """
    ans += T_sum * ((N-j)//T)
    #print((N-j)//T, T_sum)
    T_lis = mod_lis[j:i]   
    ans += sum(T_lis[:(N-j)%T])
else:
    #print("B")
    ans = sum(mod_lis)
   # print(mod_lis)
#print(T_lis)
#print((N-j)%T)
#print(T_lis[:10])
print(ans)
#print(T_sum)
#print(sum(T_lis))

Measured memory_bytes: 21104
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

A = get_int
B = get_int
C = get_int
X = get_int

count = 0
0.step(X/500) do |a|
  break if a > A
  rest = X - a * 500
  0.step(rest/100) do |b|
    break if b > B
    last = rest - b * 100
    count += 1 if 50 * C >= last
  end
end

puts count


Measured memory_bytes: 14444
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
const int N=1000009;
int n,d[N],a[N],pri[N],tot,zhi[N];
ll ans=0;
void sieve()
{
    zhi[1]=d[1]=1;
    for (int i=2; i<=n; i++)
    {
        if (!zhi[i])
            pri[++tot]=i,d[i]=2,a[i]=1;//a数组存的是每个数的最小素因数的个数
        for (int j=1; j<=tot&&i*pri[j]<=n; j++)
        {
            zhi[i*pri[j]]=1;
            if (i%pri[j])
                d[i*pri[j]]=d[i]*d[pri[j]],a[i*pri[j]]=1;
            else
            {
                d[i*pri[j]]=d[i]/(a[i]+1)*(a[i]+2);
                a[i*pri[j]]=a[i]+1;
                break;
            }
        }
    }
}
int main()
{
    cin>>n;
    sieve();
    for(int i=1; i<=n-1; i++)
    {
        ans+=d[n-i];
    }
    cout<<ans;
    return 0;
}


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

int main()
{
  int k;
  string s;
  cin >> k >> s;

  if (s.length() <= k)
  {
    cout << s << endl;
  }
  else
  {
    cout << s.substr(0, k) << "..." << endl;
  }
}


Measured memory_bytes: 3624
#include <stdio.h>

main(){
  int A, B;
  scanf ("%d %d", &A , &B );
  int a, b, c;
  int answer = 0;
  for (a = 1; a <= 9; a++){
   for (b = 0; b <= 9; b++){
    for (c = 0; c <= 9; c++){
     int x = 10001 * a + 1010 * b + 100 * c;
     if (x >= A && x <= B){
       answer++;
     }
    }
   }
  }
  printf ("%d\n",answer);
}








Measured memory_bytes: 128
#include<stdio.h>

int main(){
	int i,j;
	int m,f,r;
	char grade[5] = {'A','B','C','D','F'};
	
	for(;scanf("%d %d %d",&m,&f,&r),m!=-1||f!=-1||r!=-1;){
		if(m!=-1&&f!=-1){
			if(m+f>=80){
				printf("%c\n",grade[0]);
				
			}else if(m+f>=65 && m+f<80){
				printf("%c\n",grade[1]);
			
			}else if(m+f>=50 && m+f<65){
				printf("%c\n",grade[2]);
			
			}else if(m+f>=30 && m+f<50){
				if(r>=50){
					printf("%c\n",grade[2]);
				}else if(r<50){
					printf("%c\n",grade[3]);
				}
			
			}else if(m+f<30){
				printf("%c\n",grade[4]);
			
			}
		}else{
			printf("%c\n",grade[4]);
		}
	}
	
	return 0;
}

Measured memory_bytes: 600
#include <ctime>
#include <iomanip>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdio>
#include <list>
#include <queue>
using namespace std;

#define int long long
#define INF 1e18
#define EPS 1e-9

signed main() {
    int n; cin >> n;
    vector<int> v(n); for(int i = 0; i < n; i++) cin >> v[i];
    vector<int> dp(n, 0);
    dp[1] = abs(v[1] - v[0]);
    for(int i = 2; i < n; i++) {
        int dif1 = abs(v[i - 1] - v[i]) + dp[i - 1];
        int dif2 = abs(v[i - 2] - v[i]) + dp[i - 2];
        dp[i] = min(dif1, dif2);
    }

    cout << dp[n - 1] << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll  long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define bp __builtin_popcountll
#define MOD 1000000007
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
bool is_prime(ll n)
{
    if(n==0 || n==1)  return 0;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)   return 0;
    }
    return 1;
}
int main() 
{
    FAST;
    ll n,k;
    cin >> n >> k;
    ll S,P,R;
    cin >> R >> S>> P;
    string s;
    cin >> s;
    string t;
    for(ll i=0;i<n;i++)  t+='a';
    ll ans = 0;
    for(ll i=0;i<n;i++)
    {
        if(s[i]=='r')
        {
            t[i] = 'p';
            if(i>=k)   
            {
                if(t[i-k]!='p')   ans += P;
                else         t[i]='a';
            }
            else    ans += P;
        }
        else if(s[i]=='p')
        {
            t[i] = 's';
            if(i>=k)   
            {
                if(t[i-k]!='s')   ans += S;
                else         t[i]='a';
            }
            else    ans += S;
        }
        if(s[i]=='s')
        {
            t[i] = 'r';
            if(i>=k)   
            {
                if(t[i-k]!='r')   ans += R;
                else         t[i]='a';
            }
            else    ans += R;
        }
    }
    cout<<ans;
}

 

Measured memory_bytes: 640
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        int[] A = new int[N];

        int maxValue = 1;
        int secondMaxValue = 0;

        for(int i = 0; i < N; i++) {
            int currentValue = int.Parse(Console.ReadLine());
            A[i] = currentValue;

            if(maxValue < currentValue) {
                secondMaxValue = maxValue;
                maxValue = currentValue;

            } else if(secondMaxValue < currentValue) {
                secondMaxValue = currentValue;
            
            }
        }

        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        
        for(int i = 0; i < N; i++) {
            if (A[i] == maxValue) {
                Console.WriteLine(secondMaxValue);
            
            }
            else {
                Console.WriteLine(maxValue);
            
            }

        }

        Console.Out.Flush();
    }
}

Measured memory_bytes: 17108
#include <iostream>
using namespace std;
int main()
{
    int i, j, k, h, w;
   
    cin >> h >> w;
    while(h>0 || w>0)
    {
        for(i=1; i<=h; i++)
        {
            for(j=1; j<=w; j++)
            {
                if ((i+2)%2 == 0 && j%2 == 1 || j%2 == 0 && (i+2)%2 == 1)
                    cout << ".";
                else
                    cout << "#";
            }
            cout << endl;
        }
        cout << endl;
        cin >> h >> w;
    }
}


Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <algorithm>
#include <ios>
#include <iomanip>
#include <cmath>
#include <regex>
using namespace std;

int main(){
  string num;
  cin >> num;
  cout << count(num.begin(), num.end(), '1') << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n,i,j,t[100][100]={0};
	int b,f,r,v;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>b>>f>>r>>v;
		if(b==1){
			t[f][r]+=v;		
		}
		else if(b==2){
			t[f+4][r]+=v;		
		}
		else if(b==3){
			t[f+8][r]+=v;		
		}
		else if(b==4){
			t[f+12][r]+=v;		
		}
	}
	for(i=1;i<=15;i++){
		if(i%4==0)cout<<"####################";
		else{
			for(j=1;j<=10;j++){
				cout<<" "<<t[i][j];
			}
		}
		cout<<endl;
	}
	return 0;
}

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

int main() {
	int a,b;
	cin >> a >> b;
	if((a + b)%2 == 0){
		cout << (a+ b)/2 << endl;
	}

else{
	cout << (a+b)/2 + 1 << endl;
}
}

Measured memory_bytes: 256
#include <stdio.h>

int func(int n, int s) {
  int sum, wa, count;
  int i, j;

  sum = 0;
  for (i = 0; i < 1 << 10; i++) {
    wa = 0;
    count = 0;
    for (j = 0; j < 10; j++) {
      if ((i >> j) & 1) {
        wa += j;
        count++;
      }
    }
    if (count == n && wa == s) {
      sum++;
    }
  }

  return sum;
}

int main(){
  int i, n, s;

  while (1) {
    scanf("%d %d", &n, &s);
    if (n == 0 && s == 0) {
      break;
    }
    printf("%d\n", func(n, s));
  }

  return 0;
}


Measured memory_bytes: 2044
#include <iostream>

using namespace std;

const int MOD = 2019;

int main() {
    int l, r;
    cin >> l >> r;

    if (r - l + 1 >= MOD) {
        cout << 0 << endl;
        return 0;
    }

    int ans = MOD;
    for (int i = l; i <= r; i++)
        for (int j = i + 1; j <= r; j++)
            ans = min(ans, int((i * 1LL * j) % MOD));

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n, m, x; cin >> n >> m >> x;
    vint c(n);
    vvint a(n,vint(m));
    rep(i,n) {
        cin >> c[i];
        rep(j,m) cin >> a[i][j];
    }
    int ans = inf;
    rep(i,1<<n) {
        vint tmp(m,0);
        int cost = 0;
        rep(j,n) {
            if ((i>>j)&1) {
                rep(k,m) {
                    tmp[k] += a[j][k];
                }
                cost += c[j];
            }
        }
        bool ok = true;
        rep(j,m) {
            if (tmp[j] < x) ok = false;
        }
        if (ok) ans = min(ans,cost);
    }
    if (ans != inf ) cout << ans << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define lli long long int
#define rep(i,a,b)	for(i=a;i<b;i++)
#define M 1000000007
#define vll vector<long long int>
#define pb push_back
#define pi 3.1415926535897932384626433832795028841971
#define MOD(x) ((x>=M)?((x)%M):(x<0?((M+x)%M):x))
lli gcd(lli a,lli b){if(b==0) return a;if(a==0) return b;if(a>=b) return gcd(b,a%b);else return gcd(a,b%a);}
lli lcm(lli a,lli b){lli p=a*b;return p/gcd(a,b);}
using namespace std;


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	char ch,ch1,ch2;
	string s1,s2,s3;
    lli i,j,k,a,b,c,n,m,sum=0,ans=0,temp;
	cin >> n;
	vll v(n);
	rep(i,0,n)	cin >> v[i];
	if(n==1)	cout << "1" << endl;
	else if(n==2){
		if(v[0]>v[1])	cout << "2" << endl;
		else	cout << "1" << endl;
	}
	else{
		if(v[0]>v[1]){
			a=v[0];b=v[1];ans=2;
		}
		else{
			a=v[1];b=v[0];ans=1;
		}
		for(i=2;i<n;i++)
		{
			if(v[i]<=b){
				b=v[i];ans++;
			}
		}
		cout << ans << endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 1792
// Ryo Kamoi
// #define DEBUG

#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<set>

using namespace std;

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

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

int INF = 1000000000;

int n, m;
int par[100010];

int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
}

void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return;
    par[rx] = ry;
}

bool same(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
}


int main(){
  cin >> n >> m;
  REP(i, n) {
    par[i] = i;
  }

  REP(i, m) {
    int x, y, z;
    cin >> x >> y >> z;
    unite(x-1, y-1);
  }

  set<int> count_type;
  REP(i, n) {
#ifdef DEBUG
    cout << root(i) << endl;
#endif
    count_type.insert(root(i));
  }
  cout << count_type.size() << endl;
}


Measured memory_bytes: 5376
#include <stdio.h>

int main(){
	int q,h,s,d;
	long long n,a,sum=0;
	
	scanf("%d %d %d %d",&q,&h,&s,&d);
	scanf("%ld",&n);
	
	a=d;
	if(a>s*2) a=s*2;
	if(a>h*4) a=h*4;
	if(a>q*8) a=q*8;
	
	while(n>=2){
		n-=2;
		sum+=a;
	}
	a=s;
	if(a>h*2) a=h*2;
	if(a>q*4) a=q*4;
	while(n>=1){
		n-=1;
		sum+=a;
	}
	a=h;
	if(a>q*2) a=q*2;
	while(n>=0.5){
		n-=0.5;
		sum+=a;
	}
	if(n!=0) sum+=q;
	printf("%ld",sum);

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include <map>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include"time.h"
using namespace std;

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define dump(x)  cerr << #x << " = " << (x) << endl
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
const int INF = (1 << 30);

//毎回変える定数
#define N_MAX 200


//問題文のとおりの変数
int N, M;

//オリジナル変数
vector<vector<int>> P2L;//人から言語への辺
vector<vector<int>> L2P;//言語から人への辺

vector<bool> connectionP;
vector<bool> connectionL;

//サブ関数
//入力
void input() {
	cin >> N >> M;
	REP(i, N)connectionP.push_back(false);
	REP(i, M)connectionL.push_back(false);
	REP(i, M)L2P.push_back(vector<int>());

	int K,tmp;
	REP(i, N) {
		vector<int> tmpL;
		cin >> K;
		REP(j, K) {
			cin >> tmp;
			tmp--;

			tmpL.push_back(tmp);//P2L
			L2P[tmp].push_back(i);//L2P
		}
		P2L.push_back(tmpL);
	}
}

//計算
void connectP2L(int);
void connectL2P(int lang) {
	if (connectionL[lang])return;
	connectionL[lang] = true;
	for (auto var : L2P[lang]) {
		connectP2L(var);
	}
}

void connectP2L(int person) {
	if (connectionP[person])return;
	connectionP[person] = true;
	for (auto var : P2L[person]) {
		connectL2P(var);
	}
}

void calc() {
	connectP2L(0);
}

//出力
void output() {
	bool flag = true;
	for (auto var : connectionP) {
		if (var == false) {
			flag = false;
			break;
		}
	}
	if (flag)cout << "YES" << endl;
	else cout << "NO" << endl;
}

//デバッグ
void debug() {
	cin >> N;
}

//メイン関数
int main() {

	input();
	calc();
	output();
	debug();

	return 0;
}


Measured memory_bytes: 9212
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    int n;cin>>n;
    rep(i,n){
        int a;cin>>a;
        if(a%2!=0)continue;
        if(a%5!=0&&a%3!=0){
            cout<<"DENIED"<<endl;
            return 0;
        }
    }
    cout<<"APPROVED"<<endl;
}

Measured memory_bytes: 256
from collections import defaultdict
N = int(input())

A = list(map(int, input().split()))
stick = defaultdict(int)

for a in A:
  stick[a] += 1

stick = {key: value for key, value in stick.items() if value >= 2}


if len(stick) >= 2:
  len1 = max(stick.keys())
  if stick[len1] < 4:
    stick.pop(len1)
  len2 = max(stick.keys())
  print(len1 * len2)
else:
  print(0)

Measured memory_bytes: 22296
#include <bits/stdc++.h>
#define rep(i,n)	for(int i=0;i<n;i++)
using namespace std;
void print(vector< long long int > &v){
	for(int i=0;i<v.size();i++){
		cout<<v[i]<<" ";
	}
	cout<<endl;
}
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    //write your code here
		int h, w;
		cin>> h>> w;
		vector<string> v(h,"");
		rep(i, h)	cin>>v[i];
		vector<vector<long long int > > dp(h, vector<long long int > (w,0));
		rep(i,h){
			if(v[i][0]=='.')
				dp[i][0]=1;
			else
				break;
		}
		rep(i,w){
			if(v[0][i]=='.')
				dp[0][i]=1;
			else
				break;
		}
		for(int i=1;i<h;i++){
			for(int j=1;j<w;j++){
				if(v[i][j]=='.'){
					int up = (v[i-1][j]=='.')?dp[i-1][j]:0;
					int left = (v[i][j-1]=='.')?dp[i][j-1]:0;
					if(up==0&&left==0)
						dp[i][j]=0;
					else
						dp[i][j]= (up%1000000007+left%1000000007)%1000000007;
				}
			}
		}
		cout<<dp[h-1][w-1]<<endl;

    return 0;
}


Measured memory_bytes: 9216
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#define rep(i,N) for(int i=0;i<N;i++)

long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;

int main(){
long long N,M,L;
cin>>N>>M>>L;

long long w_shall[N][N];
rep(i,N)rep(k,N)w_shall[i][k]=INF;

rep(i,M){
    int a,b;
    long long c;
    cin>>a>>b>>c;
    a--,b--;
    if(c>L)c=INF;
    w_shall[a][b]=w_shall[b][a]=c;
}
long long  charge[N][N]={};
rep(i,N)rep(k,N)charge[i][k]=INF;
//charge[i][k]:=町iからkへ行くまでに必要な給油回数
rep(_,3){
    rep(i,N){
        rep(k,N){
            rep(j,N){
            w_shall[i][k]=min(w_shall[i][k],w_shall[i][j]+w_shall[j][k]);    
            }
        }
    }
}

rep(i,N){
    rep(k,N){
       if(w_shall[i][k]<=L){
           charge[i][k]=1;
       }
    }
}
rep(j,N){
    rep(i,N){
        rep(k,N){
            charge[i][k]=min(charge[i][k],charge[i][j]+charge[j][k]);    
            }
        }
    }


long long Q;
cin>>Q;

for(long long i=0;i<Q;i++){
    int s,t;
    cin>>s>>t;
    s--,t--;
    if(charge[s][t]==INF)cout<<"-1"<<endl;
    else{
        cout<<charge[s][t]-1<<endl;
    }
}

 return 0;
}
/*
3 2 5
1 2 3
2 3 3
2
3 2
1 3

0
1

4 0 1
1
2 1

-1

5 4 4
1 2 2
2 3 2
3 4 3
4 5 2
20
2 1
3 1
4 1
5 1
1 2
3 2
4 2
5 2
1 3
2 3
4 3
5 3
1 4
2 4
3 4
5 4
1 5
2 5
3 5
4 5

0
0
1
2
0
0
1
2
0
0
0
1
1
1
0
0
2
2
1
0


*/

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

const int INF = 1 << 30;

int main(){
  int D, N, a[100], e[100], r[100];
  while(cin >> D >> N, D){
    for(int i = 0; i < N; i++){
      cin >> a[i] >> e[i] >> r[i];
    }
    vector< vector< int > > dp(D + 1, vector< int >( 101, INF));
    dp[D][0] = 0;
    for(int i = D; i > 0; i--){
      for(int j = 0; j <= 100; j++){
        if(dp[i][j] == INF) continue;
        for(int k = 0; k < N; k++){
          if(j < r[k]) continue;
          dp[max( 0, i - a[k])][min( 100, j + e[k])] = min( dp[max( 0, i - a[k])][min( 100, j + e[k])], dp[i][j] + 1);
        }
      }
    }
    int ret = INF;
    for(int i = 0; i < 101; i++) ret = min( ret, dp[0][i]);
    if(ret == INF) cout << "NA" << endl;
    else cout << ret << endl;
  }
}

Measured memory_bytes: 1260
function main()
    s = rstrip(readline())
    if s[1] != 'A'
        print("WA\n")
        return
    end
    cnt = 0
    for i in 3:length(s)-1
        if s[i] == 'C'
            cnt += 1
        elseif isupper(s[i])
            print("WA\n")
            return
        end
    end
    if cnt != 1
        print("WA\n")
        return
    end
    if isupper(s[2]) || isupper(s[end])
        print("WA\n")
        return
    end
    print("AC\n")
    return
end

main()


Measured memory_bytes: 109768
N = gets.to_i
ds = gets.chomp.split(' ').map{|n| n.to_i}
i, sum = 0, 0
while i < N - 1 do
  j = i + 1
  while j <= N - 1 do
    sum += ds[i] * ds[j]
    j += 1
  end
  i += 1
end
puts sum

Measured memory_bytes: 1788
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
#define ll long long
const ll mod=1e9+7;
const int maxn=3e3+5;
char s[maxn];
ll num[maxn][maxn],nxt[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    scanf("%s",s);
    for(int i=1;i<=n;i++)
        num[1][i]=1;
    for(int i=1;i<n;i++)
    {
        char c=s[i-1];
        for(int j=1;j<=n-i+1;j++)
        {
            if(c=='<')
            {
                nxt[1]=(nxt[1]+num[i][j])%mod;
                nxt[j]=(nxt[j]-num[i][j]+mod)%mod;
            }
            else
            {
                nxt[j]=(nxt[j]+num[i][j])%mod;
                nxt[n-i+1]=(nxt[n-i+1]-num[i][j]+mod)%mod;
            }
        }
        for(int j=1;j<=n-i;j++)
            num[i+1][j]=(num[i+1][j-1]+nxt[j])%mod;
        for(int j=1;j<=n;j++)
            nxt[j]=0;
    }
    printf("%lld\n",num[n][1]);
    return 0;
}
/*
 '<': dp(i,j)->dp(i+1,1~(j-1))
 '>': dp(i,j)->dp(i+1,j~(n-i))
4
<><
 
5
<<<<
 
20
>>>><>>><>><>>><<>>
 
2
<
 */


Measured memory_bytes: 49996
#include<stdio.h>
#include<stdlib.h>
int main(){
    long n,k,ans1,ans2;
    scanf("%ld %ld",&n,&k);
    
    ans1 = n % k;
    ans2 = labs(ans1-k);
    if(ans1 <= ans2) printf("%ld\n",ans1);
    else printf("%ld\n",ans2);
    return 0;
}


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

using namespace std;
const int MAXN = 4e5+5;
set<pair<int,int>> v1[MAXN];
stack<int> q1;
int q,w;
vector<int> res;
vector<int> ans;
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        int x,y;
        cin>>x>>y;
        v1[x].insert(make_pair(y,i));
        v1[y].insert(make_pair(x,i));
        
    }
    int mxdeg = 0;
    int cnt4 =0;
    for(int i=1;i<=n;i++){
        if(v1[i].size()%2 == 1){
            cout<<"No"<<endl;
            return 0;
        }
        if(v1[i].size() ==4){
            cnt4++;
        }
        mxdeg = max(mxdeg,(int)v1[i].size());
    }
    if(mxdeg>=6){
        cout<<"Yes"<<endl;
        return 0;
    }
    if(mxdeg<=2){
        cout<<"No"<<endl;
        return 0;
    }
    if(cnt4>=3){
        cout<<"Yes"<<endl;
        return 0;
    }
    if(cnt4<=1){
        cout<<"No"<<endl;
        return 0;
    }
    for(int i=1;i<=n;i++){
        if(v1[i].size() == 4){
            if(!q1.size()){
                q1.push(i);
                q = i;
            }else{
                w = i;
            }
            
        }
    }
    while(!q1.empty()){
        int curr = q1.top();
        res.push_back(curr);
        
        if(v1[curr].size() == 0){
            
            q1.pop();
        }
        for(auto x:v1[curr]){
            //cout<<curr<<" "<<x.first<<" "<<x.second<<endl;
            int val = x.first;
            int ind = x.second;
            q1.push(val);
            v1[val].erase(v1[val].find(make_pair(curr,ind)));
            v1[curr].erase(v1[curr].find(make_pair(val,ind)));
            break;
            
        }
    }
    for(int x:res){
        if(x==q||x==w){
            ans.push_back(x);
            
        }
    }
    for(int i=0;i<ans.size()-1;i++){
        if(ans[i]==ans[i+1]){
            
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 29560
#include <stdio.h>
#include<math.h>
#include <algorithm>
using namespace std;

int main(){

	int T,H,S,seconds,seconds3;

	while(true){
		scanf("%d %d %d",&T,&H,&S);
		if(T == -1 && H == -1 && S == -1)break;
		seconds = 7200 - (3600*T + 60*H + S);
		seconds3 = 3*seconds;
		printf("%02d:%02d:%02d\n",seconds/3600,(seconds%3600)/60,(seconds%3600)%60);
		printf("%02d:%02d:%02d\n",seconds3/3600,(seconds3%3600)/60,(seconds3%3600)%60);
	}

    return 0;
}

Measured memory_bytes: 2564
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const llint mod=1e9+7;
const llint big=1e15+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
int main(void){
	int n,i,j;cin>>n;n--;
	vector<int> c(n),s(n),f(n);
	for(i=0;i<n;i++){cin>>c[i]>>s[i]>>f[i];}
	for(i=0;i<n;i++){
		int ans=0;
		for(j=i;j<n;j++){
			maxeq(ans,s[j]);
			ans=((ans+f[j]-1)/f[j])*f[j];
			ans+=c[j];
		}
		cout<<ans<<endl;
	}
	cout<<0<<endl;RE;
}

Measured memory_bytes: 256
/*
g++ -ggdb -fsanitize=address -std=c++14 C.cpp && ./a.out <<< "5
4 2 5 1 3"
*/

#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for (int i = a; i < (b); i++)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);

    int n; cin >> n;
    vi P(n); rep(i, 0, n) cin >> P[i];

    int mx = INT_MAX;
    int ans = 0;
    rep(i, 0, n) {
        int a = P[i];
        if (a <= mx) {
            ans++;
            // printf("a %d, mx %d\n", a, mx);
        }
        mx = min(mx, a);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
// https://ei1333.github.io/luzhiled/
// http://beet-aizu.hatenablog.com/entry/2017/01/04/113233
// http://www.prefield.com/algorithm/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<ld>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;
using Graph = vector<vector<ll>>;
const ll INF = 1LL << 60;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
const ll tl= 1'000'000'007;
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ind(...) long double __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << endl;} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#define in1(A) REP(i,A.size()) in(A[i]);
#define in2(A,B) REP(i,A.size()) in(A[i],B[i]);
#define in3(s,t,u) REP(i,sz(s)){in(s[i] , t[i] , u[i]);}
#define in4(s,t,u,v) REP(i,sz(s)){in(s[i] , t[i] , u[i] , v[i]);}
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
struct Point{ ld x,y; };
ld dist(Point a, Point b){return sqrt(abs(a.x-b.x)*abs(a.x-b.x)+abs(a.y-b.y)*abs(a.y-b.y));} // ２点間の距離 
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;} 
ll fact(ll n){ if(n < 2) return 1; return (n * fact(n-1))%tl; } //階乗
inline ll updiv(ll a,ll b){ return (a + b - 1) / b; } //切り上げ
template<typename T,typename U>ll ceil(T a,U b){return (a + b - 1) / b;}
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
//-------------------------------------------------------------------------------------------------
int main(){
    init();
    ins(s,t);
    map<string,ll>T;
    inl(a,b);
    T[s]=a; T[t]=b;
    ins(u); T[u]--; 
    out(T[s],T[t]);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int W, H, w, h, n, x, y, a;
int main() {
	cin>>W>>H>>n;
	while(n--) {
		cin>>x>>y>>a;
		if(a==1) w = max(w, x);
		if(a==2) W = min(W, x);
		if(a==3) h = max(h, y);
		if(a==4) H = min(H, y);
	}
	cout<<(w<W && h<H ? (W-w)*(H-h) : 0);
	return 0;
}

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

int h[100004];
int dp[100004];

void solve(){
    int n;
    cin >> n;
    // int h[n];
    for(int i = 0 ; i < n ; i++)
        cin >> h[i];
    
    // int dp[n];
    dp[n-1] = 0;
    dp[n-2] = abs(h[n-1] - h[n-2]);
    
    for(int i = n-3 ; i >= 0 ; i--){
        dp[i] = min(dp[i+1] + abs(h[i] - h[i+1]) , dp[i+2] + abs(h[i] - h[i+2]));
    }
    
    cout << dp[0];
    
}

int main(){
   solve();
}




Measured memory_bytes: 4396
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int n;
void dfs(string s,char mc) {
    if (s.size() == n) {
        OUT(s)
        return;
    }
    for(char c = 'a'; c <= mc; c++) {
        if (c == mc) dfs(s + c,mc+1);
        else dfs(s + c,mc);
    }
}

int main(void)
{
    IOS
    cin >> n;
    dfs("",'a');

    return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>
int main (void)
    {
        int n,i;
        int a[100];
        scanf("%d",&n);
        for(i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
        }
        for(i=n-1;i>=0;i--)
        {
            printf("%d",a[i]);
            if(i!=0)printf(" ");
        }
        printf("\n");
        return 0;
    }


Measured memory_bytes: 2044
import math
A,B = input().split()
A = int(A)
C1 = A*int(B[0])*100
C2 = A*int(B[2])*10
C3 = A*int(B[3])
Ans = C1+C2+C3
Ans = math.floor(Ans//100)
print(Ans)

Measured memory_bytes: 9192
#include <iostream>
#include <assert.h>
#include <algorithm>
#include <vector>


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

    int32_t N;
    std::cin >> N;
    std::vector<int64_t> A(N); 
    for(auto& i : A){
        std::cin >> i;
    }

    int64_t sum = 0;
    int32_t idx_l = 0;
    int32_t idx_r = 0;
    int64_t arith_sum = 0;
    int64_t xor_sum = 0;
    while(idx_r < N){
        arith_sum += A[idx_r];
        xor_sum ^= A[idx_r];
        if(arith_sum != xor_sum){
            //std::cout << "reset at:(" << idx_l << "," << idx_r << ") sums = " << arith_sum << ", " << xor_sum << std::endl; 
            //sum += (idx_r - idx_l) + (idx_r - idx_l) * (idx_r - idx_l -1) / 2;
            //std::cout << "sum = " << sum << std::endl;
            //idx_l = idx_r;
            while(arith_sum != xor_sum && idx_l < idx_r){
                arith_sum -= A[idx_l];
                xor_sum ^= A[idx_l];
                idx_l++;
            }
        }
        sum += (idx_r - idx_l + 1);
        idx_r++;
    }
    //sum += (idx_r - idx_l) + (idx_r - idx_l) * (idx_r - idx_l - 1) / 2;
    //std::cout << "complete with :(" << idx_l << "," << idx_r << ") sums = " << arith_sum << ", " << xor_sum << std::endl; 


    std::cout << sum << std::endl;
    return 0;

}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 145, task C, 2020/05/04
//ms,
/*
精進！！！！順列全探索をできるようになろう。
*/



int main(void){
  int N;
  vector<int> towns;
  vector<int> x(8);
  vector<int> y(8);
  double ans=0;

  cin >>N;
  for(int i=0;i<N;i++){
    cin >>x.at(i) >>y.at(i);
  }

  for(int i=0;i<N;i++) towns.push_back(i);

  double tmp_dist;
  int counter=0;
  do {
    tmp_dist=0.0;
    for(int i=0;i<N-1;i++){
      tmp_dist+=sqrt(pow(x.at(towns.at(i))-x.at(towns.at(i+1)),2)
                    +pow(y.at(towns.at(i))-y.at(towns.at(i+1)),2));
    }
    //cout <<tmp_dist <<endl;
    ans += tmp_dist;
    counter++;
  }while(next_permutation(towns.begin(),towns.end()));

  ans = ans / counter;
  printf("%15f",ans);

  return 0;
}
/*
平均値なので多分全探索しかないですね。
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long double ll;
int t,n,m,k;
ll f[301][301][301];
ll calc(int x,int y,int z){

if(f[x][y][z]==0){
    ll s=0,p=0;
    if(x!=0){
        s+=x*calc(x-1,y,z);
        p+=x;
    }
    if(y!=0){
        s+=y*calc(x+1,y-1,z);
        p+=y;
    }
    if(z!=0){
        s+=z*calc(x,y+1,z-1);
        p+=z;
    }
        //cout<<s<<endl;
        s/=p;
        f[x][y][z]=s+(n/(p));
        return s+(n/(p));
}else{
return f[x][y][z];
}
}
int main(){
        cout<<fixed<<setprecision(10);
//cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

cin>>n;
ll a[3];
memset(a,0,sizeof a);
for(int i=0;i<n;i++){
ll x;
cin>>x;
if(x==1){a[0]++;}
if(x==2){a[1]++;}
if(x==3){a[2]++;}
}
ll q=(ll)(n);
f[1][0][0]=q;

for(int i=2;i<=n;i++){
    f[i][0][0]=q/i+f[i-1][0][0];
}
f[0][1][0]=2*f[1][0][0];
f[0][0][1]=3*f[1][0][0];
//f[2][0][0]=n/2+f[1][0][0];
cout<<calc(a[0],a[1],a[2])<<endl;
for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
        //cout<<f[j][i][0]<<" ";
    }
    //cout<<endl;
}
//cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;

}



Measured memory_bytes: 212892
#include<bits/stdc++.h>
using namespace std;
int main(){
long long int n,k;
cin>>n>>k;
long long int arr[n+1];
for(long long int i=0;i<=n;i++)
{
    arr[i]=i;
}
long long int s=0;
for(long long int i=k;i<=n+1;i++)
{
    long long int mins=(i*(arr[i-1]))/2;
    long long int maxs=(i*(arr[n]+arr[n-i+1]))/2;
    s+=maxs-mins+1;
}
cout<<s%1000000007;

}









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

int main() {
    ll N, K; cin >> N >> K;
    vector<ll> A(N); for (int i = 0; i < N; i++) cin >> A[i];
    vector<ll> cum(N); cum[0] = (K + A[0] - 1) % K;
    for (int i = 1; i < N; i++) cum[i] = (K + A[i] + cum[i-1] - 1) % K;
    ll ans = 0;
    map<ll, ll> group;

    group[0]++;
    for (int i = 0; i < N; i++) {
        if (i == K-1) group[0]--;
        if (i >= K) group[cum[i-K]]--;
        ans += group[cum[i]]++;
    }
    cout << ans << endl;
}


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

int main() {

     int A,B;
    cin >> A >> B;
    
    if (A >= 1 && A <= 9 && B >= 1 && B <= 9) {
        cout << A * B << endl;
    }
    
    else {
        cout << -1 << endl;
    }
    
 }


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
using namespace std;
typedef long long ll;
// cd test ; rm -R ./*; cd ..


int main(void) {
  int a, b, c,d ;
  cin >> a >> b >> c >> d;
  cout << (a != c ?1 :0) << endl;
  
  return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var w, n int
	fmt.Scan(&w)
	numbers := make([]int, w)

	fmt.Scan(&n)

	intersect := make([][2]int, n)

	for i := 0; i < n; i++ {
		var x, y int
		fmt.Scanf("%d,%d", &x, &y)
		intersect[i] = [2]int{x, y}
	}

	for i := 0; i < w; i++ {
		numbers[i] = i + 1
	}

	for _, v := range intersect {
		swap(numbers, v[0], v[1])
	}

	for _, v := range numbers {
		fmt.Println(v)
	}
}

func swap(arr []int, x, y int) {
	tmp := arr[x-1]
	arr[x-1] = arr[y-1]
	arr[y-1] = tmp
}



Measured memory_bytes: 1132