akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
#include <assert.h>   
#include <vector>
#include <algorithm>
#include <time.h>
#include <numeric>
#include <string>
#include <cstring>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <numeric>
#include <deque>
#include <iomanip>
#include <cstdlib>
#include <climits>
#include <cmath>
#include <cstdio>
using namespace std;


//#define double long double
//#define int long long
//#define int unsigned long long

#define ll long long
#define ld long double 
#define pi pair<int, int> 
#define pl pair<ll,ll>  
#define pd pair<ld,ld> 
#define str string  
#define mp make_pair
#define vi vector<int> 
#define vl vector<ll> 
#define vd vector<ld> 
#define vs vector<str> 
#define vpi vector<pi> 
#define vpl vector<pl> 
#define vpd vector<pd> 
#define si set<int> 
#define FF(i,j,n) for(signed i=j;i<=n;i++)  
#define DD(i,j,n) for(signed i=j;i>=n;i--) 
#define F(i,j,n) for(signed i=j;i<n;i++)   
#define D(i,j,n) for(signed i=j;i>n;i--) 
#define mem(a,b) memset(a,b,sizeof(a))
#define ndl cout << endl
#define ull unsigned long long 

const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;


#define sz(x) (signed)x.size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() 
#define rsz resize
#define ins insert 
#define ft front() 
#define bk back() 
#define fi first
#define se second
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define lb lower_bound 
#define ub upper_bound 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

//math


const int mod = 1e9 + 7;

ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int pct(int x) { return __builtin_popcount(x); } 
int bit(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) 
int cdiv(int a, int b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0 


//DEBUG, compile with -DLOCAL
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
  cerr << to_string(h); if (sizeof...(t)) cerr << ", ";
  DBG(t...); }
#ifdef LOCAL 
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#define HERE cout << "===GOTHERE===" << endl
#else
#define dbg(...) 42
#define HERE 42
#endif


 /* ============== END OF HEADER ============== */





const int maxn = 1e5*3+20;

int n,_,q,k;

void solve(){
	int a,b,h,m;
	cin >> a >> b >> h >> m;
	double res;
	double md = (double)m/60 * 360.0;
	double hd = 30.0*h + 30.0 * ((double)m/60.0);
	double ang = abs(md - hd);
	res = sqrt(a*a + b*b - 2*a*b*cos(ang*M_PI/180.0));

	cout << fixed << setprecision(13) << res << endl;
}

signed main(){
  //clock_t t1 = clock();  
	IOS
	solve();
  
  //cout << "THE ALGORITHM TOOK: " << (clock() - t1) * 1.0 / CLOCKS_PER_SEC * 1000 << "ms"<< endl;
	return 0;
}

Measured memory_bytes: 4160
#include <iostream>
using namespace std;
struct node{int p,l,r;};
#define MAX 100002
#define NIL -1
node T[MAX];
int D[MAX];
void setDepth(int u,int p)
{
    D[u]=p;
    if(T[u].l!=NIL)
        setDepth(T[u].l,p+1);
    if(T[u].r!=NIL)
        setDepth(T[u].r,p);
}
void print(int i)
{
    cout<<"node "<<i<<": parent = ";
    cout<<T[i].p<<", depth = ";
    cout<<D[i]<<", ";
    if(T[i].p==NIL)
        cout<<"root, [";
    else if(T[i].l==NIL)
        cout<<"leaf, [";
    else
        cout<<"internal node, [";
    for(int j=0,c=T[i].l;c!=NIL;j++,c=T[c].r)
    {
        if(j)
            cout<<", ";
        cout<<c;
    }
    cout<<"]"<<endl;
}
int main()
{
    int t,temp,root;
    cin>>t;
    for(int i=0;i<t;i++)
        T[i].p=T[i].l=T[i].r=NIL;

    for(int j=0;j<t;j++)
    {
        int idx,n;
        cin>>idx>>n;
        for(int i=0;i<n;i++)
        {
            int x;
            cin>>x;
            if(i==0)
                T[idx].l=x;
            else
                T[temp].r=x;
            temp=x;
            T[x].p=idx;
        }
    }
    for(int i=0;i<t;i++)
        if(T[i].p==NIL)
        {
            root=i;
            break;
        }
    setDepth(root,0);
    for(int i=0;i<t;i++)
        print(i);
    return 0;
}



Measured memory_bytes: 4644
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct edge
{
	char a[120];
	int x;
};
int main(void)
{
	int n, l, i, j;
	edge s[300];
	scanf("%d %d", &n, &l);
	for(i = 0; i < n; i++)
	{
		scanf("%s", s[i].a);
	}
	edge r;
	for(i = 0; i < (n-1); i++)
	{
		for(j = (i+1); j < n; j++)
		{
			if(strcmp(s[i].a, s[j].a) > 0)
			{
				r = s[i];
				s[i] = s[j];
				s[j] = r;
			}
		}
	}
	for(i = 0; i < n; i++)
	{
		printf("%s", s[i].a);
	}
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>

const int MAXN = 1E5 + 10;

int n, T;
int a[MAXN];

int main(){
	scanf("%d%d", &n, &T);
	scanf("%d", &a[0]);
	int val = a[0], diff = 0, cnt = 0;
	for (int i = 1; i < n; ++i){
		scanf("%d", &a[i]);
		if (diff < a[i] - val)
			diff = a[i] - val, cnt = 1;
		else if (diff == a[i] - val)
			++cnt;
		if (a[i] < val)
			val = a[i];
	}
	printf("%d\n", cnt);
	return 0;
}


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

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;


void solve(){
#ifdef _WIN32
	istream &cin = ifstream("input.txt");
#endif
	int n, k, x, y;
	cin >> n >> k >> x >> y;

	int ans = min(k, n) * x + max(0, n - k) * y;


	cout << ans << endl;
}


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


	solve();
	//system("PAUSE");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef long long ll;
typedef int keytype;

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

/* a[0], ..., a[n-1] の数の最大公約数 */
int ngcd(int n, int a[])
{
    int i, d;

    d = a[0];
    for (i = 1; i < n && d != 1; i++)
        d = gcd(a[i], d);
    return d;
}

void quicksort(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int is_prime(int x){
    if(x <= 1) return 0;
    for(int i = 2; i * i <= x; i++){
        if(x % i == 0) return 0;
    }
    return 1;
}

int is_substr(char s[], char t[], int i){
    int flag = 1;

    if(s[i] == '\0') flag = 0;

    for(int j = 0; j < strlen(t); ++j, ++i){
        if(s[i] != t[j]){
            flag = 0;
            break;
        }
    }
    return flag;
}

// factor list, number of factors, natural number
void factorize(int ftr[], int *num, int n){
    int a = 2, cnt = 0;

    while(n >= a){
        if(n % a == 0){
            n = n / a;
            ftr[cnt++] = a;
        }else{
            a++;
        }
    }
    *num = cnt;
}

//#define N 5
//int p[N + 1];
int nextperm(int p[], int N)  /* 辞書式順序で次の順列 */
{
    int i, j, t;

    i = N - 1;
    p[0] = 0;  /* 番人 */
    while (p[i] >= p[i + 1]) i--;
    if (i == 0) return 0;  /* 完了 */
    j = N;
    while (p[i] >= p[j]) j--;
    t = p[i];  p[i] = p[j];  p[j] = t;
    i++;  j = N;
    while (i < j) {
        t = p[i];  p[i] = p[j];  p[j] = t;  i++;  j--;
    }
    return 1;  /* 未了 */
}

void comb(int size1, int size2, int v[size1][size2]){
  for(int i = 0; i < size1; i++){
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for(int k = 1; k < size1; k++){
    for(int j = 1; j < k; j++){
      v[k][j] = (v[k-1][j-1] + v[k-1][j]);
    }
  }
}

int abs_val(int a, int b){
    if(a > b) return a - b;
    else return b - a;
}

const int inf = 1012345678;
int main(){
    int a, b;

    scanf("%d %d", &a, &b);

    int ans = b - a;
    if((b % a) == 0) ans = a + b;

    printf("%d\n", ans);

    return 0;
}


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


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = (l);x<=(u);x++)
#define RREP(x,l,u) for(ll x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 100010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

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

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n,X,Y,Z;

int A[maxn],B[maxn],C[maxn],id[maxn];

ll l[maxn],r[maxn],Bas;

priority_queue<int,vector<int>,greater<int> > Q;

bool cmp(int x,int y){
	return A[x]-B[x]<A[y]-B[y];
}

void Work(){
	REP(i,1,n)id[i]=i;
	sort(id+1,id+n+1,cmp);
	REP(x,1,n){
		int i=id[x];
		Q.push(B[i]);l[x]=l[x-1]+B[i];
		if(x>Y){
			l[x]=l[x]-Q.top();
			Q.pop();
		}
	}
	while(!Q.empty())Q.pop();
	RREP(x,n,1){
		int i=id[x];
		Q.push(A[i]);
		r[x]=r[x+1]+A[i];
		if(x<=n-X){
			r[x]=r[x]-Q.top();
			Q.pop();
		}
	}
	ll ans=-1e18;
	REP(i,Y,n-X)ans=max(ans,l[i]+r[i+1]);
	cout<<ans+Bas<<endl;
}

void Init(){
	read(X,Y,Z);n=X+Y+Z;
	REP(i,1,n){
		read(A[i],B[i],C[i]);
		Bas+=C[i];
		A[i]-=C[i];B[i]-=C[i];
	}
}

int main(){
	Init();
	Work();
	return 0;
}


Measured memory_bytes: 3832
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <cstring>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

double dp[301][301][301];
bool visited[301][301][301];
int N;

double rec(int i, int j, int k) {
    if (visited[i][j][k]) return dp[i][j][k];
    visited[i][j][k] = true;
    double ret = N;
    if (i > 0) ret += i * rec(i-1, j, k);
    if (j > 0) ret += j * rec(i+1, j-1, k);
    if (k > 0) ret += k * rec(i, j+1, k-1);
    ret /= i + j + k;
    return dp[i][j][k] = ret;
}

signed main() {
    cin >> N;
    visited[0][0][0] = true;

    int one = 0;
    int two = 0;
    int three = 0;
    int other = 0;
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        switch (a) {
            case 1:
                one++;
                break;
            case 2:
                two++;
                break;
            case 3:
                three++;
                break;
            default:
                other++;
        }
    }

    cout << setprecision(15) << rec(one, two, three) << endl;
}

Measured memory_bytes: 239872
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>
#include <set>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x)
#define PUT(x) printf("%d\n",x)
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = { 0,1,0 };

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };

int main(void) {

	ll x, result = 1;
	cin >> x;

	for (int i = 1; i < 1000; i++) {
		for (int j = 2; j < 10; j++) {
			if (pow(i, j) <= x) CHMAX(result, (ll)pow(i, j));
			else break;
		}
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
using namespace std;
long long a,b,c;
int main()
	{
		cin>>a>>b>>c;
		a=a-b;
		while(a>=0)
			{
				a-=c;
			}
		cout<<a+c<<endl;
		return 0;
	}

Measured memory_bytes: 256
import collections
n = int(raw_input())
count = 0
cc= collections.Counter()
for i in range(1,n + 1):
	j = i
	while(j <= n):
		cc[j] += 1
		j +=i
	if i % 2 and cc[i] == 8 :
		count +=1
print count

Measured memory_bytes: 66792
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if (i==0 || i==H-1 || j==0 || j==W-1) {
                        System.out.printf("#");
                    } else {
                        System.out.printf(".");
                    }
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
        }
    }
}



Measured memory_bytes: 57732
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int ans=0;
    int[][]nums=new int[3][3];
    for(int i=0;i<9;i++){
      nums[i/3][i%3]=sc.nextInt();
    }
    System.out.println(nums[1][0]-nums[0][0]==nums[1][1]-nums[0][1]&&nums[1][1]-nums[0][1]==nums[1][2]-nums[0][2]&&nums[2][0]-nums[1][0]==nums[2][1]-nums[1][1]&&nums[2][1]-nums[1][1]==nums[2][2]-nums[1][2]?"Yes":"No");
  }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define input(a) for(auto &t:a){cin>>t;}
#define maxe(a,b,c) max(a,max(b,c))
#define eb emplace_back
#define em emplace
#define print(x) cout<<x<<endl;
#define fill(a,val) memset(a,val,sizeof(a))
#define in(k) int k;cin>>k
#define edl cout<<"\n"
#define ll  long long
#define ld  long double
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const ll mod=1e9+7;
signed main()
{
    //cout<<fixed<<setprecision(20);
    fastio;
    ld a,b,n;cin>>a>>b>>n;
    if(n>=b)
    {
        double ans=a*(1-(1/b));
        cout<<(ll)ans;
    }
    else
    {
        double ans=a*(n/b);
        cout<<(ll)ans;
    }
    printclock;
    return 0;
}

Measured memory_bytes: 3808
#include <iostream>
#define ll long long
using namespace std;

ll xh[200010], yh[200010];

int main() {
	ll K, X, Y;
	cin >> K >> X >> Y;
	int xf=(X<0 ? -1 : 1), yf=(Y<0 ? -1 : 1);
	X=abs(X), Y=abs(Y);
	if(K%2==0){
		if((X+Y)%2==1){
			cout << -1 << endl;
			return 0;
		}
		else if(X+Y==K){
			cout << 1 << endl;
		}
		else if(X+Y<K){
			ll t=(K-X-Y)/2;
			cout << 2 << endl;
			if(X>Y) cout << (X-K/2+t)*xf << ' ' << (Y+K/2+t)*yf << endl;
			else cout << (X+K/2+t)*xf << ' ' << (Y-K/2+t)*yf << endl;
		}
		else{
			ll ans=(X+Y+K-1)/K;
			ll t=(X+Y)%K;
			if(t==0) t=K;
			ll xnow=0, ynow=0;
			if(X>Y){
				xh[ans-2]=X-(K+t)/2;
				yh[ans-2]=Y+(K-t)/2;
			}
			else{
				xh[ans-2]=X+(K-t)/2;
				yh[ans-2]=Y-(K+t)/2;
			}
			for(ll i=ans-3; i>=0; --i){
				xh[i]=xh[i+1], yh[i]=yh[i+1];
				if(xh[i]>K) xh[i] -= K;
				else yh[i] -= K;
			}
			cout << ans << endl;
			for(ll i=0; i<ans-1; ++i) cout << xh[i]*xf << ' ' << yh[i]*yf << endl;
		}
		cout << X*xf << ' ' << Y*yf << endl;
		return 0;
	}
	if(X+Y==K){
		cout << 1 << endl;
	}
	else if(X+Y<K && (X+Y)%2==0){
		ll t=K-X-Y;
		ll xn, yn;
		if(X>Y){
			xn=X-(K-t)/2;
			yn=Y+(K+t)/2;
		}
		else{
			xn=X+(K+t)/2;
			yn=Y-(K-t)/2;
		}
		cout << 2 << endl;
		cout << xn*xf << ' ' << yn*yf << endl;
	}
	else{
		ll ans=(X+Y+K-1)/K;
		if(X+Y<K){
			ans=3;
			xh[1]=X+K, yh[1]=Y;
			ll t=xh[1]+yh[1]-K;
			xh[0]=xh[1]-(K+t)/2;
			yh[0]=yh[1]+(K-t)/2;
		}
		else{
			ll s=ans-2;
			if(ans%2!=(X+Y)%2){
				++ans;
				if(X>Y){
					xh[ans-2]=X-(K+1)/2;
					yh[ans-2]=Y+(K-1)/2;
				}
				else{
					xh[ans-2]=X+(K-1)/2;
					yh[ans-2]=Y-(K+1)/2;
				}
				ll t=(xh[ans-2]+yh[ans-2])%K;
				if(t==0) t=K;
				if(xh[ans-2]>yh[ans-2]){
					xh[ans-3]=xh[ans-2]-(K+t)/2;
					yh[ans-3]=yh[ans-2]+(K-t)/2;
				}
				else{
					xh[ans-3]=xh[ans-2]+(K-t)/2;
					yh[ans-3]=yh[ans-2]-(K+t)/2;
				}
			}
			else{
				ll t=(X+Y)%K;
				if(t==0) t=K;
				if(X>Y){
					xh[ans-2]=X-(K+t)/2;
					yh[ans-2]=Y+(K-t)/2;
				}
				else{
					xh[ans-2]=X+(K-t)/2;
					yh[ans-2]=Y-(K+t)/2;
				}
			}
			for(ll i=s-1; i>=0; --i){
				xh[i]=xh[i+1], yh[i]=yh[i+1];
				if(xh[i]>K) xh[i] -= K;
				else yh[i] -= K;
			}
		}
		cout << ans << endl;
		for(ll i=0; i<ans-1; ++i) cout << xh[i]*xf << ' ' << yh[i]*yf << endl;
	}
	cout << X*xf << ' ' << Y*yf << endl;
	return 0;
}


Measured memory_bytes: 5248
#include <iostream>
#include <queue>
using namespace std;
int main(){
  int H, W;
  cin >> H >> W;
  string M[H];
  for(int i = 0; i < H; ++i){
    cin >> M[i];
  }
  int s_x, s_y;
  for(int i = 0; i < H; ++i){
    for(int j = 0; j < W; ++j){
      if(M[i][j] == '%'){
	s_x = i;
	s_y = j;
      }
    }
  }
  queue< pair<int,int> > que;
  que.push(make_pair(s_x, s_y));
  vector< vector<int> > D(H, vector<int>(W,-1));
  D[s_x][s_y] = 0;
  int d[] = {1,0,-1,0,1};
  while(!que.empty()){
    int x = que.front().first, y = que.front().second;
    que.pop();
    for(int i = 0; i < 4; ++i){
      int x_next = x + d[i], y_next = y + d[i+1];
      if(x_next >= 0 && x_next < H && y_next >= 0 && y_next < W && M[x_next][y_next] != '#' && D[x_next][y_next] < 0){
	  D[x_next][y_next] = D[x][y] + 1;
	  que.push(make_pair(x_next, y_next));
	}
	}
    }
    int p = 1000000000, s = 1000000000;
    for(int i = 0; i < H; ++i){
      for(int j = 0; j < W; ++j){
	if(M[i][j] == '@')
	  p = D[i][j];
	if(M[i][j] == '$')
	  s = min(D[i][j],s);
      }
    }
    cout << ((p < s) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <iomanip>
using namespace std;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
int main(){
    int n; cin >> n;
    int r;
    int s = INT_MAX,ret = INT_MIN;
    for(int i = 0; i < n; i++){
        cin >> r;
        ret = max(ret,r-s);
        s = min(s,r);
    }
    cout << ret << endl;
}
  




Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
//B - Shiritori
int main(void){
    int n;
    std::cin >> n;
    char last;
    set <string> s;
    bool b=false;
    for (int i = 0; i < n; i++) {
        string c;
        std::cin >> c;
        if(s.find(c)!=s.end() || (i!=0 && c[0]!=last)){
            b=true;
        }else{
            s.insert(c);
        }
        last=c[c.size()-1];
    }
    if(b)
        std::cout << "No" << std::endl;
    else
        std::cout << "Yes" << std::endl;
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int a; cin >> a;
  int ans = a+a*a+a*a*a;
  cout << ans << endl;
  
  return 0;
}


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

const int N = 1e5 + 5;

int pr[N];

void solve() {
  int n, m;
  scanf("%d%d", &n, &m);
  int ans1 = 0;
  int ans2 = 0;
  for (int i = 1; i <= m; ++i) {
    int p;
    char s[5];
    scanf("%d%s", &p, s);
    if (s[0] == 'W') {
      if (pr[p] == -1) continue;
      pr[p] ++;
    } else {
      if (pr[p] == -1) continue;
      ans1 ++;
      ans2 += pr[p];
      pr[p] = -1;
    }
  }
  printf("%d %d\n", ans1, ans2);
}

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


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <math.h>
#include <tuple>
#include <queue>
#include <set>

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

    int N, M;

    cin >> N >> M;

    vector<int> pref_vec(M);

    int tmp_K;
    int tmp_A;
    for(int i = 0; i < N; i++){
        cin >> tmp_K;
        
        for(int j = 0; j < tmp_K; j++){
            cin >> tmp_A;
            pref_vec[tmp_A-1] += 1;
        }
    }

    int ans = 0;
    for(int i = 0; i < M; i++){
        if(pref_vec[i] == N){
            ans = ans+1;
        }
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1) << endl;

    return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main() 
{
	ios::sync_with_stdio(false);
	int a, b, c;
	cin >> a >> b >> c;
	if ((c > a && c < b) || (c<a && c>b))
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <fstream>
#include <queue>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <sstream>
#include <math.h>
#include <functional>

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

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define SORT(c) sort((c).begin(),(c).end())
#define vi(m,a) vector<int> m(a)
#define vti(m,a,i) vector<vector<int>> m(a,vector<int>(i))
#define ALL(it,a) for(auto it = a.begin(); it!=a.end(); it++)
#define Fe(it,a) for(auto &it : a)
#define all(a) begin(a),end(a)

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define WARU 1000000007

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

int main() {
	string s;
	cin >> s;
	bool ok = true;
	rep(i, s.length()) {
		if ((i+ 1) % 2 == 0) {
			if (s[i] == 'R')
				ok = false;

		}
		else {
			if (s[i] == 'L')
				ok = false;
		}
	}
	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

}



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

int main(void){
	int a,b;
	int c = 0;
	int count = 0; //入力回数の制限

	while(scanf("%d %d", &a,&b) != EOF){
		if(++count>200)	break; //200回以上は中止
		if(a<0 || a> 1000000 || b<0 || b> 1000000)
			cout<<"0から1000000までの値を入力してください."<<'\n';
		else{
			c = a+b;
			int digit = 0;
			do{
				digit++;
				c /= 10;
			}while(c != 0);
			cout<<digit<<'\n';
		}
	}

	//終了
	return 0;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair



int main() {
  int n, k;
  cin >> n >> k;
  vi a(n);
  rep (i, n) cin >> a[i];
  vi ans;
  int mi = inf, now = -1;
  rep (i, n) {
    if (mi > a[i]) {
      mi = a[i];
      now = i;
    }
  }
  int pre = -1;
  while (k >= 0) {
    rep (i, n) {
      if (i == pre || i == now) continue;
      if (a[i] == 0) {
        cout << -1 << endl;
        return 0;
      }
      ans.push_back(i);
      a[i]--;
    }
    if (a[now] == 0) {
      cout << -1 << endl;
      return 0;
    }
    ans.push_back(now);
    a[now]--;
    k--;
    int mi = inf, nex = -1;
    rep (i, n) {
      if (i == now) continue;
      if (mi > a[i]) {
        mi = a[i];
        nex = i;
      }
    }
    pre = now;
    now = nex;
  }
  cout << ans.size() << endl;
  rep (i, ans.size()) {
    cout << ans[i] + 1 << " ";
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define tag "spoj"
#define maxn 100007
#define oo 1000000007
#define mid ((l+r)>>1)
#define meset(a,x) memset(a,x,sizeof(a))
#define loop(x) for(int LoOpEr=1;LoOpEr<=x;LoOpEr++)
///>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#define base 13
#define MOD 1000000007
int n;
int main()
{
    #ifdef dmdd
    freopen(tag".inp","r",stdin); freopen(tag".out","w",stdout);
    #endif //dmdd
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

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

    int f[base],g[base];

    meset(f,0);
    f[0]=1;
    for(const char &c: s)
    {
        meset(g,0);

        for(int i=0;i<10;i++)
        {
            if(c!='?' && c!='0'+i) continue;

            for(int k=0;k<base;k++)
                (g[(k*10+i)%base]+=f[k])%=MOD;
        }
        swap(f,g);
    }

    cout<<f[5];
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <map>
#include <math.h>
using namespace std;
typedef long long int ll;

double dist(double a,double b,double c,double d){
	if(floor(b/10)==floor(d/10)){
		swap(a,b); swap(c,d);
	}
	if(floor(a/10)==floor(c/10)){
		if(b==d)return abs(a-c);
		a-=floor(a/10)*10,c-=floor(c/10)*10;
		return abs(b-d)+min(a+c,20-a-c);
	}
	return abs(a-c)+abs(b-d);
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> x(n),y(n);
	int xi=1e9,xa=-1e9;
	int yi=1e9,ya=-1e9;
	for(int i=0;i<n;i++){
		cin >> x[i] >> y[i];
		xi=min(xi,x[i]+y[i]);
		xa=max(xa,x[i]+y[i]);
		yi=min(yi,x[i]-y[i]);
		ya=max(ya,x[i]-y[i]);
	}
	double res=1e9;
	xi=(xi+xa)/2,yi=(yi+ya)/2;
	int xx=(xi+yi)/2,yy=(xi-yi)/2;
	xx-=xx%10,yy-=yy%10;
	for(int X=xx-50;X<=xx+50;X+=10){
		for(double Y=yy-50;Y<=yy+50;Y+=0.5){
			double d=0;
			for(int i=0;i<n;i++){
				d=max(d,dist(x[i],y[i],X,Y));
			}
			res=min(res,d);
		}
	}
	for(int Y=yy-30;Y<=yy+30;Y+=10){
		for(double X=xx-30;X<=xx+30;X+=0.5){
			double d=0;
			for(int i=0;i<n;i++){
				d=max(d,dist(x[i],y[i],X,Y));
			}
			res=min(res,d);
		}
	}
	printf("%.9f\n",res);
}



Measured memory_bytes: 3336
n=[int(x) for x in input()]

dp=[[100000000000 for i in range(len(n)+1)]for j in range(2)]
dp[0][0]=0
dp[1][0]=1
for i in range(len(n)):
  d=n[i]
  dp[0][i+1]=min(dp[0][i+1],min(d,11-d)+dp[0][i],10-d+dp[1][i])
  dp[1][i+1]=min(dp[1][i+1],d+1+dp[0][i],9-d+dp[1][i])
  
  
print(dp[0][len(n)])
#print(dp)

Measured memory_bytes: 92908
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        var nums = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var diff = nums[2] + nums[3] - nums[0] - nums[1];
        if(diff>0)
        {
            Console.WriteLine("Right");
        } else if (diff < 0)
        {
            Console.WriteLine("Left");
        } else
        {
            Console.WriteLine("Balanced");
        }
    }
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair
 
using namespace std;
 
const LL MOD=1e9+7;

int a[3][3],b[3][3],n,x,ok=0;

int main()
{
	rep(i,3) rep(j,3) cin>>a[i][j];
	cin>>n;
	rep(i,n)
	{
		cin>>x;
		rep(i,3) rep(j,3) if(a[i][j]==x) b[i][j]=1;
	}
	rep(i,3)
	{
		int bb=1;
		rep(j,3) bb&=b[i][j];
		ok|=bb;
	}
	rep(j,3)
	{
		int bb=1;
		rep(i,3) bb&=b[i][j];
		ok|=bb;
	}
	ok|=(b[0][0]==1&&b[1][1]==1&&b[2][2]==1)|(b[0][2]==1&&b[1][1]==1&&b[2][0]==1);
	puts(ok ? "Yes":"No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <math.h>
using namespace std;

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define PB push_back
typedef long long ll;

int main(){
	int n;
	vector <int> a;
	ll ans=-1,tmp;
	cin >> n;
	rep(i,0,n){
		cin >> tmp;
		a.PB(tmp);
	}
	rep(i,-100,101){
		tmp = 0;
		rep(j,0,n){
			tmp+=pow(a[j]-i,2);
		}
		if(ans == -1)ans=tmp;
		ans = min(ans,tmp);
	}
	cout << ans <<endl;



	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()
#define int long long
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ

signed main(){
    int n; cin >> n;
    vector<int> a(n),b(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    int ans=1001001;
    rep(bit,1<<n){
        vector<P> v,w;
        rep(i,n){
            if(bit&(1<<i)){ //omote
                if(i%2==0) v.pb({a[i],i});
                else w.pb({a[i],i});
            }else{ //ura
                if(i%2==0) w.pb({b[i],i});
                else v.pb({b[i],i});
            }
        }
        sort(ALL(v));
        sort(ALL(w));
        if(v.size()==w.size()||v.size()==w.size()+1){
            bool ok=1;
            vector<P> lst(n);
            rep(i,n){
                if(i%2==0) lst[i]=v[i/2];
                else lst[i]=w[i/2];
            }
            rep(i,n-1){
                if(lst[i].fi>lst[i+1].fi) ok=0;
            }
            if(ok){
                int res=0;
                rep(i,n){
                    rep(j,n){
                        if(i<j&&lst[i].se>lst[j].se) res++;
                    }
                }
                chmin(ans,res);
            }
        }
    }
    cout << (ans==1001001 ? -1 : ans) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0,(i##_len)=(n);(i)<(i##_len);(i)++)
#define rep2(i,a,b) for(ll (i)=(a),(i##_len)=(b);(i)<=(i##_len);(i++))
#define Yes(n) cout<<((n)?"Yes\n":"No\n")
#define vll vector<ll>
#define pb push_back
using namespace std;
using ll = long long;

static inline void ignore_ret(auto x) {}
template<class T> bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> T abs(T x){return max(x,-x);}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm(T m,T n) {return m*n/gcd(m,n);}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm<T>(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
template<class T> T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> T sum(vector<T>v){return reduce(all(v),0LL);}

// Template ends here

void solve(ll N, vector<ll> A){
    vll R(N); rep(i, N) R.at(A.at(i) - 1) = i + 1;
    rep(i, N) cout << R.at(i) << " ";
}

int main() {
    ll N;
    ignore_ret(scanf("%lld",&N));
    vector<ll> A(N);
    for(int i = 0 ; i < N ; i++){
        ignore_ret(scanf("%lld",&A[i]));
    }
    solve(N, move(A));
    return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

ll lcm(int a, int b){
  function<ll(ll, ll)> lcmgcd = [&](ll x, ll y){
    if(y == 0) return x;
    return lcmgcd(y, x % y);
  };
  return a / lcmgcd(a, b) * b;
}

int main(){
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  ll l = (ll)lcm(C, D);
  ll candivide = B/C - (A-1)/C + B/D - (A-1)/D - B/l + (A-1)/l;
  cout << B - A + 1 - candivide << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string sS = System.Console.ReadLine().Trim();
            int iN = int.Parse(sS);
            List<string> lstsS = new List<string>();
            for (long i = 0; i < iN; i++)
            {
                lstsS.Add(System.Console.ReadLine().Trim());
            }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = lstsS.Distinct().Count();

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 48020
def a_diverse_word(S):
    from string import ascii_lowercase
    if len(S) < 26:
        # 26字未満なら、Sにまだ現れていない文字で辞書順最小のものを末尾に加えたものが解
        ans = S + min(set(list(ascii_lowercase)) - set(S))
    else:  # Sの長さは定義上26字以下なので、Sが26字のときこの処理を行う
        idx = 0  # S[idx]以降末尾まで降順になっている
        for k in range(len(S) - 1, 0, -1):
            if S[k] > S[k - 1]:
                idx = k
                break
        if idx == 0:
            ans = '-1'  # Sは辞書の最後の単語だった。「次」はない
        else:
            for c in ascii_lowercase:
                if (S[idx - 1] < c) and (c not in S[:idx]):
                    ans = S[:idx - 1] + c
                    break
    return ans

S = input().strip()
print(a_diverse_word(S))

Measured memory_bytes: 3772
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;

int main(){
    int n;
    cin>>n;
    map<int,int> m;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        m[a]++;
    }
    
    vector<int> v;
    for(auto p : m){
        if(p.second>=4) v.push_back(p.first);
        if(p.second>=2) v.push_back(p.first);
    }
    sort(v.rbegin(),v.rend());
    if(v.size()<2) cout<<0<<endl;
    else cout<<1LL*v[0]*v[1]<<endl;
}

Measured memory_bytes: 8292
#include <bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
int abs(int x){
    if(x<0) return -x;
    else return x;
}
int main() {
    int n,x;
    cin>>n>>x;
    vector<int> m(n);
    int sum=n;
    for(int i=0;i<n;i++){
        cin>>m.at(i);
        x-=m.at(i);
    }
    sort(m.begin(),m.end());
    sum+=x/m.at(0);
    cout<<sum<<endl;
    
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#define int long long
using namespace std;
int a[114];
signed main() {
	int n, cnt = 0;
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < n; i++) {
		if (a[i] % 2 == 0)cnt++;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 3100
N = int(input())
MOD = 10 ** 9 + 7
C = 'ACGT'

dp = [{} for _ in range(N+1)]

def ok(l4):
  if (l4[0:3] in ['AGC', 'GAC', 'ACG'] or
      l4[1:4] in ['AGC', 'GAC', 'ACG'] or
      l4[0:1] + l4[2:4] == 'AGC' or
      l4[0:2] + l4[3:4] == 'AGC'):
    return False
  else:
    return True

for c1 in C:
  for c2 in C:
    for c3 in C:
      l4 = 'X' + c1 + c2 + c3
      if ok(l4):
        dp[3][l4] = 1
      else:
        dp[3][l4] = 0

for i in range(4, N+1):
  for l4 in dp[i-1].keys():
    for c in C:
      next_l4 = l4[1:4] + c
      if next_l4 not in dp[i]:
        dp[i][next_l4] = 0
      if ok(next_l4):
        dp[i][next_l4] = (dp[i][next_l4] + dp[i-1][l4]) % MOD

ans = 0
for count in dp[N].values():
  ans = (ans + count) % MOD
print(ans)

Measured memory_bytes: 6164
#include <bits/stdc++.h>
using namespace std;
int a[26];
char s[26];
int main()
{
    cin >> s;
    int l = 1;
    for(int i=0; s[i]; i++) a[s[i]] = 1 , l++;
    for(int c = 'z'; c >= 'a'; c--)
        if(!a[c])s[l++] = c;
    if(next_permutation(s , s + l))
        cout << s;
    else
        cout << -1;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int n;
	cin >> n;
	int *Tree = new int[n+1]; 
	for (int i=1;i<=n;i++) {
		cin >> Tree[i];
	}
	
	for (int i=1;i<=n;i++) {
		cout << "node " << i << ": key = " << Tree[i];
		if (i / 2 > 0) {
			cout << ", parent key = " << Tree[i/2];
		}
		if (2 * i <= n ) {
		   cout <<", left key = " << Tree[2*i];
	    } 
	    if (2 * i + 1 <= n) {
	    	cout << ", right key = " << Tree[2*i+1];
		}
		cout <<  ", " << endl;
	}
	delete[] Tree;
	return 0;
	
}


Measured memory_bytes: 3100
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
const int DEF = (1 << 21);

int a(int x){
    return x * x * x;
}

int b(int x){
    return (x * (x - 1) * (x - 2)) / 6;
}

int c(int n, int x){
    return n - x;
}

int main(){
    int n;
    while(cin >>n){
        if(n == 0) break;
        int ans = DEF, tmp;
        for(int i = 1; i < 100; i++){
            tmp = c(n, a(i));
            if(tmp < 0) break;
            else ans = min(ans, tmp);
            for(int j = 1; j < 100; j++){
                tmp = c(n, a(i) + b(j));
                if(tmp < 0) break;
                else ans = min(ans, tmp);
            }

        }
        for(int i = 1; i < 100; i++){
            tmp = c(n, b(i));
            if(tmp < 0) break;
            else ans = min(ans, tmp);
        }
        cout <<n - ans <<endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

ll gcd(ll n,ll m){
    if(n%m==0) return m;
    else return gcd(m,n%m);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,M;
    cin >> N >> M;
    vec<ll> A(N);
    ll lcm = 1;
    bool ok = true;
    for(int i=0;i<N;i++){
        ll a;
        cin >> a;
        a /= 2;
        ll g = gcd(lcm,a);
        lcm = lcm/g*a;
        if(lcm>M){
            ok = false;
        }
        A[i] = a;
    }
    if(!ok) cout << 0 << endl;
    else{
        bool c = true;
        for(int i=0;i<N;i++) c &= ((lcm/A[i])%2)==1;
        if(!c) cout << 0 << endl;
        else cout << (M-lcm)/(2*lcm)+1 << endl;
        
    }
}

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

#define MAX 100000

using namespace std;

int main() {
    int n, v;
    scanf("%d", &n);
    vector< vector<int> > d(2, vector<int>(MAX + 1));
    for (int i = 0; i < n; ++i) {
        scanf("%d", &v);
        ++d.at(i % 2).at(v);
    }
    auto a = max_element(d.front().begin(), d.front().end()), b = max_element(d.back().begin(), d.back().end());
    if (a - d.front().begin() != b - d.back().begin()) printf("%d\n", n - *a - *b);
    else {
        int va = *a, vb = *b;
        *a = 0, *b = 0;
        a = max_element(d.front().begin(), d.front().end()), b = max_element(d.back().begin(), d.back().end());
        printf("%d\n", min(n - va - *b, n - vb - *a));
    }
    return 0;
}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		String s = scan.next();

		if(a >= 3200)
			System.out.println(s);
		else
			System.out.println("red");
	}
}

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

using ll = long long;
ll n,ans;

void dfs(ll x,int a,int b,int c){
    //cout<<x<<endl;
    //cout<<"n="<<n<<endl;
    if(x>n){ return; }
    //cout<<"a="<<a<<",b="<<b<<",c="<<c<<endl;
    if(a&&b&&c){ ans++;}
    dfs(x*10+3,1,b,c);
    dfs(x*10+5,a,1,c);
    dfs(x*10+7,a,b,1);
}
int main(){
    cin>>n;
    dfs(0,0,0,0);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> d(k);
    rep(i, k) cin >> d[i];
    for (int i = n; i <= n * 10; ++i) {
        int num = i;
        set<int> st;
        while(1) {
            if (num == 0) break;
            st.insert(num % 10);
            num /= 10;
        }
        bool ok = true;
        for (auto dd: d) {
            if (st.count(dd) != 0) {
                ok = false;
                break;
            } 
        }
        if (ok) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


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


int main(){
    string a, b; cin >> a >> b;
    if(a.size() == 1 && b.size() == 1) cout << stoi(a) * stoi(b) << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	long long int n, m;
	cin >> n >> m;
	long long int ans = 1;
	for(long long int i = 1; i * i <= m; i++){
		if(m % i > 0) continue;
		if(m / i >= n) ans = max(ans, i);
		if(i >= n) ans = max(ans, m / i);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ar array
#define vec vector 


void solve(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << c << ' ' << a << ' ' << b << endl;
}

int main(){
    //clock_t startTime = clock();
    solve();
    //cout << double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int ans = a*b > c*d || a*b == c*d ? a*b : c*d;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll          long long
#define vl          vector<ll>
#define vi          vector<int>
#define pi          pair<int,int>
#define pl          pair<ll,ll>
#define all(a)      a.begin(),a.end()
#define mem(a,x)    memset(a,x,sizeof(a))
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define trace(x)    cerr<<#x<<" : "<<x<<endl;
#define trace2(x,y) cerr<<#x<<" : "<<x<<" | "<<#y<<" : "<<y<<endl;
#define trace3(x,y,z) cerr<<#x<<" : "<<x<<" | "<<#y<<" : "<<y<<" | "<<#z<<" : "<<z<<endl;
#define fast_io 	std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

using namespace std;


int main()
{
	fast_io;
	int a,b;
	cin>>a>>b;
	int x,y,z;
	x=a+b;
	y=a-b;
	z=a*b;
	int ans=max(x,y);
	ans=max(ans,z);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256