akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>                                                  
#include<iostream>                                                 
using namespace std;                                               
int main()                                                         
{                                                                  
        int a;                                                     
        cin>>a;                                                    
        cout<<a+a*a+a*a*a;                                         
        return(0);                                                 
} 

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

int main(){
    int n;
    cin >> n;
    int sum = 0;

    int A[n], B[n];
    for(int i = 0; i < n; i++){
        cin >> A[i];
        if(i == 0){
            B[i] = abs(A[i]);
        }
        else{
            B[i] = abs(A[i] - A[i - 1]);
        }
        sum += B[i];
    }
    sum += abs(A[n - 1]);
    int sum2;
    for(int i = 0; i < n; i++){
        sum2 = sum;
        if(i == 0){
            sum2 = sum2 - B[i] - B[i + 1] + abs(A[i + 1]);
        }
        else if(i == n - 1){
            sum2 = sum2 - B[i] - abs(A[n - 1]) + abs(A[i - 1]);
        }
        else{
            sum2 = sum2 - B[i] - B[i + 1] + abs(A[i + 1] - A[i - 1]);
        }

        cout << sum2 << endl;
    }
    return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



void _main() {
        int n, r; cin >> n >> r;
        cout << (n + 2 * r) / (2 * r + 1);
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

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

#define x first
#define y second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pr pair<int,int>
#define SZ(S) int(S.size())
#define REP(i,a,b) for(int i=a;i<b;++i)
#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define FORD(i,b,a) for(int i=b;i>=a;--i)
#define CLR(A,x) memset(A,x,sizeof(A))
#define ALL(S) S.begin(),S.end()

#define OUT(a,l,r) cout<<#a": ";FOR(i,l,r)cout<<a[i]<<" ";cout<<endl
#define PRT(a) cout<<"--> "#a" "<<a<<endl

using namespace std;
typedef long long ll;

const int N=1005,INF=0x3f3f3f3f;
const ll P=1e9+7;

template<typename T>
inline void read(T& x,int f=1,char s=getchar()) {
	for(x=0;s>'9'||s<'0';s=getchar()) if(s=='-') f=-1; 
	while(s<='9'&&s>='0') x=x*10+s-'0',s=getchar();x*=f;
}

int idx(char c) {return c-'a';}

char s[N][N];
int v[N];
int a,b,c;

int main() {
	int n,m;
	cin>>n>>m;
	FOR(i,1,n) {
		scanf("%s",s[i]+1);
	}
	FOR(i,1,n) FOR(j,1,m) {
//		cout<<s[i][j]<<" ";
		v[idx(s[i][j])]++;
	}
//	cout<<endl;
//	REP(i,0,26) cout<<v[i]<<" ";cout<<endl;
	int x=n&1,y=m&1;
	if(x+y==2) {
		a=(n-1)*(m-1)/4;
		b=(n-1)/2+(m-1)/2;
		c=1;
	}
	if(x+y==1) {
		if(y) swap(n,m);
		a=m*(n-1)/4;
		b=m/2;
		c=0;
	}
	if(x+y==0) {
		a=n*m/4;
		b=c=0;
	}
//	cout<<a<<" "<<b<<" "<<c<<endl;
	REP(i,0,26) {
		while(a&&v[i]>=4) a--,v[i]-=4;
	}
	REP(i,0,26) {
		while(b&&v[i]>=2) b--,v[i]-=2;
	}
	REP(i,0,26) {
		while(c&&v[i]>=1) c--,v[i]-=1;
	}
	if(a||b||c) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 384
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cctype>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#include <numeric>
#define  rep(i,n) for(int i=0;i<(n);i++)
#define  REP(i,a,n) for(int i=a;i<(n);i++)
#define  rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define  VI	vector<int>
#define	 VS vector<string>
#define  all(a) (a).begin(),(a).end()
#define  debug(x) cout<<#x<<": "<<x<<endl

using namespace std;
typedef long long int ll;
typedef string::const_iterator State;
typedef pair<int,int> P;
class ParseError {};
const ll INF=1LL<<50;
char fi[101][101];
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
double EPS = 1e-14;
const int MAX_V=100;
const int MAX_N=100;
char o[3]={'+','-','*'};
#define md 1000003



int bow[353][353]={0};
double add(double a,double b){
	if(abs(a+b)<EPS*(abs(a)+abs(b)))
	return 0;
	return a+b;
}

/*struct P{
	double x,y;
	P(){}
		P(double x,double y):x(x),y(y){
		}
		P operator + (P p){
			return P(add(x,p.x),add(y,p.y));
		}
		P operator - (P p){
			return P(add(x,-p.x),add(y,-p.y));
		}
		P operator *(double d){
			return P(x*d,y*d);
		}
		double dot(P p){
			return add(x*p.x,y*p.y);
		}
		double det(P p){
			return add(x*p.y,-y*p.x);
		}
};

bool cmp_x(const P& p,const P& q){
	if(p.x!=q.x) return p.x<q.x;
	return p.y<q.y;
}

vector<P> convex_hull(P* ps, int n){
	sort(ps,ps+n,cmp_x);
	int k=0;
	vector<P> 	qs(n*2);
	
	rep(i,n){
		while(k>1&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0)
			k--;
		qs[k++]=ps[i];
	}
	for(int i=n-2,t=k;i>=0;i--){
		while(k>t&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0)
		k--;
		qs[k++]=ps[i];
	}
	qs.resize(k-1);
	return qs;
}

int n,m;
vector<double> p;
P ps[101];
*/
//char c[520][520];
long long mod=1000000007;
long long pow(ll i,ll j){
	ll tmp=1;
	while(j){
		if(j%2) tmp=tmp*i%mod;
		i=i*i%mod;
		j/=2;
	}
	return tmp;
}

int expression(State&);
int term(State&);
int factor(State&);
int number(State&);
int expression(State &begin){
	int ret = term(begin);
	
	for(;;){
		if(*begin == '+'){
			begin++;
			ret += term(begin);
		}
		else if(*begin == '-'){
			begin++;
			ret -= term(begin);
		}
		else
			break;
	}
	return ret;
}

int term(State &begin){
	int ret = factor(begin);
	
	for(;;){
		if(*begin=='*'){
			begin++;
			ret *= factor(begin);
		}
		else if(*begin=='/'){
			begin++;
			ret /= factor(begin);
		}
		else
			break;
	}
	return ret;
}

int factor(State &begin){
	int ret;
	if(*begin == '('){
		begin++;
		ret = expression(begin);
		begin++;
	}
	else
	ret = number(begin);
	
	return ret;

}

int number(State &begin){
	int ret =0;
	
	while(isdigit(*begin)){
		ret*=10;
		ret+=*begin - '0';
		begin++;
	}
	return ret;
}



int main(void){
	
	int x,y;
	
	cin>>x>>y;
	
	int d[13];
	
	for(int i=1;i<=12;i++){
		if(i==2)
			d[i]=3;
		else if(i==4||i==6||i==9||i==11)
			d[i]=2;
		else
			d[i]=1;
	}
	
	if(d[x]==d[y])
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
		
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N, K;
    cin >> N >> K;
    if(N<2*K-1){
    	cout << -1 << endl;
    }else{
    	ll a, b, c;
    	if(N%2==1){
    		REP(i, (N+1)/2){
    			a = K + (N+1)/2 - 1 - i;
    			b = K + 2*N  - 1 - i;
    			c = K + 3*N - 1 - 2*i;
    			cout << a << " " << b << " " << c << endl;
    		}
    		REP(i, (N-1)/2){
    			a = K + N - 1 - i;
    			b = K + N + (N-1)/2 - 1 - i;
    			c = K + 3*N - 2 - 2*i;
    			cout << a << " " << b << " " << c << endl;
    		}
    	}else{
    		REP(i, N/2){
    			a = K + N/2 - 1 - i;
    			b = K + 2*N - 1 - i;
    			c = K + 3*N - 1 - 2*i;
    			cout << a << " " << b << " " << c << endl;
    		}
    		REP(i, N/2){
    			a = K + N - 1 - i;
    			b = K + N + N/2 - 1 - i;
    			c = K + 3*N - 2 - 2*i;
    			cout << a << " " << b << " " << c << endl;
    		}
    	}
    }
    return 0;
}

Measured memory_bytes: 2304
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0

using namespace std;
using ll = long long;

void testcase() {
    int n, m;
    cin >> n >> m;

    string res = "";
    rep (i, 0, n-1) res += "-";

    while (m--) {
    	int s, c;
    	cin >> s >> c;
    	s--;

    	char ch = (c+48);
    	if (res[s]=='-' || res[s]==ch) {
    		res[s] = ch;
    	} else {
    		cout << "-1\n";
    		return;
    	}
    }

    rep (i, 0, n-1)
    	if (res[i]=='-')
    		res[i] = ((i==0 && n>1)? '1' : '0');


    if (n > 1 && res[0]=='0') {
    	cout << "-1\n";
    	return;
    }
    cout << res << endl;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>

using namespace std;

void Diverta2019_A()
{
	int N, K;
	cin >> N >> K;
	cout << N - K + 1 << endl;
}

int main()
{
	Diverta2019_A();
	return 0;
}

Measured memory_bytes: 256
main(){long double a,b,x;scanf("%Lf%Lf%Lf",&a,&b,&x);printf("%.10Lf",x<=a*a*b/2?atanl(a*b*b/(2*x))*57.29577951:atanl(2*(a*a*b-x)/(a*a*a))*57.29577951);}

Measured memory_bytes: 2216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Maxn 4000007
const int INF = 1e9 + 5;
const int  N = 2e5 + 314;
void foo(){
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])cout<<"Yes\n";
    else cout<<"No\n";   
}
int main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)foo();
}

Measured memory_bytes: 256
<?php
$date = [
    "SUN" => 7,
    'MON' => 6,
    'TUE' => 5,
    'WED' => 4,
    'THU' => 3,
    'FRI' => 2,
    'SAT' => 1,
];
$S = trim(fgets(STDIN));
echo($date[$S]);
?>

Measured memory_bytes: 4604
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

typedef long long ll;

int main() {
  int n, m;
  cin >> n >> m;
  // priority_queue<int, vector<int>, greater<int>> pq;
  priority_queue<int> pq;
  vector<int> la(n);
  for (int i = 0; i < n; ++i) {
    cin >> la[i];
    pq.push(la[i]);
  }
  for (int i = 0; i < m; ++i) { 
    int p = pq.top(); pq.pop();
    pq.push(p/2);
  }
  ll ans = 0;
  for (int i = 0; i < n; ++i) { 
    int p = pq.top(); pq.pop();
    // cout << p << endl;
    ans += p;
  }
  cout << ans << endl;
}



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

int main(){
  int N, C=0;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0; i < N; ++i){
    cin >> vec.at(i);
  }
  
  for(int i = 0; i < N ; ++i){
    if(vec.at(i) != i+1){
      ++C;
    }
    if(C >= 3){break;}
  }
  
  if(C <= 2){
    cout << " YES " << endl;
  }else{
    cout << " NO " << endl;
  }
}

Measured memory_bytes: 256
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val N, L = sc.nextInt

    val apples = (L until L + N).toArray
    val result = if (L > 0) {
      apples.tail.sum
    } else if (L <= 0 && 0 < L + N - 1) {
      apples.sum
    } else {
      apples.dropRight(1).sum
    }

    println(result)
  }
}

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

void swap(int *a, int *b)
{
    int  tmp;

    tmp = *a;
    *a = *b;
    *b = tmp;
}

int main (void) {
    int a[3];

    scanf("%d %d %d", &a[0], &a[1], &a[2]);

    if (a[0] > a[1]) swap(&a[0], &a[1]);
    if (a[0] > a[2]) swap(&a[0], &a[2]);
    if (a[1] > a[2]) swap(&a[1], &a[2]);

    printf("%d\n", abs(a[2] - a[1]) + abs(a[1] - a[0]));

    return 0;
}

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

const int P = 1e9 + 7;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	vector<int> a(n);
	for (int &x : a) {
		cin >> x;
	}
	vector<int> prefix_sums(n + 1);
	vector<int> zero_cnt(n + 1);
	for (int i = 0; i < n; i++) {
		prefix_sums[i + 1] = prefix_sums[i] ^ a[i];
		zero_cnt[i + 1] = zero_cnt[i] + (prefix_sums[i + 1] == 0);
	}
	vector<int> cnt(1 << 20);
	vector<int> sum(1 << 20);
	vector<int> ans(n + 1);
	for (int i = 1; i <= n; i++) {
		if (prefix_sums[i]) {
			int x = prefix_sums[i];
			int &cur = ans[i];
			cur = (cnt[x] * 1LL * zero_cnt[i] + P - sum[x] + 1) % P;
			cnt[x] = (cnt[x] + cur) % P;
			sum[x] = (sum[x] + cur * 1LL * zero_cnt[i]) % P;
		}
	}
	if (prefix_sums[n]) {
		cout << ans[n] << endl;
		return 0;
	}
	int m = count(prefix_sums.begin(), prefix_sums.end(), 0);
	int cur = 1;
	for (int i = 0; i < m - 2; i++) {
		cur = 2 * cur % P;
	}
	int ret = cur;
	for (int i = 1; i < 1 << 20; i++) {
		ret = (ret + cnt[i]) % P;
	}
	cout << ret << endl;
	return 0;
}

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

#define DB	double
#define lf	else if
#define	I64	long long
#define Rd()	(rand() << 15 | rand())
#define For(i,a,b)	for(int i=a;i<=b;i++)
#define Rep(i,a,b)	for(int i=a;i>=b;i--)
	
#define fi	first
#define se	second
#define MK	make_pair
#define PA	pair<int, int>

#define CH	(ch=getchar())
int		IN()	{
		int x= 0, f= 0, ch;
		for (; CH < '0' || ch > '9';)	f= (ch == '-');
		for (; ch >= '0' && ch <= '9'; CH)	(x*= 10)+= ch - '0';
		return	f ? -x : x;
}

#define n	55

int		N, M, A[n];

PA		G[n << 1];

void	Add(int p, int i)	{
		A[i]+= A[p];
		G[++ M]= (MK)(p, i);
}

int		main()	{
		N= IN();
		For(i, 1, N)	A[i]= IN();
		
		int p= 1;
		For(i, 2, N)	if	(abs(A[i]) > abs(A[p]))	p= i;
		For(i, 1, N)	if	(i != p)	Add(p, i);
		
		int flag= 1;
		For(i, 1, N)	if	(A[i] < 0)	flag= 0;
		
		if	(flag)	{
			For(i, 2, N)	Add(i-1, i);
		}
		else	{
			Rep(i, N, 2)	Add(i, i-1);
		}
		
		printf("%d\n", M);
		For(i, 1, M)	printf("%d %d\n", G[i].fi, G[i].se);
		
		return	0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include<vector>

using namespace std;
typedef long long ll;
//#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i =0;i<n;++i)
//#define mod (ll)(1e9+7)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll K;
    string S;
    cin >> S;
    cin >> K;
    ll t = S.length();
    for(ll i = 0;i<S.length();i++){
        if(S[i]!='1'){
            t = i+1;
            break;
        }
        
    }
    if(t>K){
        cout << '1' << endl;
    }else{
        cout << S[t-1] << endl;
    }
    return 0;
}

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

int main()
{
    int n;

    string s;

    cin >> s;

    n = s.size();

    int cnt = 0, one = 0, zero = 0, mn;

    for(int i = 0; i < n; i++){
        if(s[i] == '1') one++;
        else zero++;

        mn = min(one, zero);

        cnt += mn;
        one -= mn;
        zero -= mn;
    }

    cout << cnt*2 << "\n";

    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(int argc, char *argv[])
{
	int n, i, max = 0, a[10] = {0}, k = 0, sum = 0;
	scanf("%d", &n);
	for ( i = 0; i < n; i++ ) {
		scanf("%d", &a[i]);
		if ( max < a[i]) {
			max = a[i];
			k = i;
		}
	}
	i = 0;
	while ( i < n ) {
		if ( i != k )
		sum += a[i++];
		else sum += a[i++] / 2;
	}
	
	printf("%d", sum);
	
	return 0;
}

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

#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for(ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for(ll i = a; i >= (ll)(b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

#define INF 1000000000000
#define MOD 10000007 
#define MAXR 100000 

signed main() {
    ll N, K; cin >> N >> K;
    ll A[N + 1];
    ll V[N];
    FOR(i, 1, N) {
        cin >> A[i];
        V[i] = INF;
    }

    ll i = 1;
    ll t = 0;
    ll s[N];
    ll r = 0;
    while(true) {
        if (V[i] != INF) {
            r = t - V[i];
            t = V[i];
            break;
        }
        V[i] = t;
        s[t] = i;
        i = A[i];
        t++;
    }
    if (K > t) {
        ll tgt = (K - t) % r + t;
        cout << s[tgt] << endl;
    } else {
        cout << s[K] << endl;
    }

}

Measured memory_bytes: 8216
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1<<29;
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
const int MAX_N = 210;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, r; cin >> n >> m >> r;
    vector<int> v(r);
    for(int i = 0; i < r; i++) { cin >> v[i]; v[i]--; }
    sort(v.begin(), v.end());
    int dist[MAX_N][MAX_N];
    for(int i = 0; i < MAX_N; i++)
    {
        for(int j = 0; j < MAX_N; j++) dist[i][j] = INF;
        dist[i][i] = 0;
    }
    for(int i = 0; i < m; i++)
    {
        int a, b, c; cin >> a >> b >> c;
        a--, b--;
        dist[a][b] = c;
        dist[b][a] = c;
    }
    for(int k = 0; k < n; k++)
        for(int i = 0; i < n; i++)
            for(int j = 0; j < n; j++)
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    int ans = INF;
    do
    {
        int total = 0;
        for(int i = 1; i < r; i++) total += dist[v[i]][v[i - 1]];
        ans = min(ans, total);
    }
    while(next_permutation(v.begin(), v.end()));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>

#define rep(i,n) for(int i=0; i<(n); ++i)
#define pai 3.1415926535897932384

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

#define MAX_N 8

int perm[MAX_N];
vector<P> pos;


void permutation(int n){
    for(int i=0; i<n; i++){
        perm[i]=i;
    }
    
    double ans=0;
    double count=0;
    do{
        /* ここにpermの処理を書く */
        for(int i=0; i+1<n; i++){
            int x1 = pos[perm[i]].first;
            int y1 = pos[perm[i]].second;
            int x2 = pos[perm[i+1]].first;
            int y2 = pos[perm[i+1]].second;
            
            ans += (double)sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
        }
        count++;
        
    }while(next_permutation(perm, perm+n));
    
    cout << setprecision(7) << ans/count << endl;
}

int main(int argc, const char * argv[]) {
    int N;
    cin >> N;
    
    rep(i, N){
        P p;
        cin >> p.first >> p.second;
        pos.push_back(p);
    }
    
    permutation(N);
    
    return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, e = map(int, readline().split())

for x in range(n + 1):
    for y in range(n + 1 - x):
        if 10000 * x + 5000 * y + 1000 * (n - x - y) == e:
            print(x, y, n - x - y)
            exit()
print("-1 -1 -1")

Measured memory_bytes: 3060
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cmath>
#include<cstdint>
//#include<>
using namespace std;

typedef int64_t i64;typedef int32_t i32;
typedef int16_t i16;typedef int8_t i8;
typedef uint64_t ui64;typedef uint32_t ui32;
typedef uint16_t ui16;typedef uint8_t ui8;

typedef i32 int__;
#define rep(i,j) for(int__ i=0;i<j;i++)
#define repeat(i,j,k) for(int__ i=(j);i<(k);i++)
#define repeat_eq(i,j,k) for(int__ i=(j);i<=(k);i++)
#define all(v) begin(v),end(v)

const i32 INF=1<<30;//=10E10

class Path{

  public:
  struct Edge{i32 to,cost;Edge(i32 to_,i32 cost_):to(to_),cost(cost_){;}};


  vector< vector<Edge> > G;//接続リスト
  i32 V_num;
  i32 E_num;
  
  Path(i32 n){G.resize(n);V_num=n;E_num=0;}

  void add_arc(i32 x,i32 y,i32 c)
  {
    G[x].push_back(Edge(y,c));
    E_num+=1;
  }

  vector<i32> BellmanFord(i32 start){
    vector<i32> dist(V_num,INF);
    dist[start]=0;
    
    rep(cnt,V_num-1){
      bool update=false;
      rep(i,G.size()){
	rep(j,G[i].size()){
	  if(dist[i]!=INF && dist[G[i][j].to]>dist[i]+G[i][j].cost){
	    dist[G[i][j].to]=dist[i]+G[i][j].cost;
	    update=true;
	    if(cnt==V_num-2)return vector<i32>(0);
	  }
	}
      }
      if(!update)break;
    }
    return dist;
  }
};



int main()
{
  i32 v,e,r;cin>>v>>e>>r;
  Path Graph(v);
  rep(i,e){
    i32 s,t,d;cin>>s>>t>>d;
    Graph.add_arc(s,t,d);
  }
  vector<i32> dist=Graph.BellmanFord(r);
  if(dist.size()==0)cout<<"NEGATIVE CYCLE"<<endl;
  else{
    for(auto d : dist){
      if(d==INF)cout<<"INF"<<endl;
      else cout<<d<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1264
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
	char c[51];
	cin>>c;
	int n=strlen(c);
	int p=n;
	for(int i=0;i<n;i++){
		if(p<=8){
			break;
		}
		cout<<c[i];
		p--;
	}
	cout<<"\n";
	return 0;
}

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

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> p(n),q(n);
    rep(i,n) cin>>p[i];
    rep(i,n) q[i]=i+1;
    int cnt=0;
    rep(i,n){
      if(p[i]!=q[i]) cnt++;
    }
    if(cnt<=2) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    int n, ans = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        while (a % 2 == 0) {
            ans++;
            a /= 2;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
     string a,b,c;
     cin>>a>>b>>c;
     if(a[a.length()-1]==b[0] && b[b.length()-1]==c[0])
        {
            cout<<"YES"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }

}


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

int main() {
  char c;
  cin >> c;
  if (c=='a'||c=='e'||c=='u'||c=='i'||c=='o'){
   cout << "vowel" << endl; 
  }else{
   cout << "consonant" << endl;
  }
}

Measured memory_bytes: 3556
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

void destroy ( vector<string>& field, int i, int j, int symbol ) {
  if( field[ i ][ j ] == symbol ) {
    int symbol = field[ i ][ j ];
    field[ i ][ j ] = '-';
    destroy( field, i - 1, j,     symbol );
    destroy( field, i + 1, j,     symbol );
    destroy( field, i    , j - 1, symbol );
    destroy( field, i    , j + 1, symbol );
  }
}

int search ( vector<string>& field, int i, int j ) {
  static int counter = 0;
  if( i == 1 && j == 1 ) { counter = 0; }
  if( field[ i ][ j ] == '-' ) { return counter; }
  counter++;
  int symbol = field[ i ][ j ];
  field[ i ][ j ] = '-';
  destroy( field, i - 1, j,     symbol );
  destroy( field, i + 1, j,     symbol );
  destroy( field, i    , j - 1, symbol );
  destroy( field, i    , j + 1, symbol );
  return counter;
}


int main() {
  while( 1 ) {
    int h, w;
    cin >> h >> w;
    if( !( h | w ) ) { return EXIT_SUCCESS; }
    vector<string> field( h + 2 );
    
    field[ 0 ] = "";
    field[ h + 1 ] = "";
    for( int j = 0; j <= w + 1; j++ ) {
      field[ 0 ] += "-";
      field[ h + 1 ] += "-";
    }
    for( int i = 1; i <= h ; i++ ) {
      cin >> field[ i ];
      field[ i ] = "-" + field[ i ] + "-";
    }
    
    int n;
    for( int i = 1; i <= h; i++ ) {
      for( int j = 1; j <= w; j++ ) {
        n = search( field, i, j );
      }
    }
    
    cout << n << endl;
  }
}

Measured memory_bytes: 2012
N = int(input())
A = [0] * N
ts = [None] * N

for i in range(N):
    A[i] = int(input())
    t = [None] * A[i]
    for j in range(A[i]):
        t[j] = list(map(int, input().split()))
    ts[i] = t

ans = 0

for bit in range(1 << N):
    for i in range(N):
        if ((bit >> i) & 1) == 0:
            continue
        for j in range(A[i]):
            x, y = ts[i][j]
            x -= 1
            if ((bit >> x) & 1) != y:
                break
        else:
            continue
        break
    else:
        count = bin(bit).count("1")
        ans = max(count, ans)

print(ans)


Measured memory_bytes: 3064
/*氏名：保坂優介, 学籍番号：200441141
  概要：ベクトルと行列の積*/

#include<stdio.h>

int main(void)
{
    int i, j, k, m, n, b[101] = { 0 }, A[101][101] = { 0 }, c[101] = { 0 };     //変数の宣言

    scanf("%d %d", &n, &m);     //入力

    for (i = 0; i < n; i++)     //n回繰り返す
    {
        for (j = 0; j < m; j++)     //m回繰り返す
        {
            scanf("%d", &A[i][j]);     //入力
        }
    }

    for (i = 0; i < m; i++)     //m回繰り返す
    {
        scanf("%d", &b[i]);     //入力
    }

    for (i = 0; i < n; i++)     //m回繰り返す
    {
        for (j = 0; j < m; j++)     //m回繰り返す
        {
            c[i] = c[i] + b[j] * A[i][j];
        }
    }

    for (i = 0; i < n; i++)     //n回繰り返す
    {
        printf("%d\n", c[i]);     //表示
    }

    return 0;
}


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

int main() {
  int n, cards[52] = {};
  cin >> n;
  string suits = "SHCD";

  for (int i = 0; i < n; i++) {
    char suit;
    int num;
    cin >> suit >> num;
    int row = suits.find(suit);
    int index = row * 13 + (num - 1);
    cards[index] = num;
  }

  for (int i = 0; i < 52; i++) {
    int num = cards[i];
    if (num != 0) continue;

    int row = i / 13;
    int lessNum = i - 13 * row + 1;
    cout << suits[row] << ' ' << lessNum << endl;
  }

  return 0;
}



Measured memory_bytes: 3064
(n, k) = tuple(map(int, input().split(" ")))

sa = [0 for i in range(n)]
for i in range(k):
    input()
    for a in map(int, input().split(" ")):
        sa[a - 1] += 1
c = 0
for i in range(n):
    if sa[i] == 0:
        c += 1
print(c)

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

int main() {
  int H,W;
  cin >> H >> W;
  string s[H];
  int score[H+2][W+2];
  for(int i=0;i<H+2;i++){
    for(int j=0;j<W+2;j++){
      score[i][j]=0;
    }
  }
  for(int i=0;i<H;i++){
    cin >> s[i];
    for(int j=0;j<W;j++){
      if(s[i].at(j)=='#'){
        score[i+1][j+1]-=10;
        score[i][j]++;
        score[i][j+1]++;
        score[i][j+2]++;
        score[i+1][j]++;
        score[i+1][j+2]++;
        score[i+2][j]++;
        score[i+2][j+1]++;
        score[i+2][j+2]++;
      }
    }
  }
  for(int i=1;i<H+1;i++){
    for(int j=1;j<W+1;j++){
      if(score[i][j]<0){
        cout << '#';
      }
      else{
        cout << score[i][j];
      }
      if(j==W){
        cout << endl;
      }
    }
  }
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        long w = sc.nextLong();
        long m1 = 0;
        ArrayList<ArrayList<Long>> map = new ArrayList<>();
        for(int i = 0; i < 4; i++){
            map.add(new ArrayList<>());
        }
        m1 = sc.nextLong();
        map.get(0).add(sc.nextLong());
        for(int i = 0; i < n-1; i++){
            long m = sc.nextLong();
            long v = sc.nextLong();
            map.get((int)(m-m1)).add(v);
        }
        long[][] cum = new long[4][n+1];
        for(int i = 0; i < 4; i++){
            Collections.sort(map.get(i),Comparator.reverseOrder());
            for(int j = 0; j < map.get(i).size(); j++){
                cum[i][j+1] = cum[i][j] + map.get(i).get(j);
            }
        }
        long ans = 0;
        int imax = map.get(0).size();
        int jmax = map.get(1).size();
        int kmax = map.get(2).size();
        int lmax = map.get(3).size();
        for(int i = 0; i <= imax; i++){
            for(int j = 0; j <= jmax; j++){
                for(int k = 0; k <= kmax; k++){
                    for(int l = 0; l <= lmax; l++){
                        if(m1*i + (m1+1)*j + (m1+2)*k + (m1+3)*l > w){
                            break;
                        }
                        ans = Math.max(ans,cum[0][i]+cum[1][j]+cum[2][k]+cum[3][l]);  
                    }
                }
            }
        }
        System.out.println(ans);
    }
    
}

class Point{
    long x,y;
    public Point(long x, long y){
        this.x = x;
        this.y = y;
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


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

using namespace std;

int ans[1000][1000];

int main(){
    int H, W, N;
    cin >> H >> W >> N;
    vector<int> a(N);
    for(int i = 0; i < N; ++i){
        cin >> a[i];
    }
    
    int line_now = 0, column_now = 0;
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < a[i]; ++j){
            if(line_now % 2 == 0){
                ans[line_now][column_now++] = i + 1;
                if(column_now == W){
                    line_now++;
                    column_now--;
                }
            }
            else{
                ans[line_now][column_now--] = i + 1;
                if(column_now == -1){
                    line_now++;
                    column_now++;
                }
            }
        }
    }
    
    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
int K;
vector<int> A;

ll f(int i, ll N)
{
    return N - N % A[i];
}

ll g(ll N)
{
    rep(i, 0, K)
    {
        N = f(i, N);
    }
    return N;
}

ll BinarySearch(ll ng, ll ok, function<bool(ll)> IsOK)
{
    while (abs(ng - ok) > 1)
    {
        const ll mid = (ng + ok) / 2;
        if (IsOK(g(mid))) ok = mid;
        else ng = mid;
    }
    return ok;
}

void _main()
{
    cin >> K;
    A.resize(K);
    rep(i, 0, K) cin >> A[i];

    const ll mi = BinarySearch(-1, 1LL << 60, [](ll N)
    {
        return N >= 2;
    });

    const ll ma = BinarySearch(1LL << 60, -1, [](ll N)
    {
        return N < 3;
    });

    if (mi <= ma)
    {
        cout << mi << " " << ma << endl;
    }
    else
    {
        cout << -1 << endl;
    }
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std ;
#define Rep( i , a , b ) for( i = a ; i <= b ; i ++ )
#define Rev( i , b , a ) for( i = b ; i >= a ; i -- )
#define LL long long
#define MOD 1000000007LL
LL n , m , p , t , caseno , k ;

LL a[100005] ;
LL dp[100005] ;
bool visit[100005] ;

LL Fun( LL pos ){
    if( pos == n ) return 0 ;
    if( visit[pos] ) return dp[pos] ;
    LL ret = 0 ;
    ret = abs( a[pos+1] - a[pos] ) + Fun( pos + 1 ) ;
    if( n - pos >= 2 ) ret = min( ret , abs( a[pos+2] - a[pos] ) + Fun( pos + 2 ) ) ;
    visit[pos] = 1 ;
    return dp[pos] = ret ;
}

int main(){
    LL i , j ;
    scanf("%lld",&n) ;
    Rep( i , 1 , n ){
        scanf("%lld",&a[i]) ;
    }
    printf("%lld\n",Fun( 1LL )) ;
    return 0 ;
}


Measured memory_bytes: 4992
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

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

    rep(i, h){
        rep(j, w){
            string s;
            cin >> s;

            if("snuke" == s){
                cout << (char)('A'+j) << i+1 << endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 384
import sys

input = sys.stdin.readline

def main():
    n = int(input())
    s = input()[::-1]
    ans = 0
    l = 0
    r = 1
    for r in range(1,n):
        if s[l:r] in s[r:]:
            ans=r-l
        else:
            l += 1
    print(ans)

main()


Measured memory_bytes: 3064
//#include<bits/stdc++.h>
//using namespace std;
//#define mem(a) memset(a,0,sizeof(a))
//#define dbg(x) cout<<#x<<" = "<<x<<endl
//#define ll long long
////不要再爆long long了！！！！！！！！不要再爆long long了！！！！！！！ 
//int a[200010];
//int main()
//{
//	int n,i,j,t,s=0;
//	scanf("%d",&n);
//	for(i=0;i<n;i++)scanf("%d",&a[i]);
//	sort(a,a+n);
//	vector<int>b;
//	//vector< vector<int>::iterator > c;
//	b.push_back(a[0]);
//	int temp=-1;
//	for(i=1;i<n;i++)
//	{
//		if(a[i]==a[i-1]){if(a[i]!=temp)s++,temp=a[i];goto loop;}
//		for(vector<int>::iterator it=b.begin();it!=b.end();it++)
//		{
//			if(a[i]%(*it)==0)//已经有了，不可以 
//			{
//				//if(a[i]==*it)c.push_back(it)/*s++*/;
//				goto loop;
//			}
//		}
//		b.push_back(a[i]);
//		loop:;
//	} 
//	//for(vector< vector<int>::iterator >::iterator itt=c.begin();itt!=c.end();itt++)b.erase(*itt);
//	printf("%d",b.size()-s);
//	return 0;
//}

#include<bits/stdc++.h>
using namespace std;
#define mem(a) memset(a,0,sizeof(a))
#define dbg(x) cout<<#x<<" = "<<x<<endl
#define ll long long
//不要再爆long long了！！！！！！！！不要再爆long long了！！！！！！！ 
bool b[1000010]={0};
int a[200010];
int main()
{
	int n,i,j,s=0,scong=0,ci,now;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a+1,a+n+1);
	for(i=1;i<=n;i++)
	{
		now=a[i];
		if(b[now]==0)//还没有这个 
		{
			ci=1000000/a[i];
			for(j=1;j<=ci;j++)b[j*now]=1/*,dbg((ci*now))*/;
			if(a[i]!=a[i-1]&&a[i]!=a[i+1])s++/*,dbg(i)*/;//独一无二 
		}
	}
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 5520
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#define ll long long
#define N 100010
using namespace std;

ll n,m,tot,ans,a[N],father[N],cnt[N];
//tot表示连通块个数
//a表示每个点的权值
//father表示并查集的父节点
//cnt表示连通块i对应的q是哪个
vector<ll> t,q[N];
//t表示前tot个点选完之后剩下的
//q[i]表示第i个连通块里的点的权值

inline ll read(){//读入优化
    ll x=0,tmp=1;
    char ch=getchar();
    while(!isdigit(ch)){
        if(ch=='-') tmp=-1;
        ch=getchar();
    }
    while(isdigit(ch)){
        x=(x<<3)+(x<<1)+(ch^48);
        ch=getchar();
    }
    return tmp*x;
}

ll searchfather(ll v){//并查集
    if(father[v]==v) return father[v];
    return father[v]=searchfather(father[v]);
}

int main(){
    n=read(); m=read();
    for(ll i=1; i<=n; i++){
        a[i]=read();
        father[i]=i;
    }
    while(m--){
        ll x=read()+1,y=read()+1;
        ll f1=searchfather(x),f2=searchfather(y);
        if(father[f1]!=f2) father[f1]=f2;
    }
    for(ll i=1; i<=n; i++){
        father[i]=searchfather(i);
        if(!cnt[father[i]]) cnt[father[i]]=++tot;//当前连通块没有被统计
        q[cnt[father[i]]].push_back(a[i]);//加入权值
    }
    if(tot==1) return printf("0\n")&0;//图已经联通了
    for(ll i=1; i<=tot; i++) sort(q[i].begin(),q[i].end());//排序
    for(ll i=1; i<=tot; i++) ans+=q[i][0];//取走第一个
    for(ll i=1; i<=tot; i++){
        for(ll j=1; j<q[i].size(); j++) t.push_back(q[i][j]);//从第二个开始往后取
    }
    sort(t.begin(),t.end());
    if(t.size()<tot-2) return printf("Impossible\n")&0;//不够
    for(ll i=0; i<tot-2; i++) ans+=t[i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8064
a,b = map(int,input().split())
st,ch = [],[]
for i in range(a):
    c,d = map(int,input().split())
    st.append([c,d])
for i in range(b):
    c,d = map(int,input().split())
    ch.append([c,d])    

for i in range(len(st)):
    li = []
    for j in range(len(ch)):
        dis = abs(st[i][0] - ch[j][0]) + abs(st[i][1] - ch[j][1])
        li.append(dis)
    #print(li)
    print(li.index(min(li))+1)

Measured memory_bytes: 3064
/*package whatever //do not write package name here */

import java.util.*;

public class Main {
    static LinkedList<Integer>[] adj;
    static int[] dist;
    static boolean[] marked;
    static int[] indeg;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), m = sc.nextInt();
		adj = new LinkedList[n];
		dist = new int[n];
		indeg = new int[n];
		marked = new boolean[n];
		for(int i=0;i<n;i++){
		    adj[i] = new LinkedList<>();
		}
		for(int i=0;i<m;i++){
		    int u = sc.nextInt()-1, v = sc.nextInt()-1;
		    adj[u].add(v);
		    indeg[v]++;
		}
		for(int i=0;i<n;i++){
		    if(!marked[i] && indeg[i]==0){
		        dfs(i);
		    }
		}
		int max = 0;
		for(int i=0;i<n;i++){
		    max = Math.max(max, dist[i]);
		}
		System.out.println(max);
	}
	static void dfs(int u){
	    marked[u] = true;
	    for(int i : adj[u]){
	        dist[i] = Math.max(dist[i], dist[u]+1);
	        indeg[i]--;
	        if(indeg[i]==0) dfs(i);
	    }
	}
}

Measured memory_bytes: 101404
#include<iostream>
using namespace std;
long double x[4], y[4], xp[2], yp[2]; int n;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3];
		xp[0] = x[0] - x[1];
		yp[0] = y[0] - y[1];
		xp[1] = x[2] - x[3];
		yp[1] = y[2] - y[3];
		if (yp[0] == 0 && yp[1] == 0) { goto E; }
		if (yp[0] == 0 && yp[1] != 0) { goto F; }
		if (yp[0] != 0 && yp[1] == 0) { goto F; }
		if ((xp[0] / yp[0]) == (xp[1] / yp[1])) { goto E; }
		goto F;
	E:; cout << "YES" << endl;
		goto G;
	F:; cout << "NO" << endl;
	G:;
	}
}

Measured memory_bytes: 1224
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
vector<string> split(const string &str, char sep){
    std::vector<std::string> v;
    auto first = str.begin();
    while(first != str.end()){
        auto last = first;
        while(last != str.end() && *last != sep) ++last;
        v.push_back(std::string(first,last));
        if(last!=str.end()) ++last;
        first=last;
    }
    return v;
}

string s;
int main(){
    cin>>s;
    if ((s[0]==s[s.size()-1])^(s.size()%2==0)){
        cout<<"Second"<<endl;
    }else{
        cout<<"First"<<endl;
    }
    return 0;
}

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





int main() {
  
string o,e;
  cin>>o>>e;
  
  int osize=int(o.size());
  int esize=int(e.size());
  string answer="";
  
  for (int i=0;i<esize;i++){
    answer+=o.at(i);
    answer+=e.at(i);
  }
  
  if (osize-esize==1){
    answer+=o.at(osize-1);
  }
  
  cout<<answer<<endl;
}










Measured memory_bytes: 256
# -*- coding: utf-8 -*-

"""
解説参考
・必要な値を出してから再帰で場合分け
"""

N, X = map(int, input().split())

# まず、それぞれのレベルについて全体の厚さとパティの枚数を求める
A = [1] * (N+1)
P = [1] * (N+1)
for i in range(1, N+1):
    A[i] = A[i-1] * 2 + 3
    P[i] = P[i-1] * 2 + 1

# レベルn、食べる厚さx
def dfs(n, x):
    # レベル0まで来て食べる厚さが残ってればパティ1枚
    if n == 0:
        if x >= 1:
            return 1
        else:
            return 0
    # ひとつ前の総数 + 左端バンズ = 真ん中のパティの手前まで
    if x <= A[n-1] + 1:
        # 前のレベルを調べる(食べる厚さは左端バンズを引く)
        return dfs(n-1, x-1)
    # 食べる厚さが真ん中のパティまでより多い
    else:
        # ひとつ前の総取り + 真ん中 + 前のレベルを調べる
        # (食べる厚さは前半のひとつ前の分と、左端バンズと真ん中パティを引く)
        # ※右端バンズを食べる場合でも、最終的にn == 0で1を返す時xの残数が1多いだけなので考慮しなくていい
        return P[n-1] + 1 + dfs(n-1, x-A[n-1]-2)

print(dfs(N, X))


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

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

#define MAX_N 200000
int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
 	int N;  cin >> N;
	//Bは添え字 - 1番目までの合計(累積和)
	ll A[MAX_N + 1], B[MAX_N + 1];  B[0] = 0;
	for(int i = 0 ; i < N ; i++){
    	cin >> A[i];
      	B[i + 1] = B[i] + A[i];
    }

	sort(B, B + N + 1);

	ll ans = 0, same_number_count = 1;
	for(int i = 0 ; i < N ; i++){
		if(B[i] == B[i + 1])	same_number_count += 1;
		else{
			ans += same_number_count * (same_number_count - 1) / 2;
        	same_number_count = 1;
  		}
	}
	if(same_number_count > 1)
    	ans += same_number_count * (same_number_count - 1) / 2;
  
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3328
ws = input()
list_e=[]
list_o=[]

for n, v in enumerate(ws):
  if n % 2 == 0:
    list_e.append(v)
  else:
    list_o.append(v)

if "L" not in list_e and "R" not in list_o:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <list>
#include <stack>

using namespace std;

/* constant */

const int INF = 1 << 30;
const int mod = 1000000007;

/* typedef */

typedef long long ll;

/* global variables */

/* function */

/* main */
int main() {

    int S; cin >> S;
    int hour = S / 3600;
    S %= 3600;
    int minute = S / 60;
    S %= 60;
    int second = S;

    cout << hour << ':' << minute << ':' << second << '\n';

}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

struct UnionFind{
    vector<int> d;
    UnionFind(int n=0):d(n,-1){}
    int root(int x){
        if(d[x]<0)return x;
        return d[x]=root(d[x]);
    }
    bool unite(int x,int y){
        x=root(x);y=root(y);
        if(x==y)return false;
        if(d[x]>d[y])swap(x,y);
        d[x]+=d[y];
        d[y]=x;
        return true;
    }
    bool same(int x,int y){return root(x)==root(y);}
    int usize(int x){return -d[root(x)];}
};

int main(){
    int n,m;cin>>n>>m;
    V a(m);
    V b(m);
    for (int i = 0; i < m; ++i) {
        cin >>a[i]>>b[i];
        a[i]--;
        b[i]--;
    }
    ll ans=0;
    for (int i = 0; i < m; ++i) {
        UnionFind uni(n);
        for (int j = 0; j < m; ++j) {
            if(i==j)continue;
            uni.unite(a[j], b[j]);
        }
        if(uni.usize(0)!=n)ans++;
    }
    cout <<ans <<endl;
}



Measured memory_bytes: 3540
N, L = input().split(" ")
N = int(N)
L = int(L)
trimRingoIndex = 0
trimRingoAji = 0
for value in range(N):
    aji = abs(L + value)
    if value == 0:
        trimRingoAji = aji
    else:
        if trimRingoAji > aji:
            trimRingoIndex = value
            trimRingoAji = aji

totalAji = 0
for value in range(N):
    if value != trimRingoIndex:
        totalAji += L + value

print(totalAji)

Measured memory_bytes: 3064
package main

import "fmt"

func main() {
	var a, b, c, x int
	fmt.Scan(&a, &b, &c, &x)

	var sum int
	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for k := 0; k <= c; k++ {
				if i*500+j*100+k*50 == x {
					sum++
				}
			}
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 512