akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
	
	public Main() {
		FastScanner scanner = new FastScanner();
		int N = scanner.nextInt();
		int X = scanner.nextInt();
		int T = scanner.nextInt();
		
		System.out.println( (N+X-1)/X*T );
	}
	
	public static void main(String[] args) {
		new Main();
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	
	private int readByte() {
		if (hasNextByte()) return buffer[ptr++];
		else return -1;
	}
	
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
		return hasNextByte();
	}
	
	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	
	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}
	
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 32400
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>
using namespace std;

typedef long long ll;
typedef string S;
typedef pair<int,int> P;
typedef vector<int> vi;
const int mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n),b(n);
    vector<P> pairs(n);
    for(int i=0;i<n;i++){
        cin >> a[i] >> b[i];
        pairs[i].first=a[i]+b[i];
        pairs[i].second=i;
    }
    sort(pairs.begin(),pairs.end());
    reverse(pairs.begin(),pairs.end());
    ll resT=0,resA=0;
    for(int i=0;i<n;i++){
        if(i%2==0){
            resT+=a[pairs[i].second];
        }else{
            resA+=b[pairs[i].second];
        }
    }
    cout << resT-resA << endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main{
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int count = 0;
		for(int i = 1 ; i <= N; i++) {
			if(String.valueOf(i).length() % 2 == 1)count++;
		}

		System.out.println(count);

	}
}

Measured memory_bytes: 26324
#include <stdio.h>

int main(void){

  int n;
  scanf("%d", &n);
  char s[n+1];
  scanf("%s", s);
  int red = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'R') {
      red++;
    }
  }
  if (red*2 > n) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}

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

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

  vector<string> v;
  for (int i=0; i<s.size(); i++) {
    for (int j=0; j<5; j++) {
      if (i+j > s.size()) continue;
      v.push_back(s.substr(i, j+1));
    }
  }

  sort(v.begin(), v.end());
  unique(v.begin(), v.end());
  cout << v[k-1] << endl;

  return 0;
}


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

int main(){
  int A,B,C;
  cin>>A>>B>>C;
  if(A==B){
    cout<<C<<endl;
  }else if(B==C){
    cout<<A<<endl;
  }else{
    cout<<B<<endl;
  }
}


Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    char r, g, b;
    scan(r, g, b);
    string s = [r, g, b];
    writeln((s.to!long % 4 == 0) ? "YES" : "NO");
}


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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vll = V<ll>;
using VVll = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

const double PI = acos(-1);
const ll MOD = 1e9+7;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

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

    V<Pii> v(n);
    REP(i, n) {
        int a, b;
        cin >> a >> b;
        v[i] = make_pair(a, b);
    }

    Vi dp(h+1, 1e9);
    dp[0] = 0;
    REP(i, n) {
        int a = v[i].first, b = v[i].second;
        REP2(j, 1, h+1) {
            if (j < a) {
                dp[j] = min(dp[j], b);
            } else {
                dp[j] = min(dp[j], dp[j-a] + b);
            }
        }
    }

    std::cout << dp[h] << '\n';


    return 0;
}


Measured memory_bytes: 256
import bisect,collections,copy,itertools,math,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
N = I()
A = LI()
_123 = [0]*N
_123count = [0]*N
for x in A:
    _123[x-1] += 1
_123copy = copy.copy(_123)
_123copy.sort(reverse=True)
_count = {}
for i,x in enumerate(_123copy):
    if x==0:
        break
    if x==1:
        _123count[i] = 0
    elif i!=0 and _123copy[i]==_123copy[i-1]:
        _123count[i] = _123count[i-1]
    else:
        _123count[i] = math.factorial(x)//((math.factorial(x-2))*(math.factorial(2)))
        _count[x] = _123count[i]
_sum = sum(_123count)
for x in A:
    temp = _123[x-1]-1
    if temp<=0:
        print(_sum)
    elif temp==1:
        print(_sum-1)
    else:
        if (temp+1) in _count:
            tempminus = _count[temp+1]
        else:
            tempminus = math.factorial(temp+1)//((math.factorial(temp-1))*(math.factorial(2)))
            _count[temp+1] = tempminus
        if (temp) in _count:
            tempplus = _count[temp]
        else:
            tempplus = math.factorial(temp)//((math.factorial(temp-2))*(math.factorial(2)))
            _count[temp] = tempplus
        print(_sum-tempminus+tempplus)


Measured memory_bytes: 121264
PROGRAM main
  implicit none
  integer(8) :: N
  integer(8) :: j
  
  read *, N
  
  do j = int(sqrt(dble(N))) +1, 1, -1
    if(mod(N,j) == 0)then
      print "(i0)", max(int(log10(dble(j))), int(log10(dble(N/j))))+1
      exit
    endif
  enddo

END PROGRAM main

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;


const ll MM = 1e9 + 7;
int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for(ll &i:A)cin >> i;
    ll sum =0,count=0;
    vector<ll> B(N);
    
    for(ll j=N-1;j>=0;j--){
      //  cout << j << endl;
        sum += A[j]%MM;
        sum %= MM;
        B[j]=sum;
        
    }
    
    for(ll i=0;i<N-1;i++){
        count += (A[i]*B[i+1])%MM;
        count %= MM;
       
    }
    
   cout << count << endl;
}


Measured memory_bytes: 6212
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<double> v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  if(n==2){
    cout<<(v[0]+v[1])/2.0<<endl;
    return 0;
  }
  sort(v.begin(),v.end());
  double ans=(v[0]+v[1])/2.0;
  for(int i=0;i<n-2;i++){
    ans=(ans+v[i+2])/2.0;
  }
  cout<<ans<<endl;
}

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

int main() {
  int n; ll k;
  cin >> n >> k;
  vector<int> p(n);
  vector<ll> c(n);
  rep(i,0,n) {cin >> p[i]; p[i]--;}
  rep(i,0,n) cin >> c[i];
  vector<P> a(n);
  rep(i,0,n) {
    int t = i;
    int j = 0;
    while(true) {
      t = p[t];
      a[i].first += c[t];
      j++;
      if (t == i) break;
    }
    a[i].second = j;
  }
  ll ans = -1000000000000010000;
  rep(i,0,n) {
    ll t = 0;
    if (a[i].second < k) {
      if (a[i].first > 0) {
        ll r = k/a[i].second;
        t += a[i].first * r;
        ans = max(ans,t);
        int s = i;
        rep(j,0,k % a[i].second) {
          s = p[s];
          t += c[s];
          ans = max(t,ans);
        }
        t = a[i].first * (r-1);
        s = i;
        rep(j,0,a[i].second) {
          s = p[s];
          t += c[s];
          ans = max(t,ans);
        }
      } else {
        int s = i;
        rep(j,0,a[i].second) {
          s = p[s];
          t += c[s];
          ans = max(t,ans);
        }
      }
    } else {
      int s = i;
      rep(j,0,k) {
        s = p[s];
        t += c[s];
        ans = max(t,ans);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3768
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.AGC_Challenge
{
    class _004_A
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int[] abc = ReadInts();
            Array.Sort(abc);
            long a = abc[0];
            long b = abc[1];
            long c = abc[2];
            if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
            {
                Console.WriteLine(0);
                return;
            }
            else
            {
                long res = a * b;
                Console.WriteLine(res);
            }
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

int n;
ll m;

bool isok(vector<int>& a,int x) {
    ll sum = 0;
    rep(i,n) {
        sum += n - (lower_bound(a.begin(),a.end(),x-a[i]) - a.begin());
    }
    return sum >= m;
}



int main() {
    cin >> n >> m;
    vector<int>a(n);
    rep(i,n) cin >> a[i];
    vector<ll>s(n+1);
    sort(a.begin(),a.end());
    rep(i,n) {
        s[i+1] = s[i] + a[i];
    }
    int ok = 0;int ng = 200010;
    while(ng - ok > 1) {
        int mid = (ok+ng)/2;
        if(isok(a,mid)) ok = mid;
        else ng = mid;
    }
    // cout << ok << endl;
    ll ans = 0;
    ll cnt = m;
    rep(i,n) {
        ll pos = (lower_bound(a.begin(),a.end(),ok-a[i])-a.begin());
        // cout << pos << endl;
        ans += a[i] * (n- pos);
        ans += s[n] - s[pos];
        cnt -= (n-pos);
    }
    // cout << cnt << endl;
    ans += cnt*ok;
    cout << ans << endl;
}

    




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

int main(){
	int x, y;
	
	while(1){
		cin >> x >> y;
		if ( x == 0 && y == 0){
			break;
		}
		if(x < y){
			cout << x << " " << y << endl;
		}else{
			cout << y << " " << x << endl;
		}
	}
	
	return 0;	
}

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

int N;
int K;
int h[1000000];

int main(){
    cin >> N;
    cin >> K;
    for(int i = 0;i < N;i++) {
        cin >> h[i];
    }

    // ソートする
    sort(h,h + N);

    int diffirence = h[K - 1] - h[0];

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

        if(i + K >= N) break;
    }

    cout << diffirence << endl;


}

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

int main(){
    int n, a, b, c, i , ans[10000];
    while(1){
        scanf("%d", &n);
        if(n == 0) break;
        for(i = 0; i < n; i++){
            ans[i] = 0;
            scanf("%d %d %d", &a, &b, &c);
            if((a == 100 || b == 100 || c == 100) || (a + b) / 2 >= 90 || (a + b + c) / 3 >= 80) ans[i] = 2;
            else{
                if((a + b + c) / 3 >= 70 || ((a + b + c) / 3 >= 50 && a >= 80) || ((a + b + c) / 3 >= 50 && b >= 80)) ans[i]++;
            }
        }
       for(i = 0; i < n; i++){
            if(ans[i] > 1) printf("A\n");
            if(ans[i] == 1) printf("B\n");
            if(ans[i] == 0) printf("C\n");
       }
    }
    return 0;
}

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

void get_intint(char *line, int size, int *a1, int *a2) {
  if(!fgets(line, size, stdin)) return;
  sscanf(line, "%d %d", a1, a2);
}

#define BUF_SIZE 20


struct problem {
  int point;
  int bonus;
  int cnt;
  int sum;
};

int solve_min(struct problem* probs, int grades, int goal) {
  int mincnt = INT_MAX;
  int i, j;
  for(i = 0; i < (1<<grades); i++) {
    int sum = 0;
    int tmpcnt = 0;
    // get bonus
    for(j = 0; j < grades; j++) {
      int flag = !!(i & (1<<j));
      tmpcnt += probs[j].cnt*flag;
      sum += probs[j].sum*flag;
    }
    if(tmpcnt > mincnt) continue; // skip
    if(sum >= goal) {
      mincnt = tmpcnt;
      continue;
    }
    // append reminder
    for(j = grades-1; j >= 0; j--) {
      int flag = !!(i & (1<<j));
      if(flag) continue; // it would get bonus twice
      int rem = (goal-sum+probs[j].point-1) / probs[j].point;
      if(rem >= probs[j].cnt) continue;
      tmpcnt += rem;
      if(mincnt > tmpcnt) mincnt = tmpcnt;
      break;
    }
  }
  return mincnt;
}

int main(void) {
  int grade, total_score;
  char line[BUF_SIZE];
  get_intint(line, BUF_SIZE, &grade, &total_score);

  struct problem probs[10];

  int i, j;
  int max_cnt = 0;
  for(i = 0; i < grade; i++) {
    int cnt, bonus;
    get_intint(line, BUF_SIZE, &cnt, &bonus);
    probs[i].cnt = cnt;
    probs[i].bonus = bonus;
    probs[i].point = (i+1)*100;
    probs[i].sum = probs[i].point * probs[i].cnt + bonus;
    max_cnt += probs[i].cnt;
  }

  int res = solve_min(probs, grade, total_score);
  printf("%d\n", res);
}

Measured memory_bytes: 128
#!/usr/bin/env ruby
# require 'pry'

gets
ary = gets.split(' ').map(&:to_i)
num = (ary.include?(0)) ? 0 : 1

ary.each do |ele|
  break if num == 0 || num > 10**18
  num *= ele
end

puts (num > 10**18) ? '-1' : num


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

int64_t F(int64_t N){
  int64_t M = (N+1)/2;

  if((N+1) % 2 == 0){
    if(M % 2 == 0) return 0;
    else return 1;
  } else {
    if(M % 2 == 0) return N ^ 0;
    else return N ^ 1;
  }
}

int main(){
  int64_t A, B;
  cin >> A >> B;

  //cout << F(B) << " " << F(A) << endl; 
  cout << (F(B) ^ F(A-1)) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map> // pair
using namespace std;
int main(){
  vector<int> A={1,3,5,7,8,10,12};
  vector<int> B={4,6,9,11};
  int x,y;
  cin>>x>>y;
  string ans="No";
  int count=0;
  for(int i=0;i<A.size();i++){
    if(A.at(i)==x||A.at(i)==y)count++;
    if(count==2)ans="Yes";
  }
  count=0;
  for(int i=0;i<B.size();i++){
    if(B.at(i)==x||B.at(i)==y)count++;
    if(count==2)ans="Yes";
  }
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <numeric>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

// namespace
using namespace std;
namespace mp = boost::multiprecision;

// types
using pii = pair<int, int>;
using ll = long long int;
using ld = long double;
using mpi = mp::cpp_int;
using mpf = mp::number<mp::cpp_dec_float<1024>>;

// consts
int MOD = 1000000007;  // https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a


int main() {
    int n, a;
    map<int, int> m;
    cin >> n;
    for (int i = 2; i <= n; ++i) {
        cin >> a;
        m[a]++;
    }
    for (int i = 1; i <= n; ++i) {
        cout << m[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 13012
import java.util.Scanner;

public class Main {
    public static int islandsNum;
    public static int maxWidth;
    public static int maxHeight;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        while (true) {
            // ???width
            maxWidth = sc.nextInt();
            // ??????height
            maxHeight = sc.nextInt();
            if (maxWidth == 0 && maxHeight == 0)
                break;

            int[][] map = scanMap(maxWidth, maxHeight, sc);

            islandsNum = 0;
            countIslands(map);
            System.out.println(islandsNum);
        }
        sc.close();
    }

    // ??°???????????????????´?????????¢??°
    public static int[][] scanMap(int w, int h, Scanner sc) {
        int[][] returnMap = new int[h][w];
        for (int i = 0; i < returnMap.length; i++) {
            for (int j = 0; j < returnMap[i].length; j++) {
                returnMap[i][j] = sc.nextInt();
            }
        }
        return returnMap;
    }

    // ??°????????¶(?????????????´????1)?????????????????¢?´¢
    public static void countIslands(int[][] map) {
        for (int i = 0; i < map.length; i++) {
            for (int j = 0; j < map[i].length; j++) {
                if (map[i][j] == 1) {
                    islandsNum++;
                    deleteIsland(map, i, j);
                }
            }
        }
    }

    public static void deleteIsland(int[][] map, int h, int w) {
        // ??¢?´¢??????8??????????¨????
        int[] x = { -1, -1, -1, 0, 1, 1, 1, 0 };
        int[] y = { -1, 0, 1, 1, 1, 0, -1, -1 };

        // countIslands??§?????????????????£???????´????0?????????
        map[h][w] = 0;

        for (int i = 0; i < 8; i++) {
            boolean boundCheckFlag = (0 <= h + x[i] && h + x[i] < maxHeight
                    && 0 <= w + y[i] && w + y[i] < maxWidth);
            if (boundCheckFlag && map[h + x[i]][w + y[i]] == 1) {
                deleteIsland(map, h + x[i], w + y[i]);
            }
        }

    }

    // ??°????????¨???????????¢??°
    // public static void showMap(int[][] map) {
    // for (int i = 0; i < map.length; i++) {
    // for (int j = 0; j < map[i].length; j++) {
    // System.out.print(map[i][j] + " ");
    // }
    // System.out.println();
    // }
    // }
}

Measured memory_bytes: 51676
import java.util.*;

import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	int[] Eratosthenes(int n) {
		boolean[] dp = new boolean[n+1];
		dp[0] = dp[1] = true;
		List<Integer> prime = new LinkedList<Integer>();
		for (int i = 2; i <= n; i++) {
			if (dp[i]) continue;
			prime.add(i);
			for (int j = i + i; j <= n; j += i) 
				dp[j] = true;
		}
		
		int[] ret = new int[prime.size()];
		int count = 0;
		for (int num : prime)
			ret[count++] = num;
		
		return ret;
	}
	
	void run() {
		int n, p;
		int[] prime = Eratosthenes(200275);
		List<Integer> list = new ArrayList<Integer>();
		while (true) {
			n = sc.nextInt();
			p = sc.nextInt();
			if (n == -1) return;
			int index = 0;
			while (prime[index] <= n) index++;
			list.clear();
			for (int i = index; i < index+100; i++) {
				for (int j = i; j < index+100; j++) {
					list.add(prime[i]+prime[j]);
				}
			}
			Collections.sort(list);
			out.println(list.get(p-1));
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 66792
N, M = map(int, input().split())

tmp1, tmp2 = 0, 10**5

for i in range(M):
    L, R = map(int, input().split())
    tmp1, tmp2 = max(L, tmp1), min(R, tmp2)


if tmp2-tmp1 >= 0:
    print(tmp2-tmp1+1)
else:
    print(0)





Measured memory_bytes: 3060
xy = [list(map(int,input().split())) for _ in range(3)]

angle = [0]*3
import numpy as np
import math
ans = 0
for i in range(3):
    cnt = 0
    a = [[0,0] for _ in range(2)]
    for j in range(3):
        if j==i:continue
        a[cnt] = [xy[j][0]-xy[i][0],xy[j][1]-xy[i][1]]
        cnt += 1
    val = (a[0][0]*a[1][0] + a[0][1]*a[1][1]) / (np.sqrt(a[0][0]**2 + a[0][1]**2)*np.sqrt(a[1][0]**2 + a[1][1]**2))
    theta = math.acos(val)
    angle[i] = theta/2
    
idx = [[1,2],[0,2],[0,1]]

for i in range(3):
    c = [xy[idx[i][0]][0] - xy[idx[i][1]][0],xy[idx[i][0]][1] - xy[idx[i][1]][1]]
    L = np.sqrt(c[0]**2 + c[1]**2)
    tmp = 0
    for j in range(3):
        if i==j:continue
        tmp += 1/np.tan(angle[j])
    r = L / (2 + tmp)
    ans = max(ans,r)
print(ans)

Measured memory_bytes: 12504
import sys

input = sys.stdin.readline


def main():
    h, w, n = map(int, input().split())
    y, x = map(int, input().split())
    y -= 1
    x -= 1
    s, t = input().rstrip(), input().rstrip()

    u, d, l, r = 0, h - 1, 0, w - 1

    for ss, tt in zip(s[::-1], t[::-1]):
        if tt == 'U':
            d = min(d + 1, h - 1)
        elif tt == 'D':
            u = max(u - 1, 0)
        elif tt == 'L':
            r = min(r + 1, w - 1)
        else:
            l = max(l - 1, 0)  # tt == 'R'

        if ss == 'U':
            u += 1
        elif ss == 'D':
            d -= 1
        elif ss == 'L':
            l += 1
        else:
            r -= 1  # ss == 'R'

        if l > r or u > d:
            print('NO')
            return

    if l <= x <= r and u <= y <= d:
        print('YES')
        return
    else:
        print('NO')
        return


if __name__ == '__main__':
    main()

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

int main() {
  int k, a, b;
  cin >> k >> a >> b;

  if ((b-a) >= k){
    cout << "OK" << endl;
  }
  
  if ((b-a) < k){
    if ( (a % k) == 0 ) {
      cout << "OK" << endl;
    }
    else if ( (b % k) ==0 ){
      cout << "OK" << endl;
    }
    else if ((a % k) <= (b % k)) {
      cout << "NG" << endl;
    }
    else {
      cout << "OK" << endl;
    }
  }
}



Measured memory_bytes: 3632
// In the Name of Allah
#include<bits/stdc++.h>
#define bp(i) __builtin_popcount(i)
#define double long double
typedef long long ll;
const ll MAX_N = 1e5+100;
const ll MOD = 1e9+7;
using namespace std;

int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int s = ceil(a/(double)d);
    int t = ceil(c/(double)b);
    if (t>s)
        cout << "No";
    else
        cout << "Yes";
    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;

const int MAX_N = int(1e6) + 10;


struct fenwick{
  int lim;
  int *tree;
  fenwick(int _lim){
      lim=_lim;
      tree=new int[lim];
  }
  void init(){
    for(int i=0;i<lim;i++){
      tree[i]=0;
    }
  }
  void update(int x){
    while(x<lim){
      tree[x]+=1;
      x+=x&(-x);
    }
  }
  int query(int x){
    int ans=0;
    while(x>0){
      ans+=tree[x];
      x-=x&(-x);
    }
    return ans;
  }
  int _query(int k){
    int low=1;
    int high=500000;
    int ans=0;int x=k;
    while(low<=high){
      int mid=low+(high-low)/2;
      if(query(mid)>=x){
        ans=mid;
        high=mid-1;
      }else{
        low=mid+1;
      }
    }
    return ans;
  }
};
int a[500005];
int main() {

  int n;
  cin>>n;

  long long int sum=0;
  sum+=(n-1)*1LL*n/2LL;cout<<sum;


   return 0;
}
   


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <climits>
#include <vector>
using namespace std;
typedef pair<pair<int,int>,int> NODE;
#define cost first.first
#define ticket first.second 
#define pos second
#define ppp(a,b,c) make_pair(make_pair(a,b),c)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<21)

int info[100][100];
int n;

int dijk(int a,int b,int c){
	priority_queue<NODE,vector<NODE>,greater<NODE> > que;
	int memo[100][11];
	rep(i,100)rep(j,11)memo[i][j] = INF;
	//rep(j,11)memo[a][j] = 0;
	
	que.push(ppp(0,c,a));
	while( !que.empty() ){
		NODE q = que.top();que.pop();
		
		if(memo[q.pos][q.ticket]<=q.cost)continue;
		
		if(q.pos == b)return q.cost;
		
		memo[q.pos][q.ticket] = q.cost;
		
		for(int i=0;i<n;i++){
			que.push(ppp(info[q.pos][i]+q.cost ,q.ticket,i));
			if(q.ticket)que.push(ppp(info[q.pos][i]/2+q.cost ,q.ticket-1,i));

		}
	}
	
	/*ツ個ゥツづつつゥツづァツづ按つゥツづつス*/
	return -1;
}
int main(){
	int c,m,s,d,a,b,f;
	while(cin >> c >> n >> m >> s >> d ,c ){
		s--;d--;
		rep(i,100)rep(j,100)info[i][j]=INF*2;
		
		for(int i=0;i<m;i++){
			cin >> a >> b >> f;
			a--;b--;
			info[a][b] = info[b][a] = f;
		}
		cout << dijk(s,d,c) << endl;
	}
}

Measured memory_bytes: 1904
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

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

#include <iostream>

using namespace std;

int main()
{
   long long int N,K;
   cin>>N>>K;
   
   if(N%K==0)
   {
       cout<<0<<endl;
   }
   else
   {
      
      if(N>K)
      {
          if((N%K)>(K/2))
          {
              cout<<abs((N%K)-K)<<endl;
          }
          else
          {
              cout<<N%K<<endl;
          }
      }
      else
      {
          if(N<=(K/2))
          {
              cout<<N<<endl;
          }
          else
          {
              cout<<abs(N-K)<<endl;
          }
      }
      
       
   }
   

    return 0;
}


Measured memory_bytes: 256
N = input() + 1
for val in range(1,N):
	c = 0
	x = map(int,raw_input().split(' '))
	a = x[0]
	b = 0
	for n in range(1,10):
		if b > a:
			e = a
			d = b
			a = d
			b = e
		else:
			pass
		if a < x[n]:
			a = x[n]
		elif a > x[n] and b < x[n]:
			b = x[n]
		elif x[n] < b:
			c += 1
	if c == 0:
		print 'YES'
	else:
		print 'NO'

Measured memory_bytes: 4252
def inp():
	global n
	n = int(input())
	return n
def pos(p, l):
	global w
	if p < 0:
		return -1
	while l > 0 and p < n:
		l -= w[p]
		p += 1
		if l == 0:
			return p
	return -1
while inp() > 0:
	w = []
	for i in range(n):
		w.append(len(input()))
	for i in range(n):
		if pos(pos(pos(pos(pos(i,5),7),5),7),7) >= 0:
			print(i+1)
			break



Measured memory_bytes: 5612
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
struct kazu{
  ll two;
  ll five;
};
int main(){
  ll n;
  cin >> n;
  ll res = 0;
  vector<pair<ll,kazu>> a(n);
  for(int i = 0;i < n;i++){
    string ins;
    cin >> ins;
    a[i].second = {0,0};
    
    ll mul = 0;
    /*while(1){
      ll memo = (ll)in;
      if((double)memo != in)in *= 10;
      else{
        break;
      }
      mul++;
    }
    cout << (ll)in << endl;*/
    //string ins = to_string(in);
    ll point = -1;
    for(int j = 0;j < (int)ins.size();j++){
      if(ins[j] == '.')point = j;
    }
    ll eraselast = 1000;
    ll erasek = 0;
    if(point != -1){
      for(int j = (int)ins.size() - 1;j >= point;j--){
        //cout << ins[j] << endl;
        if(ins[j] == '0')eraselast = j,erasek++;
        else{
          break;
        }
      }
      if(erasek > 0)ins.erase(eraselast,erasek);//語尾の0を削除
      //cout << ins << endl;
      for(int j = (int)ins.size() - 1;j >= 0;j--){
        if(ins[j] != '.')mul++;//10の何乗倍するか確かめるため
        else{
          ins.erase(j,1);
          break;
        }
      }
      if(mul == 0)res--;
    }
    else res--;//もともと整数の時1つ多く数えられてしまうので引く
    
    //cout << ins << endl;//最終形,整数になっているはず
    ll inl = stoll(ins);
    //cout << "!" << " " << to_string(in) << endl;
    
    a[i].first = mul;//何桁上げるか
    
    //ll inc = (ll)in;
    while(1){
      if(inl % 2 != 0)break;
      a[i].second.two++;
      inl /= 2;
    }
    while(1){
      if(inl % 5 != 0)break;
      a[i].second.five++;
      inl /= 5;
    }
    //cout << 2 << endl;
    //cout << ins << " " << a[i].second.two << " " << a[i].second.five << endl;
    
    a[i].second.two -= a[i].first;
    a[i].second.five -= a[i].first;
    /*while(1){
      //if(a[i].second.two <= 0 || a[i].second.five <= 0)break;
      if(a[i].first <= 0)break;
      a[i].first--;
      a[i].second.two--;
      a[i].second.five--;
    }*/
    
    //cout << ins << " " << a[i].second.two << " " << a[i].second.five << endl;
  }
  
  
  vector<vector<ll>> sum(100,vector<ll>(100));//それぞれ+50されてる
  for(int i = 0;i < 100;i++)for(int j = 0;j < 100;j++)sum[i][j] = 0;
  for(int i = 0;i < n;i++){
    sum[a[i].second.two + 50][a[i].second.five + 50]++;
  }
  
  for(int i = 99;i >= 0;i--){
    for(int j = 99;j >= 0;j--){
      if(i == 99 && j == 99)continue;
      if(j != 99)sum[i][j] += sum[i][j + 1];
      if(i != 99)sum[i][j] += sum[i + 1][j];
      if(i != 99 && j != 99)sum[i][j] -= sum[i + 1][j + 1];
    }
  }

  /*for(int i = 0;i < 40;i++){
    for(int j = 0;j < 40;j++)cout << sum[i][j] << " ";
    cout << endl;
  }*/

  for(int i = 0;i < n;i++){
    //cout << i << " " << sum[a[i].second.two * -1 + 50][a[i].second.five * -1 + 50] << endl;
    //cout << sum[a[i].second.two * -1 + 20][a[i].second.five * -1 + 20];
    res += sum[a[i].second.two * -1 + 50][a[i].second.five * -1 + 50];
  }
  //cout << res << endl;
  res /= 2;//相互なのでわる2
  cout << res << endl;
}

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

using namespace std;
using ll = long long;

int main() {
	int n, m, v, p;
	scanf("%d %d %d %d", &n, &m, &v, &p);
	vector<ll> arr(n);
	for (int i = 0; i < n; ++i) scanf("%lld", &arr[i]);
	sort(begin(arr), end(arr));
	vector<ll> psums(n + 1);
	for (int i = 0; i < n; ++i) psums[i + 1] = psums[i] + arr[i];
	int ans = 0;
	for (int i = 0; i < n; ++i) {
//		printf("checking %d\n", i);
		// can the ith problem be included?
		auto firstExc = upper_bound(begin(arr), end(arr), arr[i] + m);
		int unbeatCt = distance(firstExc, arr.end());
		if (unbeatCt >= p) {
//			printf("%d beats boosted %d\n", unbeatCt, i);
			continue;
		}
		// strat is, we vote for top p - 1 + problem i
		// then ask if we can throw the other votes elsewhere
		auto firstExcUnmod = upper_bound(begin(arr), end(arr), arr[i]);
		if (distance(firstExcUnmod, arr.end()) < p) {
//			printf("%d wins unboosted\n", i);
			++ans;
			continue;
		}
		// now WLOG i is not in the top p - 1 at first
		ll remPerJudge = v - p;
		if (remPerJudge <= 0) {
//			printf("%d wins if boosted right", i);
			++ans;
			continue;
		}
//		printf("%d vpj left\n", remPerJudge);
		// for a problem p such that v_i < v_p <= v_i + m, count v_i + m - v_p
		// for a problem p such that v_p <= v_i, count m
		ll firstExcStart = distance(arr.begin(), firstExcUnmod);
//		printf("fex %lld\n", firstExcStart);
		ll totalFromBetween = psums[n - p + 1] - psums[firstExcStart];
		ll checkCount = (n - p - firstExcStart + 1) * (arr[i] + m) - totalFromBetween; 
		ll totalFromBehind = max(0LL, (firstExcStart - 1) * m);
//		printf("tfbet cc tfbeh %lld %lld %lld\n", totalFromBetween, checkCount, totalFromBehind);
		if (totalFromBehind + checkCount >= m * remPerJudge) {
//			printf("%d wins with check count %lld\n", i, totalFromBehind + checkCount);
			++ans;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1920
import java.util.Scanner;

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

		String S = sc.nextLine();

		String T = sc.nextLine();
		//int T = sc.nextInt();
		int ans = T.length();

		for(int start = 0; start <= S.length() - T.length(); start++) {
			int diff = 0;
			for(int i = 0; i<T.length();i++) {
				if(T.charAt(i) != S.charAt(start+i)) {
					diff++;
				}
			}
			ans = min(ans , diff);
		}

		System.out.print(ans);

    }

	static int min(int x,int y) {
		if(x>y) {
		return y;
		}
		else if(x<y) {
			return x;
		}
		else
			return x;
	}
}



//cabacc
//abc

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

int main() {
	string s;
	cin >> s;
	int n = s.size();
	
	bool isOdd = true;
	string a, b;
	for (int i = 0; i < n; i++) {
		if (isOdd) {
			a += '0';
			b += '1';
			isOdd = false;
		}
		else
		{
			a += '1';
			b += '0';
			isOdd = true;
		}
	}

	int ansa = 0, ansb = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] != a[i]) ansa++;
		if (s[i] != b[i]) ansb++;
	}

	if (ansa > ansb) cout << ansb << endl;
	else cout << ansa << endl;

	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define fi first
#define sz size 
#define len length 
#define se second 
const ll p = 31;
const ll mod = 67280421310721;
const ll N=1000000+6;
#define M_PI           3.14159265358979323846

struct stu{
  ll num_b4, stu;
};
  
bool comp(stu a,stu b){
  return a.num_b4<b.num_b4;
}

int main()

{
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  
   int n;cin>>n;
   stu a[n];
   int s;
   for(int i = 0;i<n;i++){
      cin>>s;
      a[i].num_b4 = s;
      a[i].stu = i;

   }
   sort(a,a+n,comp);
   for(int i = 0;i<n;i++){
    cout<<a[i].stu+1<<" ";
   }
   cout<<'\n';
}

Measured memory_bytes: 2432
n = int(input())
h = list(map(int, input().split()))
dp = [0]*n
dp[1] = abs(h[0]-h[1])
for i in range(2, n):
    dp[i] = min(dp[i-k]+abs(h[i]-h[i-k])for k in (1, 2))
print(dp[-1])


Measured memory_bytes: 13980
// http://koturn.hatenablog.com/entry/2016/02/04/050000#cpp
#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  int A, B;
  cin >> A >> B;
  if (A > B)
  {
    cout << A + A - 1 << endl;
  }
  else if (A < B)
  {
    cout << B + B - 1 << endl;
  }
  else
  {
    cout << A + B << endl;
  }

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  ll n; cin >> n;
  for(int i=1;i<=n-1;++i) {
    for(int j=i+1;j<=n;++j) {
      cout << __builtin_ffs(i^j) << " ";
    }
    cout << endl;
  }
}


Measured memory_bytes: 512
#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 a[500][500];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w;
    cin >> h >> w;
    for (int i = 0; i < h; ++i)
        for (int j = 0; j < w; ++j)
            cin >> a[i][j];

    vector<tuple<int, int, int, int> > sol;
    for (int i = 0; i < h; ++i)
    {
        if (i % 2 == 0)
        {
            for (int j = 0; j < w - 1; ++j)
            {
                if (a[i][j] % 2)
                    a[i][j + 1]++, sol.emplace_back(i, j, i, j + 1);
            }
            if (i != h - 1 && a[i][w - 1] % 2)
                a[i + 1][w - 1]++, sol.emplace_back(i, w - 1, i + 1, w - 1);
        }
        else
        {
            for (int j = w - 1; j > 0; --j)
            {
                if (a[i][j] % 2)
                    a[i][j - 1]++, sol.emplace_back(i, j, i, j - 1);
            }
            if (i != h - 1 && a[i][0] % 2)
                a[i + 1][0]++, sol.emplace_back(i, 0, i + 1, 0);
        }
    }
    cout << sol.size() << '\n';
    for (auto k : sol)
    {
        int a, b, c, d;
        tie(a,b,c,d) = k;
        cout << a + 1 << ' ' << b + 1 << ' ' << c + 1 << ' ' << d + 1 << '\n';
    }
}


Measured memory_bytes: 5232
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp make_pair
#define fi first
#define se second
#define pt(num) cout << num << "\n"
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 100010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;



int main(void) {
    ll N, K;
    cin >> N >> K;
    ll a[111];
    ll dp[101010][2];
    ll i, j;
    memset(dp, -1, sizeof(dp));
    for(i=0; i<N; i++) cin >> a[i];
    sort(a, a+N);
    
    for(i=0; i<=K; i++) {
        dp[i][0]=1;
    }
    
    for(i=0; i<=K; i++) {
        dp[i][1]=0;
    }
    
    for(i=0; i<=K; i++) {
        for(j=0; j<N; j++) {
            if(i>=a[j] && dp[i-a[j]][1]==0) {
                dp[i][0]=0;
                break;
            }
        }
        
        for(j=0; j<N; j++) {
            if(i>=a[j] && dp[i-a[j]][0]==1) {
                dp[i][1]=1;
                break;
            }
        }
    }
    
    if(dp[K][0]==0) puts("First");
    else puts("Second");
    
    
    
    
}






Measured memory_bytes: 1792
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

void dout() { cerr << '\n'; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << " " << H;
    dout(T...);
}

#ifdef LOCAL
    #define dbg(...) cerr << #__VA_ARGS__, dout(__VA_ARGS__)
#else
    #define dbg(...) ;
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;



int main() {
    ios_base::sync_with_stdio(false), cin.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif

    ll n, m;
    cin >> n >> m;
    if (n == 1 && m == 1) {
        cout << 1;
    }   else {
        if (n == 1) {
            cout << m - 2;
            return 0;
        }
        if (m == 1) {
            cout << n - 2;
            return 0;
        }
        cout << (n - 2) * (m - 2);
    }
}


Measured memory_bytes: 256
from collections import deque
import sys


def bfs(x1, y1, d):
    q = deque()
    q.append((d, x1, y1))

    while q:
        d, x1, y1 = q.popleft()

        M[x1][y1] = d

        if [x1, y1] == [xg, yg]:
            return

        for dx, dy in ((0, 1), (1, 0), (0, -1), (-1, 0)):
            for k in range(1, K + 1):
                x2 = x1 + dx * k
                y2 = y1 + dy * k

                if (0 <= x2 < H) and (0 <= y2 < W):
                    if m[x2][y2] == "@":
                        break
                    elif M[x2][y2] == -1:
                        M[x2][y2] = d + 1
                        q.append((d + 1, x2, y2))  # 新しい点を足す。
                    elif M[x2][y2] < d + 1:
                        break
                else:
                    break


H, W, K = map(int, input().split())
# K = min(K, max(H, W))
xs, ys, xg, yg = map(int, input().split())
xs, ys, xg, yg = xs - 1, ys - 1, xg - 1, yg - 1

m = []
for i in range(H):
    m.append(list(map(str, sys.stdin.readline().strip())))

M = [[-1] * W for i in range(H)]

bfs(xs, ys, 0)

print(M[xg][yg])


Measured memory_bytes: 45032
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int x,y; cin>>x>>y;

    int ans=abs(abs(y)-abs(x));
    if((int64_t)x*y<0) ans++;
    else if((int64_t)x*y==0){
        if(y-x<0) ans++;
    }else{
        if(y-x<0) ans+=2;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}

import           Data.List

main :: IO ()
main = readLn >>= print . totient

totient :: Int -> Int
totient n = n `quot` product ps * (product $ map (subtract 1) ps)
  where
    ps = map head . group $ primeFactors n

smallPrimes :: [Int]
smallPrimes=2:[n|n<-[3,5..46337],and.map((0<).rem n)$takeWhile(\x->x*x<=n)smallPrimes]

primeFactors :: Int -> [Int]
primeFactors n | n < 2 = []
primeFactors n = go n smallPrimes
  where
    go !n pps@(p:ps)
        | n < p * p = [n]
        | r > 0     = go n ps
        | otherwise = p : go q pps
      where
        (q, r) = quotRem n p
    go n [] = [n]

Measured memory_bytes: 4156
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;


int n,m,k;
int a[100010],b[100010],c[100010],d[100010];
using Graph=vector<vector<int>>;
Graph G,G2;

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n, -1) {}
    void init(int n) { par.assign(n, -1); }

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

    bool issame(int x, int y)
    {
        return root(x) == root(y);
    }
    bool merge(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        if (par[x] > par[y])
            swap(x, y);
        par[x] += par[y];
        par[y] = x; //大きさが正になるよ
        return true;
    }
    int size(int x)
    {
        return -par[root(x)];
    }
};

signed main()
{
    cin>>n>>m>>k;
    G.assign(n,vector<int>());
    G2.assign(n, vector<int>());
    REP(i,m) cin>>a[i]>>b[i];
    REP(i,k) cin>>c[i]>>d[i];
    REP(i,m) a[i]--,b[i]--;
    REP(i,k) c[i]--,d[i]--;
    UnionFind uni(n);
   // uni.merge(0,1);
    REP(i,m){
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
        uni.merge(a[i],b[i]);
    }
    int cnt=0;
    for (int i = 0; i < n; i++)
    {
        if(G[i].size()==0) cnt++;
    }
    REP(i, k)
    {
        G2[c[i]].push_back(d[i]);
        G2[d[i]].push_back(c[i]);
        
    }
    REP(i,n){
        
        //cout<<n-1-cnt-G[i].size()-G2[i].size()<<" ";
        int cnt=0;
        //cerr<<uni.size(i)<<endl;
        for (int j = 0; j < G2[i].size(); j++)
        {
            if(uni.issame(i,G2[i][j])) cnt++;
        }
        //cerr<<cnt<<endl;
        cout<<uni.size(i)-1 - G[i].size() - cnt<<" ";
        
    }
    cout<<endl;
    
     return 0;
}


Measured memory_bytes: 16884
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

struct P {
  int x,y,hp,time;
  P(int x, int y, int hp, int time) : x(x),y(y),hp(hp),time(time) {}
};

int main() {
  int w,h;
  while(cin>>w>>h,w) {
    int ba[w][h];
    queue<P> Q;
    REP(y,h) {
      REP(x,w) {
        cin >> ba[x][y];
        if (ba[x][y] == 2) {
          Q.push(P(x,y,6,0));
        }
      }
    }
    bool visited[w][h][7];
    memset(visited,0,sizeof(visited));
    const int dx[] = {0,-1,0,1};
    const int dy[] = {1,0,-1,0};
    int res = -1;
    while(!Q.empty()) {
      P now = Q.front();Q.pop();
      int x = now.x, y =now.y;
      int hp = now.hp;
      if (visited[x][y][hp]) continue;
      visited[x][y][hp] = 1;

      if (ba[x][y] == 3) {
        res = now.time;
        break;
      }

      if (ba[x][y] == 4) hp = 6;
      if (hp == 1) continue;
      REP(k,4) {
        int xx = x+dx[k];
        int yy = y+dy[k];

        if (xx<0||xx>=w||yy<0||yy>=h) continue;
        if (visited[xx][yy][hp-1]) continue;
        if (ba[xx][yy] == 0) continue;
        Q.push(P(xx,yy,hp-1,now.time+1));
      }
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

int INF = 1000000000;

int main() {

  int N, M, a[55], b[55], c[55], d[55];

  cin>>N>>M;
  REP(i,0,N) cin>>a[i]>>b[i];
  REP(i,0,M) cin>>c[i]>>d[i];

  REP(i,0,N){
    int ans = INF, no = -1;
    REP(j,0,M){
      if(ans > abs(a[i]-c[j]) + abs(b[i]-d[j])){
        ans = abs(a[i]-c[j]) + abs(b[i]-d[j]);
        no = j;
      }
    }
    cout<<no+1<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()

A = 0
B = 0
res = 0
for i in range(N):
	if S[i] == 'A':
		A, B = 1, 0
	elif A == 1 and S[i] == 'B':
		A, B = 0, 1
	elif B == 1 and S[i] == 'C':
		A, B = 0, 0
		res += 1
	else:
		A, B = 0, 0
print(res)

Measured memory_bytes: 38384
import sys
input = sys.stdin.readline

def main():

    import sys
    input = sys.stdin.readline

    a,b,c = map(int, input().split())

    print("Yes" if (4*a*b<(c-a-b)**2)and(c-a-b>0) else "No")

if __name__ == '__main__':
    main()

Measured memory_bytes: 2940