akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
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 ( 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 ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
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 , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        n: usize, m: usize,
        ab: [(usize1, usize1);m]
    }
    for i in 0..n {
        let mut cnt = 0;
        for &(a,b) in &ab {
            if a == i || b == i {
                cnt += 1;
            }
        }
        println!("{}", cnt);
    }
}

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

int main(void){
  int x,y,z,w;
  cin >> x >> y >> z >> w;
  if(x+y > z+w){
    cout << "Left" << endl;
  }else if(x+y == z+w){
    cout << "Balanced" << endl;
  }else{
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
let input = require('fs').readFileSync('/dev/stdin', 'utf8');
let Arr = (input.trim()).split("\n");
let N1 = Number(Arr[0]);
let arr1 = Arr[1].split(" ").map(Number);
// const N2 = Number(Arr[2]);
let arr2 = Arr[3].split(" ").map(Number);

let mid;
const binarySearch = (key, arr, N) => {
  let left = 0;
  let right = N;
  if (key < arr[0] || arr[N-1] < key) return 0;
  while (left < right) {
    mid = Math.floor((left + right) / 2);
    if (key < arr[mid]) right = mid;
    else if (key > arr[mid]) left = mid + 1;
    else return 1;
  }
  return 0;
}

console.log(arr2.map(e => binarySearch(e, arr1, N1)).reduce((a, b) => a + b, 0));




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

#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define vi vector<int>
#define pi pair<int, int>
#define mem(a,b) memset(a,b,sizeof(a))
#define mp make_pair
const int mod = (int)1e9+7;
typedef long long int ll;

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int n,k;
	cin>>n;
	ll a[n+5],b[n+5],c[n+5],dp[n+5][3];
	for(int i=0;i<n;i++)
		cin>>a[i]>>b[i]>>c[i];
	dp[0][0]=a[0];
	dp[0][1]=b[0];
	dp[0][2]=c[0];
	for(int i=1;i<n;i++){
		dp[i][0] = a[i] + max(dp[i-1][1], dp[i-1][2]);
		dp[i][1] = b[i] + max(dp[i-1][0], dp[i-1][2]);
		dp[i][2] = c[i] + max(dp[i-1][1], dp[i-1][0]);
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1], dp[n-1][2]))<<endl;
}

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

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		euclid(x,y);
	}
	public static void euclid(int x , int y)
	{
		int temp;
		if (x == 0 || y == 0) {
			System.out.println((x+y));
			return ;
		}
		if(x < y){
			temp = x;
			x = y;
			y = temp;
		}
		
		euclid(y,x % y);
	}
}

Measured memory_bytes: 26224
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;
int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    out(max(a*b, c*d));
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;

#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)

int v, dp[5001];
const int m[] = {200, 300, 500, 1000, 1200, 1500};
const int p[] = {380, 550, 850, 1520, 1870, 2244};
const int INF = 10000000;

/*
  @ツ残ツづィツづ個重ツつウ
*/

int dfs(int w) {
  if (w <= 0) return 0;
  if (dp[w] >= 0) return dp[w];
  int res = INF;
  rep(i,6) {
    if (w-m[i] < 0) continue;
    res = min(res, dfs(w-m[i]) + p[i]);
  }
  return dp[w] = res;
}

void solve() {
  memset(dp, -1, sizeof dp);
  cout<<dfs(v)<<endl;
  //cout<<dp[v]<<endl;
}

int main (int argc, char const* argv[]) {
  /*
  rep(i,5001) dp[i] = INF;
  
  dp[0] = 0;
  rep(z,6) for(int i=0;i+m[z]<5001;i++) {
    dp[i+m[z]] = min(dp[i+m[z]], dp[i] + p[z]);
  }
  rep(i,5001) rep(z,6) {
    if (i+m[z] >= 5001) continue;
    dp[i+m[z]] = min(dp[i+m[z]], dp[i] + p[z]);
  }
  */

  while (cin>>v, v) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 0
N=int(input())
l=[]
for i in range(N):
  a=input()
  l.append(a)
AC_num=l.count("AC")
WA_num=l.count("WA")
TLE_num=l.count("TLE")
RE_num=l.count("RE")
print("AC x",AC_num)
print("WA x",WA_num)
print("TLE x",TLE_num)
print("RE x",RE_num)

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

#define FastRead        ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl            "\n"
#define sq(x)           ((x)*(x))
#define MAX             500005

typedef long long ll;


int main()
{
    FastRead

    char ch;

    cin>>ch;

    if(ch>='A' and ch<='Z')
        cout<<"A";
    else
        cout<<"a"<<endl;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll P = 1e9+7;


int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	ll t= 1;
	// cin>>t;

	while(t--){
		ll x,k,d;
		cin>>x>>k>>d;

		x = abs(x);

		ll m = x/d;
		if(m < k){
			x -= m*d;
			k -= m;
			if(k%2==1)
				x = abs(x-d);
			cout<<x<<"\n";
		}
		else if(m == k){
			x -= m*d;
			cout<<x<<"\n";
		}
		else{
			x -= k*d;
			cout<<x<<"\n";
		}

	}

	return 0;
}

Measured memory_bytes: 3640
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		sc.close();
		if (n % (2 * d + 1) == 0) {
			System.out.println(n / (2 * d + 1));
		} else {
			System.out.println(n / (2 * d + 1) + 1);
		}
	}

	public static int[] arrayInt(Scanner sc, int n) {
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		return array;
	}

	public static long[] arrayLong(Scanner sc, int n) {
		long[] array = new long[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextLong();
		}
		return array;
	}

	public static double[] arrayDouble(Scanner sc, int n) {
		double[] array = new double[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextDouble();
		}
		return array;
	}
}

Measured memory_bytes: 21844
def isPrime(n):
    i = 2
    while i * i <= n:
        if n % i == 0:
            return False
        i += 1
    
    return True

N = int(input())
cnt = 0

for _ in range(N):
    a = int(input())
    if isPrime(a):
        cnt += 1

print(cnt)

Measured memory_bytes: 7660
N = int(input())
a,b,c = [],[],[]
for n in range(N):
  a_,b_,c_ = map(int, input().split())
  a.append(a_)
  b.append(b_)
  c.append(c_)
do_a = [a[0]] #do a in n-th day
do_b = [b[0]] #same
do_c = [c[0]]

for day in range(1,N):
  do_a.append(a[day] + max(do_b[day-1], do_c[day-1]))
  do_b.append(b[day] + max(do_a[day-1], do_c[day-1]))
  do_c.append(c[day] + max(do_a[day-1], do_b[day-1]))
print(max(do_a[N-1],do_b[N-1], do_c[N-1]))

Measured memory_bytes: 32520
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,srt,end) for( ll i=(ll)(srt); i<(ll)(end); i++ )
#define VL vector<ll>
#define INF 1e18

int main(){
    ll N,T;
    cin>>N>>T;
    VL c(N),t(N);
    rep(i,0,N)cin>>c[i]>>t[i];
    
    ll ans=INF;
    rep(i,0,N){
        if(T>=t[i])ans=min(ans,c[i]);
    }
    if(ans==INF)cout<<"TLE"<<endl;
    else cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n,d,x,y,ans=0;
  cin>>n>>d;
  while(n--){
    cin>>x>>y;
    if(x*x+y*y<=d*d) ans++;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  string S;cin>>S;
  set<char> S_s;
  each(c,S){
    if(S_s.count(c)){
      print("no");
      return 0;
    }
    S_s.insert(c);
  }
  print("yes");

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;


template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

ll RS(ll N,ll P,ll M){
    if(P==0){
        return 1;
    }else{
        if(P%2==0){
            ll t=RS(N,P/2,M);
            return t*t%M;
        }else{
            return N*RS(N,P-1,M)%M;
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N,M;
    cin>>N>>M;
    vector<int> A(N);
    int s=0;
    REP(i,N){
        cin>>A[i];
        s+=A[i];
    }
    int cnt=0;
    REP(i,N){
        if(A[i]>=((double)s/(4*M)))cnt++;
    }
    isYes(cnt>=M);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;

int main(void) {
    string s;
    cin >> s;
    if ((s[0] == s[1]) || (s[1] == s[2]) || (s[2] == s[3])) {
        cout << "Bad" << endl;
    } else {
        cout << "Good" << endl;
    }
    return 0;
}



Measured memory_bytes: 3608
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;
import java.util.regex.*;

public class Main {

  
private static final Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
       
        String[] arrItems = scan.nextLine().split(" ");

             int a = Integer.parseInt(arrItems[0].trim());
             int b = Integer.parseInt(arrItems[1].trim());
             int c = Integer.parseInt(arrItems[2].trim());
             int d = Integer.parseInt(arrItems[3].trim());
          
             if((Math.abs(a-c)<=d)||(Math.abs(a-b)<=d && Math.abs(b-c)<=d)){
                      System.out.println("Yes");
                   }
             else{
                         System.out.println("No");
                   }
        

    }
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

ll dp[110][110000];
int main()
{
	int N, W;
	cin >> N >> W;
	vec(w);
	vec(V);
	fx(N) {
		vecp(w);
		vecp2(V);
	}
	fx(N + 1) {
		fy(110000) {
			if (y == 0) {
				dp[x][y] = 0;
			}
			else {
				dp[x][y] = -1;
			}

		}
	}
	fx(N) {
		fy(110000) {
			if (dp[x][y] >= 0) {
				if (dp[x][y] + w[x] <= W) {
					if (dp[x + 1][y + V[x]]>=0) {
						dp[x + 1][y + V[x]] = min(dp[x + 1][y + V[x]], dp[x][y] + w[x]);
					}
					else {
						dp[x + 1][y + V[x]] = dp[x][y] + w[x];
					}
					
				}
				if (dp[x + 1][y]>=0) {
					dp[x + 1][y] = min(dp[x + 1][y], dp[x][y]);
				}
				else {
					dp[x + 1][y] = dp[x][y];
				}
				

			}
		}
	}

	ll ans = 0;
	fx(110000) {
		if (dp[N][x]>=0) {
			ans = x;
		}
	}
	ce(ans)
    return 0;
}



Measured memory_bytes: 88320
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
#define rint register int
using namespace std;
inline int read(){int w=1,s=0;char ch=getchar();while(!isdigit(ch)){if(ch=='-')w=-1;ch=getchar();}while(isdigit(ch)){s=s*10+ch-'0';ch=getchar();}return w*s;}
int n,A[1010],K;
ll Sum[1000010];
vector<int> vec[60];
int vis[1000010];
int main()
{
	n=read();K=read();
	for(rint i=1;i<=n;++i) A[i]=read();int cnt=0;
	for(rint i=1;i<=n;++i){
		ll res=0;
		for(rint j=i;j<=n;++j) res=res+A[j],Sum[++cnt]=res,vis[cnt]=1;
	}ll res=0;
	for(rint i=60;i>=0;--i){
		int tmp=0;
		for(rint j=1;j<=cnt;++j){
			if((1ll<<i)&Sum[j]){
				tmp+=vis[j];
			}
//			else vis[j]=0;
		}
		if(tmp>=K){
			res+=(1ll<<i);
			for(rint j=1;j<=cnt;++j){
				if(!((1ll<<i)&Sum[j]))vis[j]=0;
			}
		}
	}cout<<res;
	return 0;
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;


#include <random>

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

    int D;
    cin>>D;
    int c[26];
    int q[D];
    rep(i,26){
        cin>>c[i];
    }
    int s[D][26];
    rep(i,D){
        rep(j,26){
            cin>>s[i][j];
        }
    }
    int ans=0;
    //map<int,int> m;
    int l[26]{};
    int y=0;
    rep(i,D){

        int an=-INF;
        int x=0;
        rep(k,26){
            int a=ans;
            //map<int,int> ma=m;
            int la[26];
            rep(_,26){
                la[_]=l[_];
            }
            a+=s[i][k];
            rep(j,26){
                if(j==k){
                    //ma[k]=0;
                    la[k]=0;
                }else{
                    //ma[j]++;
                    la[j]++;
                    a-=la[j]*c[j];
                }
            }
            if(an<a){
                x=k;
                an=a;
            }
        }
        y=x;
        ans+=s[i][y];
        rep(j,26){
            if(j==y){
                l[y]=0;
            }else{
                l[j]++;
                ans-=l[j]*c[j];
            }
        }
        y++;
        q[i]=y;
    }

    int tr=0;
    std::random_device rnd; 
    while(tr<=20000){
        int g=rnd()%26;
        int h=rnd()%26;
        tr++;
        int ansm=0;
        int r[D];
        rep(i,D){
            if(i==g){
                if(h!=q[i]){
                    r[i]=h;
                }else{
                    r[i]=rnd()%26;
                }

            }else{
                r[i]=q[i];
            }
        }
        //map<int,int> mx;
        int lx[26]{};
        rep(i,D){
            ansm+=s[i][r[i]];
            rep(j,26){
                if(j==r[i]){
                    lx[r[i]]=0;
                }else{
                    lx[j]++;
                    ansm-=lx[j]*c[j];
                }
            }
        }
        if(ansm>ans){
            rep(i,D){
                q[i]=r[i];
            }
        }
    }
    rep(i,D){
        cout << q[i] << endl;
    }

    



}


Measured memory_bytes: 3736
#include<stdio.h>
int main(){
  int o,summ=0,sumn=0,m,n;
  for(o=0;scanf("%d,%d",&m,&n)!=-1;o++){
    summ+=m*n;
    sumn+=n;
  }
  printf("%d\n%d\n",summ,(int)((float)sumn/o+0.5));
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>

int main(void) {
	int N = 0;
	scanf("%d", &N);
	for(int i = 0; i < 10; i++){
		if(((1000 * i) < N) && (N <= (1000* (i +1)))){
			printf("%d", 1000*(i + 1)-N);
		}
	}
	return 0;
}

Measured memory_bytes: 1700
#include<iostream>
#include<algorithm>

using namespace std;

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

int main(){
	int N;
	int n,d;
	int minX,maxX,minY,maxY;
	
	
	while(cin>>N,N){
		
		int x[210]={0};
		int y[210]={0};
		minX=maxX=minY=maxY=0;
		for(int i=0;i<N-1;i++){
			cin>>n>>d;
			y[i+1]=y[n]+dy[d];
			x[i+1]=x[n]+dx[d];
		}
		for(int i=0;i<N-1;i++){
			minX=min(minX,x[i+1]);
			maxX=max(maxX,x[i+1]);
			minY=min(minY,y[i+1]);
			maxY=max(maxY,y[i+1]);
		}
		cout<<maxX-minX+1<<" "<<maxY-minY+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        long mod=1000000007;
        int n=sc.nextInt();
        int m=sc.nextInt();
        long[] x=new long[n];
        long[] y=new long[m];
        for (int i = 0; i < n; i++) {
            x[i]=sc.nextInt();
        }
        for (int i = 0; i < m; i++) {
            y[i]=sc.nextInt();
        }
        long row=0,column=0;
        for (int i = 0; i < n; i++) {
            column=(column+i*x[i]-(n-i-1)*x[i]+mod)%mod;
        }
        for (int i = 0; i < m; i++) {
            row=(row+i*y[i]-(m-i-1)*y[i]+mod)%mod;
        }
        out.println((row*column)%mod);
        out.close();
    }

    static PrintWriter out = new PrintWriter(System.out);

    static class sc {
        static Scanner s = new Scanner(System.in);

        static String next() {
            return s.next();
        }

        static int nextInt() {
            return Integer.parseInt(s.next());
        }

        static long nextLong() {
            return Long.parseLong(s.next());
        }

        static double nextDouble() {
            return Double.parseDouble(s.next());
        }
    }

}

Measured memory_bytes: 51372
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int INF = 0x7fffffff;
const ll LINF = 0x7fffffffffffffff;
const int maxn = 1e5;
const int modn = 1e9 + 7;

struct node{
    int p,w;
};
vector<node> tree[maxn+10];
int color[maxn+10];

void dfs(int o){
    int tmp=color[o];
    for (auto it=tree[o].begin();it!=tree[o].end();++it){
        if (!color[(*it).p]){
            if (!((*it).w%2)) color[(*it).p]=tmp;
            else color[(*it).p]=3-tmp;
            dfs((*it).p);
        }
    }
}

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

	int n,u,v,w;
	cin>>n;
	for (int i=1;i<n;++i){
        cin>>u>>v>>w;
        tree[u].push_back({v,w});
        tree[v].push_back({u,w});
	}
	color[1]=1;
	dfs(1);
	for (int i=1;i<=n;++i){
        cout<<color[i]%2<<"\n";
	}

	return 0;
}


Measured memory_bytes: 8448
use proconio::{input, fastout};
use proconio::marker::Usize1;
use std::collections::VecDeque;
  
#[fastout]
fn main() {
  input!{n: usize, m: usize};
  // i番目の部屋とつながった部屋
  let mut folded_path: Vec<Vec<usize>> = vec![Vec::new(); n];
  for _ in 0..m {
    input!{a: Usize1, b: Usize1};
    folded_path[a].push(b);
    folded_path[b].push(a);
  }
  // (1からの距離, 指す部屋) -1は記録なし
  let mut ans: Vec<(i64, i64)> = vec![(-1, -1); n];
  ans[0] = (0, -1);
  // BFS。first to secondの通路を見る
  let mut que: VecDeque<(usize, usize)> = VecDeque::new();
  for &room in folded_path[0].iter() {
    que.push_back((0, room));
  }
  while let Some((from, to)) = que.pop_front() {
    if ans[to].0 == -1 || ans[from].0 + 1 < ans[to].0 {
      ans[to] = ((ans[from].0 + 1) as i64, from as i64);
      for &room in folded_path[to].iter() {
        que.push_back((to, room));
      }
    }
  }
  
  if ans.iter().any(|e| e.0 == -1) {
    println!("No");
  } else {
    println!("Yes");
    for a in ans.into_iter().skip(1) {
      println!("{}", a.1 + 1);
    }
  }
}

Measured memory_bytes: 19964
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  cout << "ABC" << n << '\n';
}

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

const int MAXN = 1e6+5;

string s;
int n, m, t[MAXN], ct, cte, d[MAXN];
vector<int> g[MAXN], r[MAXN];
bool vis[MAXN];
vector<int> w;

void dfs(int v) {
	if (vis[v])
		return;
	vis[v] = 1;
	ct++;
	for (int u : g[v]) {
		cte++;
		dfs(u);
	}
}

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

	cin >> n >> m;
	cin >> s;
	for (int i = 0; i < n; ++i) {
		if (s[i] == 'B')
			t[i] = 1;
	}

	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		if (t[a] == t[b]) {
			g[a].push_back(b+n);
			g[b].push_back(a+n);
			r[a+n].push_back(b);
			r[b+n].push_back(a);
		} else {
			if (t[a] == 1)
				swap(a, b);
			g[a+n].push_back(b);
			g[b+n].push_back(a);
			r[b].push_back(a+n);
			r[a].push_back(b+n);
		}
	}

	set<int> s;
	int ct = 2*n;

	for (int i = 0; i < 2*n; ++i) {
		d[i] = g[i].size();
		if (d[i] == 0)
			s.insert(i);
	}

	while (!s.empty()) {
		ct--;
		int v = (*s.begin());
		// cout << v << endl;
		s.erase(v);
		if (vis[v])
			continue;
		vis[v] = 1;
		for (int u : r[v]) {
			d[u]--;
			if (d[u] == 0)
				s.insert(u);
		}
	}

	if (ct == 0)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
}

Measured memory_bytes: 74704
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		
		int a = Integer.parseInt(scan.next());
		int b = Integer.parseInt(scan.next());
		int c = Integer.parseInt(scan.next());
		
		if (a < b && b < c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 26148
#include <iostream>
using namespace std;
int main () {
  int h, w, n;
  cin >> h >> w >> n;
  int t = max(h, w);
  if (n%t == 0) {
    cout << n / t;
    }
  else {
    cout << int(n/t) + 1;
    }
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+10 , OO = 0x3f3f3f3f;

#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define ALL(v) ((v).begin()) , ((v).end())
#define SZ(v)  ((int)((v).size()))
typedef pair <int,int> pii ;
typedef vector < pii > vii ;
typedef vector < int > vi;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);


int n , k;



int main()
{   

      ios_base::sync_with_stdio(0);
      cin.tie(0);cout.tie(0);

      cin >> n >> k;
      double ans = 0;
      range(i , 1 , n){
            int score = i;
            double Pface = 1.0/n;
         //   double prob = 1.0/n;
            while (score < k){
                  score *= 2 ;
                  Pface *= 0.5;
                 // cout << Pface << "\n";
            }
            
            ans += Pface;
      }
      cout << fixed << setprecision(10);
     cout << ans << "\n";



      return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main()
{
  int n, h, w;
  scanf("%d%d%d", &n, &h, &w);
  int ans = 0;
  for (int i = 0; i < n; ++i)
  {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a >= h && b >= w) ++ans;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#N = int(input())
A, B = map(int, input().split())

cnt = 0
for i in range(A, B+1) :
  s = str(i)
  if s[0] == s[4] and s[1] == s[3] :
    cnt += 1

print (cnt)

Measured memory_bytes: 38896
#include<bits/stdc++.h>
    #define ll long long
    #define rep(i,a,b) for(i=a;i<b;i++)
    #define pb push_back
    #define all(v) v.begin(),v.end()
    #define F first
    #define S second
    #define root sqrtl
    #define vi vector < ll  int >
    #define CLR(a) memset((a),0,sizeof(a))
    #define mp make_pair
    #define hell 1000000007
    using namespace std;
    ll mod=hell;
 ll pr( ll x , ll y)
{
    ll ans=1;
    if(y==0) return ans;
    while(y>1)
    {
        if(y&1) ans*=x;
        x*=x;
        y/=2;
        x%=mod;
        ans%=mod;
    }
    ans*=x;
    ans%=mod;
    return ans;
}
ll fact( ll n)
{
    ll ans=1,i;
    rep(i,1,n+1)
    {
        ans*=i;
        ans%=mod;
    }
    return ans;
}
ll in(ll x) { return  pr(x,mod-2);}

bool prime[1000500];
vector < ll > v;
void pre()
{
    int n=1000000,i,j,p;
    memset(prime,true,sizeof(prime));
    prime[0]=prime[1]=false;
    for(i=2;i*i<=n;i++)
    {
        if(prime[i])
        {
            for(p=2*i;p<=n;p+=i) prime[p]=false;
        }
    }
  rep(i,0,1000000) if(prime[i]) v.pb(i);

}

ll inv(ll n)
{
    return pr(n,mod-2);
}


int cnt[26][4001];
void solve( )
{
 ll i,j=1,k,n,m=0,f,s1=0,x=1e13,c=1,y=0,a=0,b=0,d,p;

 cin>>n;
 string s;
 cin>>s;
for(i=n-1;i>=0;i--)
{
    for(j=0;j<26;j++)
    {
        cnt[j][i]=cnt[j][i+1];
    }
    cnt[s[i]-'A'][i]++;
}


for(i=0;i<n-2;i++)
{
    for(j=i+1;j<n-1;j++)
    {
        if(s[i]!=s[j])
        {
            y+=cnt['R'+'B'+'G'-s[i]-s[j]-'A'][j+1];
            d=j-i;
            if(j+d<n and s[j+d]!=s[i] and s[j+d]!=s[j]) y--;
            //cout<<y<<endl;
        }
    }
}
 cout<<y;


}
    signed main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        int t=1;
        //cin>>t;
        while(t--)
        solve();
    }


Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    long long int n, k;
    cin >> n >> k;
    //vector<long long int> mons(n);
    priority_queue<long long int> qmons;
    for (long long int i = 0; i < n; i++){
        int temp;
        cin >> temp;
        qmons.push(temp);
    } 
    //sort(mons.begin(), mons.end(), greater<int>());
    for(long long int i = 0; i < k; i++){
        if (qmons.empty()) break;
        //mons.erase(mons.begin());
        qmons.pop();
    }
    long long int mons_total_hp = 0;
    #if 0
    for (long long int i = 0; i < mons.size(); i++){
        mons_total_hp += mons[i];
    }
    #endif
    while(!qmons.empty()){
        mons_total_hp += qmons.top();
        qmons.pop();
    }
    cout << mons_total_hp << endl;
    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (int i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (int i = x.size()-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define fst first
#define scd second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int n;

int main()
{
    cin>>n;
    cout<<(n+1)/2<<endl;

    return 0;
}


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

using namespace std; 

int main(void) {
	int nov,noe,u,v;
	cin >> nov;
	vector< vector<int> > adj(nov);
	for (int i = 0; i < nov; ++i) {
		cin >> u;
		cin >> noe;
		adj[u-1] = vector<int>(noe);
		for (int j = 0; j < noe; ++j) {
			cin >> adj[u-1][j];
			--adj[u-1][j];
		}
	}
	vector<int> res(nov,-1);
	res[0] = 0;
	queue< pair<int,int> > q;
	q.push({0,0});
	pair<int,int> now;
	while (!q.empty()) {
		now = q.front();
		q.pop();
		for (int i = 0; i < adj[now.first].size(); ++i) {
			if (res[adj[now.first][i]] < 0) {
				res[adj[now.first][i]] = now.second+1;
				q.push({adj[now.first][i],now.second+1});
			}
		}
	}
	for (int i = 0; i < nov; ++i) {
		cout << i+1 << " ";
		cout << res[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 3168
#include <iostream>

using namespace std;

const int mod = 998244353;

const int MAX = 200005;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % mod;
    inv[i] = mod - inv[mod % i] * (mod / i) % mod;
    finv[i] = finv[i - 1] * inv[i] % mod;
  }
}

long long mod_comb(int n, int k, int mod) {
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

long long mod_pow(long long x, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) {
      res = res * x % mod;
    }
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

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

  COMinit();

  int N, M, K;
  cin >> N >> M >> K;

  long long ans = 0;
  for (int k = 0; k <= K; k++) {
    long long add_v = 0;
    add_v = (M * mod_pow(M - 1, N - k - 1, mod)) % mod;
    add_v = (add_v * mod_comb(N - 1, k, mod)) % mod;
    ans = (ans + add_v) % mod;
  }

  if (ans < 0) {
    ans += mod;
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 8300
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int n;
  cin >> n;
  unordered_map<int, int> mp;
  int tmp;
  REP(i,n){
    cin >> tmp;
    mp[tmp] ++;
  }
  int ans = 0;
  for(auto itr = mp.begin();itr != mp.end(); ++itr){
    if(itr->second %2 ==1){
      ans ++;
    }
  }
  cout << ans << endl;
}


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

typedef long long ll;

ll N, L;
vector<ll> T;
typedef complex<double> Complex;
Complex R;

int main() {
  cin >> N >> L;
  T.resize(N);
  for (ll i = 0; i < N; ++i) cin >> T[i];
  for (ll i = 0; i < N; ++i)
    for (ll j = i + 2; j < i + N; ++j) {
      double a = 2 * M_PI * T[i] / L,
             b = 2 * M_PI * (1. * T[j % N] / L + j / N);
      double w = 1. * (j - i - 1) / (N * (N - 1) * (N - 2) / 6);
      R += w * exp(Complex(0, (a + b) / 2 + M_PI));
    }
  cout << setprecision(15) << R.real() << " " << R.imag() << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, i;
    cin >> n >> i;
    cout << n - i + 1 << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;using int32=int_fast32_t;using uint32=uint_fast32_t;using int64=int_fast64_t;using uint64=uint_fast64_t;using pi=pair<int32,int32>;using pll=pair<int64,int64>;using vi=vector<int32>;using vvi=vector<vector<int32>>;using vll=vector<int64>;using ll=int64;using ull=uint64;
#define all(x) x.begin(),x.end()
inline ll read(){ll x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
inline string read_s(){string s="";char c=getchar();while(c<'!'||c>'~'){c=getchar();}while(c>='!'&&c<='~'){s+=c;c=getchar();}return s;}
void Main(){
    int X=read(), Y=read(), Z=read(), K=read();
    vll A(X), B(Y), C(Z);
    for(auto &a:A) a=read();
    for(auto &b:B) b=read();
    for(auto &c:C) c=read();
    vll AB(X*Y), ABC(K*Z);
    int i=0;
    for(auto a:A)for(auto b:B)AB[i++]=a+b;
    sort(all(AB), greater<ll>());
    i=0;
    int min_K_XY= min(K, X*Y);
    for(int j=0;j<min_K_XY;j++)for(auto c:C)ABC[i++]=AB[j]+c;
    sort(all(ABC), greater<ll>());
    for(int j=0;j<K;j++)printf("%lld\n", ABC[j]);
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}


Measured memory_bytes: 31616
#include <iostream>

using namespace std;
typedef long long ll;
ll x, y, c;
 
int main() {
   cin >> x >> y;
  if (y < x) {
    cout << 0 << endl;
    return 0;
  }
  c = 0;
  while (y >= x) {
    x *= 2;
    c++;
  }
 cout << c << endl;
}

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

using namespace std;

typedef long long ll;

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define INF 1000000000

int main() {

	int n, ans = 0;
	cin >> n;
	vector<int> a(n + 2), x(n + 1), y(n + 1);
	a[0] = 0;
	a[n + 1] = 0;
	eFOR1(i, n)cin >> a[i];

	ans += abs(a[1]);
	eFOR1(i, n) {
		int s = abs(a[i] - a[i + 1]);
		ans += s;
		x[i] = abs(a[i - 1] - a[i]) + s;
		y[i] = abs(a[i - 1] - a[i + 1]);
	}

	eFOR1(i, n) {
		cout << ans - x[i] + y[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#include <cstring> 
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define For2(i, st, en) for(ll i=st; i<en; i+=2)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define int long long int
#define F first
#define mem(a,b) memset(a,b,sizeof(a))
#define S second
typedef pair<int, int> pii;
#define MOD 1000000007
#define INF 1000000000000000007
#define MAXN 200008

int pass[MAXN];
int fail[MAXN];

signed main(){
 
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    #ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
 
    int n, m, ans=0, cnt=0, i;
    cin>>n>>m;
    memset(pass, 0, sizeof(pass));
    memset(pass, 0, sizeof(fail));
    for(i=0;i<m;i++){
    	int a;
    	string b;
    	cin>>a>>b;
    	if(b=="WA"&&pass[a]==0){
    		fail[a]++;
    	}
    	else if(b=="AC"&&pass[a]==0){
    		pass[a]=1;
    		cnt+=fail[a];
    		ans++;
    	}
    }
    cout<<ans<<" "<<cnt<<endl;
}

Measured memory_bytes: 2560
#include <iostream>

typedef long long ll;

#define FOR(i,a,b) for(ll i = (a);i < (b);++i)
#define REP(i,n) FOR(i,0,n)

#define debug(x) cout << #x << "=" << x << endl;

using namespace std;

#define MAX_H 50
#define MAX_W 50

char a[MAX_H+2][MAX_W+2];
int  ans[MAX_H+2][MAX_W+2];

int main(void){

  int H,W;
  int dx[8] = {-1,-1,-1, 0, 0, 1, 1, 1};
  int dy[8] = {-1, 0, 1,-1, 1,-1, 0, 1};
  cin >> H >> W;

  fill(a[0],a[MAX_H+2],'.');

  FOR(i,1,H+1){
    FOR(k,1,W+1){
      cin >> a[i][k];
    }
  }
  int bombCnt;
  FOR(i,1,H+1){
    FOR(k,1,W+1){
      if(a[i][k] == '.'){
        bombCnt = 0;
        REP(t,8){
          if(a[i+dx[t]][k+dy[t]] == '#'){
            bombCnt++;
          }
        }
      }
      ans[i][k] = bombCnt;
      bombCnt = 0;
      if(ans[i][k] == 0 && a[i][k] == '#'){
        cout << '#';
      }else{
        cout << ans[i][k];
      }
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main() {
    ll n;
    cin >> n;
    VL a(n), b(n);
    vector<ll> ma(n, 0);
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n) cin >> b[i];
    rep(i, 0, n){
        ma[a[i]]++;
    }
    VP cp(n);
    rep(i, 0, n) {
        cp[i].first = a[i];
        cp[i].second = i;
    }
    sort(a.begin(), a.end(), [&](ll l, ll r){
        if(ma[l] > ma[r]) return true;
        else if(ma[l] == ma[r] && l < r) return true;
        else return false;
    });
    sort(cp.begin(), cp.end(), [&](PL lp, PL rp){
        ll l = lp.first;
        ll r = rp.first;
        if(ma[l] > ma[r]) return true;
        else if(ma[l] == ma[r] && l < r) return true;
        else return false;
    });
    sort(b.begin(), b.end(), [&](ll l, ll r){
        if(ma[l] > ma[r]) return true;
        else if(ma[l] == ma[r] &&  l < r) return true;
        else return false;
    });
    
    //rep(i, 0, n) cerr << cp[i].first << (i == n-1 ? "\n" : " ");
    //rep(i, 0, n) cerr << a[i] << (i == n-1 ? "\n" : " ");
    //cerr << "a" << endl;

    VL ans(n);

    ll srt = -1;
    rep(i, 0, n) {
        if(a[0] != b[i]) {
            srt = i;
            break;
        }
    }
    if(srt == -1) {
        cout << "No" << endl;
        return 0;
    }
    rep(i, 0, n) ans[i] =  b[(i + srt) % n];
    rep(i, 0, n) {
        if(a[i] == ans[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    //rep(i, 0, n) cerr << ans[i] << (i == n-1 ? "\n" : " ");
    VL true_ans(n);
    rep(i, 0, n) true_ans[cp[i].second] = ans[i];
    rep(i, 0, n) cout << true_ans[i] << (i == n-1 ? "\n" : " ");
    return 0;
}


Measured memory_bytes: 14336
#include <iostream>
#include <vector>
#include <cmath>
#include <set>
#include <utility>
#include <map>
#define rep(i, n) for (int i = 0; i < n; i++)

using namespace std;

typedef long long ll;
typedef pair<ll,ll> llP;

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

ll mod_pow(ll a, ll x, ll mod) {
    if (x == 0)
        return 1;
    else if (x % 2)
        return a * mod_pow(a, x-1, mod) % mod;
    else {
        ll tmp = mod_pow(a, x/2, mod);
        return tmp * tmp % mod;
    }
}


int main() {
    int n;  cin >> n;
    map<llP, llP> mp;   //(a, b) (a >= 0, b >= 0)となるようなものの個数と(b, -a)となるものの個数を管理
    ll zero = 0, ans = 1, mod = 1e9+7;
    rep (i, n) {
        ll a, b;    cin >> a >> b;
        if (a == 0 && b == 0) {
            zero++;
            continue;
        }

        ll g = gcd(abs(a), abs(b));
        a /= g, b /= g;
        if (a < 0)
            a *= -1, b*= -1;
        if (a == 0 && b < 0)
            b *= -1;
        if (a >= 0 && b > 0)
            mp[llP(a, b)].first++;
        else 
            mp[llP(-b, a)].second++;
    }

    for (auto m: mp) {
        ll tmp = ((mod_pow(2, m.second.first, mod) - 1 + mod) % mod + (mod_pow(2, m.second.second, mod) - 1 + mod) % mod + 1) % mod;
        ans = ans * tmp % mod;
    }

    ans = (ans - 1 + zero + mod) % mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 19044
#include <iostream>
#include <cmath>
//#include <string>
using namespace std;
int main(){

    int n,m,l;
    cin>>n>>m>>l;
    int A[n][m];
    int B[m][l];
    long C[n][l];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>A[i][j];
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<l;j++){
            cin>>B[i][j];
        }
    }
    
    for(int i=0;i<l;i++){
        
        for(int j=0;j<n;j++){
            long ans=0;
            for(int u=0;u<m;u++){
                ans+=A[j][u]*B[u][i];
            }
            C[j][i]=ans;
        }
        
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
           if(j!=l-1) cout<<C[i][j]<<' ';
           else cout<<C[i][j]<<endl;
        }
    }
    
    
    return 0;
}



Measured memory_bytes: 3260
#!/usr/bin/env python3
import sys

def r(i,j):
    return ((x[i]-x[j])**2 + (y[i]-y[j])**2)**0.5

def rsum_nC2(N):
    ret=0
    for i in range(N):
        for j in range(N):
            if i==j:
                continue
            ret+=r(i,j)
    return ret/N/(N-1)

def solve(N: int, x: "List[int]", y: "List[int]"):
    print(rsum_nC2(N)*(N-1))

    return

x = [int()] * (8)  # type: "List[int]"
y = [int()] * (8)  # type: "List[int]"
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    solve(N, x, y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<double> v(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	double ans = v[0];
	for (int i = 0; i < N; i++) {
		ans = (ans + v[i]) / 2;
	}
	cout << setprecision(10) <<  ans << endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    h = list(map(int, input().split()))
    dp = [0] * n

    def cost(i,j):
        return abs(h[i]-h[j])

    dp[1] = cost(0,1)
    for i in range(2,n):
        dp[i] = min(dp[i-2] + cost(i-2,i), dp[i-1] + cost(i-1,i))
    print(dp[n-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 52208
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  ll k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll num[62][2] = {};
  rep(i, n) rep(j, 62)
    num[j][a[i]>>61-j&1]++;
  ll dp[63][2];
  memset(dp, -1, sizeof(dp));
  dp[0][0] = 0;
  rep(i, 62) {
    rep (j, 2) {
      if (dp[i][j] < 0)
        continue;
      int t = k>>61-i&1;
      rep (l, j?2:t+1)
        chmax(dp[i+1][j||l<t], dp[i][j]+(num[i][l^1]<<61-i));
    }
  }
  cout << max(dp[62][0], dp[62][1]) << endl;
  return 0;
}

Measured memory_bytes: 1024