akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
  
#define fo(i, n) for (long long i = 0; i < n; i++)
#define sc(x) cin >> x
#define pr(x) cout << x << endl;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define br cout << endl
typedef long long int lli;
typedef pair<int, int> pii;
typedef pair<lli, lli> pll;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
lli max(lli a, lli b){ return (a>b)?a:b; }
lli min(lli a, lli b){ return (a<b)?a:b; }

lli gcd(lli a, lli b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}


lli n;
int a[100005], b[100005], c[100005];

int main()
{
    // Fast Input/Output
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    // Test Cases
    int t = 1;
//    cin >> t;

    while (t--) {
        lli n, w;
        sc(n); sc(w);
        lli weight[n+1], val[n+1];
        for(int i=1; i<=n; i++)
        {
            cin >> weight[i] >> val[i];
        }
        
        lli dp[n+1][w+1];
        
        for(int i=0; i<=w; i++)
        {
            dp[0][i] = 0;
        }
        for(int i=0; i<=n; i++)
        {
            dp[i][0] = 0;
        }
        
        for(int i=1; i<=n; i++)
        {
            for(int j=1; j<=w; j++)
            {
                if(weight[i] <= j)
                {
                    dp[i][j] = max(dp[i-1][j], val[i]+dp[i-1][j-weight[i]]);
                }
                else
                {
                    dp[i][j] = dp[i-1][j];
                }
            }
        }
        
        pr(dp[n][w]);
    }
    return 0;
}







Measured memory_bytes: 82464
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtcoderCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            var argABC = s.Split().Select(a => long.Parse(a)).ToArray();

            long A = argABC[0], B = argABC[1], C = argABC[2];

            long K = long.Parse(Console.ReadLine());

            bool isOK = false;

            for(long i = 0; i < K; i++)
            {
                if(B <= A)
                {
                    B *= 2;
                }else if(C <= B)
                {
                    C *= 2;
                }

                if(A < B && B < C)
                {
                    isOK = true;
                    break;
                }
            }

            if (isOK)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 28140
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <string>
#include <sstream>
#include<map>
using namespace std;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
#define NIL -1
const double PI  = acos(-1.0);
const int INF = 1e9 + 7;
//-------------------------------------------



int main(){
	int n;
	cin >> n;
	map<int,int> mp;
	
	for(int i = 0;i < n;i++){
		int p;
		cin >> p;
		mp[p] = i+1;
	}
	
	int cnt = 1;
	int temp = 1;
	for(int i = 1;i <= n;i++){
		if(mp[i] < mp[i+1]){
			temp++;
		}else{
			cnt = max(cnt,temp);
			temp = 1;
		}
	}
	
	cout << n - cnt << endl;
	return 0;
}


Measured memory_bytes: 9600
#include <stdio.h>
#include <stdlib.h>
#define ms_valtype int

//比較関数
int compare_ms(ms_valtype a, ms_valtype b){
	return b - a;
}

//昇順
void sort_sub(ms_valtype *origin, int left, int right, ms_valtype *tmp){
	if(right - left > 1){
		int i, j, k, half = (left + right) / 2;
		sort_sub(origin, left, half, tmp);
		sort_sub(origin, half, right, tmp);
		for(i = left; i < right; i++){
			tmp[i] = origin[i];
		}
		for(i = left, j = left, k = half; i < right; i++){
			if(k == right){
				origin[i] = tmp[j];
				j++;
			}
			else if(compare_ms(tmp[j], tmp[k]) <= 0 && j < half){
				origin[i] = tmp[j];
				j++;
			}
			else{
				origin[i] = tmp[k];
				k++;
			}
		}
	}
}

void sort(ms_valtype *origin, int N){
	ms_valtype *tmp = (ms_valtype *)malloc(sizeof(ms_valtype) * N);
	sort_sub(origin, 0, N, tmp);
	free(tmp);
}

int main(){
	int N, i, ans = 0;
	scanf("%d", &N);
	int *a = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%d", &a[i]);
	}
	sort(a, N);
	for(i = 0; i < N; i++){
		if(i % 2 == 0){
			ans += a[i];
		}
		else{
			ans -= a[i];
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> ab1(n);
    priority_queue<int> q;

    for (auto i = 0; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        ab1[i] = pair<int, int>(a, b);
    }

    sort(ab1.begin(), ab1.end());

    long long ans = 0;

    int index = 0;

    for (auto day = 1; day <= m; day++)
    {
        while (index < n)
        {
            if (ab1[index].first <= day)
            {
                q.push(ab1[index].second);
                index += 1;
            }
            else
            {
                break;
            }
        }
        if (!q.empty())
        {
            ans += q.top();
            q.pop();
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, pii> plp;
typedef complex<double> xy_t;
typedef vector<lint> poly;

const lint mod = 1e9 + 7;
const lint INF = mod * mod;

int main(){
    double a, b, x;
    scanf("%lf%lf%lf", &a, &b, &x);
    if(a*a*b/2 <= x) {
        double t = 2 * x / (a * a) - b;
        printf("%.12lf\n", atan((b - t) / a) * 180.0 / M_PI);
    }
    else{
        double t = 2*x/(a*b);
        printf("%.12lf\n", atan(b/t)*180.0/M_PI);
    }
}

Measured memory_bytes: 512
N = int(input())
ans = [0 for _ in range(N)]
for x in range(1, 1000):
    if x**2 > N:
        continue
    for y in range(1, 1000):
        if x**2 + y**2 > N:
            break
        for z in range(1, 1000):
            n = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if n <= N:
                ans[n-1] += 1
            if n > N:
                break
for a in ans:
    print(a)

Measured memory_bytes: 69092
N=int(input())
L=list(map(int,input().split()))
L.sort()
from bisect import bisect_left
ans = 0
for i1 in range(N-2):
  for i2 in range(i1+1,N-1):
    l1,l2 = L[i1],L[i2]
    #th = bisect_left(L[i2+1:],l1+l2)
    #print(l1,l2,L[i2+1:],(l2-l1+1)*(-1),th)
    th = bisect_left(L,l1+l2)
    ans += max(th-i2-1,0)
print(ans)

Measured memory_bytes: 9348
H, W = map(int, input().split())
A = [[] for i in range(H+2)]
for i in range(H):
    A[i+1] = list(input())
    A[i+1].insert(0,'.')
    A[i+1].append('.')

A[0] = list('.' * (W+2))
A[H+1] = list('.' * (W+2))

for i in range(H+2):
    A[i] = ''.join(A[i])
    #print(A[i])



check = 0

for i in range(1,H+1):
    for j in range(1, W+1):
        if i == 1 and j ==1 :
            if A[i][j] == '#':
                if A[i+1][j] == '.' and A[i][j+1] == '#':
                    pass
                elif A[i+1][j] == '#' and A[i][j+1] == '.':
                    pass
                else:
                    check = 1
                pass
            else:
                check = 1

        elif i == H and j ==W :
            if A[i][j] == '#':
                if A[i-1][j] == '.' and A[i][j-1] == '#':
                    pass
                elif A[i-1][j] == '#' and A[i][j-1] == '.':
                    pass
                else:
                    check = 1
                pass
            else:
                check = 1

        else:
            if A[i][j] == '#':
                if A[i+1][j] == '.' and A[i][j+1] == '#' and A[i-1][j] == '.' and A[i][j-1] == '#':
                    pass
                elif A[i+1][j] == '#' and A[i][j+1] == '.' and A[i-1][j] == '.' and A[i][j-1] == '#':
                    pass
                elif A[i+1][j] == '.' and A[i][j+1] == '#' and A[i-1][j] == '#' and A[i][j-1] == '.':
                    pass
                elif A[i+1][j] == '#' and A[i][j+1] == '.' and A[i-1][j] == '#' and A[i][j-1] == '.':
                    pass
                else:
                    check = 1

if check == 0:
    print('Possible')
else:
    print('Impossible')


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

    int n,temp;
    long long int dm=-100000000000000000,diff;
    cin>>n;
    vector<int> v;
    long long int fsum[2*n];
    long long int  bsum[2*n];
    priority_queue<long  int> pde;// decendgin;
    priority_queue<long  int,vector<long int>,greater<long int> > pin;
    for(int i = 0;i<(3*n);i++)
    { cin>>temp;
        v.push_back(temp);

    }

    for(int i2 = 0;i2<(2*n);i2++)
    {

        pin.push(v[i2]);
        if(i2>=1)
        {


        fsum[i2] = fsum[i2-1]+v[i2];
        }
        else
            fsum[i2] = v[i2];
            if(i2>=n)
            {
                int t =  pin.top();
               fsum[i2] = fsum[i2] - t;
               pin.pop();
            }
    }
       for(int i3 = 3*n-1;i3>(n-1);i3--)
    {

        pde.push(v[i3]);
        if(i3<3*n-1)
        {


        bsum[3*n-i3-1] = bsum[3*n-i3-2]+v[i3];
        }
        else
            bsum[3*n-i3-1] = v[i3];
            if(i3<=(2*n-1))
            {
               int t =  pde.top();
               bsum[3*n-i3-1] = bsum[3*n-i3-1] - t;
               pde.pop();
            }
    }
    for(int j = 0;j<(2*n);j++)

    {

      //  cout<<"fsum "<<fsum[j]<<"bsum "<<bsum[j]<<"\n";
    }
    for(int f = 0;f<(n+1);f++)
    {

      diff = fsum[n+f-1] - bsum[2*n-1-f];
     // cout<<diff<<"\n";

      dm = max(dm,diff);
    }
    cout<<dm;
}


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

#define ft first
#define sd second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
const int  p=31,po=1,N=1e5+1, M=(ll)1e9+1 ;
const int mod = (ll)1e9 +7;
// struct node{
//   ll prefixsum,suffixsum,bettersum,totalsum;
//   void create(ll val){
//     prefixsum=suffixsum=bettersum=val;
//   }
//   void Merge(node& a,node &b){
//     prefixsum=max(a.prefixsum,a.totalsum+b.prefixsum);
//     suffixsum=max(b.suffixsum,a.suffixsum+b.sum);
//     totalsum=a.totalsum+b.totalsum;
    
//   }
// }
//ll dp[2][100];
vl compute(string s){
        vl has(s.length());
        ll i;

        for(i=0;i<s.length();i++){
            if(i==0){
                has[i]=((s[i]-'a'+1))%mod;
            }
            else
                has[i]=(has[i-1]*p + (s[i]-'a'+1))%mod;
        }
        return has;
}
vl g[N],dist(N+1,0);
vector<bool>vis(N,false);
void dfs(ll x){
  vis[x]=true;
  for(auto to:g[x]){
    if(!vis[to])
      dfs(to);
    dist[x]=max(dist[x],dist[to]+1);

  }
}
int main(){
 ios_base::sync_with_stdio(0);
 ll i,j,n,m;
 cin >> n >> m;
 for(i=1;i<=m;i++){
   ll u,v;
   cin >> u >> v;
   g[u].pb(v);
 }
 dfs(1);
 ll mi=0;
  for(i=1;i<=n;i++)
    if(!vis[i])
      dfs(i);
  for(i=1;i<=n;i++)
    mi=max(mi,dist[i]);
  cout << mi;
    return 0;
}



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

int main(){
  int N, M, ans = 0;
  cin >> N >> M;
  
  for(int i = 0; i < M; i++){
    int x = 0;
    cin >> x;
    ans += x;
  }
  
  //cout << ans << endl;
  
  if(N - ans < 0){
    cout << -1 << endl;
  }
  else{
    cout << N - ans << endl;
  }
  
}

Measured memory_bytes: 3640
#include <cstdio>
#include <map>
#define maxn 200010
#define LL long long
using namespace std;
int a[maxn],n;
LL ans;
map<int,int> mp;
int main()
{
    int i;
    scanf("%d",&n);
    for(i=1; i<=n; i++)
        scanf("%d",&a[i]);
    for(i=1; i<=n; i++)
        if(i-a[i]>0)
            mp[i-a[i]]++;//记录i-a[i]的数量
    for(i=1; i<=n; i++)
        if(mp[a[i]+i])
            ans+=mp[a[i]+i];//查重
    printf("%lld\n",ans);
    return 0;
}

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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	int x[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>x[i];
	}
	int mi=1000000000;
	for (int i = 1; i < 101; ++i)
	{
		int now=0;
		for (int j = 0; j < n; ++j)
		{
			now+=(x[j]-i)*(x[j]-i);
		}
		mi=min(mi,now);
	}
	cout<<mi<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,l;
	cin>>n>>l;
	vector<string> s;
	string in;
	string ans="";
	for(int i=0;i<n;i++){
		cin>>in;
		s.push_back(in);
	}	
	sort(s.begin(),s.end());
	for(int i=0;i<n;i++){
		ans+=s[i];
	}
	cout<<ans;
}

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

using namespace std;
typedef long long ll;

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

    vector<ll> numbers;

    for(ll i = 1; i <= N; i++) {
        if(i % 3 != 0 && i % 5 != 0) {
            numbers.push_back(i);
        }
    } 

    cout << accumulate(numbers.begin(), numbers.end(), 0LL) << endl;

    return 0;
}

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

#define SZ(v) ((int)(v).size())
using ll = long long;

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

	ll S, W;
	cin >> S >> W;
	if (S <= W)
		cout<< "unsafe" << endl;
	else
	cout << "safe" << endl;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

const double INF = 10000.0;
const int MAX_V = 1000;

int n;
struct cell{ double x,y,z,r; };

double cost[MAX_V][MAX_V];
double mincost[MAX_V];
bool used[MAX_V];

void add_edge(int u, int v, double cost_){
	cost[u][v] = cost[v][u] = cost_;
}

double prim(){
	for(int i=0 ; i < n ; i++ ){
		mincost[i] = INF;
		used[i] = false;
	}
	mincost[0] = 0;
	double res = 0.0;
	
	while( true ){
		int v = -1;
		for(int u=0 ; u < n ; u++ ){
			if( !used[u] && (v == -1 || mincost[u] < mincost[v] ) )
				v = u;
		}
		
		if( v == -1 ) break;
		used[v] = true;
		res += mincost[v];
		
		for(int u=0 ; u < n ; u++ ){
			mincost[u] = min( mincost[u] , cost[v][u] );
		}
	}
	return res;
}

double D(cell c1, cell c2){
	double dx = c1.x - c2.x;
	double dy = c1.y - c2.y;
	double dz = c1.z - c2.z;
	double d = sqrt( dx * dx + dy * dy + dz * dz ) - c1.r - c2.r;
	if( d < 0.0 ) 
		d = 0.0;
	return d;
}

int main(){
	while( scanf("%d", &n ) , n ){
		vector<cell> v;
		
		for(int i=0 ; i < n ; i++ ){
			double x,y,z,r;
			cell c;
			scanf("%lf %lf %lf %lf", &x, &y, &z, &r);
			c.x = x;
			c.y = y;
			c.z = z;
			c.r = r;
			v.push_back( c );
		}
		for(int i=0 ; i < v.size() ; i++ ){
			for(int j=i+1 ; j < v.size() ; j++ ){
				double d = D( v[i] , v[j] );
				add_edge( i , j , d );
			}
		}
		double ans = prim();
		printf("%.3f\n", ans );
	}
}

Measured memory_bytes: 0
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: i64,
        b: i64,
        c: i64,
        x: i64,
        y: i64,
    }
    let mut ans = std::i64::MAX;
    for i in 0..100_001 as i64 {
        let acc = i * 2 * c + max(0, x - i) * a + max(0, y - i) * b;
        ans = min(acc, ans);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder
{
    class Program
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] h = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            Console.WriteLine("{0}", f(h, 0, N - 1));
        }

        public static int f(int[] nums, int l, int r)
        {
            for (int i = l; i < r + 1; i++)
            {
                if (nums[i] > 0) { nums[i]--; continue; }
                // Console.WriteLine("{0} {1} {2}", i, l, r);
                return (l == r) ? 0 :
                       (i == l) ? f(nums, i + 1, r) :
                       (i == r) ? 1 + f(nums, l, i - 1)
                                : 1 + f(nums, l, i - 1) + f(nums, i + 1, r);
            }
            return 1 + f(nums, l, r);
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
signed main(void){
    itn n; cin>>n;
    vector <int> a(n); 
    rep(i,n) cin>>a[i];
    int ans = 0;
    int p;
    rep(i,n){
        if(i==0){
            ans += a[i]-1;
            p = 2;
            continue;
        }
        ans += (a[i]-1)/p;
        if(p==a[i]) p++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
	char a, b;
	cin >> a >> b;
	if (a == 'H') {
		cout << b << endl;
	}
	else {
		if (b == 'H') {
			cout << 'D' << endl;
		}
		else {
			cout << 'H' << endl;
		}

	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int count = 0;
        for (int i = 0; i <= k; i++) {
            int diff = s - i;
            for (int j = 0; j <= k; j++) {
                int diff2 = diff - j;
                if (diff2 >= 0 && diff2 <= k) {
                    count++;
                }
//                for (int l = 0; l <= k; l++) {
//                    if (diff2 - l == 0) {
//                        count++;
//                    }
//                }
            }
        }
        System.out.println(count);
    }

}


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

using namespace std;
int main() {
  string S;
  bool f=false;
  cin>>S;
  int N=S.size();
  if(N%2==1) N--;
  else N-=2;
  for(int i=N/2;i>0;i--){
    for(int j=0;j<i;j++){
      if(S[j]!=S[j+i]) break;
      if(j==i-1){
        cout<<i*2<<endl;
        f=true;
        break;
      }
    }
    if(f) break;
  }
}	


Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数

// デフォルト変数定義
int n,m,a,b,c,x,y,z;
double d,e,f;
string s,t;
//

signed main() {
  RAPID;
  IN2(x,y);
  OUT(x+y/2);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;

const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main(){
    string S; cin >> S;
    long long K; cin >> K;
    long long cho = 5000000000000000;
    int ans;
    for(int i=0;i<S.size();i++){
        int n = S[i]-'0';
        K-=pow(n,cho);
        if(K<=0) {ans=n; break;}
    }
    cout << ans << endl;
}




Measured memory_bytes: 256
import math
from functools import reduce

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n = int(input())
t = []
for _ in range(n):
    t.append(int(input()))

print(lcm_list(t))

Measured memory_bytes: 9396
#include<iostream>
using namespace std;
int main(){
	int K[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int n;
	cin>>n;
	cout<<K[--n];
} 

Measured memory_bytes: 256
#include <stdio.h>

int n, A[50];

int solve(int i, int m)
{
	if(m == 0) return 1;
	if(i >= n) return 0;
	int res = solve(i + 1, m) || solve(i+1, m-A[i]);
	return res;
}


int main(void)
{
	int q, M, i;
	
	scanf("%d", &n);
	for(i=0; i<n; i++) scanf("%d", &A[i]);
	scanf("%d", &q);
	for(i=0; i<q; i++){
		scanf("%d", &M);
		if(solve(0, M)) printf("yes\n");
		else printf("no\n");
	}
	
	return 0;
}



Measured memory_bytes: 2136
#include <bits/stdc++.h>
const int M = 2e5+10;

int f[M];
int d[M];

int find(int x) {
	if(f[x] == -1) return x;
	int fa = f[x];
	f[x] = find(fa);
	d[x] += d[fa];
	return f[x];
}

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	memset(f, -1, sizeof(f));
	bool flag = true;
	for(int i = 0; i < m; i ++) {
		int u, v, w;
		scanf("%d%d%d", &u, &v, &w);
		u --, v --;
		int fa = find(u);
		int fb = find(v);
		// printf("%d %d\n", fa, fb);
		if(fa == fb) {
			if(d[v]-d[u] != w) flag = false;
		} else {
			f[fb] = fa;
			d[fb] = d[u] - d[v] + w;
		}
	}
	if(flag) puts("Yes");
	else puts("No");
}


Measured memory_bytes: 1408
from collections import Counter
N = int(input())
S = list(map(int,input().split()))
T = []
for i in range(N):
    T.append((i,S[i]))
U = sorted(T,key=lambda x:x[1], reverse=True)

Ans = [0]*N
c,v = 0,10**10

for i in range(N-1):
    c+=1
    v = min(v,U[i][0])
    if U[i][1]==U[i+1][1]:
        continue
    else:
        Ans[v] += (U[i][1] - U[i+1][1])*c
else:
    Ans[0] = 0
    Ans[0] = sum(S) - sum(Ans)

for i in range(N):
    print(Ans[i])

Measured memory_bytes: 23852
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	array<int, 55> primelist = {2,7,17,37,47,67,97,107 ,127,137,157,167,197,227,257,277,307,317,337,347,367,397,457,467,487,547,557,577,587,607,617,647,677 ,727,757,787,797,827,857,877,887,907,937,947,967,977,997,1087,1097,1117,1187,1217,1237,1277,1297};
	int N;
	cin >> N;
	for( int i = 0; i < N; ++i ){
		cout << primelist.at(i);
		if( i != N-1 ){
			cout << " ";
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 311;
#define fr(i,a,b) for(int i = a;i <= b; ++i)
#define nfr(i,a,b) for(int i = a;i >= b; --i)

int n,m,p;
int f[N][N];
int sum[N];
int c[N][N];

inline void add(int &x,int y){
   x += y; if(x >= p)x -= p;
}

int main(){
   scanf("%d%d%d",&n,&m,&p);
   memset(f,0,sizeof f);
   
   fr(i,0,n)c[i][0] = 1;
   fr(i,1,n){
      fr(j,1,n){
         c[i][j] = (c[i-1][j]+c[i-1][j-1])%p;
      }
   }
   
   fr(i,0,m)f[i][1] = 1;
   fr(i,2,n+1){
      memset(sum,0,sizeof sum);
      nfr(j,m-1,0){
         fr(k,1,i-1)add(sum[k],f[j+1][k]);
         fr(k,1,i-1){
            add(f[j][i],1LL*f[j][i-k]*sum[k]%p*c[i-2][k-1]%p);
         }
      }
   }
   printf("%d\n",f[0][n+1]);
   return 0;
}


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



int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	std::map<string,int>m;
	int mx = 0;
	string s;
	for (int i = 0; i < n; ++i)
	{
		cin>>s;
		m[s]+=1;
		mx = max(mx,m[s]);
	}
	for(std::map<string, int>::iterator it=m.begin();it!=m.end();it++){
		if(m[it->first]==mx) cout<<it->first<<endl;
	}
	return 0;
}

Measured memory_bytes: 25216
n, m = map(int, input().split())
mod = 10**9 + 7
dp = [0 for i in range(n+1)]
for i in range(m):
    dp[int(input())] = -1
dp[0] = 1
for i in range(n):
    if dp[i] != -1:
        if dp[i+1] != -1:
            dp[i+1] += dp[i]
            dp[i+1] %= mod
        if i+2 <= n and dp[i+2] != -1:
            dp[i+2] += dp[i]
            dp[i+2] %= mod
print(dp[n])

Measured memory_bytes: 45088
#include <bits/stdc++.h>
using namespace std;
void init_ios() {ios_base::sync_with_stdio(false); cin.tie(nullptr);}

int N, K;
int D[10];

int ok(int x) {
	do {
		if (D[x%10]) return 0;
		x /= 10;
	} while (x);
	return 1;
}

int main() {
	scanf("%d%d", &N, &K);
	for (int i = 0; i < K; ++i) {
		int d;
		scanf("%d", &d);
		D[d] = 1;
	}

	if (K == 10) {
		printf("%d\n", 0);
		return 0;
	}

	while (!ok(N)) ++N;

	printf("%d", N);

	return 0;
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	ll D; cin >> D;
	int cnt = 0;
	F0R(i, N) {
		ll x, y; cin >> x >> y;
		if (x * x + y * y <= D * D) ++cnt;
	}
	print(cnt);
}

Measured memory_bytes: 3644
#include <iostream>

void input_ex(int arr[], int* N);
void output_ex(int arr[], int N);
void sort_ex(int arr[], int N);

int main()
{
    int arr[100];
    int N;

    input_ex(arr, &N);
    output_ex(arr, N);
    sort_ex(arr, N);

}

void sort_ex(int arr[], int N)
{
    int v, j, i;

    for (i = 1; i < N; ++i){
        v = arr[i];
        j = i - 1;
        while(j >= 0 && arr[j] > v){
            arr[j + 1] = arr[j];
            --j;
        }
        arr[j + 1] = v;
        output_ex(arr, N);
    }
}

void output_ex(int arr[], int N)
{
    for (int x = 0; x < N; ++x){
        if (x > 0)
            std::cout << " ";

        std::cout << arr[x];
    }
        std::cout << std::endl;

    return;
}

void input_ex(int arr[], int* N)
{
    std::cin >> *N;
    for (int x = 0; x < *N; ++x){
        std::cin >> arr[x];
    }

    return;
}



Measured memory_bytes: 3104
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>

using namespace std;
using ll = long long;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};


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

// dp[n][t]
// nまでの料理でt分以下で食べられるおいしさの最大値
int dp[3010][3010];

int main() {
    int n, t; cin >> n >> t;
    vector<pair<int, int>> ab(n);
    for (int i = 0; i < n; i++) cin >> ab[i].first >> ab[i].second;
    sort(ab.begin(), ab.end());

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

    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < t; j++) {
            chmax(dp[i+1][j], dp[i][j]);                                    // a[i]を食べない場合
            int next = j + ab[i].first;
            if (next < t) chmax(dp[i+1][next], dp[i][j] + ab[i].second);    // 食べる場合
        }
        int now = dp[i][t-1] + ab[i].second;
        chmax(ans, now);
        // cout << ans << ' ' << ab[i].first << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35712
#include<stdio.h>

int main(void)
{
	int a, b, c;
	int temp;

	scanf("%d %d %d", &a, &b, &c);

	if (a > b)
	{
		temp = a;
		a = b;
		b = temp;
	}// a < b

	if (a > c)
	{
		temp = a;
		a = c;
		c = temp;
	}// a < c

	if (b > c)
	{
		temp = b;
		b = c;
		c = temp;
	}// b < c

	printf("%d %d %d\n", a, b, c);

	return 0;
}


Measured memory_bytes: 2036
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException{
		SunukeColoring2 solver = new SunukeColoring2();
		solver.readInput();
		solver.solve();
		solver.writeOutput();
	}

	static class SunukeColoring2 {

		private int w;
		private int h;
		private int n;

		private int vertex[] = new int[4];

		private Scanner scanner;
		private int output;

		public	SunukeColoring2() {
			scanner = new Scanner(System.in);
		}

		public void readInput() {
			int x,y,a;
			w = new Integer(scanner.next());
			h = new Integer(scanner.next());
			n = new Integer(scanner.next());
			vertex[0] = 0;
			vertex[2] = 0;
			vertex[1] = w;
			vertex[3] = h;
			for(int i=0;i<n;i++) {
				x = new Integer(scanner.next());
				y = new Integer(scanner.next());
				a = new Integer(scanner.next());
				a --;
				switch(a) {
				case 0:
					vertex[a] = Math.max(x,vertex[a]);
					break;
				case 1:
					vertex[a] = Math.min(x,vertex[a]);
					break;
				case 2:
					vertex[a] = Math.max(y,vertex[a]);
					break;
				case 3:
					vertex[a] = Math.min(y,vertex[a]);
					break;
				}
			}
			return ;
		}
		public void solve() {
			int xLen,yLen;

			xLen = vertex[1]-vertex[0];
			yLen = vertex[3]-vertex[2];

			if (xLen<=0 || yLen<=0) {
				output = 0;
				return ;
			}

			output = xLen * yLen;
			return;
		}
		public void writeOutput() {
			System.out.println(output);
			return ;
		}
	}

}


Measured memory_bytes: 22996
import java.util.*;
public class Main {
	
	public static int[][] lenearsum(int numval, int sum) {
		int sep = (int)Math.pow(10, 9)+7;
		int[][] dp = new int[numval+1][sum+1];
		for(int i=0;i<sum+1;i++) {
			dp[1][i] = 1;
		}
		for(int i=2;i<numval+1;i++) {
			for(int n=0;n<sum+1;n++) {
				if(n==0) dp[i][n] = 1;
				else dp[i][n] = ((dp[i][n-1])%sep+(dp[i-1][n])%sep)%sep;
			}
		}
		return dp;
	}
	
	public static void calci(int K, int N, int i, int[][] dp) {
		int sep = (int)Math.pow(10, 9)+7;
		if(N-K-(i-1)<0) {
			System.out.println(0);
			return;
		}
		long ret = 1;
		ret *= dp[i][K-i];
		ret %= sep;
		ret *= dp[i+1][N-K-(i-1)];
		ret %= sep;
		System.out.println(ret);
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[][] dp = lenearsum(k+1,n+1);
		for(int i=1;i<=k;i++) {
			calci(k,n,i,dp);
		}
	}
}


Measured memory_bytes: 52308
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

#define ll long long int

void solve();

int main() {

   solve();
   return 0;

}

void solve() {

   ll a,b,c;
   cin >>a >>b>>c;
   (a<=c && c<=b)?cout << "Yes":cout << "No";
   cout << endl;

}

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

using namespace std;

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

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

    const int dy[] = {-1, -1, 0, 1, 1, 1, 0, -1};
    const int dx[] = {0, 1, 1, 1, 0, -1, -1, -1};

    for (int y = 0; y < h; y++) {
        for (int x = 0; x < w; x++) {
            int bomb = 0;
            if (s[y][x] == '.') {
                for (int k = 0; k < 8; k++) {
                    int yy = y + dy[k];
                    int xx = x + dx[k];
                    if (xx < 0 || xx >= w || yy < 0 || yy >= h) continue;
                    if (s[yy][xx] == '#') bomb++;
                }
                s[y][x] = (char)(bomb + '0');
            }
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cout << s[i][j];
        }
        cout << "\n";
    }

    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

typedef ll Data;
typedef vector<Data> Array;
typedef vector<Array> Matrix;

Matrix operator*(const Matrix &lhs, const Matrix &rhs) {
	Matrix res(lhs.size(), Array(rhs[0].size(), 0));
	REP(i, lhs.size()) REP(j, rhs[0].size()) REP(k, rhs.size())
	{
		res[i][j] += (lhs[i][k] * rhs[k][j]) % MOD;
		res[i][j] %= MOD;
	}
	return res;
}
Array operator*(const Matrix &lhs, const Array &rhs) {
	Array res(lhs.size());
	REP(i, lhs.size())
	{
		res[i] = inner_product(begin(lhs[i]), end(lhs[i]), begin(rhs), Data(0));
		res[i] %= MOD;
	}
	return res;
}

Matrix pow(Matrix x, ll n)
{
	Matrix res = { {1,0},{1,0} };
	while (n > 0)
	{
		if (n & 1) res = res * x;
		x = x*x;
		n >>= 1;
	}
	return res;
}


ll fib(ll a)
{
	a++;
	Matrix mat = { {1,1},{1,0} };
	Array p = { 1,0 };
	Array q = pow(mat, a) * p;
	return q[0] % MOD;
}

ll calc(ll a, ll b)
{
	return fib(a) * fib(b) % MOD;
}


int main()
{
	cin.sync_with_stdio(false);
	ll k;
	cin >> k;
	if (k == 1)
	{
		puts("1");
		return 0;
	}
	ll lb = 0, ub = INT_MAX;
	while (ub - lb > 1)
	{
		ll mid = (lb + ub) / 2;
		if (mid % 2)
		{
			ll tmp = mid / 2 + 1;
			ll cnt = (1 + tmp)*tmp;
			if (cnt >= k) ub = mid;
			else lb = mid;
		}
		else
		{
			ll tmp = mid / 2;
			ll cnt = (1 + tmp)*tmp + tmp + 1;
			if (cnt >= k) ub = mid;
			else lb = mid;
		}
	}
	ll tmp = (lb + 1) / 2;
	ll cnt = (1 + tmp)*tmp;
	if (lb % 2 == 0) cnt += tmp + 1;
	ll p = k - cnt - 1;
	ll a;
	ll len = ub / 2 + 1;
	if ((len + 1) / 2 > p) a = 2 * p;
	else a = (len - p - 1) * 2 + 1;
	cout << calc(ub - a, a) << endl;
	return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

signed main(){
    
    int n; cin >> n;
    cout << (n - 2) * 180 << endl;   
    return 0;
}


Measured memory_bytes: 256
n=gets.to_i
a=gets.split.map(&:to_i)
b=a.dup
n.times do |i|
  a[i]=a[i]-i
  b[i]=-b[i]-i
end
a=a.sort+[nil]
b=b.sort+[nil]
ca,cb=1,1
i,j=0,0
c=0
while !(i==n||j==n)
  if a[i]==b[j]
    while a[i+1]==a[i]
      i+=1
      ca+=1
    end
    while b[j+1]==b[j]
      j+=1
      cb+=1
    end
    c+=ca*cb
    ca,cb=1,1
    i+=1 if i<n
    j+=1 if j<n
  elsif a[i]>b[j]
    j+=1
  elsif a[i]<b[j]
    i+=1
  end
end
puts c



Measured memory_bytes: 35304
/**
 * author:    Ziel
 * created:   23.04.2020 20:19:46
**/

// ~zaletaet~

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>

#define fi first
#define se second
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define pb push_back

using namespace std;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const ll N = 1e5 + 123, MOD = 1e9 + 7, oo = 1e9 + 9, INF = 1e18 + 9;
const double EPS = 1e-9, PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1}, dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	int k, a, b;
	cin >> k >> a >> b;
	for (int i = 1; i <= 1000; i++) {
		if (k * i >= a && k * i <= b) return !(cout << "OK");
	}
	cout << "NG";
	return 0;
}

/*
	Raise your standard.
*/

Measured memory_bytes: 3652
#include <stdio.h>

int main(void){
	int h, w;
	int i, j;

	while(1){
		scanf("%d", &h);
		scanf("%d", &w);
		if(h == 0 && w == 0){
			break;
		}
		
		for(i = 0; i < h - 2; i++){
			if(i == 0){
				for(j = 0; j < w; j++){
					printf("#");
				}
				printf("\n");
			}


			if(i != 0 || i != h - 1){
				printf("#");
				for(j = 1; j < w - 1; j++){ 
					printf(".");
				}
				printf("#");
				printf("\n");
			}

			if(i == h - 3){
				for(j = 0; j < w; j++){
					printf("#");
				}
			}
		}
		
		printf("\n");
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 572
/**
 * Allocation
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_D
 */

#include<iostream>
#include<vector>
using namespace std;

bool canPackToTrack(vector <int>w, int k, int P) {
  int capacity = 0;

  for (int i = 0; i < w.size(); i++) {
    // 最大積載量より大きい荷物は、そもそも積めない
    if (w.at(i) > P) {
      return false;
    }

    // 積載量を超えたら、トラックの数を減らして積載量をリセットする
    if (capacity + w.at(i) > P) {
      k--;
      capacity = 0;
    }

    // トラックがなくなってしまったら、もう荷物を積めない
    if (k == 0) {
      return false;
    }

    // トラックに荷物を積む
    capacity += w.at(i);
  }

  return true;
}

int main() {
  // 最初の行に荷物の数 n とトラックの数 k が空白区切りで与えられます。
  int n, k;
  cin >> n >> k;

  // 重さがそれぞれwのn個の荷物
  vector <int>w(n);
  for (int i = 0; i < n; i++) {
    cin >> w.at(i);
  }

  /**
   * 線形探索では、制限時間が足りなかった
   * for (int i = 0; 1; i++) {
   *   // cout << "=-" << i << calcV(w, k, i) << endl;
   *   if (calcV(w, k, i) >= n) {
   *     cout << i << endl;
   *     return 0;
   *   }
   * }
   */

   // 2分探索
   // 荷物の最大個数は100,000個で、最大サイズは10,000。これを超える十分に大きい最大積載量Pを最小値とする
   int min = 1, max = 100000 * 10000;
   int answer = 100000 * 10000;
   while (min < max) {
     int center = (min + max) / 2;
     if (canPackToTrack(w, k, center)) {
       // centerより大きい積載量の値は、必ず積載可能なので計算する必要がない
       max = center;
       if (center < answer) {
         answer = center;
       }
     } else {
       // centerより小さいサイズで、積載可能になることは起こり得ない
       min = center + 1;
     }
   }

   cout << answer << endl;
}



Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  int a=S.at(0)-'0',b=S.at(1)-'0',c=S.at(2)-'0',d=S.at(3)-'0';
  
  if(a+b+c+d==7){
    cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
  }
  
  else if(a+b+c-d==7){
    cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
  }
  
  else if(a+b-c+d==7){
    cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
  }
  
  else if(a+b-c-d==7){
    cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
  }
  
  else if(a-b+c+d==7){
    cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
  }
  
  else if(a-b+c-d==7){
    cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
  }
  
  else if(a-b-c+d==7){
    cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
  }
  
  else if(a-b-c-d==7){
    cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
  }
}  

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int A = 0, B = 0;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) A += a.at(i);
    else B += a.at(i);
  }
  cout << A - B << endl;
}


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

using namespace std;
using uint = unsigned;

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

    {
        uint H,W,h,w;
        cin >> H >> W >> h >> w;
        cout << (H-h)*(W-w) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

const int inf = 2147483647;
const int MAX = 2e5 + 10;

//RMQ
struct segtree {
    int N, dat[2*MAX];
    segtree() {}
    segtree(int n) {
        N = 1;
        while(N < n) N *= 2;
        for(int i = 0; i < 2*N-1; i++)
            dat[i] = inf;
    }
    // update k th element
    void update(int k, int a) {
        k += N-1; // leaf
        dat[k] = a; 
        while(k > 0) {
            k = (k - 1) / 2;
            dat[k] = min(dat[k*2+1], dat[k*2+2]);
        }
    }
    // min [a, b)
    int query(int a, int b) { return query(a, b, 0, 0, N); }
    int query(int a, int b, int k, int l, int r) {
        if(r <= a or b <= l) return inf;
        if(a <= l and r <= b) return dat[k];
        int m = (l + r) / 2;
        return min(query(a, b, k*2+1, l, m), query(a, b, k*2+2, m, r));
    }
};

signed main(){
    int n, q;
    cin >> n >> q;
    segtree sg(n);
    rep(i, 0, q){
        int c, x, y;
        cin >> c >> x >> y;
        if(c == 0){
            sg.update(x, y);
        }else{
            cout << sg.query(x, y + 1) << endl;
        }
    }
}

Measured memory_bytes: 5124
#include <iostream>
#include <vector>
using namespace std;
long long MOD = 1000000007;
int main(){
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++){
		cin >> a[i];
	}
	vector<int> b(N);
	for (int i = 0; i < N; i++){
		cin >> b[i];
	}
	long long P = 1;
	for (int i = 0; i < N - 1; i++){
		P *= 2;
		P %= MOD;
	}
	vector<bool> ok(N, true);
	vector<int> x(N, 0);
	for (int i = 0; i < 30; i++){
		long long hash_a = 0;
		for (int j = 0; j < N; j++){
			hash_a *= 2;
			hash_a += a[j] >> i & 1;
			hash_a %= MOD;
		}
		long long hash_b0 = 0;
		for (int j = 0; j < N; j++){
			hash_b0 *= 2;
			hash_b0 += b[j] >> i & 1;
			hash_b0 %= MOD;
		}
		long long hash_b1 = 0;
		for (int j = 0; j < N; j++){
			hash_b1 *= 2;
			hash_b1 += 1 - (b[j] >> i & 1);
			hash_b1 %= MOD;
		}
		for (int j = 0; j < N; j++){
			if (hash_a == hash_b1){
				x[j] += 1 << i;
			} else if (hash_a != hash_b0){
				ok[j] = false;
			}
			if (a[j] >> i & 1){
				hash_a -= P;
				hash_a += MOD;
			}
			hash_a *= 2;
			if (a[j] >> i & 1){
				hash_a++;
			}
			hash_a %= MOD;
		}
	}
	for (int i = 0; i < N; i++){
		if (ok[i]){
			cout << i << ' ' << x[i] << endl;
		}
	}
}

Measured memory_bytes: 6088
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res % p;
} 
void solve()
{
    int n = 5;
    int a, ans;
    for (int i = 0; i < n;i++){
        cin >> a;
        if(a!=i+1){
            ans = i;
        }

    }
    cout << ans + 1 << endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tc;
    tc = 1;
    //cin >> tc;
    while (tc--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3648