akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
// import java.math.*;
import java.util.*;
// import java.util.Map.*;
// import java.util.stream.*;

@SuppressWarnings ("unchecked")
public class Main {
    public static <T> List<List<T>> zip (List<T>... lists) {
        List<List<T>> zipped = new ArrayList<List<T>>();
        for (List<T> list : lists) {
            for (int i = 0, listSize = list.size(); i < listSize; i++) {
                List<T> list2;
                if (i >= zipped.size())
                    zipped.add (list2 = new ArrayList<T>());
                else
                    list2 = zipped.get (i);
                list2.add (list.get (i));
            }
        }
        return zipped;
    }
    static List<Character> toCharacterList (String s) {
        if (s == null) {
            return null;
        }
        int len = s.length();
        List<Character> lst = new ArrayList<Character>();
        for (int i = 0; i < len; i++) {
            lst.add (Character.valueOf (s.charAt (i)));
        }
        return lst;
    }
    public static void main (String[] args) throws Exception {
        BufferedReader reader =
            new BufferedReader (new InputStreamReader (System.in));
        List<Character> S = toCharacterList (reader.readLine());
        List<Character> T = toCharacterList (reader.readLine());
        List<List<Character>> z = zip (S, T);
        int ans = 0;
        for (List<Character> v : z) {
            if (v.get (0).equals (v.get (1)))
                ans++;
        }
        System.out.println (ans);
        return;
    }
}

Measured memory_bytes: 32556
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
const int INF = 1e9;
const int EPS = 1e-9; 

int main() {
  long long A, B;
  cin >> A >> B;
  long long X;
  X = A * B / __gcd(A, B);
  
  cout << X << endl;
}

Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    H,A =MI()
    print(ceil(H/A))
if __name__ == '__main__':
    main()

Measured memory_bytes: 63596
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int prevT = 0, prevX = 0, prevY = 0;
  bool ok = true;
  rep(i, N) {
    int t, x, y;
    cin >> t >> x >> y;
    int rem = (t-prevT)-(abs(prevX-x)+abs(prevY-y));
    if(rem<0 || rem%2) ok = false;
    prevT = t; prevX = x; prevY = y;
  }
  cout << (ok ? "Yes" : "No") << "\n";
  return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
  cin>>a>>b;
  string s1=to_string(a);
  string s2=to_string(b);
  for(int i=0;i<b-1;i++){
  s1=s1+to_string(a);
  }
  for(int i=0;i<a-1;i++){
   s2=s2+to_string(b);
  }
  if(a<=b)
    cout<<s1<<endl;
  else
    cout<<s2<<endl;
  return 0;
}

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

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

  int sum = 0;
  int tmpN = N;
  int remainder = 0;
  while(tmpN > 0){
    remainder = tmpN % 10;
    sum += remainder;
    tmpN /= 10;
  }
  
  if(0 == (N % sum)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
 
using namespace std;
 
#define pai 3.14159265359
#define mod 1000000007

int main()
{
    string s;
    cin >> s;
    if(s.length() == 2){
        if(s[0] == s[1]) cout << 1 << " " << 2 << endl;
        else cout << -1 << " " << -1 << endl;
        return 0;
    }
    for(int i = 1; i < s.length() - 1; i++){
        if(s[i] == s[i - 1]){
            cout << i - 1 << " " << i << endl;
            break;
        } else if(s[i] == s[i + 1]){
            cout << i + 1 << " " << i + 2 << endl;
            break;
        } else if(s[i - 1] == s[i + 1]){
            cout << i << " " << i + 2 << endl;
            break;
        } else if(i == s.length() - 2){
            cout << -1 << " " << -1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int T = sc.nextInt();

        int cntBiscuit = 0;

        int time = A;

        for(int i = 2 ; time <= T ; i++) {
        	time = A * i;

        	cntBiscuit += B;
        }

        System.out.println(String.valueOf(cntBiscuit));
	}

}

Measured memory_bytes: 25172
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>

using namespace std;

int gcd(int a, int b){
    if(b < a) {
        int t = b;
        b = a;
        a = t;
    }
    if(a == 0) return b;
    return b % a == 0 ? a : gcd(b % a, a);
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n), l(n+1), r(n+1);
    for (size_t i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (size_t i = 1; i < n+1; i++)
    {
        if(i == 1) {
            l[i] = a[i-1];
        } else {
            // cout << "gcd " << l[i-1] << ":" << a[i-1] << endl;
            l[i] = gcd(l[i-1], a[i-1]);
        }
    }
    // cout << "==" << endl;
    for (int i = n-1; i >= 0; i--)
    {
        if(i == n-1) {
            r[i] = a[i];
        } else {
            // cout << "gcd " << r[i+1] << ":" << a[i] << endl;
            r[i] = gcd(r[i+1], a[i]);
        }
    }
    // cout << "here" << endl;

    int ans = 0;
    for (size_t i = 0; i < n; i++)
    {
        ans = max(ans, gcd(l[i], r[i+1]));
    }
    cout << ans << endl;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for(auto& x :p)
    cin >> x;
    sort(p.begin(),p.end());
    *p.rbegin() /=2;
    int ans=0;
    for(auto& x : p){
        ans += x;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
<?php

$n = fgets(STDIN);
$times = 0;
$flag = false;

for($i=0;$i<$n;$i++){
    fscanf(STDIN,"%d %d" ,$x, $y);
    if($x == $y){
        $times++;
    }else{
        $times = 0;
    }
    if($times == 3){
        $flag = true;
        break;
    }
}

if($flag){
    echo "Yes\n";
}else{
    echo "No\n";
}

Measured memory_bytes: 16268
# -*- coding: utf-8 -*-

# input
N, K, Q = map(int, input().split())
A = list()
for _ in range(Q):
    A.append(int(input()))

# solve
ans = [K - Q] * N
for i in range(Q):
    ans[A[i] - 1] += 1

# output
for i in range(N):
    if ans[i] <= 0:
        print('No')
    else:
        print('Yes')


Measured memory_bytes: 10472
# ABC079 C - Train Ticket
import itertools
s = input()
a = s[0:1]
b = s[1:2]
c = s[2:3]
d = s[3:4]

OP = ('+','-')

for op in itertools.product(OP,repeat=3):
    op1,op2,op3 = op
    t = int(a)
    if op1 == '+':
        t += int(b)
    elif op1 == '-':
        t -= int(b)

    if op2 == '+':
        t += int(c)
    elif op2 == '-':
        t -= int(c)

    if op3 == '+':
        t += int(d)
    elif op3 == '-':
        t -= int(d)
    if t == 7:
        print(a+op1+b+op2+c+op3+d+'=7')
        break


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

class Program
{
    static void Main(string[] args)
    {
        var inputs = ReadInts();
        var A = inputs[0];
        var B = inputs[1];
        var K = inputs[2];

        var ans = Enumerable.Range(1, Math.Min(A, B))
            .Select(n => Tuple.Create(n, A % n == 0 && B % n == 0))
            .Where(_ => _.Item2)
            .Reverse()
            .ElementAt(K - 1)
            .Item1;

        Console.WriteLine(ans);
    }


    public static string Read() { return Console.ReadLine(); }
    public static int ReadInt() { return int.Parse(Read()); }
    public static long ReadLong() { return long.Parse(Read()); }
    public static double ReadDouble() { return double.Parse(Read()); }

    public static string[] Reads() { return Console.ReadLine().Split(' '); }
    public static int[] ReadInts() { return Reads().Select(_ => int.Parse(_)).ToArray(); }
    public static long[] ReadLongs() { return Reads().Select(_ => long.Parse(_)).ToArray(); }
    public static double[] ReadDoubles() { return Reads().Select(_ => double.Parse(_)).ToArray(); }
}




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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

string a, b, c;

int main() {
	cin >> a >> b >> c;
	if (a[a.length()-1]==b[0] && b[b.length()-1]==c[0]) cout << "YES" << ln;
	else cout << "NO" << ln;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 #include <math.h>
using namespace std;
#define ll long long
#define pi 3.14159265359


int main(){
vector<string>vec(3);
  vec={"Sunny","Cloudy","Rainy"};
 string s;
  cin>>s;
  for(int i=0;i<3;i++){
    if(vec[i]==s){
      int x=(i+1)%3;
      cout<<vec[x]<<endl;
      return 0;
    }
  }
}
  


Measured memory_bytes: 256
import sys

import numba as nb
import numpy as np

input = sys.stdin.readline


@nb.njit("i8(i8,i8,i8[:,:])", cache=True)
def solve(H, N, AB):
    INF = 10 ** 18
    dp = np.full(shape=(H + 1), fill_value=INF, dtype=np.int64)
    dp[0] = 0
    for i in range(N):
        A, B = AB[i]
        for d in range(H + 1):
            if d < A:
                dp[d] = min(dp[d], B)
            else:
                dp[d] = min(dp[d], dp[d - A] + B)

    ans = dp[-1]
    return ans


def main():
    H, N = map(int, input().split())
    AB = np.zeros(shape=(N, 2), dtype=np.int64)
    for i in range(N):
        AB[i] = input().split()

    ans = solve(H, N, AB)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 106576
#include<iostream>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int min(int a,int b){
    return (a<b) ? a : b ;
}

int max(int a,int b){
    return (a<b) ? b : a ;
}


int main() {

    string A,B,C ;
    cin >>A>>B>>C  ;

    int ac = 0 ;
    int bc = 0 ;
    int cc = 0 ;
    char next = A[0] ;
    ac++ ;

    do{
        if(next=='a')
        {
            ac++ ;
            next = A[ac-1] ;
        }else if(next=='b')
        {
            bc++ ;
            next = B[bc-1] ;
        }else{
            cc++ ;
            next = C[cc-1] ;
        }
           //cout << ac << " " << bc <<" " << cc << endl ;
    }while(ac<=A.size() && bc<=B.size() && cc<=C.size() ) ;


    if(ac>A.size()){
       cout << 'A' ;
    }else if(bc>B.size()){
       cout << 'B' ;
    }else{
       cout << 'C' ;
    }
  
     cout << endl ;

 return 0 ;
}  


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

using namespace std;

using ull=unsigned long long;
using vi=vector<int>;
using pii=pair<int, int>;
using ll=long long;

int main()
{
    int n, k;
    string s;

    cin >> n >> k >> s;

    s[k-1] = tolower(s[k-1]);

    cout << s << "\n"; 

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
double cxu,cxl,cyu,cyl;
bool bx,by;
double uR,lR,uL,lL,uU,lU,uD,lD;
bool bR,bL,bU,bD;
typedef struct{
  double x,y; char d;
}dat;
auto u = [](double& a,double b){a=max(a,b);};
auto l = [](double& a,double b){a=min(a,b);};
const double inf = 1e100;
int main(){
  dat D;
  int n;
  cin>>n;
  for(int i=0;i<n;++i){
    cin>>D.x>>D.y>>D.d;
    switch(D.d){
      case 'U':
      case 'D':
        if(bx)u(cxu,D.x),l(cxl,D.x);
        else cxu=cxl=D.x,bx=1;
        break;
      case 'L':
      case 'R':
        if(by)u(cyu,D.y),l(cyl,D.y);
        else cyu=cyl=D.y,by=1;
    }
    switch(D.d){
      case 'U':
        if(bU)u(uU,D.y),l(lU,D.y);
        else uU=lU=D.y,bU=1;
        break;
      case 'D':
        if(bD)u(uD,D.y),l(lD,D.y);
        else uD=lD=D.y,bD=1;
        break;
      case 'L':
        if(bL)u(uL,D.x),l(lL,D.x);
        else uL=lL=D.x,bL=1;
        break;
      case 'R':
        if(bR)u(uR,D.x),l(lR,D.x);
        else uR=lR=D.x,bR=1;
        break;
    }
  }
  auto xmax = [&](double t){return max({bL?uL-t:-inf,bR?uR+t:-inf,bx?cxu:-inf});};
  auto xmin = [&](double t){return min({bL?lL-t:inf,bR?lR+t:inf,bx?cxl:inf});};
  auto ymax = [&](double t){return max({bD?uD-t:-inf,bU?uU+t:-inf,by?cyu:-inf});};
  auto ymin = [&](double t){return min({bD?lD-t:inf,bU?lU+t:inf,by?cyl:inf});};
  auto dx = [&](double t){return xmax(t)-xmin(t);};
  auto dy = [&](double t){return ymax(t)-ymin(t);};
  auto f = [&](double t){u(t,-t);return fabs(dx(t)*dy(t));};
  cout<<fixed<<setprecision(12)<<min({f(lL-cxl),f((lL-lR)/2.0),f(cxl-lR),f(uL-cxu),f((uL-uR)/2.0),f(cxu-uR),f(lD-cyl),f((lD-lU)/2.0),f(cyl-lU),f(uD-cyu),f((uD-uU)/2.0),f(cyu-uU),f(0.0)})<<endl;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        long ans = 1;
        long A[] = new long[N];
        long max = (long)Math.pow(10, 18);

        for(int i = 0; i < N; i++) {
            A[i] = scan.nextLong();
            if(A[i] == 0) {
                os.println(0);
                return;
            }
        }

        for(int i = 0; i < N; i++) {
            if(ans > max/A[i]) {
                os.println(-1);
                return;
            }
            ans *= A[i];
        }
        os.println(ans);

    }
}

Measured memory_bytes: 50136
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		for (int i = 0; i < W + 2; i++) {
			System.out.print("#");
		}
		for (int i = 0; i < H; i++) {
			System.out.println();
			System.out.print("#");
			System.out.print(sc.next());
			System.out.print("#");
		}
		System.out.println();
		for (int i = 0; i < W + 2; i++) {
			System.out.print("#");
		}
		sc.close();
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    ll a,b,c,k;
    cin >> a >> b >>  c>> k;
    ll ans;

    ans = a-b;
    if(k%2 == 1) cout << -ans <<endl;
    else        cout << ans << endl;
}

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

int main() {
  int N;
  int L;
  scanf("%d%d", &N, &L);

  int ate = 1000;
  int sum = 0;
  for (int i = L; i <= L + N - 1; i++) {
    if (abs(ate) > abs(i)) ate = i;
    sum += i;
  }

  printf("%d", sum - ate);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int posx, posy;
int takara[21][21];
 
int isTakara();
 
int main(void) {
  int a, b, n, m, temp, Tcnt;
  char ch;
 
  while(1) {
    cin >> n;
     
    if(n == 0) return 0;
 
    for(int i = 0; i < 21; i++) {
      for(int j = 0; j < 21; j++) {
    takara[i][j] = 0;
      }
    }
 
    posx = 10; posy = 10; Tcnt = 0;
 
    for (int i = 0; i < n; i++) {
      cin >> a >> b;
      takara[a][b] = 1;
    }
 
    cin >> m;
 
    for(int j = 0; j < m; j++) {
      cin >> ch;
      cin >> temp;
 
      switch(ch) {
      case 'N':
    for(int i = 0; i < temp; i++) {
      posy++;
      if(isTakara() == 1) Tcnt++;
    }
    break;
 
      case 'E':
    for(int i = 0; i < temp; i++) {
      posx++;
      if(isTakara() == 1) Tcnt++;
    }
    break;
 
      case 'W':
    for(int i = 0; i < temp; i++) {
      posx--;
      if(isTakara() == 1) Tcnt++;
    }
    break;
 
      case 'S':
    for(int i = 0; i < temp; i++) {
      posy--;
      if(isTakara() == 1) Tcnt++;
    }
    break;
 
      }
 
    }
 
    if(Tcnt == n) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
 
  return 0;
}
 
int isTakara() {
 
  if(takara[posx][posy]) {
    takara[posx][posy] = 0;
    return 1;
  }
 
  return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define V(type) vector<type> 
#define all(c) (c.begin(),c.end())


/*##################################################################################*/

/*
int prime[1000000] = {0} ;
void calculateprime()
{
    //calculating primes
    prime[0] = prime[1] = 1 ;
    for(int i = 2 ; (ll)i*i <= 1000000 ; i++)
    {
        if(prime[i] == 0)
        {
            for(ll j = i*i ; j <= 1000000 ; j += i )
            {
                prime[j] = 1 ;
            }
        }
    }
}
*/

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    //cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        string str = to_string(n);
        if(str[0] == '7' or str[1] == '7' or str[2] == '7')
        {
            cout<<"Yes";
        }
        else
        {
            cout<<"No";
        }
    }
    return 0;
}

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

using lli = long long int;
using ll = long long ;
using ld=long double;
using d= double;

bool isPrime(ll n){if(n<2)return false;for(ll i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}

int main() {
    int t=1;
    //cin>>t;
    while(t--){
        ll a,b;
        cin>>a>>b;
        cout<<a*b<<endl;
    }
	
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#define REP(i,a) for(int i = 0; i < (a); i++)
using namespace std;

int main(){
	int m,nmin,nmax;
	while(cin >> m >> nmin >> nmax){
		if(m == 0 && nmin == 0 && nmax == 0)break;
		int p[m];
		REP(i, m)cin >> p[i];
		int max = 0;
		int res;
		for(int i = nmin; i < nmax + 1; i++){
			if(p[i - 1] - p[i] >= max){
				max = p[i - 1] - p[i];
				res = i;
			}
		}
		cout << res << endl;
	}
}


Measured memory_bytes: 3072
#include <cstdio>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <cmath>
using namespace std;

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

int main(){
	long H,W;
	cin >> H >> W;
	if(H<W) swap(H,W);


	if(H==2 && W == 2){
		cout << 1 <<endl;
		return 0;
	}

	//0
	int dS;
	long long out = 100000000000;



	REP(i,2){ 
		long w1 = W/2;
		long w2 = W-w1;

		//w1<w2
		if(w1>w2) swap(w1,w2);
		FOR(i,1,H){
			long long Smax = max(W*i,w2*(H-i));
			long long Smin = min(W*i,w1*(H-i));

			if((Smax - Smin) < out) out = Smax - Smin;
		}

		FOR(i,1,H){
			long h1 = (H-i)/2;
			long h2 = H-i-h1;
			//h1<h2
			if(h1>h2) swap(h1,h2);
			long Smax = max(W*i,W*h2);
			long Smin = min(W*i,W*h1);

			if((Smax - Smin) < out) out = Smax - Smin;
		}

		if(i == 1) break;
		swap(H,W);
	}
	
	cout << out << endl;

}

Measured memory_bytes: 256
a = list(map(int,input().split()))
if a[0] == 0:
    print("1")
if a[1] == 0:
    print("2")
if a[2] == 0:
    print("3")
if a[3] == 0:
    print("4")
if a[4] == 0:
    print("5")

Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,N) for(i=0;i<N;i++)
vector<string> mem;
int N;
ll X;
vector<ll> L,P;

ll eat(int n, ll X_){
  if(X_ == L[n]) return P[n];
  else if(X_<=0) return 0;
  else if(X_> L[n]/2) return P[n-1]+1+eat(n-1,X_-2-L[n-1]);
  else return eat(n-1,X_-1);
}

int main(void){
  cin >> N >> X;
  L.resize(N+1);
  P.resize(N+1);
  int i;
  L[0] = 1;
  P[0] = 1;
  REP(i,N){
    L[i+1] = 2*L[i] + 3;
    P[i+1] = 2*P[i] + 1;
  }
  cout << eat(N,X) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int H,N;
    cin >> H >> N;
    int sum=0;
    
    vector<int> vec(N);
    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }
    
    for (int i = 0; i < N; i++) {
        sum+=vec.at(i);
    }
    if(sum>=H)
    cout << "Yes" <<endl;
    else{
        cout << "No" <<endl;
    }
}


Measured memory_bytes: 640
N,M = map(int,input().rstrip().split(" "))
A = list(map(int,input().rstrip().split(" ")))
A.sort(reverse = True)
Q = []
for i in range(M):
    B,C = map(int,input().rstrip().split(" "))
    Q.append([C,B])
Q.sort(reverse = True)

p = 0
j = 0
while p < N and j < M:
    for i in range(Q[j][1]):
        if i + p > N:
            break
        A.append(Q[j][0])
    p += Q[j][1]
    j += 1
ans = 0
A.sort(reverse = True)

for i in range(N):
    ans += A[i]

print(ans)


Measured memory_bytes: 103712
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	a, b, c := getInt(), getInt(), getInt()

	ans := "NO"
	if b-a == c-b {
		ans = "YES"
	}
	out(ans)
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  string s;cin>>s;
  bool flg=true;
  if(s[0]!='A'){
  	flg=false;
  }
  ll cnt=0;
  FOR(i,2,s.size()-1){
  	if(s[i]=='C'){
  		cnt++;
  		if(cnt>1){
  			break;
  		}
  	}
  }
  if(cnt!=1){
  	flg=false;
  }

  rep(i,s.size()){
  	if(s[i]!=65&&s[i]!=67){
  		if(s[i]>96&&s[i]<122){
  			//pass
  		}else{
  			flg=false;
  		}
  	}
  }
  cout<<(flg?"AC":"WA")<<endl;
  return 0;
}

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

class Mod{
    static final long MOD = 1000_000_007;
    static final long[] fact = makeFactorialArray(1000000);
    static final long[] factInv = makeInversedArray(fact);

    public static long add(long a, long b){
        long tmp = (a+b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long adds(long... ar){
        long ans=0;
        for(long x:ar) ans = Mod.add(ans, x);
        return ans;
    }
    public static long sub(long a, long b){
        return add(a,-b);
    }
    public static long mult(long a, long b){
        long tmp = (a*b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long mults(long... ar){
        long ans=1;
        for(long x:ar) ans = Mod.mult(ans, x);
        return ans;
    }
    public static long power(long a, long x){ //calculate a^x
        if(x<0)return 0;
        if(x==0)return 1;
        if(x%2==0) {
            long half = power(a,x/2);
            return mult(half,half);
        }
        return (a*power(a,x-1)) % MOD;
    }
    public static long inverse(long a){
        return power(a,MOD-2);
    }
    public static long div(long a, long b){
        return mult(a, inverse(b));
    }
    public static long[] makeFactorialArray(int size){
        long[] array = new long[size];
        array[0]=1;
        for(int i=1;i<size;i++){
            array[i]=mult(array[i-1],i);
        }
        return array;
    }
    public static long[] makeInversedArray(long[] original){
        long[] array = new long[original.length];
        for(int i=0;i<original.length;i++){
            array[i] = inverse(original[i]);
        }
        return array;
    }
    public static long combination(int n, int r){
        if(n<0 || r<0 || n<r) return 0;
        return mult(fact[n], mult(factInv[r],factInv[n-r]));
    }
    public static long gcd(long a, long b){
        if(a<b) return gcd(b,a);
        if(b==0) return a;
        if(a%b==0) return b;
        return gcd(b,a%b);
    }
    public static long lcm(long a, long b){
        return (a/gcd(a,b))*b;
    }

}

public class Main {
    static long noDivide(long A, long X, long Y){
        return A - (A/X + A/Y - A/(Mod.lcm(X,Y)));
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        long C = sc.nextLong();
        long D = sc.nextLong();
        System.out.println(noDivide(B,C,D)-noDivide(A-1,C,D));
    }
}

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

int c;

int gcd(int x,int y){
  if(x < y)swap(x,y);
  if(!y)return x;
  c++;
  return gcd(y,x%y);
}

int main(){
  int a,b;
  int ans;

  while(1){
    cin >> a >> b;
    if(!a && !b)break;

    c = 0;
    ans = gcd(a,b);
    cout << ans << " " << c << endl;
  }
}

Measured memory_bytes: 0
N=int(input())
S=input()
DIV=1000000007
ans=1
import itertools
wasTate=True
first=True
for key,g in itertools.groupby(S):
  if len(list(g))==1:
    # 縦の場合
    if first:
      # 最初は3通り選べる
      ans=((ans%DIV)*3)%DIV
      first=False
    elif wasTate:
      # ここまで縦だった場合は2通り選べる
      ans=((ans%DIV)*2)%DIV
      wasTate=True
    else:
      # ここまで横だった場合は1通りしかない
      wasTate=True
  else:
    # 横の場合
    if first:
      ans=((ans%DIV)*6)%DIV
      # 最初は6通り選べる
      # 11 11 22 22 33 33
      # 22 33 11 33 11 22
      first=False
      wasTate=False
    elif wasTate:
      # ここまで縦だった場合は2通り選べる
      ans=((ans%DIV)*2)%DIV
      wasTate=False
    else:
      # ここまで横だった場合は3通り選べる
      # 1122 1122 1133
      # 2211 2233 2211
      ans=((ans%DIV)*3)%DIV
      wasTate=False
      
print(ans)

Measured memory_bytes: 3064
from math import sqrt
N,D=map(int,input().split())
X=[list(map(int,input().split())) for i in range(N)]
ans=0
for i in range(N):
    for j in range(i+1,N):
        s=0
        I=X[i]
        J=X[j]
        for k in range(D):
            s+=(I[k]-J[k])**2
        if s==int(sqrt(s))**2:
            ans+=1
print(ans)


Measured memory_bytes: 38384
N = int(input())
tree = []
for i in range(0, N):
	tree.append([])
for i in range(0, N-1):
	u, v, w = map(int, input().split())
	tree[u-1].append([v-1, w])
	tree[v-1].append([u-1, w])
oddeven = []
for i in range(0, N):
	oddeven.append(-1)
stack = [[0, 0]]
while stack != []:
	now = stack.pop(-1)
	oddeven[now[0]] = now[1]%2
	for i in range(0, len(tree[now[0]])):
		if oddeven[tree[now[0]][i][0]] == -1:
			stack.append([tree[now[0]][i][0], now[1]+tree[now[0]][i][1]])
for i in range(0, N):
	print(oddeven[i])

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

#define ld long double
#define eps 1e-9

bool cmp(ld A , ld B){return A + eps > B && A - eps < B;}

struct vec{
	ld x , y;
	vec(ld _x = 0 , ld _y = 0) : x(_x) , y(_y){}
	friend vec operator +(vec A , vec B){return vec(A.x + B.x , A.y + B.y);}
	friend vec operator -(vec A , vec B){return vec(A.x - B.x , A.y - B.y);}
	friend ld operator *(vec A , vec B){return A.x * B.x + A.y * B.y;}
	friend ld operator %(vec A , vec B){return A.x * B.y - A.y * B.x;}
	friend vec operator *(vec A , ld B){return vec(A.x * B , A.y * B);}
	ld len(){return sqrt(x * x + y * y);}
	ld len2(){return x * x + y * y;}
	ld angle(){return atan2(y , x);}
};

struct segment{
	vec st , ed , dir;
	segment(vec _a = vec() , vec _b = vec()) : st(_a) , ed(_b) , dir(_b - _a){}
	friend bool havesect(segment A , segment B){
		ld P = A.st.x , Q = A.ed.x , X = B.st.x , Y = B.ed.x;
		if(Q < P) swap(P , Q);
		if(Y < X) swap(X , Y);
		if(X - eps > Q || P - eps > Y) return 0;
		P = A.st.y , Q = A.ed.y , X = B.st.y , Y = B.ed.y;
		if(Q < P) swap(P , Q);
		if(Y < X) swap(X , Y);
		if(X - eps > Q || P - eps > Y) return 0;
		return
			((B.st - A.st) % A.dir) * (A.dir % (B.ed - A.st)) > -eps &&
			((B.st - A.ed) % A.dir) * (A.dir % (B.ed - A.ed)) > -eps &&
			((A.st - B.st) % B.dir) * (B.dir % (A.ed - B.st)) > -eps &&
			((A.st - B.ed) % B.dir) * (B.dir % (A.ed - B.ed)) > -eps;
	}
	friend vec getsect(segment A , segment B){
		ld t = ((A.st - B.st) % B.dir) / (B.dir % A.dir);
		return A.st + (A.dir * t);
	}
	ld len(){return dir.len();}
	ld len2(){return dir.len2();}
};

ld dist(vec P , segment seg){//minimum dist from a point to a segment
	ld T = ((P - seg.st) * seg.dir) / seg.len2();
	if(T < 0) return (seg.st - P).len();
	else if(T > 1) return (seg.ed - P).len();
	else return (seg.st + (seg.dir * T) - P).len();
}

vec getvec(){ld x , y; cin >> x >> y; return vec(x , y);}
segment getseg(){vec A = getvec() , B = getvec(); return segment(A , B);}

int main(){
	int Q;
	for(cin >> Q ; Q ; --Q){
		segment P = getseg() , Q = getseg();
		if(havesect(P , Q)) cout << 0 << endl;
		else
			cout << fixed << setprecision(10) << min(min(dist(P.st , Q) , dist(P.ed , Q)) , min(dist(Q.st , P) , dist(Q.ed , P))) << endl;
	}
	return 0;
}



Measured memory_bytes: 3268
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstdint>

int main() {
  int N;
  std::int64_t K;
  std::cin >> N >> K;
  std::vector<int> P(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> P[i];
    --P[i];
  }
  std::vector<std::int64_t> C(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> C[i];
  }
  std::vector<int> periods(N);
  std::vector<std::int64_t> scores(N);
  for (int i = 0; i < N; ++i) {
    if (periods[i] > 0) continue;
    periods[i] = 1;
    scores[i] = C[i];
    for (auto current = P[i]; current != i; current = P[current]) {
      ++periods[i];
      scores[i] += C[current];
    }
    for (auto current = P[i]; current != i; current = P[current]) {
      periods[current] = periods[i];
      scores[current] = scores[i];
    }
  }
  std::int64_t max_score = std::numeric_limits<std::int64_t>::lowest();
  for (int i = 0; i < N; ++i) {
    std::int64_t score = 0;
    for (int j = 1, current = i; j <= periods[i]; ++j) {
      if (j > K) break;
      current = P[current];
      score += C[current];
      max_score = std::max(max_score, score + (K - j) / periods[i] * std::max<std::int64_t>(0, scores[i]));
    }
  }
  std::cout << max_score << std::endl;
  return 0;
}


Measured memory_bytes: 3756
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int a,b;
    cin>>a>>b;
    cout<<(a+b)/2+((a+b)%2)<<endl;

    return 0;
}


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

int find_max(vector<int> &h) {
    int max_h = 0;
    int max_index = 0;
    for(int i = 0; i < h.size(); i++) {
        if(max_h < h.at(i)) {
            max_h = h.at(i);
            max_index = i;
        }
    }
    return max_index;
}

int main() {
    int N;
    cin >> N;
    vector<int> h(N);
    for(int i = 0; i < N; i++) {
        cin >> h.at(i);
    }

    int ans = 0;
    while(true) {
        int max_index = find_max(h);
        int max_h = h.at(max_index);
        if(max_h == 0) {
            break;
        }
        int l = max_index;
        int r = max_index;
        while(l >= 0 && h.at(l) == max_h) {
            l--;
        }
        while(r < N && h.at(r) == max_h) {
            r++;
        }
        int next = 0;
        if(l >= 0) {
            next = h.at(l);
        }
        if(r != N) {
            next = max(next, h.at(r));
        }

        int sub = max_h - next;
        for(int i = l + 1; i <= r - 1; i++) {
            h.at(i) -= sub;
        }
        ans += sub;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/*
 * @Author       : nonameless
 * @Date         : 2020-09-19 20:07:49
 * @LastEditors  : nonameless
 * @LastEditTime : 2020-09-19 20:09:15
 */
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define sz(x) (int)x.size()
#define toStr(name) (#name)
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
const double eps = 1e-6;
const double PI  = acos(-1.0);
const int INF = 0x3f3f3f3f;
const ll LNF  = 0x3f3f3f3f3f3f3f3f;
inline int gcd(int a, int b) { return b ? gcd(b,a % b):a;}
inline ll  gcd(ll  a, ll  b) { return b ? gcd(b,a % b):a;}
inline int lcm(int a, int b) { return a * b / gcd(a, b); }

template<class T>
inline void read(T &x){
    x = 0;
    int f = 1;
    char c = getchar();
    while(c < '0' || c > '9')   { if(c == '-') f = -1;  c = getchar(); }
    while(c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); }
    x = x * f;
}

template<class T>
inline void out(string a, T x){ cout << a << " = " << x << endl; }


int main(){

    int n; cin >> n;
    ll ans = 0;
    for(int a = 1; a <= n; a ++)
        for(int b = 1; b <= n / a; b ++){
            int t = a * b;
            if(n - t > 0) ans ++;
        }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
set<pair<pair<int,int>,int>> s;
int main() {
    long long a,b,c;
    cin >>a>>b>>c;

    if(a%2 || b%2 || c%2)
        cout<<"0";
    else {
        for(int i=1;; i++) {
            long long x = b/2 + c/2;
            long long y = a/2 + c/2;
            long long z = a/2 + b/2;
            a=x;
            b=y;
            c=z;
            if(a%2 || b%2 || c%2) {
                cout<<i;
                break;
            }
            if(s.find({{a,b},c}) != s.end()) {
                cout<<"-1";
                break;
            }

            s.insert({{a,b},c});
            }
        }
    }


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstring>
#include <queue>
using namespace std;
double s;
int n,m,set[11000];
struct point
{
    double x,y;
}p[11000];
struct edge
{
    int x,y;
    double w;
}e[510000];
bool cmp(const struct edge &a,const struct edge &b){return b.w<a.w;}
double dis(point&a,point&b)
{
    return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
int findset(int x)
{
    if(x!=set[x]) set[x]=findset(set[x]);
    return set[x];
}
void unionset(int x,int y)
{
    int fx=findset(x),fy=findset(y);
    if(fx!=fy) set[fx]=fy;
}
void Krusal()
{
    for(int i=0;i<=n;i++) set[i]=i;
    sort(e,e+m,cmp);
    for(int i=0;i<m;i++)
    {
        int a=findset(e[i].x),b=findset(e[i].y);
        if(a==b) continue;
        s-=e[i].w;
        unionset(a,b);
    }
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++) scanf("%lf%lf",&p[i].x,&p[i].y);
    s=0.0;
    for(int i=0;i<m;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        u--;v--;
        e[i].x=u;e[i].y=v;
        e[i].w=dis(p[u],p[v]);
        s+=e[i].w;
    }
    Krusal();
    printf("%.3lf",s);
    return 0;
}

Measured memory_bytes: 3600
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

constexpr int INF = 100000007;

int dfs(vector<vector<int>> &dist, vector<vector<int>> &dp, int V, int S, int v) {

    if (dp[S][v] >= 0) return dp[S][v];

    if (S == (1 << V) - 1 && v == 0) return dp[S][v] = 0;

    int ans = INF;
    for (int u = 0; u < V; u++) {
        if (!(S & (1 << u))) {
            ans = min(ans, dfs(dist, dp, V, S | (1 << u), u) + dist[v][u]);
        }
    }
    return dp[S][v] = ans;
}

int main() {

    int V, E;
    cin >> V >> E;

    auto dist = vector<vector<int>>(V, vector<int>(V, INF));
    for (int i = 0; i < E; i++) {
        int s, t, d;
        cin >> s >> t >> d;
        dist[s][t] = d;
    }

    auto dp = vector<vector<int>>(1 << V, vector<int>(V, -1));
    int ans = dfs(dist, dp, V, 0, 0);

    cout << (ans == INF ? -1 : ans) << endl;

    return 0;
}















































Measured memory_bytes: 6152
#include<stdio.h>
int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if (a<b)
    printf("a < b\n",a,b);
    if (a>b)
    printf("a > b\n",a,b);
    if (a==b)
    printf("a == b\n",a,b);
    return 0;

}

Measured memory_bytes: 2728
#include<cstdio>
#include<algorithm>
#define rep(i,s,t) for(register int i=s;i<=t;++i)
#define _rep(i,s,t) for(register int i=s;i>=t;--i)
using namespace std;
const int N=1e6+11,inf=2147483647,mod=1e9+7;
int a[N],w[N],mn[N],fac[N],ifac[N],cnt[N];
int n,x,y,m,t=inf,ans,num;
inline int fp(int a,int b){
	int res=1;
	for(;b;b>>=1,a=1ll*a*a%mod)
		if(b&1)
			res=1ll*res*a%mod;
	return res;
}
inline int C(int n,int m){
	return 1ll*fac[n]*ifac[n-m]%mod*ifac[m]%mod;
}
int main(){
	scanf("%d%d%d",&n,&x,&y);
	fac[0]=1;
	rep(i,1,n)
		fac[i]=1ll*i*fac[i-1]%mod;
	ifac[n]=fp(fac[n],mod-2);
	_rep(i,n,1)
		ifac[i-1]=1ll*i*ifac[i]%mod;
	rep(i,1,n)
		mn[i]=inf;
	rep(i,1,n){
		scanf("%d%d",a+i,w+i);
		mn[a[i]]=min(mn[a[i]],w[i]);
		++cnt[a[i]];
	}
	m=1;
	rep(i,1,n)
		if(mn[i]<mn[m])
			m=i;
	rep(i,1,n)
		if(m!=i&&t>mn[i])
			t=mn[i];
	rep(i,1,n){
        if(w[i]!=mn[a[i]]&&w[i]+mn[a[i]]<=x)continue;
        if(a[i]!=m&&w[i]+mn[m]<=y)continue;
        if(a[i]==m&&w[i]+t<=y)continue;
        --cnt[a[i]];
    }
    num=cnt[m];
    rep(i,1,n)
        if(mn[i]!=inf&&i!=m)
            if(mn[i]+mn[m]<=y)
				num+=cnt[i];
    ans=1;
    rep(i,1,n)
        if(mn[i]!=inf&&(i==m||mn[i]+mn[m]<=y)){
            ans=1ll*ans*C(num,cnt[i])%mod;
            num-=cnt[i];
        }
    printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 19456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int N; cin >> N;
    cout << N*(N+1)/2 << endl;
}

Measured memory_bytes: 256
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v, yes="Yes", no="No"):
    print([yes, no][not v])


def main():
    """エントリーポイント"""
    N = input(int)
    A = input([int, N])
    yesno(all([a % 2 == 1 or (a % 3 == 0 or a % 5 == 0)
               for a in A]), "APPROVED", "DENIED")


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}

int main() {
    ll N;
    string S;
    cin >>S;
    N=S.size();

    vector<vector<ll>>dp(N+1,vector<ll>(13));
    dp[0][0]=1;
    rep(i,N){
        rep(j,13){
            if(S[i]=='?'){
                rep(k,10){
                     dp[i+1][(j*10+k)%13] = (dp[i+1][(j*10+k)%13]+dp[i][j])%mod;
                }
            }else{
                ll num=ctoi(S[i]);
                dp[i+1][(j*10+num)%13] = (dp[i+1][(j*10+num)%13]+dp[i][j])%mod;
            }
        }
        
    }
    
    cout << dp[N][5] << endl;


    return 0;
    

}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/21  Problem: ABC 056 A / Link: http://abc056.contest.atcoder.jp/tasks/abc056_a  ----- */


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

	char a, b; cin >> a >> b;

	LL ans = a == b;


	cout << (ans?"H":"D") << "\n";

	return 0;
}


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

int main()
{
  int a = 0, b = 0, c = 0;
  int total = 0;
  
  cin >> a >> b >> c;
  
  total = a+b+c;
  if(total==17 && a%2!=0 && b%2!=0 && c%2!=0)
    cout << "YES";
  else
    cout << "NO";
}

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

typedef long long ll;
#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define llrep(i,n)   for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prt_dbl(i,var) cout<<fixed<<setprecision(i)<<var<<endl;

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

int main(){
  int N,ans,min;
  cin>>N;
  vector<int> h(N);
  ans = 0;
  min = 100;
  rep(i,N){
    cin>>h.at(i);
    if(min>h.at(i))min=h.at(i);
  }
  ans += min;
  rep(i,N){
    h.at(i) -= min;
  }
  int f = 0;
  int bef = 100;
  while(1){
    rep(i,N){
      if(i==0&&h.at(i)!=0){
        ans++;
        f = 1;
      }else if(i!=0&&bef==0&&h.at(i)>0){
        ans++;
        f = 1;
      }else if(h.at(i)==0){
        f = 0;
      }
      bef = h.at(i);
      if(f == 1){
        h.at(i)--;
      }
    }

  int sum = 0;
  rep(i,N){
    sum += h.at(i);
  }
  if(sum==0)break;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
int main () {
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(n*a, b);
}


Measured memory_bytes: 256