akhauriyash/Code-Regression huggingface dataset:
n = int(input())

buttons = [int(input()) for i in range(n)]

b = 0
loop_count = 0
for i in range(n):
  if b == 2:
    print(loop_count)
    exit(0)
    
  if i == 0:
    b = buttons[i]
  else:
    b = buttons[b-1]
  
  loop_count += 1

print(-1)

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

using namespace std;

#define MOD (1000000007)

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

    vector<int> a_map(N, 0);
    for ( int i = 0; i < N; i++ ) {
        int a;
        cin >> a;
        a_map.at(a)++;
    }

    bool can = true;
    for ( int i = 0; i < N; i++ ) {
        if ( N % 2 != 0 && i % 2 == 0 ) {
            if ( i == 0 ) {
                if ( a_map.at(i) != 1 ) {
                    can = false;
                    break;
                }
            }
            else {
                if ( a_map.at(i) != 2 ) {
                    can = false;
                    break;
                }
            }
        }
        if ( N % 2 == 0 && i % 2 != 0 ) {
            if ( a_map.at(i) != 2 ) {
                can = false;
                break;
            }
        }
    }

    if ( !can ) {
        cout << 0 << endl;
        return 0;
    }

    long long ans = 1;
    for ( int i = N-1; i > 0; i -= 2 ) {
        ans *= 2;
        ans %= MOD;
    }

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


Measured memory_bytes: 3624
package main

import "fmt"

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func find_candidates(m map[int]int) (int, int, int, int) {
	f, fi, s, si := 0, 0, 0, 0
	for i, cnt := range m {
		if cnt > f {
			s = f
			si = fi
			f = cnt
			fi = i
		} else if cnt > s {
			s = cnt
			si = i
		}
	}
	return f, fi, s, si
}

func main() {
	var n int
	fmt.Scan(&n)
	cntrA := make(map[int]int)
	cntrB := make(map[int]int)
	for i := 0; i < n; i += 2 {
		var a, b int
		fmt.Scan(&a, &b)
		cntrA[a]++
		cntrB[b]++
	}

	fa, fai, sa, sai := find_candidates(cntrA)
	fb, fbi, sb, sbi := find_candidates(cntrB)

	_ = sai
	_ = sbi
	if fai != fbi {
		fmt.Println(n - fa - fb)
	} else {
		fmt.Println(min(n-sa-fb, n-fa-sb))
	}
}


Measured memory_bytes: 7808
#pragma GCC optimize(2)
#include<bits/stdc++.h> 
using namespace std;
#define ll long long
#define endl "\n"
const int mod=1e9+7;
const int MAX=1e6+7;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
   int n;cin>>n;
   string s;cin>>s;
   int l=0,r=n-1,ans=0;
   while(l<=r)
   {
      if(s[l]=='W'){
         if(s[r]=='R')ans++,l++,r--; 
         else r--;
      }
      else l++;
   }
   cout<<ans;
   return 0;
} 

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

int main(){
    int N;
    int W;
    cin >> N >> W;
    vector<int>weight(110);
    vector<int>value(110);
    for(int i=0; i<N;i++){
        cin >> weight.at(i) >> value.at(i);
    }
    vector<vector<long long int>>dp(110,vector<long long int>(100100,0));
    
    //ちょうどWのときの最大の価値を計算
    for(int i=0; i<N; i++){
        for(int j=0; j<=W; j++){
            if(j-weight.at(i)>=0){
            dp.at(i+1).at(j) = max(dp.at(i).at(j-weight.at(i))+value.at(i),dp.at(i+1).at(j));
            }
            dp.at(i+1).at(j) = max(dp.at(i+1).at(j),dp.at(i).at(j));
            
        }
    }
    cout << dp.at(N).at(W) << endl;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define rep(i,N) for(int i=0;i<N;i++)

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

  string s;
  int K;
  cin>>s>>K;
  int N=s.size();
  vector<int>n(N);
  for(int i=0;i<N;i++)n[i]=s[i]-'0';

  vector<vector<vector<ll>>>dp(N+1,vector<vector<ll>>(2,vector<ll>(K+2,0)));
  dp[0][0][0]=1;

  for(int i=0;i<N;i++){
    for(int j=0;j<2;j++){
      for(int k=0;k<=(j?9:n[i]);k++){
        for(int l=0;l<=K;l++){
          if(k!=0)dp[i+1][j|k<n[i]][l+1]+=dp[i][j][l];
          else dp[i+1][j|k<n[i]][l]+=dp[i][j][l];
        }
      }
    }
  }

  cout<<dp[N][0][K]+dp[N][1][K]<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <string>
#include <array>
#include <random>
#include <chrono>
#include <algorithm>
#include <unordered_map>

int main(void){
	int N;
	int64_t x;
	std::cin >> N;
	std::cin >> x;
	std::vector<int64_t> a(N);
	for(int i=0;i<N;i++)std::cin >> a[i];
	int64_t ans = 0;
	for(int i=0;i<N-1;i++){
		int64_t sum = a[i] + a[i+1];
		if(sum <= x)continue;
		ans += sum - x;
		if(sum - x <= a[i+1]){
			a[i+1] -= sum - x;
			continue;
		}
		a[i] -= sum - x - a[i+1];
		a[i+1] = 0;
	}
	std::cout << ans << std::endl;
}

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

long long a,b;
bool input(){
  cin>>a>>b;
  return !(a==0&&b==0);
}

vector<int> solve(){
  vector<int> res(3);
  int n = b-a;
  res[2] = n/1000;
  n = n%1000;
  res[1] = n/500;
  n = n%500;
  res[0] = n/100;
  return res;
}


int main(){
  while(input()){
    auto ans = solve();
    for(int i= 0;i<ans.size();i++){
      cout<<ans[i];
      if(i!=ans.size()-1){
        cout<<" ";
      }else{
        cout<<endl;
      }
    }
  }
}

Measured memory_bytes: 1188
#include<stdio.h>
#include<stdlib.h>
#include<assert.h>

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int a, b;
	
    scanf("%d%d", &a, &b);
	if (a<=9&&b<=9) {
		printf("%d", a * b);
	}
	else {
		printf("-1");
	}
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>

int main() {
	int n,l,sum=0;
	std::cin >> n>>l;

	std::vector<int> v;



	for (int i = 0; i < n; i++) {
		v.push_back(l + i);


		sum += l + i;
	}

	//std::cout << sum << std::endl;

	int min = *min_element(v.begin(), v.end());
	int max = *max_element(v.begin(), v.end());

	if (min>0) {
		sum = sum - min;
	}

	if (max < 0) {
		sum = sum -max;
	}

	//sum = sum - min;

	//std::cout << max << std::endl;
	std::cout << sum << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define speed() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    speed();
    int N; cin >> N;
    ll H[N];
    rep(i, 0, N) cin >> H[i];
    int cnt = 0, ans = 0;
    rep(i, 0, N-1) {
        (H[i] >= H[i+1]) ? cnt++ : cnt = 0;
        ans = max(cnt, ans);
        }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)

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

    int n;
    cin >> n;

    int two = 0, four = 0, other = 0;
    REP(i, n){
        int a;
        cin >> a;
        if(!(a % 4)) four++;
        else if(!(a % 2)) two++;
        else other++;
    }

    /*four += (two / 2);
    two %= 2;
    other += two;*/
    
    if(two!=0){
        cout << (four  >= other ? "Yes" : "No") << endl;
    }else{
        cout << (four+1  >= other ? "Yes" : "No") << endl;
    }

    return 0;
}


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

int main() {
  ll N,K; cin>>N>>K;
  N++;
  vector<double> P(N);
  for(ll i=1; i<N; i++)cin>>P[i];
  for(ll i=1; i<N; i++)P[i]+=P[i-1];
  double ans=0;
  for(ll i=K; i<N; i++){
    ans=max(ans, P[i]-P[i-K]);
  }
  cout<<fixed << setprecision(10)<<(ans+K)/2<<endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define fir first 
#define sec second
#define int long long
#define endl "\n"
# define M_PI 3.14159265358979323846
using namespace std;
const int nax=1e5+5;
vector<int>adj[nax];
const int mod=1e9+7;
const int inf=1e18+7;

signed main(){
	int n;
	cin>>n;
	std::cout << std::setprecision(15) << 2*M_PI*n << endl;
	return 0;
}



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

int main() {

	int a, b;

	cin >> a >> b;

	if (a > b) {
		cout << 2 * a - 1 << endl;
	}
	else if(a < b) {
		cout << 2 * b - 1 << endl;
	}
	else {
		cout << 2 * a << endl;
	}

	return 0;

}

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

using namespace std;

int main(){
  int K;
  cin >> K;
  
  long long sum = 0;
  for(int a = 1; a <= K; a++){
    for(int b = 1; b <= K; b++){
      for(int c = 1; c <= K; c++){
        sum += gcd(gcd(a, b), c);
      }
    }
  }
  
  cout << sum << endl;
  
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <sstream>
using namespace std;
typedef pair<int,int> P;

const int max_n=1000+10;
int h,w,n,sx,sy,dx[]={0,0,-1,1},dy[]={-1,1,0,0},d[max_n][max_n],ans;
char c[max_n][max_n];

void bfs(int x,int y,int m){
	if(m>n)return;
	queue<P> q;
	memset(d,0,sizeof(d));
	q.push(P(x,y));
	d[x][y]=1;
	while(!q.empty()){
		P p=q.front();
		q.pop();
		for(int i=0;i<4;i++){
			int tx=p.first+dx[i],ty=p.second+dy[i];
			if(c[tx][ty]=='0'+m){
				ans+=d[p.first][p.second];
				bfs(tx,ty,m+1);
				return;
			}
			if(tx>=0 && tx<h && ty>=0 && ty<w && c[tx][ty]!='X' && !d[tx][ty]){
				q.push(P(tx,ty));
				d[tx][ty]=d[p.first][p.second]+1;
			}
		}
	}
}

int main(){
    scanf("%d%d%d",&h,&w,&n);
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++){
            cin>>c[i][j];
            if(c[i][j]=='S'){sx=i;sy=j;}
        }
    bfs(sx,sy,1);
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b, c;
    cin >> a >> b >> c;

    if(b >= c){
        cout << b + c << endl;
        return 0;
    }else if((a+b) >= c){
        cout << b + c << endl;
        return 0;
    }else{
        cout << a + 2 * b + 1<< endl;
        return 0;
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    long long x,y;

	
    cin  >> x >> y;
    if(x==y)cout << 1 << " " << 0 << endl;
    else if(x%2==0||y%2==0)cout << 1 << " " << 1 << endl;
    else {
      if(x>y)swap(x,y);
      if(y%x==0){
	y/=x;
	x/=x;
      }
      while(1){
	int f=0;
	for(int j=2;j*j<y;j++){
	  if(x%j==0&&y%j==0){
	    f=1;
	    x/=j;
	    y/=j;
	  }
	}
	if(f==0)break;
      }
      // cout << x << y << endl;
      cout << x*y/2+1 << " " << x*y/2<< endl;
    }
  }
  return 0;
  
}

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


int main(){
    int D,G;
    int p[D],c[D];
    cin >> D >> G;
    for(int i=0; i<D; i++){
        cin >> p[i] >> c[i];
    }
    int ans=1e9;
    for(int bit = 0; bit < (1<<D); bit++){ //完全に解く→1　解かない→2
        int sum = 0;
        int count = 0;
        int rest_max = 0;
        for(int i = 0; i < D; i++){
            if(bit & (1<<i)){
                sum += p[i]*100*(i+1) + c[i];
                count += p[i];
            }else{
                rest_max = max(rest_max,i);
            }
        }//完全に解くものをsumに足し、残った問題番号の最大を得た。
        if(G <= sum + p[rest_max]*100*(rest_max + 1)){
            while(G > sum){
                sum += 100*(rest_max+1);
                count ++;
            }
            ans = min(ans,count);
            continue;
        }else{
            continue;
        }
    }
    cout << ans;
}
        
        
            


Measured memory_bytes: 2304
//#include "stdafx.h"
#include<iostream>
#include<algorithm>
using namespace std;
void selectionSort()
{
	int A[100];
	int N;
	cin >> N;

	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		int m = i;
		for (int j = i + 1; j < N; j++)
		{
			if (A[m] > A[j])
			{
				m = j;
			}
		}

		if (m != i)
		{
			int temp = A[i];
			A[i] = A[m];
			A[m] = temp;
			ans++;
		}
	}

	for (int i = 0; i < N; i++)
	{
		if (i != N - 1)
		{
			cout << A[i] << " " << flush;
			continue;
		}
		else
		{
			cout << A[i] << endl;
		}
	}

	cout << ans << endl;
}

int main()
{
	selectionSort();
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = INT_MAX;
const long long INFL = 1LL<<40;
const double PI = atan(1)*4;
const long long MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


int main() {
    int n;cin>>n;
    vector<int> a(n+1);
    repsg(i,1,n+1){
        cin>>a[i];
    }
    
    int cnt=0;
    
    repsg(i,1,n+1){
        if(i==a[a[i]])cnt++;
    }
    
    cout<<cnt/2<<endl;
    
    
    return 0;
}





Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

using namespace std;
int c[10][10];
int main(){
	int H,W;
	cin >> H >> W;
	rep(i,0,10) rep(j,0,10) cin >> c[i][j];
	rep(k,0,10){
		rep(i,0,10){
			rep(j,0,10){
				c[i][j] = min(c[i][j],c[i][k]+c[k][j]);
			}
		}
	}
	
	ll ans = 0;
	rep(i,0,H){
		rep(j,0,W){
			int tmp;
			cin >> tmp;
			if(tmp != -1) ans += c[tmp][1];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
import java.util.NoSuchElementException
import java.lang.Math.*

fun main(args: Array<String>) = FastScanner().run {
    val x = nextLong()
    val y = nextLong()
    val ax = abs(x)
    val ay = abs(y)
    var cnt = 0L
    if (ax < ay) {
        if (x < 0) cnt++
        if (y < 0) cnt++
        cnt += ay - ax
    } else if (ax > ay) {
        if (x > 0) cnt++
        if (y > 0) cnt++
        cnt += ax - ay
    } else {
        if (x * y < 0) cnt++
    }
    println(cnt)
}

class FastScanner {
    private val printable = 33..126
    val `in` = System.`in`
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    fun hasNextByte(): Boolean {
        if (ptr < buflen) {
            return true
        } else {
            ptr = 0
            buflen = `in`.read(buffer)
            if (buflen <= 0) {
                return false
            }
        }
        return true
    }
    fun readByte(): Byte {
        return if (hasNextByte()) buffer[ptr++] else return -1
    }
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }
    fun next(): String {
        if (!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }
    fun nextLong(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }
    fun nextInt(): Int {
        val nl = nextLong()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }
    fun nextDouble(): Double {
        return next().toDouble()
    }
}

Measured memory_bytes: 31264
#include<bits/stdc++.h>
#define LLI long long int
#define ULTRA 2134567890

using namespace std;

int main()
{
    int i,j;
    LLI a,b;

    scanf("%lld %lld",&a,&b);
    if((a+b)%2==1)
        printf("IMPOSSIBLE\n");
    else
        printf("%lld\n",(a+b)/2);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cassert>

using namespace std;

int main() {
    int h, w;
    int k;
    cin >> h >> w >> k;
    vector<vector<char>> chocolate(h, vector<char>(w));

    for (size_t i = 0; i < h; ++i) {
        for (size_t j = 0; j < w; ++j) {
            cin >> chocolate[i][j];
        }
    }

    vector<vector<int>> result(h, vector<int>(w));

    int curCut = 1;
    int lastRow = -1;
    for (size_t row = 0; row < h; ++row) {
        vector<int> matches;
        for (size_t col = 0; col < w; ++col) {
            if (chocolate[row][col] == '#') {
                matches.push_back(col);
            }
        }
        if (!matches.empty()) {
            int pmatch = -1;
            for (const auto match : matches) {
                for (int i = row; i > lastRow; --i) {
                    for (int j = pmatch + 1; j <= match; ++j) {
                        result[i][j] = curCut;
                    }
                }
                pmatch = match;
                ++curCut;
            }
            lastRow = row;
        }
    }

    for (size_t row = 0; row < h; ++row) {
        int last = w - 1;
        while (last >= 0 && result[row][last] == 0) {
            --last;
        }
        if (last >= 0) {
            for (int j = last + 1; j < w; ++j) {
                result[row][j] = result[row][last];
            }
        } else {
            break;
        }
    }

    for (int col = 0; col < w; ++col) {
        int last = h - 1;
        while (last >= 0 && result[last][col] == 0) {
            --last;
        }

        assert(last >= 0);

        for (int row = last + 1; row < h; ++row) {
            result[row][col] = result[last][col];
        }
    }

    for (size_t i = 0; i < h; ++i) {
        for (size_t j = 0; j < w; ++j) {
            cout << result[i][j] << ' ';
        }
        cout << endl;
    }
}

Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <string.h>
using namespace std;

int g[24][3] = { {0, 1, 2}, {0, 2, 4}, {0, 4, 3}, {0, 3, 1}, {1, 5, 2},
				{1, 2, 0}, {1, 0, 3}, {1, 3, 5}, {2, 0, 1}, {2, 1, 5},
				{2, 5, 4}, {2, 4, 0}, {3, 1, 0}, {3, 0, 4}, {3, 4, 5},
				{3, 5, 1}, {4, 0, 2}, {4, 2, 5}, {4, 5, 3}, {4, 3, 0},
				{5, 2, 1}, {5, 1, 3}, {5, 3, 4}, {5, 4, 2} };

bool ck(string* a, string* b) {
	int k = 0;
	while (b[k] != a[0])
		k++;

	if (b[5 - k] == a[5]) {
		int l = 0;
		while (b[l] != a[1])
			l++;

		if (b[5 - l] == a[4]) {
			int u = 0;
			while (b[u] != a[2])
				u++;

			for(int i = 0; i < 24; i++)
				if (g[i][0] == k && g[i][1] == l && g[i][2] == u)
					return 1;
		}
	}

	return 0;
}

int main()
{	
	int n;

	cin >> n;

	while (n > 0) {
		string c[30][6];
		for (int i = 0; i < n; i++)
			for (int j = 0; j < 6; j++)
				cin >> c[i][j];

		bool f[30];
		memset(f, 0, sizeof(f));

		for (int i = 0; i < n - 1; i++) {
			for (int j = i + 1; j < n; j++) {
				if (ck(c[i], c[j]))
					f[j] = 1;
			}
		}

		int m = 0;
		for (int i = 0; i < n; i++)
			if (f[i])
				m++;

		cout << m << endl;

		cin >> n;
	}
	
	return 0;
}



Measured memory_bytes: 3092
import math
from collections import deque
from collections import defaultdict

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq

n = readInt()
d = readInts()

d.sort()

print(d[len(d)//2]-d[len(d)//2-1])

Measured memory_bytes: 14940
import sys

while(1):
    H, W = map(int, raw_input().split())
    if(H == 0 and W == 0):
        break
    else:
        for i in range(H):
            for j in range(W):
                if(i == 0 or i == H-1 or j == 0 or j == W-1):
                    sys.stdout.write("#")
                else:
                    sys.stdout.write(".")
            print
        print

Measured memory_bytes: 4212
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

const int mod = 1e9 + 7;
int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; cin >> n;
	vi c(n); rep(i, n) cin >> c[i];
	sort(all(c));
	
	int ans = 0;
	rep(i, n) ans = (ans + c[n - i - 1] * (i + 2ll)) % mod;
	for(int m = 2 * n - 2, x = 2; m; m /= 2){
		if(m & 1) ans = (ll)ans * x % mod;
		x = (ll)x * x % mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
// ------ lib ------ //


#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int a = 0;
	int b = 0;
	int aw = 0;
	cin >> a;
	cin >> b;
	int c[1000];
	int d[1000];
	for (int i = 0; i < b; i++)
	{
		cin >> c[i];
		cin >> d[i];
	}
	sort(c, c + b);
	for (int i = 1; i < b; i++)
	{
		if (c[i] < a)
		{
			aw += (a - c[i]);
		}
	}
	cout << aw << endl;
	return 0;
}

Measured memory_bytes: 3104
from itertools import permutations, combinations

nums = input().split()
As = input().split()
H = nums[0]
N = nums[1]
A = []


N =int(N)

As = list(map(int, As))
As = sorted(As , reverse=True)

if N != 0:
    del As[:N]

print(sum(As))

    

Measured memory_bytes: 25772
/******************************************************************************

                              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.

*******************************************************************************/
// C++ program to count all distinct elements 
// in a given array 
#include <algorithm> 
#include <iostream> 
using namespace std; 
  
int countDistinct(int arr[], int n) 
{ 
    // First sort the array so that all 
    // occurrences become consecutive 
    sort(arr, arr + n); 
  
    // Traverse the sorted array 
    int res = 0; 
    for (int i = 0; i < n; i++) { 
  
        // Move the index ahead while 
        // there are duplicates 
        while (i < n - 1 && arr[i] == arr[i + 1]) 
            i++; 
  
        res++; 
    } 
  
    return res; 
} 
  
// Driver program to test above function 
int main() 
{ 
   int i;

int arr[3];
for(i=0;i<3;++i)
cin>>arr[i]; 
    cout << countDistinct(arr, 3); 
    return 0; 
} 

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

#define fi first
#define se second
#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );

const long long N = 100100;
const long long Q = 100000001;
const long long mod = 1e9 + 7;
const long long MAGIC = 30;

using namespace std;

int n;
long long C;
long long a[N];
long long b[N];
long long s[N];
long long suf[N];
long long pref[N];

void solve()
{
        cin >> n >> C;
        for(int i = 1; i <= n; i++){
                cin >> a[i] >> b[i];
                s[i] = s[i - 1] + b[i];
        }
        for(int i = n; i >= 1; i--){
                suf[i] = suf[i + 1];
                suf[i] = max(suf[i], s[n] - s[i - 1] - C + a[i]);
        }
        for(int i = 1; i <= n; i++){
                pref[i] = pref[i - 1];
                pref[i] = max(pref[i], s[i] - a[i]);
        }
        long long ans = 0;
        for(int i = 1; i <= n; i++){
                ans = max(ans, s[i] - a[i]);
                ans = max(ans, s[n] - s[i - 1] - C + a[i]);
                ans = max(ans, s[i] - 2 * a[i] + suf[i + 1]);
                ans = max(ans, s[n] - s[i - 1] - 2 * C + 2 * a[i] + pref[i - 1]);
        }
        cout << ans << "\n";
}

bool mtest = false; int main()
{
        //fin("input.txt");
        //fout("output.txt");
        //fin("maze.in");
        //fout("maze.out");
        ios_base::sync_with_stdio(0);
        int TE = 1;
        if(mtest)
                cin >> TE;
        while(TE--)
                solve();
        return 0;
}


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

def solve(n, l, ans):
    table = [[0] * 21 for _ in xrange(n-1)]
    table[0][l[0]] = 1
    for i in xrange(1, n-1):
        for j in xrange(0, 21):
            if j - l[i] < 0:
                table[i][j] = table[i-1][j+l[i]]
            elif j + l[i] > 20:
                table[i][j] = table[i-1][j-l[i]]
            else:
                table[i][j] = table[i-1][j-l[i]] + table[i-1][j+l[i]]
    print table[n-2][ans]

if __name__ == "__main__":
    n = int(raw_input())
    l = map(int, raw_input().split())
    ans = l.pop()
    solve(n, l, ans)

Measured memory_bytes: 6480
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define repp(i,a,n) for(i=a;i<n;++i)
#define repr(i,a,n) for(i=a;i>=n;--i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

ll binpowmod(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

ll modInverse(ll n, ll p)
{
    return binpowmod(n, p-2, p);
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t,m,n,i,f=0,j,ans=0;
    cin >> n >> m >> t ;
    cout << t << " " << n << " " <<  m ;
    return 0;
}

Measured memory_bytes: 256
w,h,n = map(int,input().split())
yu = h
yd = 0
xl = 0
xr = w
for i in range(n):
    x,y,a= map(int,input().split())
    if a == 1:
        xl = max(x,xl)
    elif a == 2:
        xr = min(x,xr)
    elif a == 3:
        yd = max(y,yd)
    elif a == 4:
        yu = min(y,yu)
    # print(xl,xr,yu,yd)
print(max(0,yu-yd)*max(0,xr-xl))                        

Measured memory_bytes: 62396
#include <iostream>
#include <vector>

using namespace std;

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

    vector<int> a(n);
    vector<int> ans(n);

    for(int i = 0; i < n; ++i) 
        cin >> a[i];

    for(int i = 0; i < n; ++i)
        ans[a[i] - 1] = i + 1;
    
    for(int i = 0; i < n; ++i)
        cout << ans[i] << " ";
 	return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll = long long; // ll は long long　と同じとする。(int64_t)
int main(){
    int N , M;
    cin >> N >> M;
    pair <int , int> AB[N];
    for(int i = 0; i < N; i++){
        cin >> AB[i].first >> AB[i].second;
    }
    sort(AB , AB + N);
    int k = 0;
    ll ans = 0;
    for(int i = 0; i < M; i++){
        if(AB[k].second == 0) {
            k++;
        }
        AB[k].second--;
        ans += AB[k].first;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
N,M=input().split()
N,M=[int(N),int(M)]

def countCard(j,i):
	count = 0
	left=0
	right=0
	up =0
	down=0

	if j-1 >= 0:
		left = 1

	if j+1 < M:
		right = 1

	if i-1 >= 0:
		up = 1

	if i+1 < N:
		down = 1

	a= left + right + up + down
	if a == 4:
		return 0	#9
	elif a == 3:
		return 1	#6
	elif a == 2:
		if left + right == 0 or up+down==0:
			return 0	#3
		else:
			return 1	#4
	elif a == 1:
		return 1	#2
	elif a == 0:
		return 0

ans = 0

if M >= 3 and N >=3:
	ans = (M-2)*(N-2)
elif M == 1 and N ==1:
	ans = 1
elif N == 1 and M > 2:
	ans = M -2
elif M ==1 and N>2:
	ans = N-2
else:
	status = [[1]*M]*N
	for i in range(N):
		for j in range(M):
			status[i][j] = countCard(j,i)
			ans += status[i][j]
	ans = (M*N) - ans

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;

signed _main(){
  int N,H,ans=0; cin >> N >> H;
  v<int> a(N),b(N);
  int maxi=0;
  rep(i,N){
    cin >> a[i] >> b[i];
    chmax(maxi,a[i]);
  }
  sort(b.begin(),b.end());
  reverse(b.begin(),b.end());
  rep(i,N){
    if(b[i]>maxi){
      H-=b[i];
      ans++;
      if(H<=0){
        cout << ans << endl;
        return 0;
      }
    }
    else break;
  }
  cout << ans + (H+maxi-1)/maxi << endl;

  return 0;
}


Measured memory_bytes: 1792
N = int(input())
xyhs = [list(map(int, input().split())) for _ in range(N)]

minH = 0
for xyh in xyhs:
  minH = max(minH, xyh[2])

cx, cy, H = 0, 0, 0
for h in range(minH, minH+200):
  if H != 0: break
  for x in range(101):
    if H != 0: break
    for y in range(101):
      if H != 0: break
      for xyh in xyhs:
        if max(h - abs(xyh[0]-x) - abs(xyh[1]-y), 0) != xyh[2]:
          break
      else:
        cx, cy, H = x, y, h
        break

print(cx, cy, H)


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

int main() {
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    cout << (H2*60+M2-H1*60-M1)-K << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
#define M 1000000007
#define fors(i,n) for(int i=0;i<n;++i)
#define fore(i,a,b) for(int i=a,i<=b;++i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vv vector<int>
#define endl "\n"
#define test(i) cout<<i<<endl
#define itrt int t; cin>>t; fors(i,t)
#define itr1 int t; cin>>t;
#define ff first
#define ss second
#define pb push_back
#define vmp make_pair
#define ppb pop_back
#define sorta(a,n) sort(arr,arr+n)
#define sortv(x) sort(x.begin(),x.end())

int main(){
    string s;
    cin>>s;
    if(s=="SUN"){
    cout<<"7";
    }
    else if(s=="MON"){
    cout<<"6";
    }
    else if(s=="TUE"){
        cout<<"5";
    }
    else if(s=="WED"){
        cout<<"4";
    }
    else if(s=="THU"){
        cout<<"3";
    }
    else if(s=="FRI"){
        cout<<"2";
    }
    else if(s=="SAT"){
     cout<<"1";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
using namespace std;
const int MAXN = 21;
const LL MOD = 1000000007;

int N;
bool adj[MAXN][MAXN];
int dp[1 << MAXN];
vector<int> store[MAXN+1];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> N;
	for (int i = 0; i < (1 << N); i++) {
		int cnt = 0;
		for (int j = 0; j < N; j++) {
			cnt += i >> j & 1;
		}
		store[cnt].push_back(i);
	}
	
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> adj[i][j];
		}
	}
	
	dp[0] = 1;
	for (int i = 0; i < N; i++) {
		for (int m : store[i + 1]) {
			for (int j = 0; j < N; j++) {
				if ((m >> j & 1) && adj[i][j]) {
					(dp[m] += dp[m ^ (1 << j)]) %= MOD;
				}
			}
		}
	}
	
	cout << dp[(1 << N) - 1] << '\n';
}


Measured memory_bytes: 17852
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
signed main() {
    int x=0,y=0,z=0,w=0,n=0,m=0;
    cin >>x>>y;
    if(x-y>0)    cout << x-y;
    else cout <<0;
    return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import defaultdict
def main():
    n, x, y = map(int, input().split())
    x -= 1
    y -= 1
    dis = defaultdict(int)
    for i1 in range(n):
        for i2 in range(n):
            d = min(abs(i2-i1), abs(x-i1)+abs(y-i2)+1, abs(x-i2)+abs(y-i1)+1)
            dis[d] += 1

    for k1 in range(1, n):
        print(dis[k1]//2)

if __name__ == '__main__':
    main()


Measured memory_bytes: 75832
l, r = map(int, input().split())
ans = 2018
if r - l + 1 >= 2019:
    print(0)
else:
    for i in range(l, r + 1):
        for j in range(i + 1, r + 1):
            ans = min(ans, (i*j)%2019)
    print(ans)

Measured memory_bytes: 3060
(let ((s1 (read))
      (t1 (read))
      (s1_c (read))
      (t1_c (read))
      (l1 (read)))
  (if (eq s1 l1)
      (format t "~A ~A~%" (- s1_c 1) t1_c)
      (format t "~A ~A~%" s1_c (- t1_c 1))))

Measured memory_bytes: 3808
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
 
using namespace std;
 
#define Int int64_t
 
void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
 
 
 
 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}
 
 
 
 
int main() {
	int a, b,k;
	cin >> a >> b>>k;
 
 
	vector<int> a_f;
	vector<int> b_f;
 
	
	for (int i = 1; i <= min(a, b); i++) {
		if (a % i == 0) {
			a_f.push_back(i);
		}
		if (b % i == 0) {
			b_f.push_back(i);
		}
	}
 
	sort(a_f.begin(), a_f.end());
	sort(b_f.begin(), b_f.end());
 
	vector<int> intersection;
	set_intersection(a_f.begin(), a_f.end(), b_f.begin(), b_f.end(), back_inserter(intersection));
 
	cout << intersection[intersection.size()-k] << endl;
 
	
 
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int max = Integer.MIN_VALUE;
		int e = Integer.MAX_VALUE;
		for (int i = 1; i <= n; i++) {
			int c = scanner.nextInt();
			int d = scanner.nextInt();
			if (max < d) {
				max = d;
				e = c;
			} else if (max == d) {
				e = Math.min(e, c);
			}
		}
		System.out.println(e + " " + max);
	}
}

Measured memory_bytes: 17344
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a, b, x := intScanner(), intScanner(), intScanner()
	if a <= x && x <= a+b {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 1772
#include <stdio.h>

int main(void){
	int a,b,t,c;
	scanf("%d",&a);
	for(t=0;t<a;t++){
		scanf("%d %d",&b,&c);
		b=b%c;
		if(b==0){
			printf("%d\n",c);
		}
		else{
			printf("%d\n",b);
		}
	}

return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define mx 20000
using namespace std;
int sx, sy, tx, ty;

int main()
{
	cin >> sx >> sy >> tx >> ty;

	for(int i = 0; i < abs(sx - tx); i++)
	{
		if(sx < tx)
		{
			cout << "R";
		}
		else
		{
			cout << "L";
		}
	}

	for(int i = 0; i < abs(sy - ty); i++)
	{
		if(sy < ty)
		{
			cout << "U";
		}
		else
		{
			cout << "D";
		}
	}

	for(int i = 0; i < abs(sx - tx); i++)
	{
		if(sx < tx)
		{
			cout << "L";
		}
		else
		{
			cout << "R";
		}
	}

	for(int i = 0; i < abs(sy - ty); i++)
	{
		if(sy < ty)
		{
			cout << "D";
		}
		else
		{
			cout << "U";
		}
	}

	if(sy < ty)
	cout << "D";	
	else 
	cout << "U";

	for(int i = 0; i < abs(sx - tx) + 1; i++)
	{
		if(sx < tx)
		{
			cout << "R";
		}
		else
		{
			cout << "L";
		}
	}

	for(int i = 0; i < abs(sy - ty) + 1; i++)
	{
		if(sy < ty)
		{
			cout << "U";
		}
		else
		{
			cout << "D";
		}
	}

	
	if(sx < tx) cout << "L";
	else cout << "R";
	if(sy < ty)
	cout << "U";
	else cout << "D";
	
	for(int i = 0; i < abs(sx - tx) + 1; i++)
	{
		if(sx < tx)
		{
			cout << "L";
		}
		else
		{
			cout << "R";
		}
	}

	for(int i = 0; i < abs(sy - ty) + 1; i++)
	{
		if(sy < ty)
		{
			cout << "D";
		}
		else
		{
			cout << "U";
		}
	}

	if(sx < tx) cout << "R";
	else cout << "L";
}

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

int main() {

  int N;
  cin >> N;

  vector<string> W(N);
  for (int i = 0; i < N; i++) {
    cin >> W[i];
  }

  string answer = "Yes";
  set<string> st;
  char ls;

  st.insert(W[0]);
  ls = W[0][W[0].size()-1];

  for (int i = 1; i < N; i++) {
    if (st.find(W[i]) == st.end()) {
      if (ls == W[i][0]) {
        st.insert(W[i]);
        ls = W[i][W[i].size()-1];
      } else {
        answer = "No";
        break;
      }
    } else {
      answer = "No";
      break;
    }
  }  

  cout << answer << endl;

}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		HashSet<String> hs = new HashSet<String>();
		
		int n = scan.nextInt();
		
		for(int i = 0; i < n; i++) {
			hs.add(scan.next());
		}
		
		System.out.println(hs.size());
		
	}
		

}


Measured memory_bytes: 76948
#include <iostream>
#include <vector>
#include <cmath>
#include <typeinfo>
#include <set>
#include <bitset>
#include <string>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;



int main(){
  string s;
  cin >> s;
  int count = 0;
  for(int i=0; i<s.size()/2; i++){
    if(s[i] != s[s.size()-1-i]){
      count += 1;
    }
  }
  cout << count << endl;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    Scd(N);

    vl h(N);
    Rep(i,N) Scll(h[i]);

    stack<int> s;
    vl l(N);
    vl r(N);

    int tmp = 0;
    deque<int> q;

    Rep(i,N){
        while( s.size() && h[s.top()] >= h[i] ) s.pop();
        // tmp = s.size();
        // Rep(k,tmp) printf("%d,", s.top() ), q.push_back(s.top()), s.pop();
        // Rep(k,tmp) s.push(q.back()), q.pop_back();
        // printf ("\n");
        l[i] = s.empty() ? 0 : s.top()+1;
        s.push(i);
    }
    while( s.size() ) s.pop();
    while( q.size() ) q.pop_front();
    RRep(i,N){
        while( s.size() && h[s.top()] >= h[i] ) s.pop();
        // tmp = s.size();
        // Rep(k,tmp) printf("%d,", s.top() ), q.push_back(s.top()), s.pop();
        // Rep(k,tmp) s.push(q.back()), q.pop_back();
        // printf ("\n");
        r[i] = s.empty() ? N : s.top();
        s.push(i);
    }

    ll ans = 0;
    Rep(i,N){
        // printf ("(%lld-%lld)*%lld\n", r[i], l[i], h[i] );
        ans = max( ans, (r[i]-l[i])*h[i] );
    }

    printf ("%lld\n", ans );

    return 0;
}




Measured memory_bytes: 5712
#n=int(input())
a,b,c=map(int,input().split())
k=int(input())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

mx=max(a,b,c)
total=a+b+c-mx
for i in range(k):
    mx=2*mx

print(total+mx)


Measured memory_bytes: 9060
#include <bits/stdc++.h>
using namespace std;
static const int MAX = pow(10, 5);

int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int m = a * x + b * y;
    for(int i = 0; i <= MAX; i++) {
        m = min(m, max(x - i, 0) * a + max(y - i, 0) * b + i * 2 * c);
    }
    cout << m << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

#define PI 3.14159265358979323846
int main(void) {
    int a, b, h, m;
    scanf("%d%d%d%d", &a, &b, &h, &m);
    long double rad = PI * 2 * ((long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long double)m / 60.0);
    long double rsq = (long double)(a * a + b * b) - (long double)(2 * a * b) * cosl(rad);
    printf("%20.20Lf\n", sqrtl(rsq));
    return 0;
}

Measured memory_bytes: 2556
#include <iostream>

int main() {
  int h, n; std::cin >> h >> n;
  int attack_sum = 0;
  while (n--) {
    int a; std::cin >> a;
    attack_sum += a;
  }
  if (h <= attack_sum) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
  
  return 0;
}

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

module Main
  ( main
  )
where

import           Control.Applicative
import           Control.Monad
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as MV
import           Control.Monad.ST
import           Data.Ord

parse = fst . fromJust
parseInt = parse . BS.readInt
parseInteger = parse . BS.readInteger
readInt = parseInt <$> BS.getLine
readInteger = parseInteger <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine
readIntegerList = map parseInteger . BS.words <$> BS.getLine

main = do
  [a, b] <- map (read::String -> Float) . words <$> getLine
  let (la, ua) = (ceiling $ a / 0.08, floor $ (a + 1) / 0.08)
      (lb, ub) = (ceiling $ b / 0.1, floor $ (b + 1) / 0.1)
  print $ if ua > lb && ub > la then max la lb else -1

  

Measured memory_bytes: 508
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>

using namespace std;

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

#define INF 		2000000007
#define MOD			1000000007

#define MAX 		1000005

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;


int main(){
	int A,B,C;cin>>A>>B>>C;
	ull K;cin>>K;

	cout << ((K%2==0) ? A-B : B-A) << endl;	



	return 0;
}

Measured memory_bytes: 256