akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");
    int n = Integer.parseInt(sl[0]);

    s = r.readLine();
    sl = s.split(" ");
    int a[] = new int[n];
    for(int i = 0; i < n; i++)
    {
      a[i] = Integer.parseInt(sl[i]);
    }

    int k = 0;
    int u = 0;
    for(int i = 0; i < n; i++)
    {
      if(a[i] == k + 1) k++;
      else u++;
    }
    System.out.println(u == n ? -1 : u);
  }

}

class RemRing
{
  long module;

  public RemRing(long module)
  {
    this.module = module;
  }

  public long sum(long a, long b)
  {
    return (a + b + module) % module;
  }

  public long sub(long a, long b)
  {
    return (a - b + module) % module;
  }

  public long prod(long a, long b)
  {
    return (a * b) % module;
  }

  public long div(long a, long b)
  {
    return (a * inv(b)) % module;
  }

  public long inv(long a)
  {
    long b = this.module;
    long u = 1;
    long v = 0;
    while (b > 0)
    {
      long t = a / b;
      a -= t * b;
      u -= t * v;
      long z = a;
      a = b;
      b = z;
      z = u;
      u = v;
      v = z;
    }
    u %= this.module;
    if (u < 0)
      u += this.module;
    return u;
  }
}


Measured memory_bytes: 58672
n = gets.to_i
a = Array.new(4){Array.new(3){Array.new(10, 0)}}
n.times{
  b, f, r, v = gets.split.map &:to_i
  a[b-1][f-1][r-1] += v
}
a.each_with_index{|e, i|
  e.each{|r| puts ' ' + r.join(' ')}
  puts '#' * 20 unless i == 3
}

Measured memory_bytes: 8748
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define ll long long
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
using namespace std;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*(b/gcd(a, b)); }
template<typename T> void vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], ll n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
ll keta(ll num){ ll k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    unsigned ll s;
    cin >> s;

    ll large = 1e9;
    ll x3 = (large-s%large)%large;
    ll x2 = (x3+s)/large;

    cout << 0 sp 0 sp x2 sp 1 sp x3 sp large << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  long int h,k;
  cin>> h;
  for(int i=1;i<=40;i++){
    long int p = pow(2,i);
    if(h/p == 0){
      k = p;
      break;
    }
  }
  cout<<k-1;
  return 0;
}
      
  

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


/**
 * AIZU ONLINE JUDGE ddd
 * 3121
 *  2020/5/3
 */
public class Main {


    class ABCD {
        int a;
        int b;
        int c;
        int d;
        public ABCD(int a, int b, int c, int d) {
            this.a = a;
            this.b = b;
            this.c = c;
            this.d = d;
        }
        public ABCD(int a) {
            this.a = a;
        }
    }

    boolean main() throws IOException {

        Scanner sc = new Scanner(systemin);

        int N = sc.nextInt();
        int Q = sc.nextInt();

        List<ABCD> list = new ArrayList<>();

        loop:
        for(int i = 0; i < N; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            int d = sc.nextInt();
            if (list.size() < 100) {
                for(ABCD t : list) {
                    if (a == t.a && b == t.b && c == t.c && d == t.d)
                        continue loop;
                }
            }
            list.add(new ABCD(a, b, c, d));
        }

        // aの昇順
        Comparator<ABCD> comp = (s, t) -> s.a - t.a;
        Collections.sort(list, comp);

        for(int j = 0; j < Q; j++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            int z = sc.nextInt();
            int w = sc.nextInt();
            boolean yes = false;

            int k = Collections.binarySearch(list, new ABCD(x - 1), comp);
            if (k < 0)
                k = -k - 1;

            for(int i = k; i < list.size(); i++) {
                ABCD a = list.get(i);
                if (a.a >= y)
                    break;
                if (x < a.a && a.a < y && y < a.b &&
                    z < a.c && a.c < w && w < a.d) {
                    yes = true;
                    break;
                }
            }
            System.out.printf("%s\n", yes ? "Yes" : "No");
        }

        sc.close();
        return false;
    }



    PrintStream log;
    PrintStream result = System.out;
    BufferedReader systemin;

    static Main instance = new Main();

    Main() {
        systemin = new BufferedReader(new InputStreamReader(System.in));
        log = new PrintStream(new OutputStream() { public void write(int b) {} } );
    }

    public static void main(String[] args) throws IOException {

        instance.main();
        instance.systemin.close();
    }


}




Measured memory_bytes: 220204
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		char[] chars = str.toCharArray();

		chars = switch_ul(chars);

		for (int i = 0; i < chars.length; i++) {
			System.out.print(chars[i]);
		}

		System.out.println();
		sc.close();


	}

	private static char[] switch_ul(char[] chars) {
		char[] chars_switch = new char[chars.length];

		for (int i = 0; i < chars.length; i++) {
			if(Character.isUpperCase(chars[i]) ) {
				chars_switch[i] = Character.toLowerCase(chars[i]);
			} else if (Character.isLowerCase(chars[i])) {
				chars_switch[i] = Character.toUpperCase(chars[i]);
			} else {
				chars_switch[i] = chars[i];
			}
		}

		return chars_switch;
	}

}



Measured memory_bytes: 26984
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)

using namespace std;

int main() {
    int a,b;
    vector<vector<int>> xy;
    while(true) {
        cin >> a >> b;
        if(a == 0 && b == 0) break;
        else xy.push_back({min(a,b),max(a,b)});
    }
    rep(i,(int)xy.size()) cout << xy[i][0] << ' ' << xy[i][1] << endl;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int flag=0;
vector<int>x(9);
rep(i,9){
  int a;
  cin>>a;
  x.at(i)=a;  
}
int b=x.at(3)-x.at(0),c=x.at(6)-x.at(3);
rep(i,2){
  int d,e;
  d=x.at(i+4)-x.at(i+1);
  e=x.at(i+7)-x.at(i+4);
  if (b!=d || c!=e) {
    flag+=1;
    break;
  }
}
b=x.at(1)-x.at(0);
c=x.at(2)-x.at(1);
rep(i,2){
  int d,e;
  d=x.at(3*(i+1)+1)-x.at(3*(i+1));
  e=x.at(3*(i+1)+2)-x.at(3*(i+1)+1);
  if (b!=d || c!=e) {
    flag+=1;
    break;
  }
}
if (flag==0) {
  cout<<"Yes"<<endl;
}
else{
  cout<<"No"<<endl;
}
}

Measured memory_bytes: 256
import Foundation
func toTuple<T>(_ args: [T]) -> (T, T) { (args[0], args[1]) }
func toTuple<T>(_ args: [T]) -> (T, T, T) { (args[0], args[1], args[2]) }
func toTuple<T>(_ args: [T]) -> (T, T, T, T) { (args[0], args[1], args[2], args[3]) }
func readInts() -> [Int] { readLine()!.split(separator: " ").map { Int($0)! } }
func readDoubles() -> [Double] { readLine()!.split(separator: " ").map { Double($0)! } }
func readStrings() -> [String] { readLine()!.split(separator: " ").map { String($0) } }

let (x, y) = toTuple(readInts())

guard y % 2 == 0 else { print("No"); exit(0) }
let max = y / 2
let min = ceil((Double(max) / 2))
if (x >= Int(min) && x <= max) { print("Yes") }
else { print("No") }

Measured memory_bytes: 13708
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)x.size()
#define f first
#define s second
const int MAXN=301;
const int MAXK=19;
const int INF = 1e9;
const ll MOD = 998244353;

ll N,E,K,W,a,b,c,d;
ll A,B,C,D;
string S;
ll dp1[MAXN][MAXN][MAXN]; // eligible for free
ll dp2[MAXN][MAXN][MAXN]; // not eligible for free
ll cnt[MAXN];
ll runcnt[MAXN];
ll X,Y;

ll ask(ll x, ll y, ll move, ll elig){
  if(x>X+1||y>Y||move>K)return 0;
  if(x==X+1&&y==Y)return 1;
  if (x!=0&&runcnt[x-1] > y){return 0;}
  ll ans=0;
  if(elig==1){
    if(dp1[x][y][move]!=-1)return dp1[x][y][move];
    // freebies
    for(int i=0;i<cnt[x];++i){
      ans += ask(x+1,y+i,move,1); 
      ans%=MOD;
    }
    // not free
    ans += ask(x,y+cnt[x],move,0);
    ans%=MOD;
    dp1[x][y][move]  = ans;
  }else{
    if(dp2[x][y][move]!=-1)return dp2[x][y][move];
    ans += ask(x+1,y,move,1);
    ans += ask(x,y+1,move+1,0);
    ans%=MOD;
    dp2[x][y][move] = ans;
  }
  // cout<<"Asking "<<x<<' '<<y<<' '<<move<<' '<<elig<<' '<<ans<<'\n';
  return ans;
}

int main(){
    cin>>S>>K;
    vi V;
    int a=0;
    for (auto i:S){
      if(i=='0')++a;
      else{
        V.pb(a);
        cnt[a]++;
      }
    }
    X = a; // 0 to X
    runcnt[0]=cnt[0];
    for (int i=1;i<=X;++i)runcnt[i]= runcnt[i-1]+cnt[i];
    Y = SZ(V); // 1 to Y
    // cerr<<X<<' '<<Y<<' '<<K<<'\n';
    // K = min(K,Y);
    // for (int i=0;i<=X;++i)cout<<cnt[i]<<' ';
    memset(dp1,-1,sizeof(dp1));
    memset(dp2,-1,sizeof(dp2));
    cout<<ask(0,0,0,1); 
    // cout<<ask(0,1,1,0)<<'\n';
}

Measured memory_bytes: 429748
from collections import Counter
N = int(input())
D = list(map(int, input().split()))
MOD = 998244353

# 厳密にはmax(D)+1の長さがあれば正常系は通るが、余分に取っておく
count = [0] * N
for d in D:
    count[d] += 1

def calc():
    if D[0] != 0 or count[0] >= 2:
        return 0
    ret = 1
    for i in range(N):
        if i > 0:
            ret *= (count[i-1] ** count[i]) % MOD
            ret %= MOD
    return ret

print(calc())


Measured memory_bytes: 14780
#include<stdio.h>

long long ab(long long x){
	if(x<0)return -x;
	return x;
}

int main(){
	int N;
	long long ans=1000000000000000;
	scanf("%d",&N);
	long long a[N];
	long long sum[N+1];
	sum[0]=0;
	for(int i=0;i<N;i++){
		scanf("%lld",&a[i]);
		sum[i+1]=sum[i]+a[i];
	}
	
	for(int i=1;i<N;i++){
		long long tmp;
		tmp=ab(2*sum[i]-sum[N]);
		if(tmp<ans)ans=tmp;
	}
	printf("%lld\n",ans);
	return 0;
}

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

#define f first
#define s second
#define pb push_back
#define ll long long int 
typedef pair<int,int> pii;
vector<int>v;
map<int,int>op;
#define MAX 200005
bool visited[MAX];
vector<int>adj[MAX];
const int M=1e9+7;
const int N=505;
int n,m;
const ll INF = 1LL << 60;
ll dp[MAX];
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL); 
	cin>>n;
	int k;
	cin>>k;
	int h[n];
	for(int i=0;i<n;i++)
		cin>>h[i];
	for(int i=0;i<=n;i++)
		dp[i]=INF;
	dp[0]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=max(0,i-k);j<i;j++)
			dp[i]=min(dp[j]+abs(h[i]-h[j]),dp[i]);
	}
	cout<<dp[n-1]<<endl;
	return 0;	
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
using ll = long long;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    ll sum = 0, ans = 0;
    vector<ll>v(n+1, 0);
    rep(i, 0, n){
        if(s[i] =='<'){
            v[i+1] = v[i] +1;
        }
    }
    rrep(i, n, 0){
        if(s[i-1] == '>'){
            v[i-1] = max(v[i-1], v[i]+1);
        }
    }
    rep(i, 0, n+1){
        ans += v[i];
    }
    cout << ans << endl;
}

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

int main()
{
    // freopen("a.in","r",stdin);
    // freopen("k.out","w",stdout);
    int n,k;
    scanf("%d %d",&n,&k);
    int ans = (n-1)*(n-2)/2;
    if(ans < k)
    {
        printf("-1");
    }
    else
    {
        printf("%d\n",n-1 + ans - k );
        for(int i=2;i<=n;i++)
            printf("%d %d\n",1,i);

        for(int i=2;i<=n;i++)
            for(int j=i+1;j<=n;j++)
            {
                if(ans == k) return 0;
                printf("%d %d\n",i,j);
                ans--;
                
            }
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define fi first
#define se second
using namespace std;
typedef pair<int,int> ii;

const ll siz = 2e5 + 10;
const ll SIZ = 1e6 + 10;
const ll mod = 1e9 + 7;
const ll maxx = 2e9;
const ll MAXX = 1e18;
const ll base = 31;

int n;
int s;

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
//    freopen ("IN_3.INP", "r", stdin);
//    freopen ("OUT_3.OUT", "w", stdout);
    cin >> n;
    for (int i1 = 1; i1 <= n; i1++)
        for (int i2 = 1; i2 <= n; i2++)
            for (int i3 = 1; i3 <= n; i3++)
                s += __gcd(i1, __gcd(i2, i3));
    cout << s;
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

template <class T>
void cout_vec2(const vector<vector<T>> &vec){
  rep(i,vec.size()){
    rep(j,vec[i].size()){
      cout<<vec[i][j]<<' ';
    }
    cout<<endl;
  }
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin>>n;
  ll sum=0;
  ll tar;
  if(n==1){
    cout<<n<<endl;
    return 0;
  }
  FOR(i,1,n+1){
    sum+=i;
    if(sum>n){
      tar=i;
      break;
    }
  }
  //cout<<sum<<' '<<tar<<endl;
  FOR(i,1,tar+1){
    if(i!=sum-n){
      cout<<i<<endl;
    }
  }
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    };
    let mut map = std::collections::BTreeMap::new();
    for &a_i in a.iter() {
        *map.entry(a_i - 1).or_insert(0) += 1;
        *map.entry(a_i).or_insert(0) += 1;
        *map.entry(a_i + 1).or_insert(0) += 1;
    }
    let ans = map.values().max().unwrap();
    println!("{}", ans);
}


Measured memory_bytes: 5512
# m回増えて、N-1-m回減ったとしたときの範囲は出せるので、全探索。
N, A, B, C, D = map(int, input().split())
for m in range(N):
    lb = m * C - (N - 1 - m) * D
    ub = m * D - (N - 1 - m) * C
    if lb <= abs(B - A) <= ub:
        print("YES")
        exit()

print("NO")

Measured memory_bytes: 64476
/**
        Bismilla- hir rahma-nir rahi-m
    @uthor Md Hasibur Rahman (Evan)
                JKKNIU
*/


#include<bits/stdc++.h>
#define         ll              long long
#define         FI              freopen("input.txt","r",stdin)
#define         FO              freopen("output.txt","w",stdout)
#define         PrintCase(i)    printf("Case %d: ",i)
#define         sc(a)           scanf("%d",&a)
#define         scl(a)          scanf("%lld",&a)
#define         rep(i,n)        for(int i=0;i<n;i++)
#define         pb              push_back
#define         MAX             1000000




using namespace std;

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






bool isPowerOfTwo(ll a)
{
    if(a==1)
        return true;
    if(a&1)
        return false;
    while(a)
    {
        a/=2;
        if(a!=1 && a&1)
            return false;
        if(a==1)
            return true;
    }
    return true;
}




ll gcd(ll a, ll b)
{
    if(a<0 || b<0)
    {
        a = abs(a);
        b = abs(b);
    }
    if(a<b)
        swap(a,b);
    if(a%b==0 || b==0)
        return b;
    else
        return gcd(b,a%b);
}



ll lcm(ll a, ll b)
{
    return (a*b)/gcd(a,b);
}



ll power(ll base, ll exponent)
{
    ll ans = 1;
    for(ll i=1;i<=exponent;i++)
        ans*=base;
    return ans;
}




bool isPowerOfX(ll x, ll value)
{
    if(value==1)
        return true;
    while(value)
    {
        value/=x;
        if(value%x && value!=1)
            return false;
    }
    return true;
}





int main()
{
    int l,r ,d;
    cin>>l>>r>>d;
    int ans = r/d;
    if(l%d!=0)
        ans-=l/d;
    else if(l%d==0)
    {
        ans-=l/d;
        ans++;
    }
    cout<<ans<<"\n";
    return 0;
}




Measured memory_bytes: 3632
#include <cstdio>
#define MAXN 9
int n, m, cnt;
bool graph[MAXN][MAXN];
bool vst[MAXN];

void dfs(int v, int num) {
    if(num == n) {
        cnt++;
        return;
    }
    for(int i = 1; i <= n; i++) {
        if(graph[v][i] && !vst[i]) {
            vst[i] = true;
            dfs(i, num+1);
            vst[i] = false;
        }
    }
}

int main() {
    int a, b;
    scanf("%d%d", &n, &m);
    for(int i =1; i <= m; i++) {
        scanf("%d%d", &a, &b);
        graph[a][b] = true;
        graph[b][a] = true;
    }
    vst[1] = true;
    dfs(1, 1);

    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long int
#define INF 1000000000000
#define MOD 1000000007
#define DEBUG(x) cerr<<'>'<<#x<<':'<<x<< endl
using namespace std;
ll val[150], wt[150];
ll dp[105][100005];
ll N, W;
ll max_val = 0;

void init()
{
    for(ll i = 0; i <= N; i++)
    {
        dp[i][0] = 0;
        for(ll j = 1; j <= max_val; j++)
        {
            dp[i][j] = -1;
        }
    }
}

void DP()
{
    dp[0][0] = 0;
    ll val_so_far = 0;
    for(ll i = 1; i <= N; i++)
    {
        for(int j = 0; j <= val_so_far; j++)
        {
            if(dp[i - 1][j] != -1)
            {
                if(dp[i][j] != -1)
                    dp[i][j] = min(dp[i][j], dp[i - 1][j]);
                else
                    dp[i][j] = dp[i - 1][j];
                if(dp[i][j + val[i]] != -1)
                    dp[i][j + val[i]] = min(dp[i][j + val[i]], dp[i - 1][j] + wt[i]);
                else
                    dp[i][j + val[i]] = dp[i - 1][j] + wt[i];
                
            }
        }
        val_so_far += val[i];
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> N >> W;
    for(int i = 1; i <= N; i++)
    {
        cin >> wt[i] >> val[i];
        max_val += val[i];
    }    
    init();
    DP();
    ll ans = -1;
    
    for(int i = 0; i <= max_val; i++)
    {
        if((dp[N][i] <= W) && (dp[N][i] != -1))
        {
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 80128
#include <iostream>
#include <map>
#define rep(i, n) for(int i=0; i<n; i++)

using namespace std;

int main(void){
  int N;
  string S;
  cin >> N >> S;
  //入力終了

  int max = 0;
  rep(i, N){
    //前半の文字列の出現状況を記録
    int appeared[26]={0};
    rep(j, i+1)
      appeared[S[j]-'a']++;
    
    //appeared[]を元に共通文字があればcountを更新
    map<char, int> map;
    for(int j=i+1; j<N; j++)
      if(appeared[S[j]-'a' ] > 0)
	map[S[j] ]++;
    //最大値の更新
    if(map.size() > max)
      max = map.size();
  }

  //解答
  cout << max << endl;

  return 0;
}


Measured memory_bytes: 3612
import java.text.DecimalFormat;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        int h = in.nextInt();
        int m = in.nextInt();
        double hx = Math.sin((h+m/60.0)/12.0*2*Math.PI) * a;
        double hy = Math.cos((h+m/60.0)/12.0*2*Math.PI) * a;
        double mx = Math.sin(m/60.0*2*Math.PI) * b;
        double my = Math.cos(m/60.0*2*Math.PI) * b;
        double ans = Math.sqrt((hx-mx)*(hx-mx) + (hy-my)*(hy-my));
        DecimalFormat formatter = new DecimalFormat("0.000000000");
        System.out.println(formatter.format(ans));
    }
}


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

int main(void){
    int N,D;cin>>N>>D;
    int X[N][D];
    for(int i=0;i<N;i++){
        for(int l=0;l<D;l++){
            cin>>X[i][l];
        }
    }
    int ans=0;
    for(int i=0;i<N;i++){
        for(int l=i+1;l<N;l++){
            int sum=0;
            for(int m=0;m<D;m++){
                sum+=pow((X[i][m]-X[l][m]),2);
            }
            for(int m=0;m*m<=sum;m++){
                if(m*m==sum){
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main()
{
        int n;
        double sum, ave, disp, std;
        vector<double> result;

        while(cin>>n , n != 0)  {
                sum = 0; ave = 0; disp = 0; std = 0;
                int d[n];

                for(int i = 0; i < n; i++) {
                        cin >> d[i];
                        sum += d[i];
                }

                ave = sum/n;

                for(int i = 0; i < n; i++) {
                        disp += pow((ave - d[i]), 2);
                }

                std = sqrt(disp/n);
                result.push_back(std);
        }

        cout.setf(ios::fixed, ios::floatfield);
        for(vector<double>::iterator ite = result.begin(); ite != result.end(); ++ite) {
                cout << *ite << endl;
        }

        return 0;
}


Measured memory_bytes: 3248
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+7;
const llint big=(llint)44e15;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int main(void){
	llint x,y;cin>>x>>y;
	if(x%y==0){cout<<-1<<endl;}
	else{cout<<x<<endl;}
	return 0;
}


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

 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define sz size()

/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  st s;
    cin>>s;
  ll k;
    cin>>k;
  ll ans=0;
  ll n=s.sz;
  ll count=1;
  ll head=0;
  ll end=0;
  FOR(i,1,n){
    
    if(s[i-1]==s[i]){
      count++;
    }
    
    else if(i==count){
      head=count;
      count=1;
    }
    
    else{
      ans+=count/2*k;
      count=1;
    }
    
    if(i==n-1){
      end=count;
    }  
  }

  if(count==n){
    ans=k*n/2;
  }
  
  else if(s[0]==s[n-1]){
    ans+=(head+end)/2*(k-1);
    ans+=head/2+end/2;
  }
  
  else{
    ans+=head/2*k;
    ans+=end/2*k;
  }
  
  cout<<ans<<endl;
  
}


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

using namespace std;

long long MOD = 998244353;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    double l;
    cin >> l;
    auto v = l/3;
    auto ans = v*v*v;
    cout.precision(7);
    cout << fixed << ans << endl;
}



Measured memory_bytes: 384
#include<stdio.h>

#define N 2000001

int n;

void Counting_Sort(int a[],int b[],int k){
  int i, j, c[N];

  for(i=0; i<=k; i++) c[i]=0;

  for(j=1; j<=n; j++) c[a[j]]++;

  for(i=1; i<=k ;i++) c[i]+=c[i-1];

  for(j=n; j>0; j--) {
    b[c[a[j]]]=a[j];
    c[a[j]]--;
  }
  for(i=1;i<=n;i++){
    printf("%d",b[i]);
    if(i!=n) printf(" ");
  }
  printf("\n");
 

}


int main(){
  int i,  max=0;
 static  int a[N],b[N];
  scanf("%d",&n);

  for(i=1; i<=n; i++){
    scanf("%d",&a[i]);
    if(a[i]>max)  max=a[i];
  }
  
  Counting_Sort(a,b,max);
   

  return 0;
}

Measured memory_bytes: 15000
#include<bits/stdc++.h>
using namespace std;
const double pi=acos(-1.0);
int main(){
   double a,b,h,m;
   cin>>a>>b>>h>>m;
   double ans=a*a+b*b-2*a*b*cos(2*pi*((h+m/60)/12-m/60));
   printf("%.12lf\n",sqrt(ans));
   return 0;
}


Measured memory_bytes: 4104
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>

using namespace std;

long long x = 1000000007;


int main() {
	int n;
	cin >> n;
	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 3 != 0 && i % 5 != 0)ans += i;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;

int main()
 {
 	int n,i,a=0,w=0,t=0,r=0;
 	cin>>n;
 	string s[n];
 	for(i=0;i<n;i++)
 		cin>>s[i];
 	for(i=0;i<n;i++)
 		{
 			if(s[i]=="AC")
 				a++;
 			else if(s[i]=="WA")
 				w++;
 			else if(s[i]=="TLE")
 				t++;
 			else
 				r++;
		 }
 		cout<<"AC"<<" "<<"x"<<" "<<a<<endl;
 		cout<<"WA"<<" "<<"x"<<" "<<w<<endl;
 		cout<<"TLE"<<" "<<"x"<<" "<<t<<endl;
 		cout<<"RE"<<" "<<"x"<<" "<<r<<endl;
 	
	return 0;
}
 	
 					

Measured memory_bytes: 6664
import java.util.*;
public class Main {

	public static void main(String [] args)
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int arr[][]=new int[n][3];
		long dp[][]=new long[n][3];
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<3;j++)
			{
				arr[i][j]=sc.nextInt();
			}
		}
		for(int i=0;i<n;i++)
		{
			Arrays.fill(dp[i], -1);
		}
		long ans=rec(arr,dp,0,0);
		System.out.println(ans);
	}

	private static long rec(int[][] arr, long[][] dp, int ind, int sel) {
		// TODO Auto-generated method stub
		if(ind==arr.length)
		{
			return 0;
		}
		long ans=0;
		//System.out.println(ind+" "+sel);
		if(sel!=0&&dp[ind][sel-1]!=-1)
		{
			//System.out.println("y");
			return dp[ind][sel-1];
		}
		if(sel==0)
		{
			long opt1=arr[ind][0]+rec(arr,dp,ind+1,1);
			long opt2=arr[ind][1]+rec(arr,dp,ind+1,2);
			long opt3=arr[ind][2]+rec(arr,dp,ind+1,3);
			ans=Math.max(opt1, Math.max(opt2, opt3));
			return ans;
		}else if(sel==1)
		{
			long opt1=arr[ind][1]+rec(arr,dp,ind+1,2);
			long opt2=arr[ind][2]+rec(arr,dp,ind+1,3);
			ans=Math.max(opt1, opt2);
		}else if(sel==2)
		{
			long opt1=arr[ind][0]+rec(arr,dp,ind+1,1);
			long opt2=arr[ind][2]+rec(arr,dp,ind+1,3);
			ans=Math.max(opt1, opt2);
		}else {
			long opt1=arr[ind][0]+rec(arr,dp,ind+1,1);
			long opt2=arr[ind][1]+rec(arr,dp,ind+1,2);
			ans=Math.max(opt1, opt2);
		}
		//System.out.println(ind+" "+sel);
		dp[ind][sel-1]=ans;
		return ans;
	}
}


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 200005
#define MAX_M MAX_N
#define MAX_V MAX_N

struct edge{ int to, cost; };
typedef pair<int, int> P;   // first は最短距離、 second は頂点の番号

int V;
vector<edge> G[MAX_V];      // ノード i からのびている edge の vector 。ダイクストラ前に自分で入力する
int d[MAX_V];
int prev_p[MAX_V];  // 経路も求める場合は必要

// 始点 s から各頂点への最短距離を求める
void dijkstra(int s) {
    // greater<P>を指定することでfirstが小さい順に取り出せるようにする
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d + V, INF);
    //fill(prev_p, prev_p + V, -1); // 経路を求めるなら有効
    d[s] = 0;
    que.push(P(0, s));
    while(!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if(d[v] < p.first){ continue; }
        REP(i, G[v].size()) {
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                prev_p[e.to] = v;   // 経路も求めるなら有効
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

// 始点 s から t までの経路を vector に入れて返す(s と t 含む)
// dijkstra 後に使用
vector<int> get_path(int t) {
    vector<int> path;
    for(; t != -1; t = prev_p[t]) { path.push_back(t); }  // t が s になるまで prev_p[t] を辿っていく
    // このままだと t->s の順になっているので逆順にする
    reverse(path.begin(), path.end());
    return path;
}


ll N, M;
int main()
{
    cin >> N >> M;
    V = N;
    REP(i, M) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        edge e1, e2;
        e1.to = b;
        e1.cost = 1;
        G[a].push_back(e1);
        //e2.to = a;
        //e2.cost = 1;
        //G[b].push_back(e2);
    }
    dijkstra(0);
    //printf("%d\n", d[N-1]);
    if(d[N-1] <= 2) {
        printf("POSSIBLE\n");
    } else {
        printf("IMPOSSIBLE\n");
    }

    return 0;
}


Measured memory_bytes: 11892
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from math import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
INF = float('inf')
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
    return int(readline())
n,m = readInts()
N = [readInts() for _ in range(n)]
M = [readInts() for _ in range(m)]
for a,b in N:
    pos = INF
    ans = None
    for i,(x,y) in enumerate(M):
        if abs(a-x) + abs(b-y) < pos:
            pos = abs(a-x)+abs(b-y)
            ans = i+1
    print(ans)


Measured memory_bytes: 10324
#include <stdio.h>

int main(void)
{
	int i;
	int l = 0;
	int num;
	int num2;
	int box[100];
	int box2[100];
	int resu = 0;
	int resu2 = 0;
	for (i = 0; i < 100; i++){
		box[i] = 0;
	}
	for (i = 0; i < 100; i++){
		box2[i] = i + 1;
	}
	
	scanf("%d", &num);
	
	for (i = 0; i < num; i++){
		num2 = i + 1;
		while (num2 > 0){
			num2 = num2 / 2;
			l++;
		}
		box[i] = l;
		l = 0;
		
	}

	for (i = 0; i < num; i++){
		if (resu < box[i]){
			resu = box[i];
			resu2 = box2[i];
		}

	}
	printf("%d\n", resu2);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int dp[2005][2005][2];

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

	string s, t;
	cin >> s >> t;

	n++;
	m++;
	s = " " + s;
	t = " " + t;

	memset(dp, 0, sizeof(dp));

	REP(i, 0, n) {
		REP(j, 0, m) {

			if(i == 0 && j == 0) continue;

			bool a = false, b = false;
			if(i == 0) {
				b = true;
			} else if(j == 0) {
				a = true;
			} else {
				a = true;
				b = true;
			}

			if(a) {
				if(dp[i-1][j][1] == 0) {
					if(s[i] == 'I') {
						dp[i][j][1] = max(dp[i][j][1], dp[i-1][j][0] + 1);
					}
				} else {
					if(s[i] == 'I') {
						dp[i][j][1] = max(dp[i][j][1], dp[i-1][j][0] + 1);
					} else {
						dp[i][j][0] = max(dp[i][j][0], dp[i-1][j][1] + 1);
					}
				}
			}

			if(b) {
				if(dp[i][j-1][1] == 0) {
					if(t[j] == 'I') {
						dp[i][j][1] = max(dp[i][j][1], dp[i][j-1][0] + 1);
					}
				} else {
					if(t[j] == 'I') {
						dp[i][j][1] = max(dp[i][j][1], dp[i][j-1][0] + 1);
					} else {
						dp[i][j][0] = max(dp[i][j][0], dp[i][j-1][1] + 1);
					}
				}
			}
		}
	}

	int ans = 0;
	rep(i, n) {
		rep(j, m) {
			// cout << "(" << dp[i][j][0] << "," << dp[i][j][1] << ") ";
			ans = max(ans, dp[i][j][1]);
		}
		// cout << endl;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 32636
#include <iostream>
#include <algorithm>
#include <string>

#define MAXN 100000

using namespace std;

string s;

int main()
{
  int min = MAXN+1;
  cin >> s;

  for ( int i = 0; i < s.size()-1; ++i ) {
    if ( s[i] != s[i+1] ) {
      int tmp = s.size();
      tmp =  max(i+1, tmp-i-1);
      if ( min > tmp ) min = tmp;
    }
  }

  if ( min == MAXN+1 ) min = s.size();

  cout << min << "\n";
}


Measured memory_bytes: 1144
INF = 10 ** 9 + 7
H, W = map(int, input().split())
a = [input() for _ in range(H)]
dp = [[0 for _ in range(W)] for _ in range(H)]
dp[0][0] = 1
for i in range(H):
    for j in range(W):
        if i + 1 < H and a[i + 1][j] == '.':
            dp[i + 1][j] = dp[i][j] + dp[i + 1][j]
            dp[i + 1][j] %= INF
        if j + 1 < W and a[i][j + 1] == '.':
            dp[i][j + 1] = dp[i][j + 1] + dp[i][j]
            dp[i][j + 1] %= INF

print(dp[H - 1][W - 1])

Measured memory_bytes: 50680
#include <stdio.h>



int temp[500000],num1=0;
int x[500000];/* ????°???§???????????¨????????????????????????????????? */

int MergeSort(int x[ ], int left, int right);
int main(void);

  /* ?????? x[ ] ??? left ?????? right ???????´??????????????????????????????? */
int MergeSort(int x[ ], int left, int right)
{
    int mid, i, j, k;
	
    if (left >= right)              /* ?????????????´?????????¨????????? */
        return 0;                     /* ?????????????????§?????? */

                                    /* ????????§??????????????????????????? */
    mid = (left + right) / 2;       /* ?????????????????? */
    MergeSort(x, left, mid);        /* ???????????°???????????? */
    MergeSort(x, mid + 1, right);   /* ???????????°???????????? */

      /* x[left] ?????? x[mid] ???????\??????????????????? */
    for (i = left; i <= mid; i++)
        temp[i] = x[i];

      /* x[mid + 1] ?????? x[right] ????????????????????? */
    for (i = mid + 1, j = right; i <= right; i++, j--)
        temp[i] = x[j];

    i = left;         /* i ??¨j ???????\????????????????????????? */
    j = right;        /* k ????????????????´??????????????????? */

    for (k = left; k <= right; k++){
      num1++;/* ?°??????????????????????????????? */
      if (temp[i] <= temp[j]) x[k] = temp[i++];
      else x[k] = temp[j--];
    }
    return 0;
}

int main(void)
{
  int i,n;
      /* ??????????????????????????? */

    scanf("%d",&n);
    for(i=0;i<n;i++){
      scanf("%d",&x[i]);
    }

    MergeSort(x, 0, n - 1);

      /* ?????????????????????????????¨??? */
    //    printf("????????????\n");
    for (i = 0;; i++){
        printf("%d", x[i]);
	if(i<n-1)printf(" ");
	else break;
    }
    printf("\n%d\n",num1);
    return 0;
}

Measured memory_bytes: 4508
#include <iostream>
#include <cctype>
using namespace std;
int W,H;
char F[71][71] = {};
string dp[71][71] = {};

string dfs(int x,int y){
    if(dp[x][y]!="-1") return dp[x][y];
    string res = "",s = "";
    res += F[x][y];
    if(x==H && y==W) return res;
    if(x!=H && isdigit(F[x+1][y])){
        string now = dfs(x+1,y);
        if(s.size()<now.size()) s = now;
        else if(s.size()==now.size() && s<now) s = now;
    }
    if(y!=W && isdigit(F[x][y+1])){
        string now = dfs(x,y+1);
        if(s.size()<now.size()) s = now;
        else if(s.size()==now.size() && s<now) s = now;
    }
    return dp[x][y] = res+s;
}

int main(){
    while(cin >> W >> H && W){
        for(int i=1;i<=H;i++) for(int j=1;j<=W;j++){
            cin >> F[i][j];
            dp[i][j] = "-1";
        }
        string ans = "";
        for(int i=1;i<=H;i++) for(int j=1;j<=W;j++){
            if(isdigit(F[i][j]) && F[i][j]!='0'){
                string now = dfs(i,j);
                if(ans.size()<now.size()) ans = now;
                else if(ans.size()==now.size() && ans<now) ans = now;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3224
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, q, last, cnt, sum[2000000], ans, dp[2000000], a[2000000],b[2000000];
string str;
bool f;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ -1,0 } ,{ 0,-1 } };
struct Edge { LL to, cost; };
vector<Edge>vec[1000000];
vector<Pll>v;
map<string, LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

void add_edge(LL x, LL y, LL z) {
	vec[x].push_back(Edge{ y,z });
	vec[y].push_back(Edge{ x,z });
}
void dfs(LL i, LL d) {
	dp[i] = d;
	rep(j, vec[i].size()) {
		if (dp[vec[i][j].to] == -1)
			dfs(vec[i][j].to, d + vec[i][j].cost);
	}
}
int main() {
	cin >> n;
	rep(i, n-1) {
		LL x, y, z;
		cin >> x >> y >> z;
		add_edge(x-1, y-1, z);
	}
	rep(i, n)
		dp[i] = -1;
	cin >> q >> k;
	dfs(k - 1, 0);
	rep(i, q) {
		LL x, y;
		cin >> x >> y;
		cout << dp[x-1] + dp[y-1] << endl;
	}
	return 0;
}


Measured memory_bytes: 39808
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5+3;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

int main(void){
	int a,b,c,d;cin>>a>>b>>c>>d;
	cout<<(abs(a-c)<=d || abs(a-b)<=d && abs(b-c)<=d ? "Yes" : "No")<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int n, max, min;

	long long sum = 0;

	int a[10001];

	cin >> n;

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

		if (i == 1)
		{
			max = a[i];
			min = a[i];
		}
		else
		{
			if (a[i] > max)
			{
				max = a[i];
			}

			if (a[i] < min)
			{
				min = a[i];
			}
		}

		sum += a[i];
	}

	cout << min << ' ' << max << ' ' << sum << endl;

	return 0;
}



Measured memory_bytes: 3136
#include "bits/stdc++.h"
using namespace std;

#define OUT(x)  cerr << #x << " = " << x << endl;
#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
#define pll     pair<long long, long long>
#define ll      long long

int h, w;

bool on(int y, int x) {
        if (x == 0 || x == w || y == 0 || y == h) return true;
        return false;
}

int convert(int y, int x) {
        if (x == 0) return y;
        if (y == h) return h + x;
        if (x == w) return h + w + h - y;
        if (y == 0) return h + w + h + w - x;
        assert(0);
}

int main() {
        int n;
        cin >> h >> w >> n;
        vector<pii> pos;
        for (int i = 0; i < n; i ++) {
                int y1, x1, y2, x2;
                cin >> y1 >> x1 >> y2 >> x2;
                if (on(y1, x1) && on(y2, x2)) {
                        pos.push_back(mp(convert(y1, x1), i));
                        pos.push_back(mp(convert(y2, x2), i));

                }
        }
        sort(all(pos));
        stack<int> st;
        for (int i = 0; i < pos.size(); i ++) {
                if (st.empty() || st.top() != pos[i].second) st.push(pos[i].second);
                else st.pop();
        }
        cout << (st.empty() ? "YES" : "NO") << endl;
        return 0;
}


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

int main() {

  while(1) {

    int m, f, r;
    cin >> m >> f >> r;

    if (m == -1 && f == -1 && r == -1) {
      return 0;
    }

    if (m == -1 || f == -1) {
      cout << "F" << endl;
    } else if (80 <= m + f) {
      cout << "A" << endl;
    } else if (65 <= m + f) {
      cout << "B" << endl;
    } else if (50 <= m + f) {
      cout << "C" << endl;
    } else if (30 <= m + f) {
      if (50 <= r) {
        cout << "C" << endl;
      } else {
        cout << "D" << endl;
      }
    } else {
      cout << "F" << endl;
    }
  }

  return 0;

}


Measured memory_bytes: 3092
#include <stdio.h>
#include <stdlib.h>
int main() {
	int n, t[100000], x[100000], y[100000], dis, dist;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d%d%d", &t[i], &x[i], &y[i]);
		if (i != 0) {
			dist = t[i] - t[i - 1];
			dis = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
		} else {
			dist = t[i];
			dis = abs(x[i]) + abs(y[i]);
		}
		if (dis > dist || (dist - dis) % 2 == 1) {
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1280
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
mod util {
    use std::fmt::Debug;
    use std::io::{stdin, stdout, BufWriter, StdoutLock};
    use std::str::FromStr;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn chars() -> Vec<char> {
        line().chars().collect()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
    #[allow(dead_code)]
    pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
        let out = stdout();
        let writer = BufWriter::new(out.lock());
        f(writer)
    }
}
#[allow(unused_macros)]
macro_rules ! get { ( [ $ t : ty ] ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; ( [ $ t : ty ] ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( [ $ t ] ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }
const BIG_STACK_SIZE: bool = true;
#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}
fn solve() {
    let (a, b, c) = get!(u64, u64, u64);

    println!("{}", b + min(a + b + 1, c));
}


Measured memory_bytes: 8572
THD = 1000000

while true
  n = gets.chomp.to_i
  break if n == 0

  totals = {}
  totals.default = 0
  ids = {}

  n.times do
    i, p, q = gets.chomp.split(" ").map{|s| s.to_i}

    ts = p * q
    t = (totals[i] += ts)
    if t >= THD && ids[i].nil?
      puts i
      ids[i] = 1
    end
  end

  puts "NA" if ids.empty?
end

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

int main()
{
	int a[100],n,i,keep;

	while(1){	
		scanf("%d",&n);
		if (n<=100 && n>0)
			break;
		else
   			printf("error\n");
	}
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}

	
	// Input datas is sortting of reverse orderder;	
	for(i=0;i<n/2;i++){
		keep=a[i];
		a[i]=a[n-1-i];
		a[n-1-i]=keep;
	}
	for(i=0;i<n;i++){
		if(i) printf(" ");		
		printf("%d",a[i]);
	}
	printf("\n");
	return 0;
}
		

Measured memory_bytes: 600