akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<cstring>
#include<cmath>

using namespace std;

int main() {
	int delta_x[3] = {0, -1, -1};
	int delta_y[3] = {-1, -1, 0};
    char s[3010], t[3010];
    scanf("%s%s", s, t);
    int n = strlen(s);
    int m = strlen(t);
    int dp[n][m], dir[n][m];
    memset(dp, 0, sizeof dp);
    for(int j=0; j<m; j++) {
    	if(s[0]==t[j]) {
    		dp[0][j] = 1;
    		dir[0][j++] = 1;
    		while(j<m) {
    			dp[0][j++] = 1; 
    			dir[0][j-1] = 0;
    		}
    		break;
    	}
    }
    for(int i=0; i<n; i++) {
    	if(s[i]==t[0]) {
    		dp[i][0] = 1;
    		dir[i++][0] = 1;
    		while(i<n) {
    			dp[i++][0] = 1;
    			dir[i-1][0] = 2;
    		}
    		break;
    	}
    }
    for(int i=1; i<n; i++) {
    	for(int j=1; j<m; j++) {
    		if(dp[i][j-1] > dp[i][j]) {
    			dp[i][j] = dp[i][j-1]; dir[i][j] = 0;
    		}
    		if(dp[i-1][j] > dp[i][j]) {
    			dp[i][j] = dp[i-1][j]; dir[i][j] = 2;
    		}
    		if(s[i]==t[j] && dp[i-1][j-1]+1 > dp[i][j]) {
    			dp[i][j] = dp[i-1][j-1]+1; dir[i][j] = 1;
    		}
    	}
    }
    int i = n-1, j = m-1;
    int cur_f = dp[n-1][m-1];
    char fin[cur_f+1];
    fin[cur_f--] = '\0';
    while(cur_f>=0 && dp[i][j]>0) {
    	if(dir[i][j] == 1) {
    		fin[cur_f--] = s[i];
    	}
    	int dx = delta_x[dir[i][j]];
    	int dy = delta_y[dir[i][j]];
    	i += dx;
    	j += dy;
    }
    printf("%s\n", fin);
    return 0;
}

Measured memory_bytes: 70528
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x,a,b,c,z,k;
    string ss;
    cin>>ss;
    x=0;
    if(ss[0]=='o')x++;
    if(ss[1]=='o')x++;
    if(ss[2]=='o')x++;
    cout<<700+(100*x);
return 0;}


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

using namespace std;

int rec1[26];
int rec2[26];

int main()
{
    int n,i,max,temp;
    char s[200];
    while(~scanf("%d%s",&n,s))
    {
        temp=max=0;
        for(i=0;i<26;i++)
            rec1[i]=rec2[i]=0;
        for(i=0;i<n;i++)
        {
            rec1[s[i]-'a']++;
        }
        for(i=n-1;~i;i--)
        {
            rec1[s[i]-'a']--;
            rec2[s[i]-'a']++;
            if(rec1[s[i]-'a'] && rec2[s[i]-'a']==1)
            {
                temp++;
            }
            else if(rec1[s[i]-'a']==0 && rec2[s[i]-'a']>1)
            {
                if(temp>max)
                    max=temp;
                temp--;
            }
        }
        printf("%d\n",max);
    }
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
using namespace std;
#define N 100 + 5

int n, P[N], Del[N], Ans[N];
bool ok = true, Flag[N];

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i ++)
	{
		scanf("%d", P + i);
		Del[i] = i - P[i];
	}
	for (int i = n; ok && i; i --)
	{
		int j;
		for (j = n; j && (Del[j] || Flag[j]); j --) ;
		if (j == 0) ok = 0;
		else
		{
			Ans[i] = P[j], Flag[j] = 1;
			for (j ++; j <= n; j ++)
				Del[j] --;
		}
	}
	if (!ok) puts("-1");
	else for (int i = 1; i <= n; i ++)
		printf("%d\n", Ans[i]);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.nextLine());
        String[] notes = sc.nextLine().split(" ");
        sc.close();

        int[] junban = new int[N];
        for (int i = 0; i < notes.length; i++) {
            int studentNo = i + 1;
            int peopleCnt = Integer.parseInt(notes[i]);
            junban[peopleCnt - 1] = studentNo;
        }

        StringBuilder sb = new StringBuilder();
        for (int i : junban) {
            sb.append(i + " ");
        }

        sb.setLength(sb.length() - 1);

        System.out.println(sb.toString());
    }

}


Measured memory_bytes: 53112
h, w = map(int,input().split())
a = [input() for _ in range(h)]

remove_a = []
for i in range(h):
    if '#' in a[i]:
        remove_a.append(list(a[i]))

n = len(remove_a)
l = []
for i in range(w):
    s = ''
    for j in range(n):
        s += remove_a[j][i]
    if '#' in s:
        l.append(list(s))

ans = ''
for i in range(len(l[0])):
    s = ''
    for j in range(len(l)):
        s += l[j][i]
    ans += s
    if i != len(l[0])-1:
        ans += '\n'
print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>


using namespace std;
int a[200001];
int main()
{
    int n,k,i,x,s=0;
    cin>>n>>k;
    for(i=0;i<n;i++) { cin>>x; a[x]++; }
    sort(a,a+200001);
    for(i=0;i+k<200001;i++){
        s+=a[i];
    }
    cout<<s;
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>

using namespace std;

int main() {

  int64_t a, b, x;
  cin >> a >> b >> x;

  if(a != 0)
    cout << b / x - (a-1) / x << endl;
  else
    cout << b / x + 1 << endl;

  return 0;
}


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

int main(void){
   int N,M;
   cin>>N>>M;
   vector<int> a(N),b(N);
   for(int i=0;i<N;i++){
      cin>>a[i]>>b[i];
   }
   vector<int> c(M),d(M);
   for(int i=0;i<M;i++){
      cin>>c[i]>>d[i];
   }
   for(int i=0;i<N;i++){
      int ans=1000000007;
      int dist;
      for(int j=0;j<M;j++){
         dist=abs(a[i]-c[j])+abs(b[i]-d[j]);
         ans=min(dist,ans);
      }
      for(int k=0;k<M;k++){
         int result=abs(a[i]-c[k])+abs(b[i]-d[k]);
         if(ans==result){
            cout<<k+1<<endl;
            break;
         }
      }
   }
   return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
char s[100][100];

int tansaku(int i,int j,int h,int w){
    int c=0;
        if(s[i-1][j-1]=='#'){
            c++;
        }
            if(s[i-1][j]=='#'){
            c++;
        }
    

    
        if(s[i][j-1]=='#'){
            c++;
        }
    
        if(s[i+1][j+1]=='#'){
            c++;
        }


    

        if(s[i+1][j]=='#'){
            c++;
        }
    
        if(s[i][j+1]=='#'){
            c++;
        }
    
    
    
        if(s[i-1][j+1]=='#'){
            c++;
        }
    
        if(s[i+1][j-1]=='#'){
            c++;
        }
    

    return c;
}



int main (){
    int h,w;
    cin >> h>>w;
    for(int i=0; i<h;i++){
        for(int j=0;j<w;j++){
            cin >> s[i][j];
        }
    }
    for(int i=0; i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='#'){
                cout << "#";
            }
            else{
                int c=tansaku(i,j,h,w);
                cout << c;
            }
        }
        cout << endl;
    }
    return 0;
}

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

using namespace std;
string s;
int main()
{
    //freopen("A.in","r",stdin);
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    cin >> s;
    for (int i=0;i<s.size()-1;i++) if (s[i]==s[i+1])
    {
        cout << "Bad";
        return 0;
    }
    cout << "Good";
}


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

int main()
{
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;

    vector<int> p(A), q(B), r(C);
    for (int i = 0; i < A; i++)
    {
        cin >> p.at(i);
    }
    for (int i = 0; i < B; i++)
    {
        cin >> q.at(i);
    }
    for (int i = 0; i < C; i++)
    {
        cin >> r.at(i);
    }

    sort(p.begin(), p.end(), greater<int>());
    sort(q.begin(), q.end(), greater<int>());
    sort(r.begin(), r.end(), greater<int>());

    vector<int> s;
    for (int i = 0; i < X; i++)
    {
        s.push_back(p.at(i));
    }
    for (int i = 0; i < Y; i++)
    {
        s.push_back(q.at(i));
    }
    for (int i = 0; i < C; i++)
    {
        s.push_back(r.at(i));
    }
    sort(s.begin(), s.end(), greater<int>());

    int64_t res = 0;
    for (int i = 0; i < X + Y; i++)
    {
        res += s.at(i);
    }
    cout << res << endl;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int c[100];
bool solve(){
	int N;
	cin>>N;
	int d=0;
	rep(i,N){
		int a;
		cin>>a;
		c[a]++;
		chmax(d,a);
	}
	if(d%2==0){
		for(int i=d;i>d/2;i--){
			if(c[i]<2) return 0;
		}
		if(c[d/2]!=1) return 0;
		rep(i,d/2) if(c[i]>0) return 0;
	}else{
		for(int i=d;i>d/2+1;i--){
			if(c[i]<2) return 0;
		}
		if(c[d/2+1]!=2) return 0;
		rep(i,d/2+1) if(c[i]>0) return 0;
	}
	return 1;
}
int main(){
	if(solve()) puts("Possible");
	else puts("Impossible");
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) a.erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

int main(){
    ll n;cin>>n;
    vi ans(n);
    REP(i,1,n+1){
        REP(j,1,n+1){
            REP(k,1,inf){
                ll s=i*i+j*j+k*k+i*j+j*k+k*i;
                if(s>n)break;
                ans[s-1]++;
            }
            if(i*i+j*j>n)break;
        }
        if(i*i>n)break;
    }
    for(ll x:ans)out(x);
}

Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <algorithm>
#include <stack>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)

using namespace std;

int main(){
    long long int n,m,ans=0;
    cin>>n>>m;
    if(2*n<=m){
        m-=2*n;
        ans+=n;
    }
    else{
        ans+=m/2;
        m%=2;
    }
    ans+=m/4;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main (String[]args){
    
    Scanner sc = new Scanner (System.in);
    int S = sc.nextInt();
    int W = sc.nextInt();
      
    if(S <= W){
      System.out.println("unsafe");
    }else {
      System.out.println("safe");
    }
            }
  }

Measured memory_bytes: 35780
import sys
sys.setrecursionlimit(100000000)

moves = [(0, -1), (0, 1), (-1, 0), (1, 0)]


def search(dataset):
    min_time = 0
    mouse = 1
    gx, gy = get_start(dataset)
    for i in xrange(N):
        gx, gy, min_time_tmp = bfs(dataset, (gx, gy), mouse)
        mouse += 1
        min_time += min_time_tmp
    print min_time


def bfs(dataset, start, mouse):
    INF = 10000000
    min_time = [[INF for j in xrange(W)] for i in xrange(H)]
    min_time[start[0]][start[1]] = 0
    queue = [start]

    while len(queue) != 0:
        dx, dy = queue.pop(0)
        for i, j in moves:
            nx = dx + i
            ny = dy + j
            if 0 <= nx < H and 0 <= ny < W and dataset[nx][ny] != 'X' and min_time[nx][ny] == INF:
                cell = dataset[nx][ny]
            else:
                continue
            if type(cell) is int:
                if mouse == int(cell):
                    min_time[nx][ny] = min_time[dx][dy] + 1
                    return nx, ny, min_time[nx][ny]
            min_time[nx][ny] = min_time[dx][dy] + 1
            queue.append((nx, ny))


def get_start(dataset):
    for i in xrange(H):
        rows = dataset[i]
        for j in xrange(W):
            cell = rows[j]
            if cell == 'S':
                return i, j


dataset = []
while True:
    line = raw_input().rstrip().split()
    if len(line) == 3:
        H, W, N = map(int, line)
    else:
        row = []
        for e in line[0]:
            if e.isdigit():
                row.append(int(e))
            else:
                row.append(e)
        dataset.append(row)
    if len(dataset) == H:
        search(dataset)
        break

Measured memory_bytes: 32884
#[allow(unused_imports)]
use std::cmp::{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;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = 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::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = 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),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

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 = get!(usize; 5);
    let k = get!(usize);

    if a[4] - a[0] > k {
        println!(":(");
    } else {
        println!("Yay!");
    }


}


Measured memory_bytes: 8572
#include <iostream>
using namespace std;
int main() {
  int N, M; cin >> N >> M;
  int a[M], b[M], c[N];
  for(int i = 0; i < N; i++)
    c[i] = 0;
  for(int i = 0; i < M; i++) {
    cin >> a[i] >> b[i];
    ++(c[a[i] - 1]);
    ++(c[b[i] - 1]);
  }
  for(int i = 0; i < N; i++)
    cout << c[i] << endl;
}

Measured memory_bytes: 256
#import numpy as np
from collections import Counter
from time import time

import sys
readline = sys.stdin.buffer.readline


N = int(input())
A = list(map(int, input().split()))
#A = np.random.randint(1, 10 ** 5 + 1, 10 ** 5)

S = sum(A)
C = Counter(A)

Q = int(input())
#Q = 10 ** 5

ans = []
s = time()
for _ in range(Q):
    b, c = map(int, input().split())
    #b, c = np.random.randint(1, 10 ** 5 + 1, 2)
    #b, c = 2, 5

    count = C[b]
    S = S + (c - b) * count

    C[c] += count
    C[b] = 0
    
    ans.append(S)

print('\n'.join(map(str, ans)))
#print('time: ', time() - s)

Measured memory_bytes: 33788
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#pragma GCC optimize("Os")
#pragma GCC target("avx2,fma")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("Os")
*/
 
#include <bits/stdc++.h>
//#include <windows.h>
 
#define ll long long
#define X first
#define Y second
#define MP make_pair
 
using namespace std;
 
    /*
const int MAX_MEM = 1e8;
int mpos=0;
char mem[MAX_MEM];
inline void * operator new(size_t n){
	char *res = mem + mpos;
	mpos += n;
	assert(mpos <= MAX_MEM);
	return (void *)res;
}
 
inline void operator delete(void *){}
    */

const int N = 2e3 + 123;
const ll mod = 1e9 + 7;

int n;
pair<int, int> p[N * 100];
ll dp[N * 2][N * 2];
ll fact[N * 10];

ll bin_pow(ll x, ll y){
	ll res = 1;
	while(y){
		if(y & 1)	
			res = res * x % mod;
		x = x * x % mod;
		y >>= 1LL;
	}
	return res;
}

ll calc(ll x, ll y){
	ll res = fact[x + y] * bin_pow(fact[x] * fact[y] % mod, mod - 2) % mod;
	return res;	
}

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

	fact[0] = 1;
	for(ll i = 1;i < N * 10;i++){
		ll x = fact[i - 1] * i % mod;
		fact[i] = x;
	}

	cin >> n;
	for(int i = 1;i <= n;i++){
		cin >> p[i].X >> p[i].Y;
		dp[p[i].X + N][p[i].Y + N] += 1;
	}

	for(int i = 2 * N - 2;i >= 1;i--){
		for(int j = 2 * N - 2;j >= 1;j--){
			dp[i][j - 1] = (dp[i][j - 1] + dp[i][j]) % mod;
			dp[i - 1][j] = (dp[i - 1][j] + dp[i][j]) % mod;
		}
	}
	ll res = 0;
	for(int i = 1;i <= n;i++){
		res = (res + dp[N - p[i].X][N - p[i].Y]) % mod;
		res = (res - calc(p[i].X * 2, p[i].Y * 2) + mod) % mod;
	}

	//cout << calc(p[1].X + p[2].X, p[2].Y + p[1].Y) << "\n";

	res = res * bin_pow(2, mod - 2) % mod;
	cout << res;
	return 0;
}

Measured memory_bytes: 142848
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
n=i1()
a=i2()
x=max(a)
y=float("inf")
for i in range(n):
 if x!=a[i] and abs(y-x//2)>abs(a[i]-x//2):
    y=a[i]
print(x,y)

Measured memory_bytes: 62704
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const long long mod = 1e9+7;
long long power(long long a, long long b, long long m = mod) {
    if(b < 0) {
        return power(power(a, -b), mod-2);
    }
    long long x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}
const int N = 3e5+9;
signed main() {  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    const long double pi = 4 * atan(1);
    // cout << pi << endl;
    
    int r; cin >> r;
    cout << fixed << setprecision(15) << 2.l * pi * r << endl;

    





    return 0;
    
}


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

typedef pair<int, int> P;
typedef pair<P, int> PI;
vector<PI> v;

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

	int r;
	for( r = 0; r <= 19; r++ ) {
		if( (1 << (r + 1) ) > l ) {
			break;
		}
	}
	int n = r + 1;
	for( int i = 1; i < n; i++ ) {
		v.push_back(make_pair( make_pair(i, i + 1), 0 ) );
		v.push_back(make_pair( make_pair(i, i + 1), 1 << (i - 1) ) );
	}
	for( int t = n; t > 0; t-- ) {
		if( l - (1 << (t - 1) ) >= (1 << r) ) {
			v.push_back(make_pair( make_pair(t, n), l - (1 << (t - 1) ) ) );
			l -= 1 << (t - 1);
		}
	}

	cout << n << " " << v.size() << endl;
	for( int i = 0; i < v.size(); i++ ) {
		cout << v[i].first.first << " " << v[i].first.second << " " << v[i].second << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入
		int n = sc.nextInt();
		int k = sc.nextInt();

			System.out.println(n-k+1);

 
	}
}


Measured memory_bytes: 22740
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%3d", arr[i][j]); } cout << endl; }

using namespace std;

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

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

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */
int n, p[100];
map<string, vector<int> > res;
string s[100];

int main() {
    cin >> n;
    rep(i, n) {
        cin >> s[i] >> p[i];
        res[s[i]].push_back(p[i]);
    }
    map<int, int> mp;
    rep(i,n){
        mp[p[i]] = i+1;
    }
    for(auto e: res){
        sort(all(e.second), greater<int>());
        rep(i, e.second.size()){
            cout << mp[e.second[i]] << endl;
        }
    }
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)

int main() {
  int n,k;
  cin>>n>>k;
  string s;
  cin>>s;
  if(s[k-1]=='A') s[k-1]='a';
else if(s[k-1]=='B') s[k-1]='b';
else if(s[k-1]=='C') s[k-1]='c';
  cout<<s<<endl;
return 0;
}


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

using namespace std;
using P = pair<int, int>;

vector<P> data1[210];
vector<P> data2[210];

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

    vector<P> ab(N);
    for(int i = 0; i < N; ++i){
        cin >> ab[i].first >> ab[i].second;
        int m = max(ab[i].first, ab[i].second);
        data1[m].push_back(ab[i]);
    }
    vector<P> cd(N);
    for(int i = 0; i < N; ++i){
        cin >> cd[i].first >> cd[i].second;
        int m = min(cd[i].first, cd[i].second);
        data2[m].push_back(cd[i]);
    }

    int ans = 0;
    for(int i = 2 * N - 1; i >= 0; --i){
        for(auto& c : data1[i]){
            bool check = false;
            for(int j = 0; j < 2 * N; ++j){
                for(auto& d : data2[j]){
                    if(c.first < d.first && c.second < d.second){
                        ++ans;
                        check = true;
                        d.first = 0;
                        d.second = 0;
                        break;
                    }
                }
                if(check) break;
            }
        }
    }
    cout << ans << endl;
}

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

using namespace std;

#define INF 998244353
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
signed main()
{
    int N;
    cin >> N;
    vector<int> D;
    int A[N + 1];
    fill(A, A + N + 1, 0);
    int ans = 1;
    rep(i, N)
    {
        int a;
        cin >> a;
        D.push_back(a);
    }
    if (D[0] != 0)
    {
        cout << "0" << endl;
        return 0;
    }
    sort(D.begin(), D.end());
    if (D[1] == 0)
    {
        cout << "0" << endl;
        return 0;
    }
    for (int i = 0; i < N; i++)
    {
        A[D[i]]++;
    }
    for (int i = 1; i <= N; i++)
    {
        int calc = 1;
        for (int j = 1; j <= A[i]; j++)
        {
            calc = (calc * A[i - 1]) % INF;
        }
        ans = (ans * calc) % INF;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2168
#include <cstdio>
#include <algorithm>
int a[2000], b[2000], c[2000], N, L[2000], R[2000], O = 2000000000;
char ia[2001], ib[2001];
inline int dis(int x, int y)
{
	if (x > y)
		std::swap(x, y);
	return std::min(y - x, N - y + x);
}
void Try(int mov)
{
	static std::pair < int, int > p[2002], q[2002];
	int G = 0, T = 0;
	for (int i = 0; i < N; i++)
		if (a[i] != b[(i + mov) % N])
			p[++G] = std::make_pair(L[i], R[i]);
	std::sort(p + 1, p + G + 1);
	for (int i = 1; i <= G; i++)
	{
		while (T && p[i].second >= q[T].second)
			T--;
		q[++T] = p[i];
	}
	q[0].first = q[T + 1].second = 0;
	for (int i = 0; i <= T; i++)
	{
		O = std::min(O, G + (q[i].first << 1) + q[i + 1].second + dis(q[i + 1].second, mov));
		O = std::min(O, G + q[i].first + (q[i + 1].second << 1) + dis((N - q[i].first) % N, mov));
	}
}
int main()
{
	scanf("%s%s", ia, ib);
	while (ia[N])
		N++;
	for (int i = 0; i < N; i++)
		a[i] = ia[i] - '0';
	for (int i = 0; i < N; i++)
		b[i] = ib[i] - '0';
	if (!std::count(b, b + N, 1))
	{
		puts(std::count(a, a + N, 1) ? "-1" : "0");
		return 0;
	}
	int any = std::find(b, b + N, 1) - b;
	for (int i = any - 1; i >= 0; i--)
		R[i] = b[i] ? 0 : R[i + 1] + 1;
	R[N - 1] = b[N - 1] ? 0 : R[0] + 1;
	for (int i = N - 2; i > any; i--)
		R[i] = b[i] ? 0 : R[i + 1] + 1;
	for (int i = any + 1; i < N; i++)
		L[i] = b[i] ? 0 : L[i - 1] + 1;
	L[0] = b[0] ? 0 : L[N - 1] + 1;
	for (int i = 1; i < any; i++)
		L[i] = b[i] ? 0 : L[i - 1] + 1;
	for (int i = 0; i < N; i++)
		Try(i);
	printf("%d\n", O);
	return 0;
}


Measured memory_bytes: 256
package main

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

func isqrt(n int) int {
	if n < 0 {
		panic("isqrt argument must be nonnegative")
	}

	if n <= 1 {
		return n
	}

	ok := 0
	ng := 3037000500 // 3037000499 * 3037000499 < math.MaxInt64 < 3037000500 * 3037000500
	if n < ng {
		ng = n
	}
	for ng-ok > 1 {
		m := ok + (ng-ok)/2
		if m*m <= n {
			ok = m
		} else {
			ng = m
		}
	}
	return ok
}

func gcd(x, y int) int {
	if x < y {
		x, y = y, x
	}
	for y > 0 {
		x, y = y, x%y
	}
	return x
}

func main() {
	defer flush()

	A := readInt()
	B := readInt()

	N := gcd(A, B)
	if N == 1 {
		println(1)
		return
	}

	result := 1
	for x := 2; x < isqrt(N)+1; x++ {
		if N%x == 0 {
			result++
			for N%x == 0 {
				N /= x
			}
			if N == 1 {
				break
			}
		}
	}
	if N != 1 {
		result++
	}
	println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}


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

using namespace std;

#define rep(i, a, b)	for (int i(a); i <= (b); ++i)
#define dec(i, a, b)	for (int i(a); i >= (b); --i)
#define MP		make_pair
#define fi		first
#define se		second


typedef long long LL;

int n, m;

int main(){

	scanf("%d%d", &n, &m);
	puts(n % 500 <= m ? "Yes" : "No");


	return 0;
}




Measured memory_bytes: 256
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    static int N, W;
    static int[][] item;
    static long[][] dp;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
//        Reader sc = Reader();
        N = sc.nextInt();
        W = sc.nextInt();
        PrintWriter pw = new PrintWriter(System.out);

        item = new int[N+1][2];

        for(int i=1; i<=N; ++i) {
            item[i][0] = sc.nextInt();
            item[i][1] = sc.nextInt();
        }

        pw.println(Knapsack_1(N, W, item));
        pw.close();
    }

    public static void d0(long[][] dp) {
        System.out.print("    ");

        for(int j=0; j<dp[0].length; ++j){
            System.out.printf("%3d ", j);
        }
        System.out.println();

        for(int i=0; i<dp.length; ++i){
            System.out.printf("%3d|", i);
            for(int j=0; j<dp[0].length; ++j){
                System.out.printf("%3d ", dp[i][j]);
            }
            System.out.println();
        }
    }

    public static int myMax(int a, int b) {
        if(a>b)
            return a;

        return b;
    }

    public static long Knapsack_1(int N, int W, int[][] item) {
        dp = new long[N+1][W+1];

        for(int i=1; i<=N; ++i) {
            for(int w=1; w<=W; ++w) {
                if(item[i][0] <= w) {
                    dp[i][w] = Math.max(dp[i-1][w], dp[i-1][w-item[i][0]] + item[i][1]);
//                    dp[i][w] = myMax(dp[i-1][w], dp[i-1][w-item[i][0]] + item[i][1]);
                }
                else {
                    dp[i][w] = dp[i-1][w];
                }
            }
        }

//        d0(dp);

        return dp[N][W];
    }
}


Measured memory_bytes: 129108
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N, M;
	cin >> N >> M;
	vector<int> h(N);
	for (int i = 0; i < N; i++) {
		cin >> h.at(i);
	}
	vector<vector<int>> road(N, vector<int>(0));
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		road.at(a - 1).push_back(b - 1);
		road.at(b - 1).push_back(a - 1);
	}
	int counter = 0;
	//各灯台について調べる
	for (int i = 0; i < N; i++) {
		if (road.at(i).size() == 0) {
			counter++;
		}
		else {
			//道でつながってる全ての灯台より標高が高ければcounter++
			//1つでも低ければbreak
			int zantei = 0;
			int i_high = h.at(i);
			for (int j = 0; j < road.at(i).size(); j++) {
				if (zantei < h.at(road.at(i).at(j))) {
					zantei = h.at(road.at(i).at(j));
				}
				else {}
			}
			if (zantei < i_high) {
				counter++;
			}
			else {}
		}
	}
	cout << counter << endl;

}

Measured memory_bytes: 8804
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    N, K = map(int, input().split())

    MOD = (10**9) + 7
    ans = 0
    for i in range(K, N + 2):
        ans += sum_of_arithmetic_progression(N, -1, i) - sum_of_arithmetic_progression(0, 1, i) + 1
        ans %= MOD

    print(ans)


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9976
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    n=INT()
    a=LIST()
    a_=a.copy()

    r=0
    for x in a:
        r ^= x 

    if r==0:
        print('Yes')
    else:
        print('No')

if  __name__=='__main__':
    main()

Measured memory_bytes: 16244
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
#define loop(i, n) for(int i = 0 ; i < n ; i++)

using namespace std;

int main() {
	int w, h, x, y;
	cin >> w >> h >> x >> y;
	int h1, h2;
	h1 = w/2;
	h2 = h/ 2;
	long long ans = 1LL*w*h;
	ans /= 2;
	if(w%2 && h%2) cout << ans << ".5" << ' ';
	else cout << ans << ' ';
	if(w%2 || h %2) cout << 0;
	else if(x == h1 && y ==h2) cout << 1;
	else cout << 0;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
\
int main()
{
    int a, b, x;
    cin >> a >> b >> x;
    double pi = 3.14159265359;
    if(a * a * b / 2 < x){
        double empty = (double)(a * a * b) - (double)x;
        double bMax = (double)(empty * 2) / (double)(a * a);
        cout << setprecision(11) << atan(bMax / a) * 180 / pi << endl;
    }else{
        double aMax = (double)(x * 2) / (double)(a * b);
        cout << setprecision(11) << atan(b / aMax) * 180 / pi << endl;
    }
    return 0;
}

Measured memory_bytes: 256
s = str(input())

g_count = 0
p_count = 0
point = 0
for i in range(len(s)):
    # 必ずグーを出す状態
    if g_count == p_count:
        g_count += 1
        if s[i] == 'g':
            pass
        else:
            point -= 1
    # パーも出せる状態
    elif s[i] == 'g':
        p_count += 1
        point += 1
    elif s[i] == 'p':
        p_count += 1

ans = point
print(ans)

Measured memory_bytes: 3316
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, d, a = list(map(int, readline().split()))
    xh = [list(map(int, readline().split())) for _ in range(n)]

    from operator import itemgetter, add
    import bisect

    xh.sort(key=itemgetter(0))
    coordinate = [xh[i][0] for i in range(n)]
    hp = [xh[i][1] for i in range(n)]

    ans = 0
    dmg_cur = 0
    dmg_cum = [0] * (n + 1)

    for i in range(n):
        x = coordinate[i]
        h = hp[i]

        dmg_cur += dmg_cum[i]
        h -= dmg_cur

        if h > 0:
            num = (h + a - 1) // a
            ans += num
            dmg = a * num
            dmg_cur += dmg
            range_left = x
            range_right = x + 2 * d
            index_right = bisect.bisect_right(coordinate, range_right)
            dmg_cum[index_right] -= dmg
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 98176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    int n;cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    set<int> s(a.begin(),a.end());
    int k=s.size();
    if((n-k)%2==0) cout<<k<<endl;
    else cout<<k-1<<endl;
}

Measured memory_bytes: 5376
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
  int N;
  cin >> N;
  vector<int> P;

  for (size_t i = 0; i < N; i++) {
    int p;
    cin >> p;
    P.push_back(p);
  }

  sort(P.rbegin(), P.rend());

  int sum;
  for (size_t i = 0; i < N; i++) {
    if (i == 0) {
      sum += P[i] / 2;
    } else {
      sum += P[i];
    }
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())

win_prob = 0

import math
if n < k:
  for i in range(1, n+1):
    win_prob += 0.5 ** math.ceil(math.log2(k / i))
  print(win_prob / n)
else:
  for i in range(1, k):
    win_prob += 0.5 ** math.ceil(math.log2(k / i))
  print(win_prob / n + (n - k + 1) / n)

Measured memory_bytes: 3060
#include<stdio.h>

int main(){
    int a;
    int h = 0;
    int m = 0;
    scanf("%d",&a);
    if(a/3600!=0){
        h = a / 3600;
        a -= 3600 * h;
    }
    if(a/60!=0){
        m = a / 60;
        a -= 60 * m;
    }
    printf("%d:%d:%d\n",h,m,a);
    
    return 0;
}



Measured memory_bytes: 2100
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <math.h>
#include <iomanip>
using namespace std;
#define Would
#define you
const int INF = 999999999;
const int MOD = 1e9 + 7;

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


Measured memory_bytes: 3124
#include<cstdio>

int main(){

  double a,b,c,d,e,f,x,y;
  while(scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f)!=EOF){
    x=(c*e-b*f)/(a*e-b*d);
    y=(a*f-d*c)/(a*e-b*d);
    if(x==0)x=0;
    if(y==0)y=0;
    printf("%.3f %.3f\n",x,y);
  }
  return 0;
}

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

using namespace std;
using ll = long long;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<ll, ll>> ab(n);
    for (int i = 0; i < n; ++i) {
        cin >> ab[i].first >> ab[i].second;
    }
    sort(all(ab));

    ll have = 0, ans = 0;
    for (int i = 0; i < n; i++) {
        if (have + ab[i].second >= m) {
            ans += (m - have) * ab[i].first;
            break;
        } else {
            have += ab[i].second;
            ans += ab[i].first * ab[i].second;
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i ++) {
    cin >> a.at(i);
  }

  sort(a.begin(), a.end());
  int ans = 1000000000;
  for (int i = a.at(0); i <= a.back(); i ++) {
    int tmp_sum = 0;
    for (int j = 0; j < n; j ++) {
      tmp_sum += (i - a.at(j)) * (i - a.at(j));
    }
    ans = min(ans, tmp_sum);
  }

  cout << ans << endl;
}


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

using namespace std;

int main() {
	int n, m, l;
	int A[101][101], B[101][101];

	scanf("%d %d %d", &n, &m, &l);

	int v;
	int i, j;

	for(i = 0; i < 101; i++) {
		for(j = 0; j < 101; j++) {
			A[i][j] = 0;
			B[i][j] = 0;
		}
	}

	for(i = 0; i < n; i++) {
		j = 0;
		while(cin >> v) {
			A[i][j] = v;
			//printf("A[%d][%d] = %d\n", i, j, v);
			j++;
			if(j >= m) break;
		}
	}

	for(i = 0; i < m; i++) {
		j = 0;
		while(cin >> v) {
			B[i][j] = v;
			//printf("B[%d][%d] = %d\n", i, j, v);
			j++;
			if(j >= l) break;
		}
	}

	long int c;
	int k;
	for(i = 0; i < n; i++) {
		for(j = 0; j < l; j++) {
			c = 0;
			for(k = 0; k < m; k++) {
				c += A[i][k] * B[k][j];
			}
			printf("%ld", c);
			if(j < l - 1) printf(" ");
			else printf("\n");
		}
	}

	return 0;
}

Measured memory_bytes: 3288
k,n=(int(x) for x in input().split())

a=list(map(int,input().split()))
d0=0
dmax=0
for i in range(n):
    d=a[i]-d0
    d0=a[i]
    if d>=dmax:
        dmax=d
d1=k-a[n-1]+a[0]
if d1>=dmax:
    print(str(k-d1))
else:
    print(str(k-dmax))




Measured memory_bytes: 26420
f=0
while 1:
  n=input()
  if n==0: break
  C=[()]*n
  for i in range(n):
    a,b,c,d=raw_input().split(" ")
    C[i]=(i,int(b)*3+int(d),a)
  C=sorted(C,key=lambda x:(-x[1]))
  if f>0: print
  for e in C: print e[2]+","+str(e[1])
  f=1

Measured memory_bytes: 4228
N = int(input())
c = 0
f = 0
for i in range(N):
    a, b = map(int, input().split())
    if a == b:
        c += 1
    else:
        c = 0
    if c >= 3:
        f = 1

if f == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 62272
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#define re register
using namespace std;

inline int read() {
  int X = 0, w = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') w = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') X = X * 10 + c - '0', c = getchar();
  return X * w;
}

const int N = 3000 + 10;

int n, a[N];

struct edge {
  int v, nxt;
} e[N << 1];
int head[N];
inline void addEdge(int u, int v) {
  static int cnt = 0;
  e[++cnt] = (edge){v, head[u]}, head[u] = cnt;
}

int f[N];
inline void dfs(int u, int fa) {
  f[u] = 0;
  for (re int i = head[u]; i; i = e[i].nxt) {
    int v = e[i].v;
    if (v == fa || a[v] >= a[u]) continue;
    dfs(v, u);
    if (!f[v]) f[u] = 1;
  }
}

int main() {
  n = read();
  for (re int i = 1; i <= n; ++i) a[i] = read();
  for (re int i = 1; i < n; ++i) {
    int u = read(), v = read();
    addEdge(u, v), addEdge(v, u);
  }
  for (re int i = 1; i <= n; ++i) {
    dfs(i, 0);
    if (f[i]) printf("%d ", i);
  }
  puts("");
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
 int n;
 cin>>n;
 vector<int> a(n);
 vector<int> cnt(3,0);
 for(int i=0;i<n;i++){
  cin>>a[i];
  cnt[ a[i]%3 ]++;
 }

 if( cnt[1] == 0 && cnt[2] == 0 ){
  cout<<1<<endl;
  return 0;
 }

 //cout<<cnt[1]<<' '<<cnt[2]<<endl;

 int ans = 0;
 for(int j=1;j<=2;j++){
  vector<int> tmp= cnt;
  if( tmp[j] != 0 ){
   int sum = 0;
   sum = tmp[0]+1;
   int now = j;
   tmp[j]--;

   //cout<<sum<<' '<<now<<' '<<tmp[1]<<' '<<tmp[2]<<endl;
   while( tmp[now] != 0 ){
    tmp[now]--;
    //cout<<now<<endl;
    now += now;
    now %= 3;
    sum++;
   //cout<<sum<<' '<<now<<' '<<tmp[1]<<' '<<tmp[2]<<endl;
   }
   if( tmp[1] || tmp[2] ) sum++;
   //cout<<j<<' '<<sum<<endl;
   ans = max(ans,sum);
  }

 }
 cout<<ans<<endl;


    return 0;
}



Measured memory_bytes: 4684
n,k = map(int,input().split())
v = list(map(int,input().split()))
ans = 0
for i in range(min(n,k)+1):#左から何個とるか
    for j in range(min(n,k)+1-i):#右から何個とるか
        x = sorted(v[:i]+v[n-j:])
        for l in range(k-i-j+1):
            ans = max(ans,sum(x[l:]))
print(ans)

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <limits>
#include <numeric>
#include <set>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++)
            par[i] = i;
    }

    int
    root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if(par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x);      // xの根をrx
        int ry = root(y);      // yの根をry
        if(rx == ry)
            return; // xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] =
            ry; // xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    UnionFind tree(N);
    rep(i, 0, M) {
        int x, y, z;
        cin >> x >> y >> z;
        x--;
        y--;
        z = z % 2;
        tree.unite(x, y);
    }
    set<int> se;
    rep(i, 0, N) { se.insert(tree.root(i)); }
    cout << (int)se.size() << endl;
}

Measured memory_bytes: 5376
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#include <bits/stdc++.h>
using namespace std;
int sum(vector<int> s){return accumulate(s.begin(),s.end(),0);}
void p(vector<int> A){rep(i,A.size()){cout << A[i] << " ";}cout << "\n";}

int main(){
    int r, g, b ,n;
    cin >> r >> g >> b >> n;
    int cnt = 0;
    rep(i,n+1){
        rep(j,n+1){
            int k = n - r*i - g*j;
            if(k % b == 0 && k >= 0){
                cnt++;
            }
        }
    }
    cout << cnt;
}

Measured memory_bytes: 3608
/**
 _____      _ _              ______     
/  ___|    (_|_)             |  _  \    
\ `--. _ __ _ _  __ _ _ __   | | | |___ 
 `--. \ '__| | |/ _` | '_ \  | | | / _ \
/\__/ / |  | | | (_| | | | | | |/ /  __/
\____/|_|  |_| |\__,_|_| |_| |___/ \___|
            _/ |                         
           |__/                          
All Required Header Files ********/
#include <bits/stdc++.h>  
using 		namespace 		std;
using 		lli= 			long long  int;
using 		ulli= 			unsigned long long int;
using 		ld= 			long double;
int main() {
	
	ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);
	
	string s;
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5])
	cout<<"Yes";
	else
	cout<<"No";
	
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n;
    cin>>n;
    vl as(n);
    cin>>as;

    ll m = LINF, M = -LINF;
    ll mi = -1, Mi = -1;
    rep(i, n) {
        if (as[i] < m) {
            m = as[i];
            mi = i;
        }
        if (as[i] > M) {
            M = as[i];
            Mi = i;
        }
    }
    cout<<2 * n - 1<<endl;
    if (m + M > 0) {
        rep(i, n) cout<<Mi + 1<<" "<<i + 1<<endl;
        rep(i, n - 1) cout<<i + 1<<" "<<i + 2<<endl;
    }
    else {
        rep(i, n) cout<<mi + 1<<" "<<i + 1<<endl;
        rep(i, n - 1) cout<<n - i<<" "<<n - i - 1<<endl;
    }
}

Measured memory_bytes: 256