akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
#define endl '\n'
#define int long long

typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int w, h, x, y;
int32_t main()
{
	IOS
	//freopen("input.txt", "r", stdin);
	cin >> w >> h >> x >> y;
	double ans = 1.0*w*h/2.0;
	cout << fixed << setprecision(10);
	if (2*x == w && 2*y == h) cout << ans << ' ' << 1 << endl;
	else cout << ans  << ' ' << 0 << endl;
	
	return 0;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
  int N, val;
  cin >> N;
  vector<int> ans(N);
  REP(i, N) {
    ans[i] = 0;
  }
  FOR(x, 1, sqrt(N)) {
    FOR(y, 1, sqrt(N)) {
      FOR(z, 1, sqrt(N)) {
        val = x*x+y*y+z*z+x*y+y*z+z*x;
        if (val <= N) ans[val-1]++;
      }
    }
  }
  REP(i, N) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3524
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int N , M;
int WA[105000];
bool AC[105000];
 
void solve() {
    cin >> N >> M;
    int WAtotal = 0;
    int ACtotal = 0;
    for(int i = 1; i <= N; i++) {
        WA[i] = 0;
        AC[i] = false;
    }
    while(M--) {
        int p;
        string S;
        cin >> p >> S;
        if(AC[p]) continue;
        if(S == "AC") {
            AC[p] = true;
            ACtotal++;
            WAtotal += WA[p];
        } else if(S == "WA") {
            WA[p]++;
        }
    }
    cout << ACtotal << " " << WAtotal << endl;
    return;
}
int main() {
    solve();
    return 0;
}

Measured memory_bytes: 896
s = input()
n = len(s)

flag = True

if s != s[::-1]:
  flag = False
if s[:int((n-1)/2)] != s[:int((n-1)/2):-1]:
  flag = False
tmp = s[int((n+3)/2)-1:n]
if tmp != tmp[::-1]:
  flag = False
  
if flag:
  print("Yes")
else:
  print("No")

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

int main()
{
  int n, w;
  cin >> n >> w;
  vector<int> wt(n), v(n);
  vector<vector<long long int>> dp(n, vector<long long int>(w + 1));
  for (int i = 0; i < n; ++i)
    cin >> wt[i] >> v[i];
  dp[0][wt[0]] = v[0];
  for (int i = 1; i < n; ++i) {
    for (int ww = 0; ww <= w; ++ww) {
      dp[i][ww] = dp[i-1][ww];
      if (ww >= wt[i])
        dp[i][ww] = max(dp[i-1][ww-wt[i]] + v[i], dp[i][ww]);
    }
  }
  long long int res = 0;

  for (int i = 0; i <= w; ++i)
    res = max(res, dp[n-1][i]);

  cout << res <<'\n';


  return 0;
}


Measured memory_bytes: 79488
import heapq as hp
N, M = map(int, input().split(" "))
AB = []
for i in range(N):
    a, b = map(int, input().split(" "))
    AB.append((a, b))

AB.sort(key=lambda x: (-x[0], -x[1]))
j = 0
ans = 0
que = []
for i, (a, b) in enumerate(AB):
    if j + a <= M:
        hp.heappush(que, b)
        j += 1
        ans += b
    else:
        if len(que) > 0 and que[0] < b:
            v = hp.heappushpop(que, b)
            ans -= v
            ans += b

print(ans)

Measured memory_bytes: 30908
a,b,c,d=map(int,input().split())
n=int(input())
if a*4==min(a*4,b*2,c,d//2):
    print(n*a*4)
elif b*2==min(a*4,b*2,c,d//2):
    print(n*b*2)
elif c==min(a*4,b*2,c,d//2):
    print(n*c)
else:
    if n==1:
        ans=d*(n//2)
        if a*4==min(a*4,b*2,c):
            ans+=a*4
        elif b*2==min(a*4,b*2,c):
            ans+=b*2
        elif c==min(a*4,b*2,c):
            ans+=c
        print(ans)
    elif n%2==0:
        print((n*d)//2)
    else:
        ans=d*(n//2)
        if a*4==min(a*4,b*2,c):
            ans+=a*4
        elif b*2==min(a*4,b*2,c):
            ans+=b*2
        elif c==min(a*4,b*2,c):
            ans+=c
        print(ans)


Measured memory_bytes: 3064
N,M = map(int,input().split())
prefecture = [[] for i in range(N+1)]
ans = []
for i in range(M):
    p,y = map(int,input().split())
    prefecture[p].append([y,i])

for i in range(1,N+1):#iは県の番号
    prefecture[i].sort()
    for j in range(1,len(prefecture[i])+1):#jは何番目か，すなわちx
        ans.append([prefecture[i][j-1][1],i,j])
ans.sort()
for i in range(len(ans)):
    print('{:06}{:06}'.format(ans[i][1],ans[i][2]))
        

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

int main(void) {
    int N, input;
    vector<int> intList;
    cin >> N;
    while(N-- > 0) {
        cin >> input;
        intList.push_back(input);
    }

    cout << intList[intList.size()-1];
    for(int i=intList.size()-2; i >= 0; i--) {
        cout << " " << intList[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3104
import java.util.Scanner;

public class Main {

	private static final int MOD = 1000000007;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();

		for (int i = 0; i < s.length; i++) {
			if (i + 1 < s.length && s[i] == s[i + 1]) {
				System.out.println((i + 1) + " " + (i + 2));
				return;
			} else if (i + 2 < s.length && s[i] == s[i + 2]) {
				System.out.println((i + 1) + " " + (i + 3));
				return;
			}
		}
		System.out.println("-1 -1");
	}
}


Measured memory_bytes: 13132
#include <iostream>
#include <algorithm>
#include <list>
#include <string>

using namespace std;

void swap(string& acity, int& aprice, int& anum, string& bcity, int& bprice, int& bnum) {
	string wk;
	int iwk;

	wk = acity;
	acity = bcity;
	bcity = wk;

	iwk = aprice;
	aprice = bprice;
	bprice = iwk;

	iwk = anum;
	anum = bnum;
	bnum =iwk;

	return;
}




int main() {

	int n;

	cin >> n;

	string city[100];
	int price[100];
	int num[100];

	for (int i = 0; i < n; i++) {
		cin >> city[i] >> price[i];
		num[i] = i + 1;
	}
	
	bool loopflg = true;
	while (loopflg) {
		loopflg = false;

		for (int i = 0; i < n - 1; i++) {
			if (city[i] > city[i + 1]) {
				swap(city[i], price[i], num[i], city[i + 1], price[i + 1], num[i + 1]);
				loopflg = true;
				break;
			}

			if (city[i] == city[i + 1] && price[i] < price[i + 1]) {
				swap(city[i], price[i], num[i], city[i + 1], price[i + 1], num[i + 1]);
				loopflg = true;
				break;
			}
		}
	}

	for (int i = 0; i < n; i++) {

		cout << num[i] << endl;
	}
	







	return 0;




}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef map <ll,ll> mm;
typedef vector <ll> mv;
typedef pair <ll,ll> mp;
typedef set <ll> ms;
typedef queue <ll> mq;
typedef deque <ll> mdq;
typedef stack <ll> mst;
typedef priority_queue <ll> mpq;
typedef priority_queue <ll, vector<ll>, greater<ll> > mmh;
typedef complex<double> cd; 
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define flush cout.flush();
#define all(v) v.begin(),v.end()
#define pb(v) push_back(v)
#define cn continue
#define forl(i,n) for(ll i=0;i<n;i++)
#define forlr(i,n) for(ll i=n-1;i>=0;i--)
#define rev(s) reverse(s.begin(),s.end())
void swap(ll &a,ll &b)
{
	ll tmp=a;
	a=b;
	b=tmp;
}
ll atoistring(string s)
{
	stringstream lol(s);
	ll x;
	lol>>x;
	return x;
}
void pv(mv v)
{
	forl(i,v.size())
	{
		cout<<v[i]<<" ";
	}
	cout<<"\n";
}
void pa(ll *v,ll size)
{
	forl(i,size)
	{
		cout<<v[i]<<" ";
	}
	cout<<"\n";
}
// ll nck(ll N,ll K,ll mod)
// {
// 	if(N<K)
// 	{
// 		return 0;
// 	}
// 	return (((facs[N]*facsinv[N-K])%mod)*facsinv[K])%mod;
// }
ll power(ll x,ll y,ll p)
{
	ll res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
		{
			res=(res*x)%p;
		}
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
void checkmod(ll &x,ll mod)
{
	if(x>=mod)
	{
		x%=mod;
	}
}
ll sumofgp(ll a,ll n,ll m)
{
	// n = number of terms - 1
	if(n<0)
	{
		return 0;
	}
	if(n==0)
	{
		return 1;
	}
	if(n==1)
	{
		return (1+a)%m;
	}
	ll ans;
	if(n%2)
	{
        ans=(1+a)*sumofgp((a*a)%m,(n-1)/2,m);
	}
    else
    {
        ans=1+((a*(1+a))%m)*sumofgp((a*a)%m,n/2-1,m);
    }
    return ans%m;
}
ll power_of_2_not_less(ll n)
{
	if(!n)
	{
		return 1;
	}
	n--;
	n |= n>>1;
	n |= n>>2;
	n |= n>>4;
	n |= n>>8;
	n |= n>>16;
	n |= n>>32;
	n++;
	return n;
}
// void checktime()
// {
// 	struct timespec ts;
// 	printf("Running Program\n");
// 	clock_gettime(CLOCK_MONOTONIC_RAW,&ts);
// 	long double st=ts.tv_nsec/(1e9)+ts.tv_sec;
// 	// Call Funcn Here
// 	clock_gettime(CLOCK_MONOTONIC_RAW,&ts);
// 	long double en=ts.tv_nsec/(1e9)+ts.tv_sec;
// 	printf("Program ended\nTime = %Lf\n",en-st);
// }
ll adj[200005];
ll steps[200005];
int main(void)
{
	fastio
	ll n, k;
	cin>>n>>k;
	forl(i,n) cin>>adj[i + 1];
	ll ans = 1;
	ll cnt = 1;
	steps[1] = cnt ++ ;
	ll lol = -1;
	forl(i,n) {
		ans = adj[ans];
		if(cnt - 1 == k) {
			cout<<ans<<"\n";
			return 0;
		}
		if(steps[ans] > 0) {
			lol = steps[ans];
			steps[ans] = cnt ++ ;
			break;
		}
		steps[ans] = cnt ++ ;
	}
	// forl(i,n) cout<<steps[i+1]<<" ";
	// cout<<"\n";
	// cout<<lol<<" "<<steps[ans]<<"\n";
	ll tmp = (k + 1 - lol) / (steps[ans] - lol);
	// cout<<tmp<<"-\n";
	tmp = lol - 1 + tmp*(steps[ans] - lol);
	k -= tmp;
	while(k--) ans = adj[ans];
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 6772
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;



int main(void) {
    vvl pitsu(3,vl(3,0));
    rep(i,3) rep(j,3) cin>>pitsu[i][j];
    bool a1 = pitsu[1][0]-pitsu[0][0] == pitsu[1][1]-pitsu[0][1];
    a1 &= pitsu[1][1]-pitsu[0][1] == pitsu[1][2]-pitsu[0][2];
    bool a2 = pitsu[2][0]-pitsu[1][0] == pitsu[2][1]-pitsu[1][1];
    a2 &= pitsu[2][1]-pitsu[1][1] == pitsu[2][2]-pitsu[1][2];
    bool b1 = pitsu[0][1]-pitsu[0][0] == pitsu[1][1]-pitsu[1][0];
    b1 &= pitsu[1][1]-pitsu[1][0] == pitsu[2][1]-pitsu[2][0];
    bool b2 = pitsu[0][2]-pitsu[0][1] == pitsu[1][2]-pitsu[1][1];
    b2 &= pitsu[1][2]-pitsu[1][1] == pitsu[2][2]-pitsu[2][1];
    if(a1 && a2 && b1 && b2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
#define INF (1 << 31 - 1)
using namespace std;

bool check(string s, string aidunyan, int i){
    string div;
    for(int j = i; j < i + 8; j++){
        div+=s[j];
    }
    sort(all(div));
    if(div == aidunyan) return 1;
    else return 0;
}

int main(){
    string s, aizunyan, aidunyan;
    aizunyan = "AIZUNYAN";
    aidunyan = "AIDUNYAN";
    sort(all(aidunyan));

    cin >> s;
    if(s.size() >= 8){
        rep(i,s.size() - 7){
            if(check(s, aidunyan, i)){
                for(int j = i; j < i + 8; j++) s[j] = aizunyan[j - i];
                i+=7;
            }
        }
    }
    cout << s << endl;
}

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

int main(){
  int num[10];
  int i, j, n;
  for(i=0;i<10;i++){
	  scanf("%d",&num[i]);
  }
  for(i=0;i<3;i++){
    for(j=9;j>i;j--){
      if(num[j-1]<num[j]){
        n = num[j-1];
        num[j-1] = num[j];
        num[j] = n;
      }
    }
    printf("%d\n",num[i]);
  }
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}

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

  int n; cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  vector<int> dp(n);
  dp[0] = a[0];
  for(int i = 1; i < n; ++i) {
      dp[i] = gcd(dp[i-1], a[i]);
  }
  cout << dp[n-1] << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

int main(){
    int n;  cin >> n;
    vector<ll> a(n), b(n), c(n);
    REP(i, n)   cin >> a[i];
    REP(i, n)   cin >> b[i];
    REP(i, n)   cin >> c[i];
    sort(ALL(a));   sort(ALL(c));   sort(ALL(b));

    ll res=0;
    REP(i, n){
        ll x = b[i];
        auto top = lower_bound(ALL(a), x);
        auto bottom = upper_bound(ALL(c), x);
        if(top!=a.begin() && bottom!=c.end()){
            res += (top-a.begin())*(n-(bottom-c.begin()));
        } 
    }
    cout << res << endl;
}


Measured memory_bytes: 2560
//By Tushar Gautam
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e;++i)
#define forsn(i,s,e) for(int i = s; i < e;++i)
#define rforn(i,s) for(int i = s; i >= 0;--i)
#define rforsn(i,s,e) for(int i = s; i >= e;--i)
#define bitcount(a) __builtin_popcount(a) // set bits (add ll)
#define ln '\n'
#define getcurrtime ((double)clock()/CLOCKS_PER_SEC)
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.fi<<","<<v.se<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    forstl(x,c) out<<x<<" ";
    out<<"}"; return out;
}
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM=1e5+5,MOD=1e9+7;
int t,n,m,k,x,y,w;
signed main(){
	fastio;
	cin>>n>>m;
	int mat[m][n],req[m];
	forn(i,m) forn(j,n) mat[i][j]=0;
	forn(i,m){
		cin>>k;
		forn(j,k){
			cin>>x; --x;
			mat[i][x]=1;
		}
	}
	int ans=0;
	forn(i,m) cin>>x,req[i]=x&1;
	forn(mask,(1<<n)){
		int cur[m]={0};
		bool ok=1;
		forn(i,m){
			forn(j,n){
				if(mat[i][j] and (mask&(1<<j))) cur[i]++;
			}
			if((cur[i]&1)!=req[i]) ok=0;
		}
		if(ok) ans++;
	}
	cout<<ans<<ln;
	return 0;
}

Measured memory_bytes: 256
def main():
	s = input()
	if s[-1] == "1" or s[0] == "0":
		print(-1)
		return
	if s[0:-1][::-1] != s[:-1]:
		print(-1)
		return
	temp = 1
	init = []
	for i in range(1,int((len(s)+1)/2)):
		if s[i] == "1":
			for j in range(temp+1, i+2):
				print(temp, j, sep=" ")
			init += [temp]
			temp = i+2
	if temp != len(s):
		for j in range(temp+1, len(s)+1):
			print(temp, j, sep=" ")
	init += [temp]
	for i in range(len(init)-1):
		print(init[i], init[i+1], sep=" ")
	

main()

Measured memory_bytes: 6592
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <climits>
#include <iomanip>
#include <cmath>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << std::fixed << std::setprecision(10);

	int n;
	cin >> n;

	vector<int> a(n);
	long long num[200000] = { 0 };
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		num[a[i]-1]++;
	}

	long long sum = 0;
	for (int i = 0; i < 200000; i++) {
		sum += num[i] * (num[i] - 1) / 2;
	}

	for (int i = 0; i < n; i++) {
		cout << sum - num[a[i] - 1] * (num[a[i] - 1] - 1) / 2 + (num[a[i] - 1] - 1) * (num[a[i] - 1] - 2) / 2 << endl;
	}


	return 0;
}

Measured memory_bytes: 4992
N=int(input())
A=[]
for i in range(N):
    a=list(map(int,input().split()))
    A.append(a)
INF=10**9
dp=[[0]*3 for i in range(N+1)]#dp[i][j] i日目でjをしたときの最大の幸福度
#dp[i+1][a]:=max(dp[i][b]+a,dp[i][c]+a)
dp[0][0]=dp[0][1]=dp[0][2]=0
for i in range(N):
    for j in range(3):
        dp[i+1][j]=max(dp[i][(j+1)%3]+A[i][j],dp[i][(j+2)%3]+A[i][j])
print(max(dp[N][0],dp[N][1],dp[N][2]))


Measured memory_bytes: 74132
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>


int main() {
	std::cin.tie(nullptr); std::cin.sync_with_stdio(false);
	std::vector<int> num(5); for (auto& n : num) std::cin >> n;
	for (auto i = 0; i < num.size(); ++i) {
		if (num[i] != i + 1) {
			std::cout << i + 1 << '\n';
		}
	}
}

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {
	
	static int n;
	static char[][] buff=new char[17][10];
	static int[] length=new int[17];
	
	static int calc(int line) {
		char c;
		int level, val;
		int arg;
		level=length[line]-1;
		c=buff[line][level];
		if(c=='*') {
			line++;
			val=1;
			while(true) {
				if(length[line]-1<=level) break;
				if(length[line]-1==level+1) {
					arg=calc(line);
					val*=arg;
				}
				line++;
				if(line>=n) break;
			}
			return val;
		}
		else if(c=='+') {
			line++;
			val=0;
			while(true) {
				if(length[line]-1<=level) break;
				if(length[line]-1==level+1) {
					arg=calc(line);
					val+=arg;
				}
				line++;
				if(line>=n) break;
			}
			return val;
		}
		return c-'0';
	}
	
	public static void main(String args[]){
		try(Scanner sc=new Scanner(System.in)){
			while(sc.hasNext()) {
				n=sc.nextInt();
				if(n==0) break;
				for(int i=0; i<n; i++) {
					String str=sc.next();
					length[i]=str.length();
					for(int j=0; j<str.length(); j++) {
						buff[i][j]=str.charAt(j);
					}
				}
				System.out.println(calc(0));
			}
			
		}
	}
} 


Measured memory_bytes: 30344
// In the name of Allah
// #Isart
// yedoone bashe, mashti bashe ...

#include<bits/stdc++.h>

#define pii pair<int, int>
#define pb push_back
#define F first
#define S second
#define ll long long
#define ld long double

using namespace std;

const int MAXN = 1e5 + 10;
int mark[MAXN], d[MAXN], cnt = 0;
vector<int> a[MAXN];
bool is;

void dfs(int v, int parent){
	cnt ++;
	mark[v] = true;
	for(auto u : a[v]){
		if(mark[u] == false)
			d[u] = d[v] + 1, dfs(u, v);
		else{
			if((d[v] - d[u]) % 2 == 0)
				is = false;
		}
	}
}

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < m; i ++){
		int x, y;
		cin >> x >> y;
		a[x].pb(y); a[y].pb(x);
	}	
	ll com = 0, two = 0, one;
	for(int i = 1; i <= n; i ++){
		if(mark[i] == false){
			cnt = 0;
			is = true;
			dfs(i, -1);
			if(is and cnt > 1) two ++;
			else if(cnt > 1) com ++;
			else one ++;
		}
	}
	ll ans = 0;
	ans += one * one + one * (n - one) * 2;
	ans += com * com + two * com + com * two + two * two * 2;
	cout << ans << endl;
	return 0;	
}

Measured memory_bytes: 10368
package main

import "fmt"
import "bufio"
import "os"
import "strconv"
import "sort"

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {

	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	var N, K int
	fmt.Scan(&N, &K)

	p := make([]int, N)
	sc.Split(bufio.ScanWords)

	for i := 0; i < N; i++ {
		p[i] = nextInt()
	}

	// 昇順ソート
	sort.Ints(p)

	res := 0
	for i := 0; i < K; i++ {
		res += p[i]
	}

	fmt.Println(res)
}


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

int main()
{
	int N;
	cin >> N;
	vector<long long> A( N );
	map<long long, int> mp;
	for( int i = 0; i < N; i++ ) {
		cin >> A[i];
		mp[ A[i] ]++;
	}

	long long sum = 0;
	for( auto it = mp.begin(); it != mp.end(); it++ ) {
		if( it-> second == 1 ) continue;
		else {
			int n = it->second;
			long long m = 1;
			int nn = n;
			for( int i = 0; i < 2; i++ ) {
				m *= nn;
				nn--;
			}
			sum += m / 2;
		}
	}

	for( int i = 0; i < N; i++ ) {
		long long a = A[i];
		int n = mp[ a ];
		long long m = 1;
		int nn = n;
		for( int i = 0; i < 2; i++ ) {
			m *= nn;
			nn--;
		}
		long long ans = sum - m / 2;
		nn = n - 1;
		m = 1;
		for( int i = 0; i < 2; i++ ) {
			m *= nn;
			nn--;
		}
		ans += m / 2;
		cout << ans << endl;
	}
}


Measured memory_bytes: 11008
#include <iostream>
#include <set>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>

using namespace std;

const int WALL = 100;

struct Data {
	char field[22][22];
	char x, y;
	char step;
	bool operator<(const Data& a) const {
		return (0 < memcmp(field, a.field, sizeof(field)));
	}
};

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

int main(void)
{
	int h, w, cnt = 0;
	int start[2];
	char f[22][22];
	while (cin >> w >> h){
		cnt++;
		if (h == 0 && w == 0){
			break;
		}
		for (int i = 0; i < 22; i++){
			for (int j = 0; j < 22; j++){
				f[i][j] = WALL;
			}
		}

		for (int i = 1; i <= h; i++){
			for (int j = 1; j <= w; j++){
				int v;
				scanf("%d", &v);
				f[i][j] = v;
				if (v == 2){
					start[0] = i, start[1] = j;
					f[i][j] = 0;
				}
			}
		}

		queue < Data > q;
		Data d;
		memcpy(d.field, f, sizeof(f));
		d.step = 0;
		d.x = start[1], d.y = start[0];
		for (q.push(d); !q.empty(); q.pop()){
			Data& data2 = q.front();
			// if (vis.count(data2)) continue;
			// vis.insert(data2);

			// if (cnt == 21){
			// 	cerr << endl;
			// 	for (int i = 1; i <= h; i++){
			// 		for (int j = 1; j <= w; j++){
			// 			if (i == data2.y && j == data2.x){
			// 				cerr << "* ";
			// 			}
			// 			else {
			// 				cerr << (int)data2.field[i][j] << " ";
			// 			}
			// 		}
			// 		cerr << endl;
			// 	}
			// 	cin >> ddd;
			// }

			if (data2.step + 1 > 10){
				continue;
			}
			for (int i = 0; i < 4; i++){
				Data data = data2;
				int ny = data.y, nx = data.x;
				if (data.field[ny + dy[i]][nx + dx[i]] == 1){
					continue;
				}
				while (1){
					ny += dy[i], nx += dx[i];
					if (data.step + 1 <= 10 && data.field[ny][nx] == 3){
						// goal
						cout << data.step + 1 << endl;
						goto GOAL;
					}
					if (data.field[ny][nx] == WALL){
						// fault
						break;
					}
					if (data.field[ny][nx] == 1){
						// wall
						data.field[ny][nx] = 0;
						data.y = ny - dy[i], data.x = nx - dx[i];
						data.step++;
						q.push(data);
						break;
					}
				}
			}
		}
		// cout << "size " << q.size() << endl;
		cout << -1 << endl;
		GOAL :;
	}
	return 0;
}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int n , m ,a , b;

int main()
{
    _FastIO;
    string s , t;
    cin >> s >> t;
    string flag = "Yes";
    for(int i = 0; i < s.size(); i++){
        if(s[i] != t[i])
            flag = "No";
    }
    cout << flag << endl;
    return 0;
}


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    string s;
    cin >> s;
    const int n = s.size();

    vector<vector<ll>> dp(n, vector<ll>(2, -1));
    dp[0][0] = dp[1][1] = 1;
    FOR(i, 1, n) {
        // dp[i-1][0] → dp[i][0] s[i-1]!=s[i]
        if(s[i-1]!=s[i] && dp[i-1][0]!=-1) {
            chmax(dp[i][0], dp[i-1][0] + 1);
        }
        // dp[i-1][1] → dp[i][0]
        if(dp[i-1][1]!=-1) {
            chmax(dp[i][0], dp[i-1][1] + 1);
        }
        // dp[i-2][0] → dp[i][1]
        if(i>=2 && dp[i-2][0]!=-1) {
            chmax(dp[i][1], dp[i-2][0] + 1);
        }
        // dp[i-3][1] → dp[i][1]
        if(i>=3 && dp[i-3][1]!=-1) {
            chmax(dp[i][1], dp[i-3][1] + 1);
        }
    }
    cout << max(dp[n-1][0], dp[n-1][1]) << endl;

    return 0;
}


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

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

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

    int count=0;
    for(int i=0;i<n-1;i++){
        int minj = i;
        for(int j=i;j<n;j++) if(a[j] < a[minj]) minj = j;
        int tmp = a[i];
        a[i] = a[minj];
        a[minj] = tmp;
        if(i != minj) count++;
    }
    for(int i=0;i<n-1;i++) cout << a[i] << " ";
    cout << a[n-1] << endl;
    cout << count << endl;
}

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

int main()
{
    int K;
    cin >> K;
    long long seven = 7;
    int i = 1;
    while(1)
    {
        if(seven % K == 0)
        {
            cout << i << endl;
            return 0;
        }
        seven = seven*10 + 7;
        seven %= K;
        i++;
        if(i>100000000)
        {
            cout << "-1" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3620
// ABEY SAALE
// QUESTION KHUD KR SOLUTION KYU DEKH RHA H
 
 
 
 
 
 
 
 
//MAAF KIJIYEGA ME GUSSE ME IDHAR UDHAR NIKAL JATA HU
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define senky_bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;

ll fac[2000005];
void pre(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=(i*fac[i-1])%mod;}
ll power(ll a,ll b){ll res=1;while(b){if(b&1) res=(res*a)%mod;a=(a*a)%mod;b=b/2;}return res%mod;}
ll ncr(ll n,ll r){return ((fac[n]*power(fac[r],mod-2))%mod*power(fac[n-r],mod-2))%mod;}
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE

signed main()
{   


      
      senky_bansal
      IIIT_ALLAHABAD
      
      // pre();
      ll t;
      // cin>>t;
      t=1;
      while(t--)
      { 
         
          string s;
          cin>>s;
          ll p1 = s.size();
          for(int i=0;i<p1;i++)
          cout<<"x";
         

      }
      






}



























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

int main(){
    int r, c;
    cin >> r >> c;
    int sheet[c] = {};
    int sheetsum[c] = {};
    int temp;
    int ans;
    
    for(int i = 0; i < r; i++){
        ans = 0;
        for(int j = 0; j < c; j++){
            cin >> temp;
            ans += temp;
            sheet[j] = temp;
            sheetsum[j] += temp;
        }

        for(int j = 0; j < c; j++){
            cout << sheet[j] << " ";
        }
        cout << ans << endl;
    }

    ans = 0;
    for(int i = 0; i < c; i++){
        cout << sheetsum[i] << " ";
        ans += sheetsum[i];
    }
    cout << ans << endl;
}



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

int main() {
  int N, M, K;
  cin >> N >> M >> K;
  vector<long long> A(N + 1), B(M + 1);
  for (int i = 1; i <= N; ++i) {
    cin >> A[i];
  }
  for (int i = 1; i <= M; ++i) {
    cin >> B[i];
  }

  for (int i = 2; i <= N; ++i) {
    A[i] += A[i - 1];
  }
  for (int i = 2; i <= M; ++i) {
    B[i] += B[i - 1];
  }

  int ans = -1;
  for (int i = 0; i <= N; ++i) {
    if (A[i] > K) {
      break;
    }

    int books = i;
    auto b = upper_bound(B.begin(), B.end(), K - A[i]);
    books += max(distance(B.begin(), b) - 1, 0l);

    ans = max(books, ans);
  }

  cout << ans << endl;
}


Measured memory_bytes: 6376
"use strict";

const main = (input) => {
    const spi = input.split('\n');
    let [a, b, c, d] = spi[0].split(' ').map(e => Number(e));

    let turn = true;
    while (a > 0 && c > 0) {
        if (turn) c -= b;
        else a -= d;
        turn = !turn;
    }

    console.log(turn ? "No" : "Yes");
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29520
n,m = map(int, input().split())
c = list(map(int, input().split()))
INF = 10**9
  
dp = [INF] * (n+1)
dp[0] = 0

for i in range(n+1):
  for j in range(m):
    if i >= c[j]:
      dp[i] = min(dp[i], dp[i-c[j]]+1)
  
print(dp[n])



Measured memory_bytes: 7264
s = list(input())
t = list(input())

s.sort()
t.sort(reverse = True)

for i in range(min(len(s), len(t))):
    if s[i] < t[i]:
        print('Yes')
        break
    elif s[i] > t[i]:
        print('No')
        break
    else:
        continue
else:
    if len(t) > len(s):
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 8980
/*
	AOJ_0173:Kannondou
*/

#include	<iostream>
#include	<utility>
#include	<algorithm>

using namespace std;

/*prototype declaration*/
long long getPattern(int x);

long long dp[30] = {1, 2, 4};

int main() {
	while(1) {
		int a;
		long long gp;
		
		cin >> a;
		if(a == 0) { break; }
		
		gp = getPattern(a);
		if(gp % 3650 != 0) {
			cout << gp / 3650 + 1 << endl;
		} else {
			cout << gp / 3650 << endl;
		}
	}
	return 0;
}

long long getPattern(int x) {
	if(x < 3) {
		return dp[x-1];
	} else {
		if(dp[x-1] != 0) {
			return dp[x-1];
		} else {
			dp[x-1] = getPattern(x-1) + getPattern(x-2) + getPattern(x-3);
			return dp[x-1];
		}
	}
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;

int main()
{
	int x;
    cin >> x;
    int ans = 360;
    int GCD = gcd(ans,x);
    if (ans%GCD==0)
    {
        ans /= GCD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int n;
	cin >> n;
	vector <char> str(n);
	int count =0;
	for(int i =0; i< n; i++) {
		cin >> str[i];
	}
	for(int i =0; i< n-2; i++) {
		if (str[i] == 'A' && str[i+1] == 'B' && str[i+2] == 'C') {
			count++;
		}
	}
	cout << count << endl;
	return 0;
}


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

map<string, vector<string> > G;
map<string, bool> is_group;
map<string, bool> used;
int N;
int cnt;

void dfs(string s) {
  if ( used[s] ) return;
  used[s] = true;
  if ( is_group[s] ) {
    for ( string t : G[s] ) {
      dfs(t);      
    }
  } else {
    cnt++;
  }
}

int main() {
  while ( cin >> N, N ) {
    string g1 = "";    
    G.clear();
    is_group.clear();
    used.clear();
    cnt = 0;
    for ( int n = 0; n < N; n++ ) {
      string group;
      string s;    
      string t = "";
      cin >> s;      
      for ( int i = 0; i < (int)s.size(); i++ ) {
	if ( s[i] == ':' ) {
	  group = t;
	  is_group[t] = true;	  
	  if ( g1 == "" ) g1 = group;	  
	  t = "";
	} else if ( s[i] == ',' || s[i] == '.' ) {
	  G[group].emplace_back(t);	  
	  t ="";
	} else {
	  t += s[i];	  
	}
      }
    }

    dfs(g1);
    cout << cnt << endl;
  }
  return 0;
}



Measured memory_bytes: 3412
from sys import stdin,stdout
n=int(stdin.readline())
a=list(map(int,stdin.readline().split()));ans=0
for i in range(n-1):
    f=a[i];b=a[i+1]
    if b<f:
        ans+=(f-b)
        a[i+1]+=(f-b)
print(ans)

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


int main(){
    int N; cin >> N;
    vector<pair<int, int>> tasks(N);
    for (int i = 0; i < N; i++) {
        int A, B; cin >> A >> B;
        tasks[i] = make_pair(B, A);
    }
    sort(tasks.begin(), tasks.end());

    int time = 0;
    for (int i = 0; i < N; i++) {
        time += tasks[i].second;
        if (time > tasks[i].first) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 1792
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
a,b=nii()
p=lnii()

x=0
y=0
z=0

for i in p:
  if i<=a:
    x+=1
  elif i>=b+1:
    z+=1
  else:
    y+=1

print(min(x,y,z))

Measured memory_bytes: 9156
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,k;
int main(){
	scanf("%d%d",&n,&k);
	if (k&1){
		n/=k;
		printf("%lld\n",(ll)n*n*n);
	} else{
		k/=2;
		int a=n/k,b=a/2;a=(a+1)/2;
		printf("%lld\n",(ll)a*a*a+(ll)b*b*b);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
#include <map>
using namespace std;

const double PI=acos(-1);

int main(){
    string s, t = "";
    cin >> s;
    long ans = 0, left = 0, right = 0, value = 0;
    vector<pair<long, long>> l;
    for(int i = 0; i < s.length(); i++){
        if(s[i] == '>' && s[i+1] == '<'){
            right++;
            l.push_back(make_pair(left, right));
            left = right = 0;
        }else{
            if(s[i] == '>') right++;
            else left++;
        }
    }
    if(left != 0 || right != 0) l.push_back(make_pair(left,  right));
    for(auto i : l){
        //cout << i.first << " " << i.second << endl;
        long m = max(i.first, i.second), mm = min(i.first, i.second);
        ans += m*(m+1)/2;
        if(mm > 1) ans += mm*(mm-1)/2;
    }
    cout << ans << endl;
    return 0;
    // < > < > < > < > < > < > < > < > < > > >
    //0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 3 2 1 0
}

Measured memory_bytes: 3068
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
//const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    int mm1 = h1 * 60 + m1;
    int mm2 = h2 * 60 + m2;
    mm2 -= k;
    cout << abs(mm1 - mm2) << endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define N 100005
using namespace std;
int a[N];
int main()
{
    int n;
    while (~scanf("%d", &n)) {
        for (int i = 1; i <= n; i++)
            scanf("%d", &a[i]);
        int x = 1,ans = 1, flag = 0;
        for (int i = 1; i <= n; i++) {
            x = a[x];
            ans++;
            if (x == 2) {
                flag = 1;
                break;
            }
        }
        if (flag)
            printf("%d\n", ans - 1);
        else
            printf("-1\n");
    }

    return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define null nullptr
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

using namespace std;

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
typedef unordered_map<int,int> mp;

const int mod = 1e9+7;



int32_t main(){
    FAST;

    int i = 1;

    double n,m;  cin >> n >> m;

    if(m == 1){
        cout << 0;
        return 0;
    }

    if(m <= n){
        cout << 1;
        return 0;
    }
   while(n+i*(n-1)<m){
            i++;
        }
        cout << 1+i << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
//#include <fstream>

using namespace std;

int stoi (string str )
{
	stringstream ss (str );
	int n;
	ss >> n;
	
	return n;
}

int main()
{
//	cut here before submit 
//	freopen("testcase.hit6blow", "r", stdin);
	string A = "", B = "";
	
	while (cin >> A >> B ) {
		if ( stoi(A) == 0 && stoi(B) == 0 ){
			break;
		} // end if

		int hit = 0;
		int blow = 0;
		int i,j;

		for (i = 0; i < 4; ++i){
			if (A[i] == B[i]){
				++hit;
				A[i] = B[i] = 'e';
			} // end if
		} // end for
		
		for (i = 0; i < 4; ++i){
			for (j = 0; j < 4; ++j){
				if (A[i] != 'e' && B[j] != 'e' && A[i] == B[j]){
					++blow;
					A[i] = B[j] = 'e';
				} // end if
			} // end for
		} // end for
		cout << hit << ' ' << blow << endl;
	} // end while

	return 0;
}

Measured memory_bytes: 936
class Card(object):
    def __init__(self, card):
        self.suit = card[:1]
        self.value = int(card[1:])
    
    def __str__(self):
        return self.suit + str(self.value)

def is_stable(bs, ss):
    if bs == ss:
        return 'Stable'
    else:
        return 'Not stable'

def bubble_sort(c, n):
    c = c.split()
    c = [Card(card) for card in c]
    for i in range(n-1):
        for j in range(n-1):
            if c[j].value > c[j+1].value:
                c[j], c[j+1] = c[j+1], c[j]
    return c

def selection_sort(c, n):
    c = c.split()
    c = [Card(card) for card in c]
    for i in range(n):
        mink = i
        for v in range(i, n):
            if c[v].value < c[mink].value:
                mink = v
        if mink != i:
            c[i], c[mink] = c[mink], c[i]
    return c

n = input()
nums = input()

bs = bubble_sort(nums, int(n))
bs_str = [str(card) for card in bs]
print(' '.join(bs_str))
print('Stable')

ss = selection_sort(nums, int(n))
ss_str = [str(card) for card in ss]
print(' '.join(ss_str))
print(is_stable(bs_str, ss_str))


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

int main(){
  ll N, La = 2, Lb = 1;
  cin >> N;
  
  if(N % 2 == 1){
    for(int i = 0; i < (N-1) / 2; i++){
      La += Lb;
      Lb += La;
    }
    cout << Lb << endl;
  }
  
  else{
    for(int i = 0; i < N / 2; i++){
      La += Lb;
      Lb += La;
    }
    cout << La << endl;
  }
}

Measured memory_bytes: 3636
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;

template<class T> inline void chmax(T& a, const T& b) { if(b > a) a = b; }

int d, n;
vector<int> a, b, c, t;

int memo[200][101];
int dfs(int day, int prev) {
	if(day == d)
		return 0;

	if(memo[day][prev] != -1)
		return memo[day][prev];

	int res = 0;
	for(int i = 0; i < n; ++i)
		if(a[i] <= t[day] && t[day] <= b[i])
			chmax(res, abs(prev - c[i]) + dfs(day + 1, c[i]));

	return memo[day][prev] = res;
}

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

	cin >> d >> n;

	t.resize(d);
	for(int i = 0; i < d; ++i)
		cin >> t[i];

	a.resize(n);
	b.resize(n);
	c.resize(n);
	for(int i = 0; i < n; ++i)
		cin >> a[i] >> b[i] >> c[i];

	memset(memo, -1, sizeof(memo));
	int ans = 0;
	for(int i = 0; i < n; ++i)
		if(a[i] <= t[0] && t[0] <= b[i])
			chmax(ans, dfs(1, c[i]));

	cout << ans << endl;

	return EXIT_SUCCESS;
}

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

int main() {
  int W, a, b;
  cin >> W >> a >> b;
  int diff;
  if (abs(a-b)<=W)
    diff = 0;
  else if(b>a)
    diff = b-(a+W);
  else
    diff = a-(b+W);
  cout << diff << endl;
}

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

int main(){
    int a,b,max=0;
    bool flag=0;
    cin >>a >>b;
//for文の前処理
if(a>b)max=a;
else max=b;

    for(int i=0; i<max; i++){
        if(abs(a-i)==abs(b-i)){
        cout <<i <<endl; //k
        flag=1;//kが存在した
        }
    }
if(flag==0){
    cout <<"IMPOSSIBLE"<<endl;
}
return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':

	A = "abcdefghijklmnopqrstuvwxyz"

	while True:
		try:
			line = input()

			for d in range(1,27):
				t = line.translate(str.maketrans(A,A[d:] + A[:d]))
				if 'the' in t or 'this' in t or 'that' in t:
					print(t)
					break

		except EOFError:
			break



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

int main(){
    long long n, a, b;
    cin >> n >> a >> b;

    if((a- b) % 2 == 0){
        cout << abs(b - a)/2;
        return 0;
    }

    if(a <b) swap(a, b);

    long long aa, bb, ans;
    ans = 0;
    bb = 1;
    aa = a - b;
    ans += b;

    ans += (aa - bb) / 2;

    long long an, bn, ann;
    ann = 0;
    an = n;
    bn = b + (n + 1 - a);
    ann += (n + 1 - a);

    ann += (an - bn) / 2;

    cout << min(ans, ann);
}


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

using namespace std;

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define int long long
#define mp make_pair
#define ff first
#define ss second
#define pii pair<int,int>
#define INF LLONG_MAX
#define EPS 1e-9
#define all(v) (v).begin(),(v).end()
#define sq(x) ((x)*(x))
#define foreach(it, v) for(auto it=(v).begin(); it != (v).end(); ++it)
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)


#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
 
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}
 
typedef long double dbl;
bool codejam = 0;

const int MOD = 1000*1000*1000 + 7;
const int NMAX = 1000*1000 + 11;

int n,m,p,q,k,a,b,c;
string s,str;
char ch;
vector<int> v;
vector<vector<int> > gr;
vector<int> ans(NMAX,-1);
int dist[NMAX];

void bfs(int src){
    queue<int> q;
    q.push(src);
    dist[src] = 1;

    for(int i=0;i<n+1;i++){
        dist[i] = INF;
    }

    while(!q.empty()){
        int cur = q.front();
        q.pop();
        for(auto ch:gr[cur]){
            if(dist[ch] == INF){
                dist[ch] = dist[cur] + 1;
                ans[ch] = cur;
                q.push(ch);
            }else{
                continue;
            }
        }
    }
}
void solve()
{
    cin>>n>>m;
    gr.resize(n+1);

    for(int i=0;i<m;i++){
        cin>>a>>b;
        gr[a].pb(b);
        gr[b].pb(a);
    }

    bfs(1);
    bool found = 0;
    for(int i=2;i<=n;i++){
        if(ans[i] == -1){
            // cout<<i<<" ";
            found = 1;
        }
        // cout<<ans[i]<<" ";
    }
    if(found){
        cout<<"No\n";
        return;
    }else{
        cout<<"Yes\n";
    }

    for(int i=2;i<=n;i++){
        if(ans[i] == -1){
            found = 1;
        }
        cout<<ans[i]<<" ";
    }
}

int32_t main(){ fio;
    int t = 1;
    int cs = 1;
    // cin>>t;
    while(t--){
        if(codejam){
            cout<<"Case #"<<cs<<": ";
        }
        cs++;
        solve();
        cout<<"\n";
    }
}

Measured memory_bytes: 20564