akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <regex>
#include <locale>
using namespace std;

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_Len=int(b);i<i##_Len;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

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

using ll = long long;

int main () {
  int a, b;
  cin >> a >> b;
  
  a %= 3;
  b %= 3;
  cout << (!a || !b || !((a+b)%3) ? "Possible" : "Impossible") << endl;
}

Measured memory_bytes: 3000
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	private class DisjointSet {
		
		int[] p;
		int[] rank;

		public DisjointSet(int size) {
			p = new int[size];
			rank = new int[size];
			for (int i = 0; i < size; i++) makeSet(i);
		}

		private void makeSet(int x) {
			p[x] = x;
			rank[x] = 0;
		}
		
		public boolean same(int x, int y) {
			return findSet(x) == findSet(y);
		}

		private int findSet(int x) {
			int parent = p[x];
			int v = x;
			while (parent != v) {
				parent = p[v];
				v = p[parent];
				p[x] = parent;
			}
			return parent;
		}
		
		public void unite(int x, int y) {
			link(findSet(x), findSet(y));
		}

		private void link(int x, int y) {
			if (rank[x] < rank[y]) {
				p[y] = x;
			} else {
				p[x] = y;
				if (rank[x] == rank[y]) {
					rank[y]++;
				}
			}
		}
	}	
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(reader.readLine());
		int n = Integer.parseInt(st.nextToken());
		DisjointSet ds = new DisjointSet(n);
		int m = Integer.parseInt(st.nextToken());
		for (int i = 0; i < m; i++) {
			st = new StringTokenizer(reader.readLine());
			int id1 = Integer.parseInt(st.nextToken());
			int id2 = Integer.parseInt(st.nextToken());
			ds.unite(id1, id2);
		}
		
		int q = Integer.parseInt(reader.readLine());
		for (int i = 0; i < q; i++) {
			st = new StringTokenizer(reader.readLine());
			int id1 = Integer.parseInt(st.nextToken());
			int id2 = Integer.parseInt(st.nextToken());
			if (ds.same(id1, id2)) {
				System.out.println("yes");
			} else {
				System.out.println("no");
			}
		}
		reader.close();
	}
}


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

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

//---------------------------

int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    bool flag = true;
    if(c-a-b <= 0) flag = false;
    if(4*a*b >= (c-a-b)*(c-a-b)) flag = false;
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    
    //insertion sort
    for (int i = 0; i < n; i++)
    {
        int temp = a[i];
        int j = i-1;
        while (j>=0 and a[j]>temp)
        {
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = temp;
        for (int i = 0; i < n-1; i++)
        {
            cout << a[i] << " ";
        }
        cout << a[n-1] << endl;
    }
    
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    --a;
    ll e = lcm(c, d);
    c = b / c - a / c;
    d = b / d - a / d;
    e = b / e - a / e;
    cout << b - a - c - d + e << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <sstream>
using namespace std;
int main(){
	int x;
	string day[7]={"thu","fri","sat","sun","mon","tue","wed"};
	cin>>x;
	cout<<day[x%7]<<endl;
	return 0;
}

Measured memory_bytes: 3168
import std.stdio;

void SectoTime(int sec){
	int h = sec / 3600, m = sec % 3600 / 60, s = sec % 3600 % 60;
	writefln("%02d:%02d:%02d", h, m, s);
}

void main(){
	int h, m, s;
	while(1){
		readf("%d %d %d\n", &h, &m, &s);
		if(h == -1)break;
		int t = h * 3600 + m * 60 + s;
		SectoTime(120*60-t);
		SectoTime((120*60-t)*3);
	}
}

Measured memory_bytes: 980
# C
N = int(input())
a = [0] * N
b = [0] * N
c = [0] * N
for i in range(N):
    a[i], b[i], c[i] = map(int, input().split())

dp = [[0] * 3 for _ in range(N)]

dp[0][0] = a[0]
dp[0][1] = b[0]
dp[0][2] = c[0]
for i in range(1, N):
    dp[i][0] = max(dp[i-1][1] + a[i], dp[i-1][2] + a[i])
    dp[i][1] = max(dp[i-1][0] + b[i], dp[i-1][2] + b[i])
    dp[i][2] = max(dp[i-1][0] + c[i], dp[i-1][1] + c[i])
print(max(dp[-1]))

Measured memory_bytes: 34636
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

#define mx 1003
char S[mx],T[mx];

int main(){
    scanf("%s",S);
    scanf("%s",T);

    int ns=strlen(S);
    int nt=strlen(T);

    int ans=1e9;

    for(int i=0;i<=ns-nt;i++){
        int del=0;
        for(int j=0;j<nt;j++){
            if(S[i+j]!=T[j]) del++;
        }
        ans=min(ans,del);
    }
    printf("%d\n",ans);
}


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

int main() {
  int A, B, C, D;
  string input;
  cin >> input;
  A = stoi(input.substr(0, 1));
  B = stoi(input.substr(1, 1));
  C = stoi(input.substr(2, 1));
  D = stoi(input.substr(3, 1));
  
  string message = "No"; // Noの確率が高い

  // 3つ連続して同じ数字＜BとCは同じ数字
  if (B == C) {
    // 3つ連続して同じ数字
    // -> AとB または CとD は同じ数字
    if (A == B || C == D){
      message = "Yes";
    }
  }

  cout << message << endl; 
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> PLL;

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

    for (char c = 'a'; c <= 'z'; ++c) {
        int last = -100;
        for (int j = 0; j < s.size(); ++j) {
            if (s[j] == c) {
                if (j - last <= 2) {
                    cout << last+1 << ' ' << j+1 << endl;
                    return 0;
                }
                last = j;
            }
        }
    }

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


Measured memory_bytes: 888
<?php
fscanf(STDIN, "%d %d", $a, $b);

$base = [];
for ($i = 0; $i < 100; $i++) {
	$base[$i] = [];
	for ($j = 0; $j < 100; $j++) {
		if ($i < 50) {
			$base[$i][$j] = ".";
		} else {
			$base[$i][$j] = "#";
		}
	}
}

for ($i = 0; $i < $b - 1; $i++) {
	$base[2 * (floor($i / 50))][($i % 50) * 2] = "#";
}
for ($i = 0; $i < $a - 1; $i++) {
	$base[51 + 2 * (floor($i / 50))][($i % 50) * 2] = ".";
}

echo "100 100\n";
foreach ($base as $row) {
	foreach ($row as $point) {
		echo $point;
	}
	echo "\n";
}
echo "\n";

Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
main(){
int i,j,k,l,m;
char s1[100000];
while(cin>>s1){
  int x[150]={0};
  l=strlen(s1);
  for(i=0;i<l;i++) x[s1[i]]++;
  k=0;
  for(i=0;i<150;i++) if(x[i]>1)k++;
  if(k>0) cout<<"no"<<endl;
  else cout<<"yes"<<endl;
} return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
AB = []
for _ in range(M):
    AB.append(list(map(int, input().split())))

from operator import itemgetter
AB.sort(key=itemgetter(1))

ans = 0
lastcut = 0
for a, b in AB:
    if a < lastcut <= b:
        continue
    lastcut = b
    ans += 1

print(ans)


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

public class Main {
	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int time = Integer.parseInt(br.readLine());
		time += Integer.parseInt(br.readLine());
		time += Integer.parseInt(br.readLine());
		time += Integer.parseInt(br.readLine());
		System.out.println(time / 60);
		System.out.println(time % 60);
	}
}

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


namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            
            int count=0;

            for(int i=0;i<s.Length;i+=2)
            {
                if(s[i] == 'L')
                {
                    count++;
                }
            }

            for(int i=1;i<s.Length;i+=2)
            {
                if(s[i] == 'R')
                {
                    count ++;
                }
            }

            Console.WriteLine(count > 0 ? "No" : "Yes");
        }
    }
}


Measured memory_bytes: 11092
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define int long long
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
ll mod = 1e9+7;
const int MN = 100010;
ll inf = 3e18;
int N;
ll X[2],a[MN];
ll dp[MN][2];
ll sum[MN][2];
int oksum[MN][2];

ll ran(int L,int R,int t){
	return (sum[R+1][t]-sum[L][t])%mod;
}
bool can(int L,int R,int t){
	return a[R]-a[L]>=X[t];
}
bool canran(int L,int R,int t){
	return oksum[R][t]-oksum[L][t] == R-L;
}
signed main(){
	cin>>N>>X[0]>>X[1];
	a[0]=-inf,a[1]=-inf,a[N+2]=inf;
	rep(i,N) cin>>a[i+2];

	dp[0][0]=dp[0][1]=1;
	sum[1][0]=sum[1][1]=1;

	N+=3;

	rep(i,N-1){
		rep(t,2){
			oksum[i+1][t]=oksum[i][t] + (a[i+1]-a[i]>=X[t]);
		}
	}

	for(int v=2;v<N;v++){	//put v
//		show(v);
		//(v-1,v)	dp[v-1]
		rep(t,2){	// put to A : 0
			int ub=v-1,lb=-1;
			while(ub-lb>1){
				int m=(ub+lb)/2;
				if(can(m,v,t)) lb=m;
				else ub=m;
			}

			int R = lb;		//  ,R]

			ub=v-1,lb=0;
			while(ub-lb>1){
				int m=(ub+lb)/2;
				if(canran(m,v-1,1-t)) ub=m;
				else lb=m;
			}
			int L = ub-1;	//[L,
//			printf("[%d,%d]\n",L,R);
			if(L>R) continue;
			// show(v-1);
			// show(1-t);
			// show(L);
			// show(R);
			dp[v-1][1-t] = ran(L,R,t);
//			printf("dp[%d][%d]=%lld\n",v-1,1-t,dp[v-1][1-t]);
		}
		rep(t,2) sum[v][t] = (sum[v-1][t] + dp[v-1][t])%mod;
	}
	ll ans=(dp[N-2][0]+dp[N-2][1]+mod*2)%mod;
	if(ans%2==1) ans+=mod;
	ans/=2;
	cout<<ans<<endl;
}


Measured memory_bytes: 5760
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
#include <cstring>
using namespace std;
using ll = long long;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
int main(){
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a,a+3);
  cout << a[0] * a[1] / 2;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    if (s.size() == 1)
        return cout << 1, 0;
    
    int sol = 1;
    for (int i = 1; i < s.size();)
    {
        // a aa a a
        if (s[i] == s[i - 1])
        {
            i++;
            if (i < s.size())
                sol++, i++;
            if (i < s.size())
                sol++, i++;
        }
        else
            ++i, ++sol;
    }
    cout << sol;
}


Measured memory_bytes: 720
from collections import deque
import sys
def main():
  a,b=map(int,sys.stdin.readline().split())
  e=[[]for i in range(a)]

  for i in range(a-1):
    c1,c2=map(int,sys.stdin.readline().split())
    e[c1-1].append(c2-1)
    e[c2-1].append(c1-1)

  g=[[]for i in range(a)]
  f=deque([(0,-1)])
  ans=[0 for _ in range(a)]
  for i in range(b):
    ten,p=map(int,input().split())
    ans[ten-1]+=p
  i=0
  while len(f)!=0:
    i,fr=f.pop()
    for j in e[i]:
      if j==fr:
        continue
      else:
        ans[j]+=ans[i]
        f.append((j,i)) 
  print(*ans)
if __name__ == '__main__':  
  main()
    
  

  
  


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

namespace ABC115C
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int N = line[0]; int K = line[1];

            int[] h = new int[N];

            for(var i = 0; i < N; i++)
            {
                h[i] = int.Parse(Console.ReadLine());
            }

            Array.Sort(h);
            
            int hlen = 1000000000;

            for(var i = 0; i < N - K + 1; i++)
            {
                int hmin = h[i]; int hmax = h[i + K - 1];
                if(hmax - hmin < hlen)
                {
                    hlen = hmax - hmin;
                }
            }

            Console.WriteLine(hlen);
        }
    }
}


Measured memory_bytes: 17632
using System;

class Program
{
    const int mod = (int)1e9 + 7;

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

        var dp = new int[n + 1, 4, 4, 4];
        dp[0, 3, 3, 3] = 1;

        for (int len = 0; len < n; len++)
        {
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    for (int k = 0; k < 4; k++)
                    {
                        for (int a = 0; a < 4; a++)
                        {
                            if (j == 0 && k == 1 && a == 2) continue;
                            if (i == 0 && k == 1 && a == 2) continue;
                            if (j == 1 && k == 0 && a == 2) continue;
                            if (j == 0 && k == 2 && a == 1) continue;
                            if (i == 0 && j == 1 && a == 2) continue;
                            dp[len + 1, j, k, a] += dp[len, i, j, k];
                            dp[len + 1, j, k, a] %= mod;
                        }
                    }
                }
            }
        }

        var ans = 0;
        for (int i = 0; i < 4; i++)
        {
            for (int j = 0; j < 4; j++)
            {
                for (int k = 0; k < 4; k++)
                {
                    ans += dp[n, i, j, k];
                    ans %= mod;
                }
            }
        }

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13140
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  int h, w;
  char s[11];

  cin >> h >> w;
  int cnt = 0;
  for (int i = 0; i < h; ++i) {
    cin >> s;
    cnt += count(s, s+w, '#');
  }

  puts((cnt == h+w-1) ? "Possible" : "Impossible");


  return 0;
}



Measured memory_bytes: 256
#include "iostream"
using namespace std;
 
int main(){
 char S[3]={0};
  
 cin >> S;
   
 if(S[0] == 'S' && S[1]=='U' && S[2]=='N') cout << 7; 
 if(S[0] == 'M' && S[1]=='O' && S[2]=='N') cout << 6; 
 if(S[0] == 'T' && S[1]=='U' && S[2]=='E') cout << 5; 
 if(S[0] == 'W' && S[1]=='E' && S[2]=='D') cout << 4; 
 if(S[0] == 'T' && S[1]=='H' && S[2]=='U') cout << 3; 
 if(S[0] == 'F' && S[1]=='R' && S[2]=='I') cout << 2; 
 if(S[0] == 'S' && S[1]=='A' && S[2]=='T') cout << 1; 
return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> v(H);
    for (int i = 0; i < H; i++) cin >> v[i];
    int ans = 0;
    for (int b1 = 0; b1 < (1 << H); b1++) {
        for (int b2 = 0; b2 < (1 << W); b2++) {
            int cnt = 0;
            for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) {
                if (b1 >> i & 1) continue;
                if (b2 >> j & 1) continue;
                if (v[i][j] == '#') cnt++;
            }
            if (cnt == K) ans++;
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3612
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>
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) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main( ) {
    //freopen("A.01.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k;
    scanf("%d",&k);
    printf("%d",(k%2==0)?(k/2)*(k/2):(k/2+1)*(k/2));
    return 0;
}

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

#define ll long long
#define rep(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

#define fi first
#define se second

using namespace std;

/////////////////////////////////////////////////////



ll N,Q;
ll C[505050];
pll LR[505050];
pll LI[505050];
ll mk[505050],mk2[505050];
ll ans[505050];
ll i, j, k;

const ll fwtn = 20;
ll fwt[5 << fwtn - 2];

void addi(ll n,ll x){
    ++n;
    for (; n <= (1 << fwtn); n += n & -n)
    {
        fwt[n] += x;
    }
}
ll calci(ll n){
    ++n;
    ll ret = 0;
    for (; n > 0;n-=n&-n){
        ret += fwt[n];
    }
    return ret;
}




void query(){
    ll L, R;
    scanf("%lld%lld", &L, &R);
}

int main(){
    scanf("%lld%lld", &N, &Q);
    rep(i,0,N){
        scanf("%lld", &C[i]);
    }
    rep(i,0,505000){
        mk[i] = -1;
    }
    rep(i,0,Q){
        ll l, r;
        scanf("%lld%lld", &l, &r);
        LR[i] = {l, r};
        LI[i] = {l, i};
    }
    sort(LI, LI + Q);
    reverse(LI, LI + Q);


    for (i = N-1;i>=0; --i)
    {
        if(mk[C[i]]==-1){
            mk[C[i]] = i + 1;
        }else{
            ll p = mk[C[i]];
            addi(p, 1);
            mk[C[i]] = i + 1;
        }
        //printf("\n%lld:\n", i);
        while(j<Q&&LI[j].first==i+1){
            ll ii = LI[j].second;

            //printf("%lld,%lld,%lld\n", j, LR[ii].first, LR[ii].second);
            ans[ii] = LR[ii].second - LR[ii].first + 1;
            ans[ii] -= calci(LR[ii].second) - calci(LR[ii].first);
            ++j;
        }
    }

    rep(i,0,Q){
        printf("%lld\n", ans[i]);
    }
    return 0;
}

Measured memory_bytes: 35048
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;

ll gcd(ll x, ll y){
    if(x<y) swap(x, y);
    if(y==0) return x;

    return gcd(y, x%y);
}

ll lcm(ll x, ll y){
    return x/gcd(x, y)*y;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> aa(n);
    rep(i, n) cin >> aa[i];
    sort(aa.begin(), aa.end(), greater<ll>());
    ll ans = aa[0];
    rep(i, n){
        if(i==0) continue;
        ans = lcm(ans, aa[i]);
    }
    cout << ans << endl;
    return 0;
}

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

public class Main {

    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        StringBuilder s = new StringBuilder();
        
        for(int i = 0; i < str.length(); i++){
        if(Character.isUpperCase(str.charAt(i))){
          
 s.append(Character.toLowerCase(str.charAt(i)));
        }else if((Character.isLowerCase(str.charAt(i)))){
            s.append(Character.toUpperCase(str.charAt(i)));
        }else{
            s.append(str.charAt(i));
        }
            }
        System.out.println(s);
    }   
}

Measured memory_bytes: 24148
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <limits>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <complex>

using namespace std;

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

#define INF (INT_MAX/3)
#define PI (2*acos(0.0))
#define EPS (1e-8)

typedef long long ll;
typedef unsigned long long ull;

int main(){
  ios_base::sync_with_stdio(0);
  int n, m;
  while(cin >> n >> m, n || m){
    vector<int> masu(n, 0);
    for(int i = 0; i < n; i++) cin >> masu[i];
    int now = 0, cnt = 0;
    for(int i = 0; i < m; i++){
      int dice; cin >> dice;
      if(now < n - 1) cnt++;
      now += dice;
      if(now >= n) now = n - 1;
      now += masu[now];
      if(now >= n) now = n - 1;
    }
    cout << cnt << endl;
  }
  return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll three[40];

using P = pair<ll, ll>;

ll solve2(int K, ll a, ll b, ll c, ll d) {
  if (a == c && b == d) return 0;
  const ll L = three[K-1];
  vector<ll> ps({0, L-1, 2*L, 3*L-1});
  vector<P> checkpoints;
  for (ll r : ps) {
    for (ll c : ps) {
      checkpoints.push_back({r, c});
    }
  }
  // pv(ALL(checkpoints));
  // cout <<  K << " " << a << " " << b << " " << c << " " << d << endl;
  ll ans = 1LL << 61;
  for (P p : checkpoints) {
    ll cur = 0;
    cur += abs(a - p.first) + abs(b - p.second);
    cur += abs(c - p.first) + abs(d - p.second);
    chmin(ans, cur);
  }
  return ans;
}

ll solve(int K, ll a, ll b, ll c, ll d) {
  if (a == c && b == d) return 0;
  ll L = three[K-1];

  bool same_row = a / L == c / L;
  bool same_col = b / L == d / L;
  if (same_row && same_col) {
    return solve(K-1, a % L, b % L, c % L, d % L);
  }
  if (!same_row && !same_col) { return solve2(K, a, b, c, d); }
  if (same_row && a/L == 1) { return solve2(K, a, b, c, d); }
  if (same_col && b/L == 1) { return solve2(K, a, b, c, d); }

  if (!same_row) {
    swap(a, b);
    swap(c, d);
    same_row = !same_row;
    same_col = !same_col;
  }

  while (L > 1) {
    L /= 3;
    if (a / L != c / L) {
      return abs(a - c) + abs(b - d);
    }
    if (abs(b/L - d/L) >= 2 && a / L == c / L && (a / L) % 3 == 1) break;
  }

  if (L == 1) {
    if (a != c) return abs(a-c) + abs(b-d);
    if (a % 3 != 1) return abs(a-c) + abs(b-d);
    if (abs(b-d) <= 1) return abs(a-c) + abs(b-d);
    return abs(b-d) + 2;
  } else {
    a %= L;
    c %= L;
    return abs(b-d) + min(a+c+2, L-a+L-c);
  }
}


int main2() {

  int Q; cin >> Q;
  while (Q--) {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = solve(31, a-1, b-1, c-1, d-1);
    cout << ans << endl;
  }
  return 0;
}

int main() {

  three[0] = 1;
  for (int i = 1; i < 40; i++) three[i] = three[i-1] * 3;

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;
//メモ
//二次元配列のresizeのしかた
//vv.resize(n);
//for(size_t i=0; i<n; i++){
// vv[i].resize(n);
//}

//メモ
//負の辺を持つ最短経路問題では到達不可経路でも初期化値より小さくなりうるので注意しよう！
int main(){
    int a,b;
    int k;
    std::cin >>k>> a>>b;
    bool bo=0;
    rrep(i,a,b+1){
        if(i%k==0)bo=1;
    }
    if(bo)std::cout << "OK" << std::endl;
    else std::cout << "NG" << std::endl;
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define FOR(i,a,n) for(i=a;i<n;i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
int main(void)
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(c>=a&&c<=b) puts("Yes");
	else puts("No");
	return 0;
}
    

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		int h,w,wsum = 0,E=0,O=0;
		int [][] box;
		Scanner sc = new Scanner(System.in);
		h = sc.nextInt();
		w = sc.nextInt();
		box = new int [h+1][w+1];

		for(int i =0; i<h; i++) {
			for(int j = 0; j < w; j++) {
				box[i][w]+= box[i][j] = sc.nextInt();
				box[h][j]+= box[i][j];
				System.out.print(box[i][j] + " ");
			}
			System.out.print(box[i][w]);
			box[h][w]+=box[i][w];
			System.out.println("");
		}
		for(int i=0; i<box[h].length;i++) {
			System.out.print(box[h][i]);
			if(i < box[h].length-1) {
				System.out.print(" ");
			}
		}
		System.out.println("");
	}
}



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

void solve(){
    string t;
    cin >> t;
    int n=t.size();
    rp(i,n){
        if(t[i]=='?') t[i]='D';
    }
    print(t);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PI acos(-1.0)
#define sq(n) (n)*(n)

using namespace std;
typedef long long ll;

int main()
{
    FAST;
  string s;
        cin>>s;
        ll a=0;


        if(s[0]=='R' && s[1]=='R' && s[2]=='R')
        {
            cout<<"3"<<endl;
        }
        else if(s[0]=='R' && s[1]=='R' && s[2]=='S')
        {
            cout<<"2"<<endl;
        }
        else if(s[0]=='S' && s[1]=='R' && s[2]=='R')
        {
            cout<<"2"<<endl;
        }
        else if(s[0]=='R' || s[1]=='R' || s[2]=='R')
        {
            cout<<"1"<<endl;
        }

        else
            {
                cout<<"0"<<endl;
            }


        return 0;
    }





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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int N, K;
  cin >> N >> K;

  // 解答
  if (N < K) {
    cout << 1 << endl;
  } else {
    cout << (N % K == 0 ? 0 : 1) << endl;
  }
  return 0; 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef long double ld;
typedef vector<ll>VI;
typedef pair<ll,ll>P;
#define VV(T) vector<vector<T>>
#define sz(x) int(x.size())
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=max(x,a)
#define chmin(x,a) x=min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX6 1001001//6
#define MAX7 10010010//7
#define SENTINEL 2000000000//9
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define CLR(mat) memset(mat, 0, sizeof(mat))
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}
using Edge=pair<int,ll>;
using Graph=vector<vector<ll> >;//ll or Edge
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// sort_reverse -> greater<long long>()
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
//push_back -> emplace_back

int main(){
   int n,k;
   cin>>n>>k;
   vector<int> a(n);
   rep(i,n)cin>>a[i];
   ll sum=0;
   rep(i,n)sum+=a[i];
   set<ll> candidates;
   for(int i=1;i*i<=sum;i++){
      if(sum%i==0){candidates.insert(i);
      candidates.insert(sum/i);}
   }
   ll ans=1;
   for(ll x:candidates){
      ll need;
      {
      vector<ll>r(n);
      rep(i,n)r[i]=a[i]%x;
      sort(ALL(r));
      ll tot=0;
      rep(i,n)tot+=r[i];
      int l=n-tot/x;
      need=0;
      rep(i,l)need+=r[i];
      }
      if(need<=k)ans=max(ans,x);
   }
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 3684
arr = [input() for i in range(4)]
 
count = 0
for fi in range(0, int(arr[0])+1):
    for hun in range(0, int(arr[1])+1):
        for fifty in range(0, int(arr[2])+1):
            sum = fi * 500 + hun * 100 + fifty * 50
            if sum == int(arr[3]):
                count += 1
print(count)

Measured memory_bytes: 3060
n = int(input())
A = list(map(int,input().split()))

#ユーグリッドの互除法で、a,bを与えて、aをbで割ってあまりを計算する
#あまりがないときは、最後に割った数を返す（最大公約数）
#あまりがあるときは、bにあまりを入れて、再び計算する
def gcd(a,b):
	if b == 0:
		return a
	return gcd(b,a%b)


x = A[0]
for i in A[1:]:
	x = gcd(x,i)
print(x)

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

int main()
{
    long long N, A, B;
    cin >> N >> A >> B;

    if (A == 0) {
        cout << 0 << endl;
    }
    else {
        long long count = N / (A + B);
        long long remain = N % (A + B);

        long long ans = A * count;
        if (remain >= A) {
            ans += A;
        }
        else {
            ans += remain;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    a.erase( unique(a.begin(), a.end()), a.end());

    cout << a.size() - (a.size()%2==0) << endl;
}

Measured memory_bytes: 640
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

long f(long b, long n)
{
    long r;
    while (n) {
        r += n%b;
        n /= b;
    }
    return r;
}

void main()
{
    auto n = readln.chomp.to!long;
    auto s = readln.chomp.to!long;

    if (n == s) {
        writeln(n + 1);
    } else {
        long i = 1;
        for (;;) {
            ++i;
            if (i*i > n) break;
            if (f(i, n) == s) {
                writeln(i);
                return;
            }
        }
        i = 0;
        long min_b = long.max;
        for (;;) {
            ++i;
            if (i*i > n || s - i < 0) break;
            auto b = (n - s) / i + 1;
            if (b < 2) continue;
            if (f(b, n) == s) {
                min_b = min(min_b, b);
            }
        }
        writeln(min_b == long.max ? -1 : min_b);
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())



void init() {

}

void input() {

}

void solve() {
  int n, a, b;
  cin >> n;
  if (n == 1) {
    cout << "Hello World" << endl;
    return;
  }
  cin >> a >> b;
  cout << a+b << endl;
}

int main() {
	init();
	input();
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <cmath>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    list<int> prime;
    prime.push_back(2);
    int n;
    cin >> n;
    for(int i = 2; i <= n; ++i){
        bool is_prime = true;
        repi(p, prime){
            if(i % *p == 0){
                is_prime = false;
                break;
            }
        }
        if(is_prime){
            prime.push_back(i);
        }
    }
    repi(i, prime){
        //cout << *i << endl;
    }
    vector<int> factor(prime.size(), 0);
    for(int i = 2; i <= n; i++){
        int num = i;
        int index = 0;
        repi(p, prime){
            while(num % *p == 0){
                num /= *p;
                ++factor[index];
            }
            ++index;
            if(num <= 1){
                break;
            }
        }
    }
    
    ll ans = 1;
    repi(i, factor){
        ans = (ans * (*i + 1)) % 1000000007;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    int l, m[12], n[12], x, a;
    for(; scanf("%d", &l), l;){
        for(x = 0; x < 12; x++){
            scanf("%d%d", m+x, n+x);
        }
        a = 0;
        for(x = 0; x < 12; x++){
            a += m[x]-n[x];
            if( a >= l ) break;
        }
        if(x/12){
            puts("NA");
        }else{
            printf("%d\n", x+1);
        }
    }
    return 0;
}

Measured memory_bytes: 1040
n=int(input())
p=[int(i) for i in input().split()]
cnt=0
for i in range(1,n-1):
  if p[i-1]<p[i] and p[i]<p[i+1]:
    cnt+=1
  elif p[i-1]>p[i] and p[i]>p[i+1]:
    cnt+=1
print(cnt)

Measured memory_bytes: 3060
#include <stdio.h>

int main()
{
int a[3];
int tmp;
int i, j;
scanf("%d %d %d", &a[0], &a[1], &a[2]);

for(i=0;i<3;i++){
    for(j=2;j>i;j--){
          if(a[i] > a[j]){
          tmp = a[i];
          a[i] = a[j];
         a[j] = tmp;
          }
     }
   }

printf("%d %d %d\n", a[0], a[1], a[2]);
return 0;
}
   

 

Measured memory_bytes: 596
import sys

args = [int(input()) for i in range(5)]
#args = [29,20,7,35,120]
smallest = 10
i = 0
sum = 0
arg_num = 0

for tmp in args[:4]:
    if tmp % 10 < smallest:
        if tmp % 10 != 0:
            smallest = tmp % 10
            arg_num = i
    i+=1

#print("smallest:" + str(arg_num))

for i in range(5):
    if i != arg_num:
        if args[i] % 10 != 0:
            args[i] = args[i] + (10 - args[i] % 10)
    #print("args[" + str(i) + "]:" + str(args[i]))
    sum += args[i]

print(sum)


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

#define pq priority_queue
#define mp make_pair
#define cauto const auto &

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define clr(ar, val) memset(ar, val, sizeof(ar))

typedef long long int64;
typedef long long lint;
typedef long long lli;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;

typedef pair<int, int> pint;
typedef pair<long, long> plong;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T = int> T in() {
    T x;
    cin >> x;
    return (x);
}
template <class T> void print(T &x) {
    cout << x << '\n';
    return;
}

template <class T> ll sized_subset(T &comb) {
    T x = comb & -comb, y = x + comb;
    return ((comb & ~y) / x) >> 1 | y;
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    int a,b,k;
    cin>>a>>b>>k;
    int l=k;
    for(int i=max(a,b);i>0;i--){
        if(a%i==0&&b%i==0){l--;}
        if(l==0){cout<<i<<endl;break;}
    }
    return 0;
}


Measured memory_bytes: 256
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <bits/stdc++.h>
#define re register
using namespace std;
typedef long long ll;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

int n,a[20],p=0;

inline int qpow(int a,int b) { int c=1;
    for (;b;b>>=1,a*=a) if (b&1) c*=a;
    return c;
}

int pw[10];

int main() {
    n=read(); ll ans=0;
    pw[0]=1; for (re int i=1;i<=6;++i) pw[i]=pw[i-1]*10;
    for (re int i=1;i<10;++i)
        for (re int j=1;j<10;++j) {
            int s1=0,s2=0;
            if (i==j&&i<=n) ++s1;
            if (i*10+j<=n) ++s1;
            for (re int l=1;l<=4;++l)
                for (re int k=0;k<pw[l];++k)
                    if (i*pw[l+1]+k*10+j<=n) ++s1;
            if (j==i&&j<=n) ++s2;
            if (j*10+i<=n) ++s2;
            for (re int l=1;l<=4;++l)
                for (re int k=0;k<pw[l];++k)
                    if (j*pw[l+1]+k*10+i<=n) ++s2;
            ans+=1ll*s1*s2;
        }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def root(x):
        if par[x] == x:
            return par[x]
        s[par[x]] += s[x]
        s[x] = 0
        par[x] = root(par[x])
        return par[x]

    def unite(x,y):
        x = root(x)
        y = root(y)
        if rank[x] < rank[y]:
            par[x] = y
            s[y] += s[x]
            s[x] = 0
        else:
            par[y] = x
            s[x] += s[y]
            s[y] = 0
            if rank[x] == rank[y]:
                rank[x] += 1

    n,m = LI()
    v = []
    for i in range(m):
        a,b = LI()
        a -= 1
        b -= 1
        v.append((a,b))
    par = [i for i in range(n)]
    rank = [0]*n
    s = [1]*n
    su = n*(n-1) >> 1
    ans = [su]
    for i,j in v[1:][::-1]:
        ri = root(i)
        rj = root(j)
        if ri != rj:
            su -= s[ri]*s[rj]
            unite(i,j)
        ans.append(su)
    for i in ans[::-1]:
        print(i)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 102364
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int k, a, b; cin >> k >> a >> b;
  for (int i=a; i<=b; i++){
    if (i%k==0){
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
}

Measured memory_bytes: 3608
N = int(input())

A = [0 for i in range(N)]
B = [0 for i in range(N)]
for i in range(N):
    a,b = map(int,input().split())
    A[i] = a
    B[i] = b
A.sort()
B.sort()
if N%2:
    print(B[N//2]-A[N//2]+1)
else:
    print(B[N//2]+B[(N-1)//2]-A[N//2]-A[(N-1)//2]+1)


Measured memory_bytes: 94168