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

using namespace std;

vector<string> ans;
string str;

void solve(int idx, string s, string used)
{
  // cout << idx << " " << s << " " << used << endl;
  if(idx == str.size()){
    ans.push_back(s);
    return;
  }
  if(str[idx] == 'a'){
    solve(idx + 1, s + str[idx], used);
    if(used.find(str[idx]) == -1) solve(idx + 1, s + (char)(str[idx] + 1), used + str[idx]);
    return;
  }
  if(str[idx] != 'z' && used.find(str[idx]) == -1){
    solve(idx + 1, s + (char)(str[idx] + 1), used + str[idx]);
  }
  if(s.find(str[idx]) != -1){
    solve(idx + 1, s + str[idx], used);
  }

  return;
}

int main()
{
  while(cin >> str, str != "#"){
    string non = "";
    solve(0, non, non);
    sort(ans.begin(), ans.end());
    ans.erase(unique(ans.begin(), ans.end()), ans.end());
    cout << ans.size() << endl;
    if(ans.size() <= 5){
      for(int i = 0; i < ans.size(); i++){
	cout << ans[i] << endl;
      }
    } else {
      for(int i = 0; i < ans.size(); i++){
	if(i < 5 || ans.size()-5 <= i) cout << ans[i] << endl;
      }
    }
    ans.clear();
  }
  return 0;
}

Measured memory_bytes: 2388
#include<stdio.h>
int main(){
int x,y;

while(1){
scanf("%d %d",&x,&y);
if((x==0)&&(y==0)){
break;
}else{
if(x<=y){
printf("%d %d\n",x,y);
}else{
printf("%d %d\n",y,x);
}
}
}
return 0;
}

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

int main(){
    string s;

    cin >> s;

    int ans= 0;

    for(int i = 0; i < 3; ++i){
        if(s[i] == 'o') ans++;
    }

    cout << 700 + 100 * ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int
const int MAX = 510000;


using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int num = 0;
    int ans = 0;
    rep(i, s.size() - 1){
        if(s[i] == 'R' && s[i + 1] == 'L') num ++;
        else if(s[i] == 'L' && s[i + 1] == 'L') ans ++;
        else if(s[i] == 'R' && s[i + 1] == 'R') ans ++;
    }
    //cout << ans << endl;
    //cout << num << endl;
    if(num >= k) cout << ans + 2 * k << endl;
    else cout << n - 1 << endl;
}

Measured memory_bytes: 892
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  int a[3];
  for (int i = 0; i < 3; i++) cin >> a[i];
  int count = 0;

  if (a[2] == a[1]) count++;
  if (a[2] == a[0]) count++;
  if (a[0] == a[1]) count++;

  int ans;
  if (count == 3) ans = 1;
  else ans = 3 - count;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,h,j;
    int m=0,c=0;
    scanf("%d",&n);
    scanf("%d",&h);
    j=h;n--;
    while(n--){
        scanf("%d",&h);
        if(j>=h){
            c++;
            if(c>m)
            m=c;
        }
        else {
            c=0;
        }
        j=h;
    }
    printf("%d",m);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
constexpr ll INF = 1000000000;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int a, b, c, d; cin >> a >> b >> c >> d;
	cout << min(a, b) + min(c, d) << endl;
}

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

using namespace std;

int main(void) {
	int h, w, H, W, i, x, y, k, ok = false;
	cin >> h >> w >> k;
	H = max(h, w);
	W = min(h, w);
	for (i = 0; !ok && i <= W; i++) {
		x = k - i * H;
		y = W - (i << 1);
		if (y == 0) {
			if (x == 0)
				ok = true;
		}
		else if (x % y == 0) {
			x /= y;
			if (x >= 0 && x <= H)
				ok = true;
		}
	}
	if (ok)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

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

using namespace std;

typedef long int lint;
typedef long long int llint;

#define INF 1073741824
#define LINF 4611686018000000000
#define MOD 1000000007

int a[1100][1100];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int h, w;

bool dfs(int i, int j, int color) {
    if (i < 0 || i >= h || j < 0 || j >= w) return false;
    if (a[i][j] == 0 || a[i][j] > 1) {
        return false;
    }
    a[i][j] = color;
    for (int x = 0; x < 4; x++) {
        dfs(i + dx[x], j + dy[x], color);
    }
    return true;
}

int main() {
    cin >> h >> w;
    int c, d;
    cin >> c >> d;
    c--; d--;
    int x, y;
    cin >> x >> y;
    x--; y--;
    char aa;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> aa;
            if (aa == '#') {
                a[i][j] = 0;
            } else {
                a[i][j] = 1;
            }
        }
    }
    int color = 2;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (dfs(i, j, color))
                color++;
        }
    }

    vector< set < int > > v(color);
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            int cc = a[i][j];
            if (cc > 1)
                for (int k = 0; k < 25; k++) {
                    int ii = i - 2 + k / 5;
                    int jj = j - 2 + k % 5;
                    if (ii < 0 || ii >= h || jj < 0 || jj >= w) continue;
                    if (a[ii][jj] == 0) continue;
                    if (ii == i && jj == j) continue;
                    int ccc = a[ii][jj];
                    v[cc].insert(ccc);
                    v[ccc].insert(cc);
                }
        }
    }
    int src = a[c][d];
    int dest = a[x][y];
    vector<bool> visited(color, false);
    queue<pair<int, int>> q;
    q.push({src, 0});
    visited[src] = true;
    int ans = -1;
    while (!q.empty()) {
        pair<int, int> p = q.front(); q.pop();
        if (p.first == dest) {
            ans = p.second;
            break;
        }
        for (set<int>::iterator it = v[p.first].begin(); it != v[p.first].end(); it++) {
            if (!visited[*it]) {
                visited[*it] = true;
                q.push({*it, p.second + 1});
            }
        }
    }
//    for (int i = 0; i < h; i++) {
//        for (int j = 0; j < w; j++) {
//            cout << a[i][j];
//        }
//        cout << endl;
//    }
//    cout << src << " " << dest << endl;
//    cout << endl;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 33532
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static long[] s,r;
	static int[] a;
	static void Main(){
		Sc sc=new Sc();
		s=sc.La;
		a=sc.Ia;
		Array.Sort(a,(u,v)=>v.CompareTo(u));
		r=new long[s[0]+1];
		for(int i = 1;i<=s[0];i++) {
			r[i]=r[i-1]+a[i-1];
		}
		int lb=-1,ub=10000001,mid=0;
		long c=0,d=0;
		while(ub-lb>1){
			mid=(ub+lb)/2;
			var e=Fu(mid);
			if(e.Item1<=s[1]&&e.Item1>c){
				c=e.Item1;
				d=e.Item2;
			}
			if(e.Item1<=s[1]){ub=mid;}
			else{lb=mid;}
		}
		Console.WriteLine("{0}",(s[1]-c)*lb+d);
	}
	static Tuple<long,long> Fu(int n){
		long p=0,z=0;
		for(int i = 0,j=(int)s[0]-1;i<s[0];i++) {
			while(j>=0&&a[i]+a[j]<n){
				j--;
			}
			p+=j+1;
			z+=r[j+1]+((long)a[i])*(j+1);
		}
		return Tuple.Create(p,z);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 19808
#include <iostream>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C; cin >> A >> B >> C;
    if (B < C) swap(B, C);
    if (A < B) swap(A, B);
    cout << A * 10 + B + C << "\n";
}

Measured memory_bytes: 256
n = int(input())
array = [int(x) for x in input().split()]
ans = [0 for x in range(n)]
res = []
count = 0
for i in reversed(range(n)):
    a = array[i]
    if a == 1 and sum([x for x in ans[i::i+1]]) % 2 == 0:
        ans[i] = 1
        count += 1
        res.append(str(i+1))
    elif a == 0 and sum([x for x in ans[i::i+1]]) % 2 == 1:
        ans[i] = 1
        count += 1
        res.append(str(i+1))
print(count)
print(" ".join(res))




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

using namespace std;

const int mod = 1e9+7;
int dp[3005][3005];

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

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

	int n;
	string s;
	cin >> n >> s;

	dp[1][0] = 1;
	for (int i = 1; i <= n; ++i)
		for (int g = 0; g < n; ++g)
		{
			add(dp[i][g], g ? dp[i][g-1] : 0);
			add(dp[i+1][g*(s[i-1]=='>')], dp[i][g]);
			add(dp[i+1][g+(n-i-g)*(s[i-1]=='>')], mod-dp[i][g]);
		}

	cout << dp[n][0] << "\n";

	return 0;
}


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

typedef long long ll;

int main()
{
	string s;
	cin >> s;
	int len = (int)s.size();

	ll sum = 0;

	for (int i = 0; i < (1<<(len-1)); i++){
		int bit = 1;
		ll tmp = 0;
		int radix = 1;
		tmp = (s[0]-'0');
		for (int j = 0; j < (len-1); j++){
			if (bit << j & i){
				sum += tmp;
				tmp = (s[j+1]-'0');
			}
			else {
				tmp *= 10;
				tmp += (s[j+1]-'0');
			}
		}
		sum += tmp;
	}
	cout << sum << endl;

}


Measured memory_bytes: 256
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int h, n; cin >> h >> n;
	vector<pair<int, int>> c(n);
	rep(i, n)
	{
		int a, b; cin >> a >> b;
		c[i] = { a,b };
	}
	sort(all(c));
	int INF = 1e9;
	vector<int> dp(100100, INF);
	dp[0] = 0;
	rep(i, n)rep(j, h)
	{
		int a = c[i].first;
		int b = c[i].second;
		dp[j + a] = min(dp[j + a], dp[j] + b);
	}
	int res = INF;
	for (int i = h; i < 30000; ++i)res = min(res, dp[i]);
	cout << res << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	vector<int> a;
	for(int i=0;i<n;i++)
	{
		int q;
		cin>>q;
		a.push_back(q);
	}
	vector<int> b=a;
	sort(b.begin(),b.end());
	int t=0;
	for(int i=0;i<n-1;i++)
	{
		if(a[i]!=(i+1))
		{
			t++;
		}
	}
	if(t>2)
	{
		cout<<"NO"<<endl;
	}
	else
	{
		cout<<"YES"<<endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
using namespace std;

int main(){
    int N,K,ans=0;cin>>N>>K;
    deque<int> dq(60);
    int v;
    for(int i=0;i<N;i++){
        cin>>v;
        dq[i]=v;
    }

    int M=min(K,2*N);
    for(int k=0;k<=M;k++){
        int l=min(k,N);
        int i=l,j=k-l;
        while(i>=j){
            priority_queue<int> pq;
            for(int x=0;x<=i;x++){
                int sum=0;
                int y=0;
                while(y<=x-1){
                    pq.push(-dq[y]);
                    sum+=dq[y];
                    y++;
                }
                int z=N-1,count=0;
                while(count<i-x){
                    pq.push(-dq[z]);
                    sum+=dq[z];
                    z--;
                    count++;
                }
                for(int w=1;w<=j;w++){
                    sum+=pq.top();
                    pq.pop();
                }
                ans=max(ans,sum);
                while(!pq.empty())
                    pq.pop();
            }
            i--;
            j++;
        }
    }
    cout<<ans<<endl;
    return 0;   

}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace Line
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var A = cin.ReadInt;
            var B = cin.ReadInt;
            var ans = 0;
            for (int i = 1; i <= N; ++i)
            {
                var sum = 0;
                foreach (var c in i.ToString())
                    sum += (int)(c - '0');
                if (A <= sum && sum <= B)
                    ans += i;
            }
            WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
int main()
{
    Hello
    int a, b;
    cin >> a >> b;
    for(int i = 1; i <= 1e6; i++)
    {
        int aa = i * 0.08;
        int bb = i * 0.1;
        if(aa == a && bb == b)
        {
            cout << i;
            return 0;
        }
    }
    cout << -1;
    return 0;
}


Measured memory_bytes: 256
#queue
n,q=(int(i) for i in input().split())
nl=[]
t=[]
et=0
for i in range(n):
    na,ti=(j for j in input().split())
 #   print(t)
    nl.append(na)
    t.append(int(ti))
i=0
while len(nl)>0:
    t[i]-=q
    et+=q
 #   print(t)
    if t[i]<=0:
        et+=t[i]
        print(nl[i]+" "+str(et))
        nl.pop(i)
        t.pop(i)
        i-=1
    i+=1
    if i>=len(nl):
        i=0

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

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

#define SORT(v, n) sort(v, v + n);
// #define SORT(v, n) stable_sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(5);

    int a, b;
    cin >> a >> b;

    int c;
    c = max({a + b, a - b, a * b});

    cout << c << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long 
using namespace std;
LL n,sum[110][6],W,w[6],cnt=1,c1=0,c2=0,c3=0,c4=0;
LL res=0,ans=0;
struct Node{
	int w,v;
}a[110];
bool cmp(Node x,Node y){
	if(x.w<y.w) return true;
	if(x.w==y.w&&x.v>y.v) return true;
	return false;
}
LL getsum(int i,int j,int k,int l){
	return (sum[i][1]+sum[j][2]+sum[k][3]+sum[l][4]);
}
int main(){
	cin>>n>>W;
	for(int i=1;i<=n;i++){
		cin>>a[i].w>>a[i].v;
	}
	sort(a+1,a+1+n,cmp);
	w[cnt]=a[1].w;
	for(int i=1;i<=n;i++){
		if(a[i].w!=w[cnt])
		w[++cnt]=a[i].w;
	}
	for(int i=1;i<=n;i++){
		if(a[i].w==w[1]){
			sum[++c1][1]=sum[c1-1][1]+a[i].v;
		}
		else if(a[i].w==w[2]){
			sum[++c2][2]=sum[c2-1][2]+a[i].v;
		}
		else if(a[i].w==w[3]){
			sum[++c3][3]=sum[c3-1][3]+a[i].v;
		}
		else 
			sum[++c4][4]=sum[c4-1][4]+a[i].v;
	}
	for(int i=c1+1;i<=n;i++){
		sum[i][1]=sum[i-1][1];
	}
	for(int i=c2+1;i<=n;i++){
		sum[i][2]=sum[i-1][2];
	}
	for(int i=c3+1;i<=n;i++){
		sum[i][3]=sum[i-1][3];
	}
	for(int i=c4+1;i<=n;i++){
		sum[i][4]=sum[i-1][4];
	}
	LL k,m;
	LL tem=(W/w[1])+1;
	m=min(n,tem);
	for(int i=0;i<=m;i++){
		for(int j=0;i+j<=m;j++)
			for(int k=0;i+j+k<=m;k++){
				res=i*w[1]+j*w[2]+k*w[3];
				if(res>W) continue;
				else if(res<=W){
					int l=0;
					if(w[4]!=0) l=(W-res)/w[4];
					ans=max(ans,getsum(i,j,k,l));
				}
			}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
/*

    author : s@if

*/

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define 		NIL 			-1
#define		 	fi	 		    first
#define 		sec 			second
#define 		MAX 			INT_MAX
#define			INF 			1e9
#define 		ll 			    long long
#define 		PI 			    acos(-1.0)
#define			MOD 			1000000007
#define 		PLL 			pair<ll,ll>
#define 		PII			    pair<int,int>
#define 		ull 			unsigned long long
#define 		For(i,a,b) 		for(int i=a;i<=(int)b;i++)
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> new_data_set;

//*find_by_order(k)  gives the kth element;
//order_of_key(item)   gives the index(number of element strictly less than item) of item;


inline int in() {int x; scanf("%d", &x); return x; }
bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};    // King's move
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hx[]={-2,-2,-1,+1,+2,+2,-1,+1};    // Knight's move
int hy[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)2e5+9;


int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */

    int i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

    char c;
    cin>>c;
    if(c>='A' && c<='Z') cout<<"A"<<endl;
    else cout<<"a\n";

    return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)


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

typedef long long ll;

ll N, K;
set<pair<ll, ll>> AccIs;
ll BitMax;
vector<ll> Bit;
ll R;

void init() { Bit.resize(BitMax + 1); }
void add(ll i) {
  ++i;
  for (; i <= BitMax; i += (i & -i)) ++Bit[i];
}
ll sum(ll i) {
  ++i;
  ll res = 0;
  for (; i >= 1; i -= (i & -i)) res += Bit[i];
  return res;
}
int main() {
  cin >> N >> K;
  ll acc = 0;
  AccIs.insert(make_pair(0, 0));
  for (ll i = 0; i < N; ++i) {
    ll a;
    cin >> a;
    a -= K;
    acc += a;
    AccIs.insert(make_pair(acc, i + 1));
  }
  BitMax = N + 1;
  init();
  for (auto acci : AccIs) {
    ll i = acci.second;
    R += sum(i);
    add(i);
  }
  cout << R << endl;
  return 0;
}


Measured memory_bytes: 14336
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::prelude::BufRead;
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufReader, BufWriter, Write};
#[allow(unused_imports)]
use std::mem::swap;
#[allow(unused_imports)]
use std::str::FromStr;

fn main() {
    let n = read::<usize>();
    let mut arr = read_vector::<usize>().into_iter().map(|x| x - 1).collect::<Vec<_>>();
    let mut diff = (0..n).map(|i| i - arr[i]).collect::<Vec<_>>();
    let mut operations = vec![];
    for _ in 0..n {
        let mut index = diff.len();
        for j in (0..diff.len()).rev() {
            if diff[j] == 0 {
                index = j;
                break;
            }
        }
        if index == diff.len() {
            println!("-1");
            return;
        }
        operations.push(index + 1);
        arr.remove(index);
        diff.remove(index);
        for i in index..arr.len() {
            diff[i] -= 1;
        }
    }

    for &num in operations.iter().rev() {
        println!("{}", num);
    }
}

#[allow(dead_code)]
fn read<T>() -> T
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    return buf.trim().parse().unwrap();
}

#[allow(dead_code)]
fn read_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::with_capacity(100);
    stdin().read_line(&mut buf).unwrap();
    return buf.split_whitespace().map(|s| s.parse().unwrap()).collect();
}

#[allow(dead_code)]
fn read_matrix<T>() -> Vec<Vec<T>>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    use std::io::prelude::*;
    let stdin = stdin();
    let mut reader = BufReader::with_capacity(100 * 1024, stdin);
    let mut line = String::with_capacity(100);
    let mut matrix: Vec<Vec<T>> = Vec::new();

    while reader.read_line(&mut line).unwrap() > 0 {
        matrix.push(
            line.trim()
                .split_whitespace()
                .map(|s| s.parse().unwrap())
                .collect(),
        );
        line.clear();
    }

    return matrix;
}

#[allow(dead_code)]
fn read_chars() -> Vec<char> {
    let stdin = stdin();
    let mut buf = String::new();
    let _bytes = stdin.read_line(&mut buf).unwrap();
    return buf.trim().chars().collect();
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0; i<n; i++)
int main()
{
	ll mod = 1000000007;
	ll ans = 0;
	ll N,inp,sum,zizyo;
	sum = 0;
	cin >> N;
	rep(i,N){
		cin >> inp;
		ans = (ans + sum*inp)%mod;
		sum = (sum + inp)%mod;
	}

	cout << ans;
	cin >> N;
	
	return 0;	
}


Measured memory_bytes: 3620
/*
  AUTHOR:SOURABH
  CREATED:10:01:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<ll , null_type, less< ll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 1000000007
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

string s[20];
bool vis[20][20];
ll sum[20][20];
ll n,m,x1,yy,x2,y2;

void bfs(ll x1,ll yy)
{
    ll i,j;
    vis[x1][yy]=1;
    queue<pll> q;
    q.push({x1,yy});
    pll p;
    W(!q.empty())
    {
        p=q.front();
        q.pop();
        i=p.fi;
        j=p.se;
        if(i+1<n && s[i+1][j]=='.' && !vis[i+1][j])
        {sum[i+1][j]=sum[i][j]+1;vis[i+1][j]=1;q.push({i+1,j});}
        if(j+1<m && s[i][j+1]=='.' && !vis[i][j+1])
        {sum[i][j+1]=sum[i][j]+1;vis[i][j+1]=1;q.push({i,j+1});}
        if(i-1>=0 && s[i-1][j]=='.' && !vis[i-1][j])
        {sum[i-1][j]=sum[i][j]+1;vis[i-1][j]=1;q.push({i-1,j});}
        if(j-1>=0 && s[i][j-1]=='.' && !vis[i][j-1])
        {sum[i][j-1]=sum[i][j]+1;vis[i][j-1]=1;q.push({i,j-1});}

    }
    return;
}

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

    //freopen("in.txt","r",stdin);
    //freopen(2 "out.txt","w",stdout);

    ll k,i,j,ma,o;
    cin>>n>>m;
    vector<pll> ans;
    fn(i,n)
    {
        cin>>s[i];
        fn(j,m)
        {
            if(s[i][j]=='.')
            ans.pb({i,j});
        }
    }
    k=ans.size();
    ma=0;
    fn(i,k)
    {
        x1=ans[i].fi;
        yy=ans[i].se;
        memset(vis,0,sizeof(vis));
        memset(sum,0,sizeof(sum));
        bfs(x1,yy);
        fs(j,i+1,k)
        {
            x2=ans[j].fi;
            y2=ans[j].se;
            ma=max(ma,sum[x2][y2]);
        }
    }
    cout<<ma;
    return 0;
}









Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//void p(vector<int> A){rep(i,A.size()){cout << A[i] << " ";}cout << "\n";}

int main(){
    int n,k,x,y;
    cin >> n >> k >> x >> y;
    if(n <= k)cout << x*n;
    else cout << x*k+y*(n-k);
}

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

// グラフを隣接行列で管理する
bool G[10][10];

int main() {
    int N, M; cin >> N >> M;
    for (int i = 0; i < M; ++i) {
        int a, b; cin >> a >> b; --a, --b;
        G[a][b] = G[b][a] = true;
    }

    // 順列
    vector<int> ord(N);
    for (int i = 0; i < N; ++i) ord[i] = i;

    // 順列を全部試すa
    int res = 0;
    do {
        if (ord[0] != 0) break;

        bool ok = true;
        for (int i = 0; i + 1 < N; ++i) {
            int from = ord[i];
            int to = ord[i+1];
            if (!G[from][to]) ok = false;
        }
        if (ok) ++res;
    } while (next_permutation(ord.begin(), ord.end()));

    cout << res << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cmath>
#include<iomanip>
using namespace std;
int main(){
  long double x1,y1,x2,y2;
  cout<<fixed<<setprecision(12);
  cin >> x1 >> y1 >> x2 >> y2 ;
  cout << (sqrtl((x1-x2) * (x1-x2) + (y1-y2)*(y1-y2) )) << endl;
  return 0;
}



Measured memory_bytes: 3256
using System;

namespace _0512
{
    class Program
    {
        static void Main(string[] args)
        {
            //     string[] a = new string { "a" };
            string str = Console.ReadLine();

            for (int i = 0; i < str.Length; i++)
            {
                string a = str.Substring(i, 1);
                if (a == " ") { Console.Write(" "); }
                else if (a == ".") { Console.Write("."); }
                else if (str.Substring(i, 1) == "a") { Console.Write("A"); }
                else if (str.Substring(i, 1) == "b") { Console.Write("B"); }
                else if (a == "c") { Console.Write("C"); }
                else if (a == "d") { Console.Write("D"); }
                if (a == "e") { Console.Write("E"); }
                else
                if (a == "f") { Console.Write("F"); }
                else if (a == "g")
                {
                    Console.Write("G");
                }

                else if (a == "h") { Console.Write("H"); }

                else if (a == "i") { Console.Write("I"); }
                else if (a == "j") { Console.Write("J"); }
                else if (a == "k") { Console.Write("K"); }
                else if (a == "l") { Console.Write("L"); }
                else if (a == "m") { Console.Write("M"); }
                else if (a == "n") { Console.Write("N"); }
                else if (a == "o") { Console.Write("O"); }
                else if (a == "p") { Console.Write("P"); }
                else if (a == "q") { Console.Write("Q"); }
                else if (a == "r") { Console.Write("R"); }
                else if (a == "s") { Console.Write("S"); }

                else if (a == "t")
                {
                    Console.Write("T");
                }

                else if (a == "u") { Console.Write("U"); }
            
                else if (a == "v") { Console.Write("V"); }

                else if (a == "w") { Console.Write("W"); }

                else if (a == "x") { Console.Write("X"); }

                else if (a == "y") { Console.Write("Y"); }

                else if (a == "z") { Console.Write("Z"); }
                if (i == str.Length - 1) { Console.WriteLine(); }

            }
            Console.ReadLine();
        }

    }

}

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

void yo(string s) 
{ 

	// Finding the length of the string 
	int n = s.length(); 

	// To store the number of replacement operations 
	int cc = 0; 

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

		// If the characters at location 
		// i and n-i-1 are same then 
		// no change is required 
		if(s[i]== s[n-i-1]) 
			continue; 

		// Counting one change operation 
		cc+= 1; 

		// Changing the character with higher 
		// ascii value with lower ascii value 
		if(s[i]<s[n-i-1]) 
			s[n-i-1]= s[i] ; 
		else
			s[i]= s[n-i-1] ; 
	} 
	cout<<cc<<endl; 
} 
 
int main() 
{ 
	string s;
	cin>>s;
	yo((s)); 
	return 0; 
} 
//contributed by Arnab Kundu 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int a,b;
  cin>>a>>b;
  Yes((a*b)%2);


}

Measured memory_bytes: 256
import java.util.*

val sc = Scanner(System.`in`)
val D = sc.nextInt()
val N = sc.nextInt()

fun main(args: Array<String>) {
    println((N + if (N == 100) 1 else 0) * pow(100, D))
}

fun pow(a: Int, n: Int): Int {
    var result = 1
    repeat(n) {
        result *= a
    }
    return result
}


Measured memory_bytes: 31264
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

struct Unionfind {
	vector<int> UF;

	Unionfind(int n){
		UF = vector<int>(n, -1);
	}

	int root(int x) {
		if (UF[x] < 0) 
			return x;
		return root(UF[x]);
	}

	bool unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (UF[x] > UF[y]) swap(x, y); //UF[y]の方が大きい(UF[x]の方が要数数が多い)
		UF[x] += UF[y]; //要素数を足す
		UF[y] = x; //yをxに繋ぐ
		return true;
	}

	int sizeofmax(int n) {
		int max=-1;
		rep(i, n) {
			if (UF[i] < max)
				max = UF[i];
		}
		return -max;
	}
};

int main() {
	int n, m;
	cin >> n >> m;
	
	Unionfind UF(n);
	rep(i, m) {
		int A, B;
		cin >> A >> B;
		A--; B--;
		UF.unite(A, B);
	}
	
	cout << UF.sizeofmax(n) << endl;

	return 0;
}

Measured memory_bytes: 4028
#include <iostream>

using namespace std;

int main()
{
	int A, B, C;
	int ans = 0;
	cin >> A >> B >> C;

	// すべて偶数
	while ((A % 2) + (B % 2) + (C % 2) == 0)
	{
		if (A == B && B == C)
		{
			ans = -1;
			break;
		}
	
		int Atmp = A;
		int Btmp = B;
		int Ctmp = C;
		A = (Btmp + Ctmp) / 2;
		B = (Atmp + Ctmp) / 2;
		C = (Atmp + Btmp) / 2;
		ans++;
	}
	
	cout << ans << endl;

	return 0;
}


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

te = ['r', 's', 'p']

def win(s):
	if s == 'r':
		return 2
	elif s == 's':
		return 0
	else:
		return 1

taka = []
cnt = 0

for i in range(n):
	winner = win(t[i])
	if i < k:
		taka.append(te[winner])
		cnt += rsp[winner]
	else:
		if taka[i-k] == te[winner]:
			if i < n-k:
				next = win(t[i+k])
				can = ['r', 's', 'p']
				del can[winner]
				if te[next] in can:
					for j in range(len(can)):
						if can[j] != te[next]:
							taka.append(can[j])
				else:
					taka.append(can[0])
			else:
				can = ['r', 's', 'p']
				del can[winner]
				taka.append(can[0])
		else:
			taka.append(te[winner])
			cnt += rsp[winner]
print(cnt)



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


int main(void) {
    int N;
    cin >> N;
    vector<int> ary(N);
    rep(i,N) cin >> ary[i];
    int ans = 0;
    rep(i,N)rep(j,N)rep(k,N){
        if (i < j && j < k) {
            if (ary[i] == ary[j]) continue;
            if (ary[i] == ary[k]) continue;
            if (ary[k] == ary[j]) continue;
            if ((ll)ary[i] + ary[j] + ary[k]  <= max({ary[i],ary[j],ary[k]}) * 2) continue;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
typedef pair<int,int> P;
typedef pair<P,int> PP;

char C( int k) {
  if(k==0) return 'N';
  else if(k==1) return 'E';
  else if(k==2) return 'S';
  return 'W';
}
int main() {
  long long n,m,l;
  while(cin >> n >> m >> l && n) {
    string s[n];
    int nx,ny,k;
    for(int i=0; i<n; i++) {
      cin >> s[i];
      for(int j=0; j<m; j++) {
        if(isalpha(s[i][j])) {
          nx=i,ny=j;
          if(s[i][j]=='N') k=0;
          else if(s[i][j]=='E') k=1;
          else if(s[i][j]=='S') k=2;
          else k=3;
        }
      }
    }
    int d[n][m][4],c=0;
    memset(d,-1,sizeof(d));
    d[nx][ny][k]=0;
    vector<PP> v;
    v.push_back(PP(P(nx,ny),k));
    while(l) {
      int x=nx+dx[k],y=ny+dy[k];
      if(!check(n,m,x,y)||s[x][y]=='#') {
        k=(k+1)%4;
        continue;
      }
      l--;
      c++;
      if(!l) cout << x+1 << " " << y+1 << " " << C(k) << endl;
      else if(d[x][y][k]==-1) {
        v.push_back(PP(P(x,y),k));
        d[x][y][k]=c;
        nx=x,ny=y;
      } else {
        long long t=c-d[x][y][k];
        PP p=v[d[x][y][k]+l%t];
        cout << p.first.first+1 << " " << p.first.second+1 << " " << C(p.second) << endl;
        break;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 1536
#include <cstdio>
#include <vector>
#include <algorithm>
#include <array>
#include <set>
#include <map>
#include <queue>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <cassert>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < int(n); ++(i))
#define whole(x) begin(x), end(x)
using namespace std;

struct disjoint_sets {
    vector<int> data;
    disjoint_sets() = default;
    explicit disjoint_sets(size_t n) : data(n, -1) {}
    bool is_root(int i) { return data[i] < 0; }
    int find_root(int i) { return is_root(i) ? i : (data[i] = find_root(data[i])); }
    int set_size(int i) { return - data[find_root(i)]; }
    int unite_sets(int i, int j) {
        i = find_root(i); j = find_root(j);
        if (i != j) {
            if (set_size(i) < set_size(j)) swap(i,j);
            data[i] += data[j];
            data[j] = i;
        }
        return i;
    }
    bool is_same(int i, int j) { return find_root(i) == find_root(j); }
};

struct edge_t { int a, b, w; };
constexpr int inf = 1e9+7;
int main() {
    while (true) {
        // input
        int n, m; scanf("%d%d", &n, &m);
        if (n == 0 and m == 0) break;
        vector<edge_t> e(m);
        repeat (i, m) {
            scanf("%d%d%d", &e[i].a, &e[i].b, &e[i].w);
            -- e[i].a;
            -- e[i].b;
        }
        // solve
        sort(whole(e), [](edge_t const & e, edge_t const & f) { return e.w < f.w; });
        int result = inf;
        for (int l = 0; l < m; ) {
            // Kruskal's method
            int cnt = 0;
            disjoint_sets ds(n);
            repeat_from (i, l, m) {
                if (e[i].w - e[l].w >= result) break;
                if (ds.is_same(e[i].a, e[i].b)) continue;
                ds.unite_sets(e[i].a, e[i].b);
                cnt += 1;
                if (cnt == n - 1) {
                    result = e[i].w - e[l].w;
                    break;
                }
            }
            // update
            int r = l;
            while (r < m and e[r].w == e[l].w) ++ r;
            l = r;
        }
        // output
        printf("%d\n", result == inf ? -1 : result);
    }
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<string> S(N);
    vector<int> T(N);
    int sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> S[i] >> T[i];
        sum += T[i];
    }
    string X;
    cin >> X;

    int listened = 0;
    for (int i = 0; i < N; i++) {
        listened += T[i];
        if (S[i] == X) {
            break;
        }
    }

    cout << sum - listened << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
 
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

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

long long lcm(long long a, long long b) {
    return a / gcd(a,b) * b;
}

int main() {

	ll N; cin >> N;

	if (N == 3) {
		cout << "2 5 63" << endl;
		return 0;
	}

	if (N == 4) {
		cout << "2 5 20 63" << endl;
		return 0;
	}

	set < ll > used;
	for (int i = 1; i <= 30000; i++) {
		if (i % 3 == 1) {
			i++;
		}
		used.insert((ll)i);
	}

	vector < ll > ans;
	ll sum = 0;
	for (ll i = 3; ; i += 3) {
		if (i % 2 != 0) {
			sum++;
			ans.push_back(i);
			N--;
			if (N <= 15000 && sum % 2 == 0 && sum > 0 && used.find(N) != used.end()) break;
		}
	}
	
	ll acc = 2;
	while (N > 0) {
		ans.push_back(acc);
		N--;
		acc += 2;
	}

	REP(i,ans.size()) {
		cout << ans[i] << " ";
	}

	cout << endl;


	return 0;
}



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


def solve(a: int, b: int, c: int, d: int):
    ans1=a*c
    ans2=a*d
    ans3=b*c
    ans4=b*d
    print(max(ans1,ans2,ans3,ans4))
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    c = int(next(tokens))  # type: int
    d = int(next(tokens))  # type: int
    solve(a, b, c, d)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9196
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";

ll MOD = 1e9+7;
ll powMod(ll a, ll b) { // a^b mod M
    ll ans = 1; ll temp = a;
    while (b > 0) {
        if ( b % 2 == 1 ) ans = (ans * temp) % MOD;
        temp = (temp * temp) % MOD;
        b = b / 2;
    }
    return ans;
}
ll nCkMod(ll n, ll k) { // nCk mod M
    ll ans = 1, temp = 1, mink = min(k, n-k);
    for (ll i = 0; i < mink; i++) {
        ans = (ans * (n - i)) % MOD;
    }
    for (ll i = 0; i < mink; i++) {
        temp = (temp * (i + 1)) % MOD;
    }
    return (ans * powMod(temp, MOD - 2)) % MOD;
}


int main() {

    CIN(ll, N);
    CIN(ll, M);
    CIN(ll, K);
    ll ans;

    ans = ( ( M * M * N * (N-1) * (N+1) + N * N * M * (M-1) * (M+1) ) / 6 ) % MOD;
    ans = ( ans * nCkMod( N * M - 2, K - 2)) % MOD;

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int const INF = 1001001001;

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

int n;
cin >> n;

int cnt[10][10] = {};

ostringstream oss;
rrep(k,n){
    string s;
    oss.str(""); 
    oss << k << flush;
    s = oss.str();
    cnt[s.front()-'0'][s.back()-'0']++; //『末尾がaで先頭がb』の個数をcountする
}

int ans = 0;

rrep(i,9) rrep(j,9){
    ans += cnt[i][j]*cnt[j][i];
}

cout << ans << endl;


return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (1LL << 55)
#define MOD (1000LL * 1000 * 1000 + 7)
#define maxn 200111

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

vector<pll> adj[maxn];
ll dps[maxn], dpt[maxn], froms[maxn], fromt[maxn];
ll n, m, s, t;

void dijkstra(ll start, ll d[], ll dp[]){
	for(int i = 1; i <= n; i++){
		d[i] = INF;
		dp[i] = 0;
	}

	priority_queue<pll> pq;
	d[start] = 0;
	dp[start] = 1;
	pq.push(mp(0, start));
	while(!pq.empty()){
		ll x = pq.top().se;
		ll val = -pq.top().fi;
		pq.pop();

		if(val > d[x])
			continue;

		for(auto i : adj[x]){
			ll v = i.fi;
			ll cost = i.se;

			if(d[v] > d[x] + cost){
				d[v] = d[x] + cost;
				dp[v] = dp[x];
				pq.push(mp(-d[v], v));
				continue;
			}
			if(d[v] == d[x] + cost)
				dp[v] = (dp[v] + dp[x]) % MOD;
		}
	}

}

int main(){
	scanf("%lld%lld%lld%lld", &n, &m, &s, &t);
	for(int i = 0; i < m; i++){
		ll a, b, c;
		scanf("%lld%lld%lld", &a, &b, &c);
		adj[a].pb(mp(b, c));
		adj[b].pb(mp(a, c));
	}

	dijkstra(s, froms, dps);
	dijkstra(t, fromt, dpt);


	ll shortest_path = froms[t];
	ll all = (dps[t] * dps[t]) % MOD; // number of all shortest paths
	ll snode = 0;	// shortest paths that intersect at node
	ll sedge = 0; 	// shortest paths that intersect at edge
	
	for(ll i = 1LL; i <= n; i++){
		if(froms[i] == fromt[i] && froms[i] + fromt[i] == shortest_path)
			snode = (snode + dps[i] * dps[i] % MOD * dpt[i] % MOD * dpt[i] % MOD) % MOD;

		for(auto j : adj[i]){
			ll v = j.fi;
			ll cost = j.se;

			if(2 * froms[i] < shortest_path && 2 * fromt[v] < shortest_path && froms[i] + fromt[v] + cost == shortest_path)
				sedge = (sedge + dps[i] * dps[i] % MOD * dpt[v] % MOD * dpt[v] % MOD) % MOD;
		}
	}

	printf("%lld\n", (all - snode - sedge + 3 * MOD) % MOD);	
	return 0;
}

Measured memory_bytes: 23508
n = int(input())
ok = False
renzoku = 0
for i in range(n):
    d1,d2 = map(int,input().split())
    if d1 == d2:
        renzoku += 1
    else:
        renzoku = 0
    if renzoku == 3:
        ok = True
if ok:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 62332
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#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)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,q;
    cin >> n >> q;
    vvint nei(n);
    REP(i,n-1){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        nei[a].pb(b);
        nei[b].pb(a);
    }
    vll wei(n);
    REP(i,q){
        int p;
        ll x;
        cin >> p >> x;
        p--;
        wei[p]+=x;
    } 
    stack<pair<int,int> > st;
    st.push(make_pair(0,n));
    while((int)st.size()>0){
        auto p = st.top();
        st.pop();
        for(int i : nei[p.fi]){
            if(i!=p.se){
                wei[i]+=wei[p.fi];
                st.push(make_pair(i,p.fi));
            }
        }
    }
    REP(i,n){
        cout << wei[i] << ((i==n-1)?"\n":" ");
    }
    return 0;
}

Measured memory_bytes: 17140