akhauriyash/Code-Regression huggingface dataset:
/*
* Welcome to my code!
*---------------------------------------------*
* author : lynmisakura(twitter : @andoreiji11)
*/

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define repn for(int i = 0;i < n;i++)
#define ain(a) for(auto& i : a)cin >> i;
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x.size()) 
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define cont continue

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using pi = pair<int,int>;
using vpi = vector<pi>;
using pl = pair<ll,ll>;
using vpl = vector<pl>;

template<class T> bool chmin(T& a,T b){if(a > b){a = b;return true;}else return false;}
template<class T> bool chmax(T& a,T b){if(a < b){a = b;return true;}else return false;}
template<class T> void print(std::vector<T> a){ int sz = a.size();
for(int i=0;i<a.size();i++)cout << a[i] << (i < sz-1 ? ' ' : '\n'); }
void ioboost(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}
///////////////////////////////////////////////////////////
void getZarr(string str, int Z[]) 
{ 
	int n = str.length(); 
	int L, R, k; 
	L = R = 0; 
	for (int i = 1; i < n; ++i) 
	{ 
		if (i > R) 
		{ 
			L = R = i; 
			while (R<n && str[R-L] == str[R]) R++;
			Z[i] = R-L; 
			R--; 
		} 
		else
		{ 
			k = i-L; 
			if (Z[k] < R-i+1) Z[i] = Z[k]; 
			else
			{ 
				L = i; 
				while (R<n && str[R-L] == str[R]) R++;
				Z[i] = R-L; 
				R--; 
			} 
		} 
	} 
} 
vector<int> search(string text, string pattern) 
{ 
	string concat = pattern + "$" + text; 
	int l = concat.length(); 
	int Z[l]; 
	getZarr(concat, Z); 
    vector<int> res;
	for (int i = 0; i < l; ++i) if (Z[i] == pattern.length())res.push_back(i - pattern.length() -1);
	return res;
} 

int main(int argc, char const *argv[])
{
	ioboost();

	string s,t;cin >> s >> t;
	string x = s;
	int n = s.size(),m = t.size();

	rep(i,max(2,(m + n - 1)/n))s += x;
	auto v = search(s,t);

	vector<int> ok(n,0);
	for(auto i : v){
		ok[i % n] = 1;
	}

	vector<int> vis(n,0);
	int ans = 0;
	rep(i,n){
		if(vis[i] || !ok[i])continue;
		int cnt = 0;
		int now = i;
		while(cnt <= n + 1){
			vis[now]++;
			if(ok[now]){
				now = (now + m) % n;
				cnt++;
			}else{
				break;
			}	
		}
		if(cnt > n){
			cout << -1 << '\n';
			return 0;
		}
		else chmax(ans,cnt);
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 20344
#include<stdio.h>
#include<string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
    if(ch == 'A') return 1;
    else if(ch == 'C') return 2;
    else if(ch == 'G') return 3;
    else if(ch == 'T') return 4;
    else return 0;
}

int getKey(char str[]){
    int sum = 0,p = 1,i;
    for(i = 0;i < strlen(str); i++){
        sum += p*(getChar(str[i]));
        p *= 5;
    }
    return sum;
}

int h1(int key){ return key%M;}
int h2(int key){ return 1+(key%(M-1));}

int find(char str[]){
    int key,i,h;
    key = getKey(str);
    for(i = 0;; i++){
        h = (h1(key) + i * h2(key)) % M;
        if(strcmp(H[h],str) == 0) return 1;
        else if(H[h][0] == '\0') return 0;
    }
    return 0;
}

int insert(char str[]){
    int key,i,h;
    key = getKey(str);
    for(i = 0;; i++){
        h = (h1(key) + i * h2(key)) % M;
        if(H[h][0] == '\0'){
            strcpy(H[h],str);
            return 0;
        }
    }
    return 0;
}

int main(){
    int i,n,h;
    char str[L],com[9];
    for(i = 0; i < M; i++) H[i][0] = '\0';
    scanf("%d",&n);
    for(i = 0; i < n; i++){
        scanf("%s%s",com,str);

        if(com[0] == 'i'){
            insert(str);
        } else {
            if(find(str)){
                printf("yes\n");
            } else {
                printf("no\n");
            }
        }
    }    return 0;
}



Measured memory_bytes: 16104
import math
mod = 1000000007
N,M = list(map(int,input().strip().split()))
l = []

def P(n, r):
  return math.factorial(n)//math.factorial(n-r)

def C(n, r):
  return P(n, r)//math.factorial(r)

ans = 1
cnt = 0
while  M%2 == 0:
  M //= 2
  cnt += 1
l.append(cnt)
cnt = 0

i = 3
while i**2 <= M:
  cnt = 0
  while M%i == 0:
    M //= i
    cnt += 1
  if cnt != 0:
    l.append(cnt)
    cnt = 0
  i += 2
if M != 1:
    l.append(1)

for i in l:
  for j in range(i):
    ans = ans*(N+j)//(j+1)

print(ans%mod)


Measured memory_bytes: 3064
#include<iostream>
#include<list>
#include<string>

using namespace std;


int main()
{
	int n,num;
	string name;
	list<int> v;
	list <int>::iterator iter;

	cin >> n;

	for (int i = 0; i != n; ++i)
	{
		cin >> name;
		if (name[0] == 'i')
		{
			cin >> num;
			v.push_front(num);
		}
		else if (name == "delete")
		{
			cin >> num;
			for (iter = v.begin(); iter != v.end(); ++iter)
			{
				if (*iter == num)
				{
					v.erase(iter);
					break;
				}
			}
		}
		else if (name[6] == 'F')
		{
			v.pop_front();
		}
		else
		{
			v.pop_back();
		}

	}
	
	num = 0;
	for (iter = v.begin(); iter != v.end(); ++iter, ++num)
	{
		if (num)
		{
			cout << " ";
		}
		cout << *iter;
	}
	cout << endl;

	return 0;

}


Measured memory_bytes: 34412
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define quick                    \
    ios::sync_with_stdio(false); \
    cin.tie(0);
#define time cerr << (0.1 * clock()) / CLOCKS_PER_SEC << endl;
#define mod 1000000007
typedef long long ll;
typedef pair<ll, ll> pl;
#define forn(n) for (ll i = 0; i < ll(n); i++)

void solve() {
    int h1, h2, m1, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int tot1 = (60 * h1) + m1;
    int tot2 = (60 * h2) + m2;
    int diff = tot2 - tot1;
    int ans = max(diff - k, 0);
    cout << ans << '\n';
}

int main() {
    quick;
    solve();
    // ll t;
    // cin >> t;
    // while (t--) {
    //     solve();
    // }
}

Measured memory_bytes: 3652
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main()
{
	long long n;
	cin >> n;
	vector<long long> a(n * 3);
	for (long long i = 0; i < n * 3; i++) cin >> a[i];
	sort(a.rbegin(), a.rend());
	long long sum = 0;
	for (long long i = 2; i <= 2 * n; i += 2) {
		sum += a[i - 1];
	}
	cout << sum << endl;
}

Measured memory_bytes: 2560
#include <cstdio>
#include <algorithm>
using std::sort;
int main(void)
{
	int *a,*b,i,N;
	int frontHalf,backHalf;
	scanf("%d",&N);
	a= new int [N];
	b= new int [N];
	for(i=0;i<N;i++)
	{
		scanf("%d",a+i);
		b[i]=a[i];
	}
	sort(b,b+N);
	frontHalf=b[N/2-1];
	backHalf=b[N/2];
	delete [] b;
	for(i=0;i<N;i++)
	{
		if(a[i]<backHalf)
			printf("%d\n",backHalf);
		else
			printf("%d\n",frontHalf);
	}
	delete [] a;
	return 0;
}

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
void printarr(vector<int>& op)
{
    for(int i=0;i<op.size();i++)
        cout<<op[i]<<" ";
}
int main()
{
  int n,k;
  cin>>n>>k;
  int ele;
  vector<int>ip;
  for(int i=0;i<n;i++)
  {
   cin>>ele;
    ip.push_back(ele);
  }
  vector<int>op(n,0);
  op[1] = abs(ip[1]-ip[0]);
 
  for(int i=2;i<n;i++)
  {
      int count=1;
      int j = i - count;
      int diff = INT_MAX;
      while(count<=k && j >= 0 )
      {
          diff = min(diff, op[j]+ abs(ip[i] - ip[j]));
          count++;
          j--;
      }
      op[i] = diff;
//   op[i] = min((op[i-1]+abs(ip[i]-ip[i-1])), (op[i-2]+abs(ip[i]-ip[i-2])));
  }
//   printarr(op);
  cout<<op[n-1]<<endl;
  
 return 0; 
}

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

int main() {
    int N, M;
    int sum = 0;
    cin >> N;
    vector<int> T(N);
    for (int i=0; i<N; i++){
        cin >> T.at(i);
        sum += T.at(i);
    }
    cin >> M;
    vector<int> P(M);
    vector<int> X(M);
   
    for (int i = 0; i < M; i++){
        cin >> P.at(i) >> X.at(i);  
    }
    
    for (int i = 0; i < M; i++){
        cout << sum-(T.at(P.at(i)-1) - X.at(i)) << endl;
    }
    return 0;  
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, B;
  
  cin >> N >> A;
  
  B = N % 500;
 
  if (B <= A) {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

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

int main() {
  int N;
  int sum = 0;
  cin >> N;
  int d[N];
  for (int i = 0; i < N; ++i) {
    cin >> d[i];
  }
  for (int i = 0; i < (N * (N - 1)) / 2; ++i) {
    for (int a = 0; a < N; ++a) {
      if (a > i) {
        sum += d[i] * d[a];
      }
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int arr[n];
    int dp[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    dp[0]=0;
    for(int i=1;i<n;i++)
    {
        dp[i]=INT_MAX;
        for(int j=i-1;j>=i-k && j>=0 ; j--)
        {
            dp[i]=min(dp[j]+abs(arr[j]-arr[i]),dp[i]);
        }
    }
    cout<<dp[n-1]<<endl;


    return 0;
}


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


int main(){
    ll a, b;
    int k; cin >> a >> b >> k;
    rep(i,k){
        if(i%2){ //青木君
            if(b%2) b -= 1;
            b /= 2;
            a += b;
        }else{ //高橋君
            if(a%2) a -= 1;
            a /= 2;
            b += a;
        }
    }
    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int N;
    cin >> N;
    int a[N];
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    int cost = 0;
    int ans = 10000000;
    for (int i = -100; i <= 100; i++)
    {
        for (int j = 0; j < N; j++)
        {
            cost += (a[j] - i) * (a[j] - i);
        }
        ans = min(ans, cost);
        cost = 0;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  if(s.size()==2){
    cout<<s<<'\n';
  }
  else{
    swap(s[0],s[2]);
    cout<<s<<'\n';
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define radrad(a)  180.0 * a / M_PI
#define pow(x) x*x
#define ll long long
static const int MAX = 100010;
static const ll INFTY = 1e12;
static const int NUMMAX = 300;


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

  vector<int> B(N-1);
  int ans = 0;

  REP(i, N-1){
    cin >> B[i];
  }

  if(N == 2){
    ans = B[0] * 2;
  } else {
    REP(i, N-2){
      ans += min(B[i], B[i+1]);
    }
    ans += B[0];
    ans += B[N-2];
  }

  cout << ans << endl;

  return 0;

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))

rate = [1, 400, 800, 1200, 1600, 2000, 2400, 2800, 3200]
a_ac = [0,   0,   0,    0,    0,    0,    0,    0]

cnt = 0

for s in a:
    if s >= rate[-1]:
        cnt += 1
        continue
    
    cont = True
    i = 0

    while cont:
        if  s < rate[i+1]:
            a_ac[i] = 1
            cont = False
        i += 1

print(max(1,sum(a_ac)))
print(sum(a_ac)+cnt)

Measured memory_bytes: 3064
import java.util.Scanner;
import java.util.Arrays;
class Main{
    public static int count = 0;
    //番兵
    
    public static void main(String[] args){
	
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int[] A = new int[N];
	for(int i = 0;i < N;i++){
	    A[i] = sc.nextInt();
	}
	mergeSort(A,0,N);
			
	for (int i = 0; i < N - 1; i ++) {
	    System.out.print(A[i] + " ");
	}
	System.out.println(A[N - 1]);
	System.out.println(count);
		
    }

    static void merge(int[] A,int left,int mid,int right){
	//分割
	int n1 = mid - left;
	int n2 = right - mid;
	
	int[] L = new int[n1 + 1];
	int[] R = new int[n2 + 1];
	
	for(int i = 0;i < n1;i++)L[i] = A[left + i];
	for(int i = 0;i < n2;i++)R[i] = A[mid + i];
	L[n1] = R[n2] = Integer.MAX_VALUE;
	int i = 0,j = 0;
	for(int k = left;k < right;k++){
	    count++;
	    /*配列L,Rに入ってる要素の小さい方から先に入れ、インクリメントを行う*/
	    if(L[i] <= R[j]){
		A[k] = L[i++];
	    }else{
		A[k] = R[j++];
	    }
	}
	

    }
        static void  mergeSort(int[] A,int left,int right){
    	if(left+1 < right){
    	    int mid = (left + right)/2;
    	    mergeSort(A, left, mid);
    	    mergeSort(A, mid, right);
    	    merge(A, left, mid, right);
    	}

    }
}



Measured memory_bytes: 166396
#include <iostream>

using namespace std;

int main() {
    int N, K;
    string S;
    
    cin >> N >> K >> S;
    K--;

    if(S[K]=='A'){
        S = S.replace(K,1,"a");
    }
    else if(S[K]=='B'){
        S=S.replace(K,1,"b");
    }
    else if(S[K]=='C'){
        S=S.replace(K,1,"c");
    }
    cout << S;

}


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

#define INF INT_MAX
#define UINF UINT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef std::pair<int,int> pii;

using namespace std;

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

    ll n,k;
    cin >> n >> k;

    ll ans = n;
    while(ans >= k){
        ans = ans % k;
        ans = min(abs(ans - k),ans);
    }

    cout << min(abs(ans - k),ans) << endl;
    return 0;
}

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

using namespace std;

int MIN = 0, MAX = 9;

int main() {
	int n;
	
	vector<int> make(100, 0);
	vector<int> maketwo(100, 0);
	
	for (int i=MIN; i <= MAX; i++) {
		for (int j=MIN; j <= MAX; j++) {
			for (int k=MIN; k<=MAX; k++) {
				for (int l=MIN; l<=MAX; l++) make[i+j+k+l]++;
			}
		}
	}
	
	while (cin >> n) {
		cout << make[n] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1196
#define ALL(obj) (obj).begin(), (obj).end()

#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
typedef long long ll;
const ll INF = 1e18;

ll N;

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

    vector<pair<ll, ll> > v(N);
    for(ll i=0; i<N; i++){
        ll a, b;
        cin >> a >> b;
        v[i] = {a + b, a - b};
    }

    sort(ALL(v));

    ll count = 0;
    ll max = -INF;

    for(auto pair: v) {
        if(pair.second >= max) {
            count++;
            max = pair.first;
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1792
import java.io.InputStream;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

public class Main {
	public static void main(String args[]) {
		MyInput in = new MyInput();
    int N = in.nextInt();
    String str = new String();
    long ans = 1;

    str = in.next();
    in.next();

    String[] bls = str.split("");
    String lastr = "";

    int stin = 1;
    boolean ty = false;
    ans *= 3;
    if(N > 2 && bls[0].equals(bls[1])) {
        ans *= 2;
        stin += 1;
        ty = true;
    }

    for(int i = stin; i < N ; i++) {
        if(i != N - 1 && bls[i].equals(bls[i+1])) {
            ans *= 2;
            if(ty) {
                ans = ans * 3 / 2;
            }
            i++;
            ty = true;
        } else {
            if(!ty) {
                ans *= 2;
            }
            ty = false;
        }
        if(ans > 1000000007) ans %= 1000000007;
    }
    if(ans > 1000000007) ans %= 1000000007;
    System.out.println(ans);

	  }
}

class MyInput {
	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;
	}

	public int readByte() { 
		if (hasNextByte()) return buffer[ptr++];
		else return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <=126;
	}

	private void skipUnprintable() {
		while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		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: 21460
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,d;
  cin >> n;
  set<int> s;
  for(int i=0; i<n; i++) {
    cin >> d;
    s.insert(d);
  }
  cout << s.size() << endl;
}

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

int main() {
  int64_t MOD = 1000000000 + 7;
  vector<int64_t> A, B;
  int N, K;
  int i = 0;
  int j = 0;
  int zero = 0;
  cin >> N >> K;
  for(int l = 0; l < N; l++) {
    int64_t a;
    cin >> a;
    if(a > 0) {
      i++;
      A.push_back(a);
    }
    else if(a < 0) {
      j++;
      B.push_back(a);
    }
    else {
      zero++;
    }
  }
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  // max < 0　のケース
  if(zero == 0 && ((K == N && j % 2 == 1) || (K != N && i == 0 && K % 2 == 1))) {
    int64_t ans = 1;
    for(int l = 0; l < i; l++) {
      ans *= A.at(l);
      ans %= MOD;
    }
    for(int l = 0; l < K - i; l++) {
      ans *= B.at(j - l - 1);
      ans %= MOD;
    }
    cout << (ans + MOD) % MOD << endl;
    return 0;
  }
  // max = 0 のケース
  else if(i + j < K) {
    cout << 0 << endl;
    return 0;
  }
  else if(i + j == K && j % 2 == 1) {
    cout << 0 << endl;
    return 0;
  }
  else if(i + j > K && i == 0 && K % 2 == 1) {
    cout << 0 << endl;
    return 0;
  }
  // max > 0　のケース
  else {
    int64_t ans = 1;
    int plus = i - 1;
    int minus = 0;
    if(K % 2 == 1) {
      ans *= A.at(plus);
      ans %= MOD;
      plus--;
      K--;
    }
    while(K > 0) {
      if(minus + 1 <= j - 1 && plus - 1 >= 0) {
        if(A.at(plus) * A.at(plus - 1) >= B.at(minus) * B.at(minus + 1)) {
          ans *= A.at(plus);
          ans %= MOD;
          ans *= A.at(plus - 1);
          ans %= MOD;
          plus -= 2;
        }
        else {
          ans *= B.at(minus);
          ans %= MOD;
          ans *= B.at(minus + 1);
          ans %= MOD;
          minus += 2;
        }
      }
      else if(minus + 1 >= j) {
        ans *= A.at(plus);
        ans %= MOD;
        ans *= A.at(plus - 1);
        ans %= MOD;
        plus -= 2;
      }
      else {
        ans *= B.at(minus);
        ans %= MOD;
        ans *= B.at(minus + 1);
        ans %= MOD;
        minus += 2;
      }
      K -= 2;
    }
    cout << (ans + MOD) % MOD << endl;
    return 0;
  }
}

Measured memory_bytes: 5536
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		System.out.println((a <= c && c <= b) ? "Yes" : "No");

		sc.close();


	}
}




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

#define int long long
#define sync ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define endl "\n"
#define ends " "
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
#define debugV(v) cerr << #v << ": [ "; for(int __ = 0; __ < v.size(); __++) cerr << v[__] << ((__ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugVP(v) cerr << #v << ": [ "; for(int ___ = 0; ___ < v.size(); ___++) cerr << '{' << v[___].first << ", " << v[___].second << '}' << ((___ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugA(a, n) cerr << #a << ": [ "; for(int ____ = 0; ____ < n; ____++) cerr << a[____] << ((____ != n - 1) ? ", " : ends); cerr << ']' << endl
#define print(args...) fprintf (stderr, args)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
const int INF = 1e9, MOD = INF + 7;

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

const int N = 3e3 + 20;

int dp[N][N];
int ps[N];

int32_t main(){

    sync;

	int n; cin >> n;
	string s; cin >> s;
	dp[1][1] = 1;
	s = "##" + s;
	for(int i = 2; i <= n; i++) {
		ps[0] = 0;
		for(int j = 1; j <= i - 1; j++) ps[j] = (ps[j - 1] + dp[i - 1][j]) % MOD;
		for(int j = 1; j <= i; j++) {
			if (s[i] == '>') dp[i][j] = (ps[i - 1] - ps[j - 1] + MOD) % MOD;
			else dp[i][j] = ps[j - 1];
		}
	}

	int ans = 0;
	for(int i = 1; i <= n; i++) ans = (ans + dp[n][i]) % MOD;
	cout << ans << endl; 

    return 0;
}

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

int main(){
  int N, Y;
  cin >> N >> Y;
  Y /= 1000;
  bool flag = true;
  
  for(int i=0; i<=N; i++){
    if(flag){
    for(int j=0; j<=N-i; j++){
      if(Y-(i*10 + j*5) >=0 && Y-(i*10 + j*5) == N-i-j){
        cout << i << " " << j << " " << Y-(i*10 + j*5) << endl;
        flag = false;
        break;
      }
    }
    }
  }
  if(flag){
    cout << -1 << " " << -1 << " " << -1 << endl;
  }
}

Measured memory_bytes: 256
/* ファイル名：ITP1_8_C.c	*/
/* 内容：与えられた英文に含まれる、各アルファベットの数を数える	*/
/*		 (小文字と大文字は区別しない)	*/
/* include	*/
#include <stdio.h>
#include <ctype.h>

/* 外部変数宣言	*/

/* プロトタイプ宣言	*/

/* 関数名:main	*/
/* 処理内容:与えられた英文に含まれる、各アルファベットの数を数える	*/
int main( void )
{
	/* 内部変数定義	*/
	/* 入力	*/
	char ch;	/* 与えられる英文(一文字ずつ入力)	*/
	
	/* 処理	*/
	int i;	/* ループ用変数	*/
	int cnt[26];	/* 各アルファベットの数	*/
	
	/* カウントの初期化	*/
	for(i = 0; i < 26; i++){
		cnt[i] = 0;
	}
	
	/* 英文の最後まで入力	*/
	while(scanf("%c",&ch) != EOF){
		/* アルファベットの場合	*/
		if(isalpha(ch)){
			/* 大文字の場合	*/
			if(isupper(ch)){
				ch = tolower(ch);	/* 小文字に変換	*/
			}
			/* 小文字の場合	*/
			else {
				/* 処理なし*/
			}
			/* 該当するアルファベットの数に加算	*/
			cnt[ch - 'a']++;
		}
		/* アルファベット以外の場合	*/
		else{
			/* 処理なし	*/
		}
	}
	
	/* 結果の出力	*/
	
	for(i = 0; i < 26; i++){
		printf("%c : %d\n",i + 'a',cnt[i]);
	}
	
	return 0;
}



Measured memory_bytes: 2044
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int N,M,X;
  cin >> N >> M >> X;
  vector<int> A(M);
  for(int i=0;i<M;i++) cin >> A.at(i);
  sort(A.begin(),A.end());

  int index;
  int cost_0=0,cost_N=0;
  for(int i=0;i<M;i++){
    if(A.at(i)<X){
      ++cost_0;
    }
    else{
      ++cost_N;
    }
  }

  cout << min(cost_0,cost_N) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#include <iostream>

using namespace std;


int main() {

    int N;
    cin >> N;

    int x = N * 800;
    int y = (N / 15) * 200;

    cout << (x - y) << "\n";

    return 0;
}

Measured memory_bytes: 256
'use strict';

function Main(input) {
    const tmp = input.split("\n")[0].split(" ");
    const A = tmp[0];
    const B = tmp[1];
    const C = tmp[2];

    if (A.slice(-1) == B.slice(0, 1) && B.slice(-1) == C.slice(0, 1)) {
        console.log("YES");
    } else {
        console.log("NO");
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7496
x,y=map(int,input().split())
a=(2*x)-y
b=(2*y)-x
if a%3==0 and b%3==0 and a>=0 and b>=0:
    a=a//3
    b=b//3
    c=a+b
    a1=1
    a2=1
    n3=10**9+7
    for i in range(a):
        a1*=c-i
        a2*=i+1
        a1%=n3
        a2%=n3
    a2=pow(a2,n3-2,n3)
    print((a1*a2)%n3)
else:
    print(0)


Measured memory_bytes: 9164
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int N,M;
    cin>>N;
    unsigned int A[N];
    for(int i=0;i<N;i++){
        A[i]=0;
    }
    for(int i=0;i<N-1;i++){
        cin>>M;
        A[M-1]++;
    }
    for(int i=0;i<=N-1;i++){
        cout<<A[i]<<endl;
    }
    return 0;
}

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

using namespace std;

int main(){

    int n,l;
    string s[100];
    cin >> n >> l;
    for(int i = 0; i < n; i++) cin >> s[i];
    sort(s, s+n);
    for(int i = 0; i < n; i++) cout << s[i];
    cout << "\n";
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int par[100002];
int rk[100002];
int p[100000];
void init(int n){
	for(int i=0; i<n; i++){
		par[i]=i;
	}
}

int find(int x){
	if(par[x]==x){
		return x;
	}else{
		return par[x]=find(par[x]);
	}
}
 
void unite(int x, int y){
	x=find(x);
	y=find(y);
	if(x==y) return;
	if(rk[x]<rk[y]){
		par[x]=y;
	}else{
		par[y]=x;
		if(rk[x]==rk[y]) rk[x]++;
	}
}
 
bool same(int x, int y){
	return find(x)==find(y);
}
int main()
{
	int n, m;
	cin>>n>>m;
    for(int i=0; i<n; i++){
        cin>>p[i]; p[i]--;
    }
    init(n);
    for(int i=0; i<m; i++){
        int x, y;
        cin>>x>>y;
        x--; y--;
        unite(x, y);
    }
    int p2[100000];
    for(int i=0; i<n; i++){
        p2[p[i]]=find(i);
    }
    int ans=0;
    for(int i=0; i<n; i++){
        if(p2[i]==find(i)) ans++;
    }
    cout<<ans<<endl;
	return 0;
}

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

const int maxs = 2e5 + 2;
const int oo = -1e18;
 
int n, m, k;
int a[3002][3002];
int dp[3002][3002][5];

int go(int x,int y,int row)
{
    if(x < 1 || x > n || y < 1 || y > m) 
        return oo;
    
    if(row > 3) 
        return oo;
    if(dp[x][y][row] != -1)
        return dp[x][y][row];
    
    
    if(x == n && y == m) 
    {
        if(row == 3)
            return 0;
        else
            return a[x][y];
    }
 
    int c1 = a[x][y] + go(x,y + 1,row + 1);
    int c2 = oo;
    if(row < 3)
        c2 = a[x][y] + go(x + 1,y,0);
    int c3 = go(x,y + 1,row);
    int c4 = go(x + 1,y,0);
    
    return dp[x][y][row] = max({c1,c2,c3,c4});
}


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    cin >> n >> m >> k;
    for(int i = 1;i <=k;++i) 
    {
        int x,y,v;
        cin >> x >> y >> v;
        a[x][y] = v;
    }
    memset(dp, -1, sizeof(dp));
    cout << go(1,1,0);
    
}

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

int main() {
    int n, a, b, res = 0, tmp, tmp10000, tmp1000, tmp100, tmp10, tmp1;
    cin >> n >> a >> b;

    for (int i = 1; i <= n; ++i) {

        if (i >= 10000) {
            tmp10000 = i / 10000;
            tmp1000 = (i % 10000) / 1000;
            tmp100 = (i % 1000) / 100;
            tmp10 = (i % 100) / 10;
            tmp1 = (i % 10);
            tmp = tmp10000 + tmp1000 + tmp100 + tmp10 + tmp1;
            if(tmp >= a && tmp <= b) {
                res += i;
            }
        }
        else if (i >= 1000) {
            tmp1000 = i / 1000;
            tmp100 = (i % 1000) / 100;
            tmp10 = (i % 100) / 10;
            tmp1 = (i % 10);
            tmp = tmp1000 + tmp100 + tmp10 + tmp1;
            if(tmp >= a && tmp <= b) {
                res += i;
            }
        }
        else if (i >= 100) {
            tmp100 = i / 100;
            tmp10 = (i % 100) / 10;
            tmp1 = (i % 10);
            tmp = tmp100 + tmp10 + tmp1;
            if(tmp >= a && tmp <= b) {
                res += i;
            }
        }
        else if (i >= 10){
            tmp10 = i / 10;
            tmp1 = (i % 10);
            tmp = tmp10 + tmp1;
            //cout << i << ':' << tmp10 << ':' << tmp1 << endl;
            if(tmp >= a && tmp <= b) {
                res += i;
            }
        }
        else {
            if(i >= a && i <= b) {
                res += i;
            }
        }
        //cout << i << ":" << res << endl;
    }

    cout << res;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long 
int main() {
	string s;
	cin>>s;
    if(s=="RRR")cout<<3<<endl;
	else if(s=="RRS"||s=="SRR")cout<<2<<endl;
	else if(s=="SSS")cout<<0<<endl;
	else cout<<1<<endl;
	return 0;
}

Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

//最大公約数
int gcd(int n, int m) {
	if (m == 0)return n;
	return gcd(m, n%m);
}

int ret(int x, int y) {
	return x + y - 1;
}

int main() {
	int x, y; cin >> x >> y;
	int g = gcd(x, y);
	int ans = ret(x / g, y / g)*g + 1;
	Cout(ans);
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
int main()
{

    string s;
    int c=0,c1=0;
    cin>>s;

        for(int i=0;i<s.length();i++)
        {
            if(s[i]=='0')
            {

                c++;

            }
        }
        c1=s.length()-c;

    c*=2;
    c1*=2;

    cout<<min(c,c1)<<endl;

    return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstring>
#include <set>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cmath>
#include <deque>
#include <bitset>
#define ll long long
#define PI 3.1415926535897932384626433832795
#define read(x) scanf("%d",&x);
#define readll(x) cin>>x;
#define FOR(x,a,b) for(int x=a;x<b;x++)
#define MP make_pair
#define PB push_back
#define pii pair<int,int>
#define readN(N,X) for(int i=0;i<N;i++) cin>>X[i];
#define pff pair<double,double>
using namespace std;

long long N,M,X,Y;
long long res[555][555];
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main(){
   std::ios::sync_with_stdio(false); 
   cin>>N>>M>>X>>Y;
   if (X==1 && Y==1) No();
   if (N==X && M==Y) No();

   for(int i=0;i<N;i++)
   	for (int j=0;j<M;j++){
   		if ((i) % X == 0 && (j) % Y == 0) res[i][j] = 999999999;
   		if ((i+1) % X == 0 && (j+1) % Y == 0) res[i][j] = -1000000000;
   	}
   	long long sum = 0;
   	for(int i=0;i<N;i++)
   	for (int j=0;j<M;j++){
   		sum += res[i][j];
   	}
   	//cout<<sum<<endl;
   	if (sum <= 0) No();
   	cout<<"Yes"<<endl;
   	for(int i=0;i<N;i++){
   	for (int j=0;j<M;j++){
   		cout<<res[i][j]<<" ";
   	}
   	cout<<endl;
   }

 
}




Measured memory_bytes: 5120
# coding: utf-8

import sys
import math
import collections
import itertools
import bisect
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return x if y == 0 else gcd(y, x%y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

A, B = LS()
A = int(A)

B = B.split('.')
Ba = int(B[0])
Bb = int(B[1])

c = 0
Bb *= A
Bb = str(Bb)
if len(Bb) >= 3:
    c = int(Bb[0:len(Bb)-2])

print(A*Ba + c)


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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int count = 0;
    for(int i = 0; i <= 100; ++i){
        if(a <= i && i < b && c <= i && i < d)
            count++;
    }
    cout << count << endl;
}

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

int main() {
  int x=0;
  int n;
  int m=0;
  cin >> n;
  string s;
  cin >> s;
  
  for(int i=0; i<n; i++){
    if(s[i] == 'I'){
      x++;
    }
    if(s[i] == 'D'){
      x--;
    }
    if(x >= m){
      m = x;
    }
  }
  
  cout << m << endl;
  
	return 0;
}


Measured memory_bytes: 256
//vec[i]の範囲外エラー表示
#define _GLIBCXX_DEBUG
//includeとusing
#include <bits/stdc++.h>
using namespace std;
//型名省略
using ll = long long;
using st = string;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vc = vector<char>;
using vvc = vector<vector<char>>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using pcc = pair<char, char>;
//定数
const ll INF = 1e9;
const ll MOD = 1e9+7;
const vl dx = {1,0,-1,0,1,0,-1,0};
const vl dy = {0,1,0,-1,0,1,0,-1};
//マクロ
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define rrep(i,n) for(ll i = (ll) n - 1; i >= 0;i--)
#define REP(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define RREP(i,x,n) for(ll i = (ll) n - 1; i >= x; i--)
#define each(i,A) for(ll i: (vl) A)
#define all(A) A.begin(), A.end()
#define Size(A) ll(A.size())
//入力
template<typename T> T input() {T x; cin >> x; return x;}
//正誤判定
void Yes(bool ans){cout << (ans? "Yes" : "No") << endl;}
void YES(bool ans){cout << (ans? "YES" : "NO") << endl;}
//余り切り上げ
ll ceil(ll a,ll b) {return (a + b - 1) / b;}
//最大値・最小値
template <typename T> bool chmax(T &a, const T& b) {if(a < b) {a = b; return true;} return false;}
template <typename T> bool chmin(T &a, const T& b) {if(a > b) {a = b; return true;} return false;}
//最大公約数
ll gcd(ll a,ll b){if(a<b)swap(a,b); if(a%b==0)return b; return gcd(b,a%b);}
//最小公倍数
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
//n乗の余り
ll modPow(ll x,ll n,ll mod){if(n==0)return 1; if(n%2==0)return modPow(x*x,n/2,mod)%mod; return x%mod*modPow(x,n-1,mod)%mod;}


/*--------------------------------------------------------------------------*/

//main関数
int main() {
    ll n, m;
    cin >> n >> m;

    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
}



Measured memory_bytes: 3600
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1e9;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
/* struct P {
	int x, y, n;
	P(int n, int x, int y):n(n), x(x), y(y){}
	P(){}
}; */

/** Problem1162 : Discrete Speed **/
const int MAX_V = 30, MAX_C = 31;
int N, M;
double d[MAX_V][MAX_C][MAX_V];

struct Node {
	int c, v, prev; double time;
	Node (double _t, int _v, int _c, int _p) : v(_v), c(_c), time(_t), prev(_p){}
	bool operator<(const Node &n)const{return time>n.time;}
};

struct Edge {
	int to, cost, lim;
	Edge(int t, int c, int l) :  to(t), cost(c), lim(l){}
};
vector<Edge> G[MAX_V];

int tmp[] = {-1, 0, 1};

void dijkstra(int s)
{
	priority_queue<Node> Q;
	
	fill(d[0][0], d[0][0]+MAX_V*MAX_V*MAX_C, INF);
	d[s][0][s] = 0;
	Q.push(Node(0, s, 0, s));
	
	while (Q.size()) {
		Node n = Q.top(); Q.pop();
		int v = n.v, c = n.c;
		//cerr << "(" << v+1 << ", " << c << ", " << n.time << ")" << endl;
		
		if (d[v][c][n.prev] < n.time) continue;
		
		for (int i=0; i<G[v].size(); i++) {
			Edge e = G[v][i];
			
			for (int j=0; j<3; j++) {
				int nc = c+tmp[j];
				if (nc>G[v][i].lim || e.to == n.prev) continue;

				if (0<nc && nc<=30) {
					if (d[e.to][nc][v] > n.time + (double)e.cost/nc) {
						d[e.to][nc][v] = n.time + (double)e.cost/nc;
						Q.push(Node(d[e.to][nc][v], e.to, nc, v));
					}
				}
			}
		}
	}
}

int main()
{
	while (cin>>N>>M, N||M) {
		rep(i, MAX_V) G[i].clear();
		int s, g; cin>>s>>g; s--, g--;
		
		rep(i, M) {
			int x, y, d, c;
			cin>>x>>y>>d>>c;
			G[x-1].push_back(Edge(y-1, d, c));
			G[y-1].push_back(Edge(x-1, d, c));
		}
		
		dijkstra(s);
		
		double ans = INF;
		for (int i=0; i<MAX_V; i++) {
				ans = min(ans, d[g][1][i]);
		}
		
		if (ans < INF) {
			cout << fixed << setprecision(10);
			cout << ans << endl;
		} else {
			cout << "unreachable" << endl;
		}
	}
}

Measured memory_bytes: 1988
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long r = sc.nextLong();
		long D = sc.nextLong();
		long x2000 = sc.nextLong();
		sc.close();

		long prev = x2000;
		for (int i = 0; i < 10; i++) {
			long ans = r * prev - D;
			System.out.println(ans);
			prev = ans;
		}
	}
}


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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

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

#define INF 1000000000

char l[20];
int idx;

int term(){
  int ret=l[idx++] - '0';
  while(l[idx]=='*'){
    idx++;
    ret *= l[idx++] - '0';
  }
  return ret;
}

int m_eval(){
  idx=0;
  int ret=term();
  while(l[idx] != '\0'){
    idx++; // skip '+'
    ret += term();
  }
  return ret;
}

int l_eval(){
  int ret=0;
  idx=0;
  while(l[idx]!='\0'){
    if(l[idx] == '+'){
      idx++;
    } else if(l[idx] == '*'){
      idx++;
      ret *= l[idx++] - '0';
    } else {
      ret += l[idx++] - '0';
    }
  }
  return ret;
}

int main(){
  int bob;
  scanf("%s\n%d", l, &bob);

  idx=0;
  int m = m_eval();
  int l = l_eval();

  if(bob==m && bob==l){
    cout << "U" << endl;
  } else if(bob==m && bob!=l){
    cout << "M" << endl;
  } else if(bob==l){
    cout << "L" << endl;
  } else {
    cout << "I" << endl;
  }

  return 0;
}

Measured memory_bytes: 1208
n = int(input())
al = list(map(int, input().split()))
al.sort()
al_cnt_d = {}

if al[0] == 0 and al[n-1] == 0:
    print('Yes')

elif n == 3:
    if al[0] ^ al[1] ^al[2] == 0:
        print('Yes')
    else:
        print('No')

elif n%3 == 0:
    for a in al:
        al_cnt_d.setdefault(a,0)
        al_cnt_d[a] += 1

    if len(al_cnt_d) == 3:
        val = 0
        for k,v in al_cnt_d.items():
            val = val^k
            if v != n//3:
                print('No')
                exit()
        if val == 0: print('Yes')
        else: print('No')
    elif len(al_cnt_d) == 2:
        if 0 not in al_cnt_d or al_cnt_d[0] != n//3:
            print('No')
            exit()            
        else:
            print('Yes')
    else:
        print('No')


else:
    print('No')

Measured memory_bytes: 93948
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;

int main(){
  int r, c;
  while(scanf("%d%d", &r, &c) && r && c)
    puts((r*c)%2?"no":"yes");

  return 0;
}

Measured memory_bytes: 1168
import math
import itertools
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

x = []
for i in range(n):
    x.append(i+1)

X = list(itertools.permutations(x,n))

a = 0
b = 0
for i in range(math.factorial(n)):
    if p == list(X[i]):
        a = i
    if q == list(X[i]):
        b = i

print(abs(a-b))        

Measured memory_bytes: 8052
s = input()
n = len(s)
def dfs(i, f):
  if i == n - 1:
    return sum(list(map(int, f.split('+'))))
  return dfs(i + 1, f + s[i + 1]) + dfs(i + 1, f + '+' + s[i + 1]) 

print(dfs(0, s[0]))

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

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1 << 29)
#define LLINF (1LL << 60)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

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

string to_string(string s) { return s; }
template <class S>
string to_string(unordered_set<S> s);
template <class S>
string to_string(set<S> s);
template <class S, class T>
string to_string(map<S, T> m);
template <class T>
string to_string(vector<T> v);

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S>
string to_string(set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S, class T>
string to_string(map<S, T> m) {
  string ret = "{";
  for (pair<S, T> x : m) ret += to_string(x) + ",";
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int N, K;
  cin >> N >> K;
  int R, S, P;
  cin >> R >> S >> P;
  string T;
  cin >> T;
  vector<vector<int>> dp(N, vector<int>(3));
  auto score = [&](int pos, int te) {
    if (T[pos] == 'r') {
      if (te == 2) return P;
    } else if (T[pos] == 's') {
      if (te == 0) return R;
    } else if (T[pos] == 'p') {
      if (te == 1) return S;
    }
    return 0;
  };
  int ans = 0;
  FOR(i, K) {
    int last = 0;
    for (int j = i; j < N; j += K) {
      dp[j][0] = max(j >= K ? dp[j - K][1] : 0, j >= K ? dp[j - K][2] : 0) +
                 score(j, 0);
      dp[j][1] = max(j >= K ? dp[j - K][0] : 0, j >= K ? dp[j - K][2] : 0) +
                 score(j, 1);
      dp[j][2] = max(j >= K ? dp[j - K][0] : 0, j >= K ? dp[j - K][1] : 0) +
                 score(j, 2);
      last = j;
    }
    ans += *max_element(ALL(dp[last]));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5840
import java.util.*;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int d = sc.nextInt();
		int t = sc.nextInt();
		int s = sc.nextInt();
		if (d <= s * t) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 35648