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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};




int main(){
	string a; cin >> a;
	int A,Z;
	for(int i = 0; i < a.size(); i++){
		if(a[i] == 'A'){
			A = i;break;
		}
	}
	for(int j = a.size()-1; j >= 0; j--){
		if(a[j] == 'Z'){
			Z = j;break;
		}
	}
	cout << Z-A+1 <<  endl;

	return 0;
}

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

const int maxn=55;
string ma[maxn];
int a[maxn][maxn]={0};
int n,m;
int dir[8][2]={-1,0,-1,-1,-1,1,0,-1,0,1,1,-1,1,0,1,1};

int cnt(int x,int y)
{
    int ans=0;
    for(int i=0;i<8;i++)
    {
        int fx=x+dir[i][0];
        int fy=y+dir[i][1];
        if(fx<0 || fy<0 || fx>=n || fy>=m) continue;
        if(ma[fx][fy]=='#')
            ans++;
    }
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    cin>>n>>m;
    for(int i=0;i<n;i++)
        cin>>ma[i];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            a[i][j]=cnt(i,j);
            if(ma[i][j]=='.')

            ma[i][j]=(char)(a[i][j]+'0');
        }
    }
    for(int i=0;i<n;i++)
        cout<<ma[i]<<endl;
    return 0;

}


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

int main(){
    int a,b;
    char op;
    while(1){
        scanf("%d %c %d",&a,&op,&b);
        if(op == '+'){
            printf("%d\n",a+b);
        }else if(op == '-'){
            printf("%d\n",a-b);
        }else if(op == '*'){
            printf("%d\n",a*b);
        }else if(op == '/'){
            printf("%d\n",a/b);
        }else{
            break;
        }
    }
    
}


Measured memory_bytes: 3200
while(1):
    x=1000-int(input())
    if x==1000:
        break
    cnt=0
    if x // 500>=1:
        cnt+=1
        x-=500
    for i in [100,50,10,5,1]:
        if x>0:
            cnt += x //i
            x%=i
    print(cnt)


Measured memory_bytes: 5588
#pragma comment(linker,"/STACK:1000000000")
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;

#define sz(x) (int)(x.size())
#define fi(a,b) for(int i=a;i<b;++i)
#define fj(a,b) for(int j=a;j<b;++j)
#define fo(a,b) for(int o=a;o<b;++o)
#define pb push_back
#define mp make_pair
typedef pair<int, int> pii;
////////////////////

int const N = 1e5 + 41;
int const H = 241;

int n, h, a[N], b[N], c[N], d[N];
int deg[H][2], d0[H][2], d1[H][2];
int w[N][2];
vector<pii> e[H][2];

pii getfrom(int a, int c){
	if(c == 0) return mp(a, 1);
	else return mp(c, 0);
}

pii getto(int b, int d){
	if(d > 0) return mp(d, 1);
	else return mp(b, 0);
}

void bad(){
	printf("NO\n");
	exit(0);
}

void dfs(pii x){
	w[x.first][x.second] = 1;
	fi(0, sz(e[x.first][x.second])){
		pii y = e[x.first][x.second][i];
		if(!w[y.first][y.second]) dfs(y);
	}
}

void solve(){
	fi(0, n){
		pii x = getfrom(a[i], c[i]);
		pii y = getto(b[i], d[i]);
		e[x.first][x.second].pb(y);
		++deg[x.first][x.second];
		--deg[y.first][y.second];
	}
	fi(1, h+1) fj(0, 2){
		if(j == 1){
			if(deg[i][j] < 0) bad();
		}else{
			if(deg[i][j] > 0) bad();
		}
	}
	fi(1, h+1) if(deg[i][1] > 0) dfs(mp(i, 1));
	fi(1, h+1) fj(0, 2) if(sz(e[i][j]) > 0 && !w[i][j]) bad();
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	
	scanf("%d %d",&n,&h);
	fi(0, n) scanf("%d %d %d %d",&a[i],&b[i],&c[i],&d[i]);

	solve();

	printf("YES\n");

	return 0;
}

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


int main() {
  string n;
  cin >> n;
  bool a = false;
  rep(i,n.size()){
    if(n.at(i) == '7'){
      cout << "Yes" << endl;
      a = true;
      break;
    }else{
      continue;
    }
  }
  if(a == false){
    cout << "No" << endl;
  }

}

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


int main(){




int ans;
rep(i,5){
    int x;
    cin >> x;
    if(x == 0) {
        ans = i + 1;
        break;
    }
}

cout << ans << endl;


}

Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    int sum = 0;
    int a[n];
    for (auto &ai:a) {
        cin >> ai;
        sum += ai;
    }
    int cnt = 0;
    for (auto &ai:a) {
        if (ai * 4 * m >= sum) cnt++;
    }
    cout << (cnt >= m ? "Yes" : "No") << '\n';
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,(n))

#include <cstdint>

template <long long Modulus> class modint {

  long long a;

public:
  constexpr modint(long long x = 0) noexcept : a((x % Modulus + Modulus) % Modulus) {}
  constexpr long long val() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr bool operator==(const modint rhs) const noexcept {
    return modint(*this).val() == rhs.val();
  }
  modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  modint &operator/=(modint rhs) noexcept {
    long long exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};
using mint = modint<MOD>;
typedef vector<mint> vec;
typedef vector<vector<mint>> mat;

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

  int n,k;
  cin >> n >> k;
 
  vector<int> a(n);
  REP(i,n) cin >> a[i];
 
  sort(a.begin(),a.end());
  
  vec fact(n+1,1);
  REP(i,n) fact[i+1] = fact[i]*(i+1);
 
  mint ans = 0;
  REP(i,n-k+1){
    ans -= fact[n-1-i]/fact[k-1]/fact[n-k-i]*a[i];
  }

  reverse(a.begin(),a.end());
  REP(i,n-k+1){
    ans += fact[n-1-i]/fact[k-1]/fact[n-k-i]*a[i];
  }
 
  cout << ans.val() << endl;

  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x,n;
	cin>>x>>n;
	if(n==0)
	{
		cout<<x;
		return 0;
	}
	
	map<int,int> m;
	
	for(int i=0;i<n;i++)
	{
		int val;
		cin>>val;
		m[val]++;
	}
	int ans=INT_MAX;
	for(int i=0;i<=1000;i++)
	{
		if(m[x+i]==0){
			ans=x+i;
			break;
		}
		
	}
	int d=abs(x-ans);
	for(int i=0;i<=1000;i++)
	{
		if(m[x-i]==0)
		{
			if(d>=i)
			{
				ans=x-i;
				break;
			}	
			
		}
	}
	cout<<ans;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
//g++ -std=c++11 

#define PI 3.14159265359

using namespace std;

long long a, b, x;


int main(){
	cin >> a >> b >> x;

	double start = 0;
	double end = PI/2;

	while(start + 0.000000001 < end) {
		double sita = (start + end)/2;
		double l = b * tan(PI/2 - sita);
		double vol;

		if(l > a) {
			double l2 = a / tan(PI/2 - sita);
			vol = ((l2 * a /2.0) + a * (b - l2)) * a;
		} else {
			vol = a * l * b / 2.0;
		}

		if(vol > x) {
			start = sita;
		} else {
			end = sita;
		}
	}

	printf("%.10f\n", 180 * start / PI);

}


Measured memory_bytes: 4164
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int n,k,a,m;
int gcd(int x,int y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
int main(void){
    scanf("%d%d%d",&n,&k,&a);
    m=a;
    for(int i=0;i<n-1;i++){
        int b;
        scanf("%d",&b);
        a=gcd(max(a,b),min(a,b));
        m=max(m,b);
    }
    if(k<=m&&k%a==0)printf("POSSIBLE\n");
    else printf("IMPOSSIBLE\n");
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
int A[101010],B[101010];
int C[101010];
int L[202020],R[202020];

template<int um> class UF {
	public:
	vector<int> par,rank;
	UF() {rank=vector<int>(um,0); for(int i=0;i<um;i++) par.push_back(i);}
	int operator[](int x) {return (par[x]==x)?(x):(par[x] = operator[](par[x]));}
	int operator()(int x,int y) {
		if((x=operator[](x))==(y=operator[](y))) return x;
		if(rank[x]>rank[y]) return par[x]=y;
		rank[x]+=rank[x]==rank[y]; return par[y]=x;
	}
};
UF<500000> uf;
vector<pair<int,int>> E[202020];
vector<int> ret;

void dfs(int cur,int pre) {
	FORR(e,E[cur]) if(e.first!=pre) {
		dfs(e.first,cur);
		if(C[e.first]) {
			ret.push_back(e.second);
			C[e.first]^=1;
			C[cur]^=1;
		}
	}

}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	vector<int> Xs;
	FOR(i,N) {
		cin>>A[i]>>B[i];
		Xs.push_back(A[i]);
	}
	Xs.push_back(1<<30);
	sort(ALL(Xs));
	FOR(i,N) {
		x=lower_bound(ALL(Xs),A[i])-Xs.begin();
		C[x]=B[i];
	}
	for(i=N;i>=1;i--) C[i]^=C[i-1];
	
	
	FOR(i,M) {
		cin>>L[i]>>R[i];
		L[i]=lower_bound(ALL(Xs),L[i])-Xs.begin();
		R[i]=lower_bound(ALL(Xs),R[i]+1)-Xs.begin();
		if(uf[L[i]]!=uf[R[i]]) {
			E[L[i]].push_back({R[i],i+1});
			E[R[i]].push_back({L[i],i+1});
			uf(L[i],R[i]);
		}
	}
	FOR(i,N+1) if(uf[i]==i) {
		dfs(i,i);
		if(C[i]) return _P("-1\n");
	}
	cout<<ret.size()<<endl;
	sort(ALL(ret));
	FORR(r,ret) cout<<r<<" ";
	cout<<endl;
		
	
	
		
		
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 16624
R=0..18
d=R.map{[0]*19}
gets
p$<.sum{|b|a=b.to_f*1e10+1
i,j=[2,5].map{|g|R.find{(a/=g)%g>1}||18}
d[..i].sum{_1[..j].sum}+0*d[~i][~j]+=1}

Measured memory_bytes: 14416
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int (i) = 0; (i) <n; (i)++) 
#include <math.h>
#include <bits/stdc++.h>
using namespace std;
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}

using namespace std;
int main(){
    int n;std::cin >> n;
    std::vector<int> a(n);
    int con=0;int Max=0;
    rep(i,n){
        std::cin >> a[i];
        Max=max(Max,a[i]);
    }
    int maxi;
    rep(i,n){
        if(Max==a[i]){con++;maxi=i;}
    }
    int second=0;
    rep(i,n){
        if(a[i]!=Max)second=max(second,a[i]);
    }
    maxi++;
    if(con>1)rep(i,n)std::cout << Max << std::endl;
    else {
        rep(i,maxi-1)std::cout << Max << std::endl;
        std::cout << second << std::endl;
        rep(i,n-maxi)std::cout << Max << std::endl;
    }
    
    
}



Measured memory_bytes: 2432
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){ 
  string s; cin >>s;
  ll n; cin >>n;
  int key;
  rep(i,s.size()){
    if(s[i]!='1'){
      key=i;
      break;
    }
  }
  if(n<=key)cout<<1<<endl;
  else cout<<s[key]<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    long MOD = (long) 1e9 + 7;

    void run() {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt(), m = sc.nextInt();
        HashMap<Integer, Integer> map = new HashMap<>();
        UnionFind uf = new UnionFind(n);
        for (int i = 0; i < n; i++) {
            map.put(sc.nextInt() - 1, i);
        }
        for (int i = 0; i < m; i++) {
            int x = sc.nextInt() - 1;
            int y = sc.nextInt() - 1;
            uf.unite(x, y);
        }
        int cnt = 0;
        // write your code
        for (int i = 0; i < n; i++) {
            cnt += uf.same(i, map.get(i)) ? 1 : 0;
        }
        System.out.println(cnt);
    }

    public class UnionFind {
        int[] parents, sizes;

        UnionFind(int n) {
            parents = new int[n];
            sizes = new int[n];
            for(int i = 0; i < n; i++) {
                parents[i] = i;
                sizes[i] = 1;
            }
        }

        public int find(int x) {
            if (x == parents[x]) return x;
            return parents[x] = find(parents[x]);
        }

        public void unite(int x, int y) {
            x = find(x);
            y = find(y);
            if (x == y) return;
            if (sizes[x] < sizes[y]) {
                int temp = x;
                x = y;
                y = temp;
            }
            parents[y] = x;
            sizes[x] += sizes[y];
        }

        public boolean same(int x, int y) {
            return find(x) == find(y);
        }

        public int size(int x) {
            return sizes[find(x)];
        }
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 102768
#include<bits/stdc++.h>
using namespace std;
int gcd(int x,int y){
  if(x%y==0){
    return y;
  }
  return gcd(y,x%y);
}
int main(){
  int K;
  cin>>K;
  int64_t ans=0;
  for(int i=1;i<=K;i++){
    for(int j=1;j<=K;j++){
      for(int l=1;l<=K;l++){
        ans+=gcd(i,gcd(j,l));
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	string s;
	cin>>n;
	set<string> dai;
	for(int t=0;t<n;t++)
	{
		cin>>s;
		dai.insert(s);
	}
	cout<<dai.size();
	return 0;
}

Measured memory_bytes: 19208
#include<iostream>
using namespace std;
int main(){
	bool num[1000000] = {0};
	for(int i=2; i<1000; i++){
		if(!num[i]){
			for(int j=i*i; j<1000000; j+=i){num[j] = 1;}
		}
	}
	for(;;){
		int n,sum = 0;
		cin >>n;
		if(n == 0){break;}
		for(int i=2; n>0; i++){
			if(!num[i]){n--;sum+=i;}
		}
		cout <<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cmath>
#include <algorithm>
int a[100002];
int dp[100002];
using namespace std;
int main()
{
    int n, k;
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);
    for (int i = 0; i < k && i < n; i++)
        dp[i] = abs(a[i] - a[0]);
    for (int i = k; i < n; i++)
    {
        dp[i] = dp[i - k] + abs(a[i] - a[i - k]);
        for (int j = 1; j < k; j++)
            dp[i] = min(dp[i], dp[i - j] + abs(a[i] - a[i - j]));
    }
    printf("%d", dp[n - 1]);
}

Measured memory_bytes: 896
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;
 
void main() {
    int Q; readf("%d\n", &Q);
    foreach (_; 0 .. Q) {
        int c, a, n; readf("%d %d %d\n", &c, &a, &n);
        int x = min(c, a, n);
        c -= x; a -= x; n -= x;
        int y = min(c / 2, a);
        c -= y * 2; a -= y;
        int z = c / 3;
        writeln(x + y + z);
    }
}

Measured memory_bytes: 1064
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<utility>
#include<array>
#include<set>
#include <numeric>
#include <boost/math/common_factor_rt.hpp>
#define EPS (1e-7)
using namespace std;
#define ll long long


int main() {

	int N, ans;
	cin >> N;
	if (N > 0 && N < 10) {
		ans = N;
	}
	else if (N > 9 && N < 100) {
		ans = 9;

	}
	else if (N > 99 && N < 1000) {
		ans = 9 + (N - 99);
	}
	else if (N > 999 && N < 10000) {
		ans = 909;
	}
	else if (N > 9999 && N < 100000) {
		ans = 909 + (N - 9999);
	}
	else {
		ans = 90909;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//============================================================================
// Name        : abc101.cpp
// Author      : sep
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cmath>
#include <ctime>
#include <functional>
#include <algorithm>
#include <vector>

using namespace std;

inline void main101A() {

	int n = 0;
	int i;
	string s;

	cin >> s;

	for (i = 0; i < s.length(); i++)
		if (s[i] == '-') {
			--n;
		} else {
			++n;
		}

	cout << n;

}

inline void main101B() {

}

inline void main101C() {

}

inline void main101D() {

}

int main() {

#ifdef TEST
	struct timespec startTime, endTime;
	while (1) {
		clock_gettime(CLOCK_REALTIME, &startTime);
#endif

		main101A();

#ifdef TEST
		cout << flush;
		cerr << flush;
		cerr << endl << "Elapsed Time:";
		clock_gettime(CLOCK_REALTIME, &endTime);
		if (endTime.tv_nsec < startTime.tv_nsec) {
			cerr << endTime.tv_sec - startTime.tv_sec - 1 << "."
					<< endTime.tv_nsec + 1000000000 - startTime.tv_nsec << "s"
					<< endl;
		} else {
			cerr << endTime.tv_sec - startTime.tv_sec << "."
					<< endTime.tv_nsec - startTime.tv_nsec << "s" << endl;
		}

		cerr << endl;
	}
#endif

	return 0;
}


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

using namespace std;

struct coordinate{ int x; int y;};
vector<coordinate> ans;

int main(){
	while(1){
		int n;
		cin >> n;
		if(n == 0)break;
		map<int,coordinate> mp;
		bool field[401][401];//center is 200 200
		for(int i = 0;i < 401;i++){
			for(int j = 0;j < 401;j++){
				field[i][j] = false;
			}
		}
		coordinate za;
		za.x = 200; za.y=200;
		mp[0] = za;
		field[200][200] = true;
		
		for(int i = 1;i < n;i++){
			int from;
			int dir;
			cin >> from >> dir;
			
			coordinate move;
			if(dir == 0){move.x = -1; move.y = 0;}
			else if(dir == 1){move.x = 0;move.y = -1;}
			else if(dir == 2){move.x = 1;move.y = 0;}
			else{move.x = 0;move.y = 1;}
			
			coordinate to;
			to.x = mp[from].x + move.x;
			to.y = mp[from].y + move.y;
			field[to.y][to.x] = true;
			mp[i] = to;
		}
		
		coordinate mx,mn;
		mx.x = 0; mx.y = 0;
		mn.x = 1e9; mn.y = 1e9;
		for(int i = 200 - n;i < (200 + n);i++){
			for(int j = 200 - n;j < (200 + n);j++){
				if(field[i][j]){
					mx.x = max(mx.x,j);
					mx.y = max(mx.y,i);
					mn.x = min(mn.x,j);
					mn.y = min(mn.y,i);
				}
			}
		}
		
		coordinate si;
		si.x = mx.x - mn.x + 1;
		si.y = mx.y - mn.y + 1;
		
		ans.push_back(si);
	}
	for(int i = 0;i < ans.size();i++) cout << ans[i].x << " " << ans[i].y <<endl;
	
	return 0;
}

Measured memory_bytes: 3224
#include<bits/stdc++.h>
#define N 50
using namespace std;
int n;
vector<int> data(N);


void fibo(int n){
	data.at(0) = data.at(1) = 1;
	for(int i=2;i<=n;i++) data.at(i) = data.at(i-1) + data.at(i-2);
}

int main(){
	cin >> n;
	fibo(n);
	cout << data.at(n) << endl;
}


Measured memory_bytes: 3100
#include<cstdio>
#include<iostream>
#include<string>

using namespace std;

int main(void) {

	string s;

	cin >> s;

	if (s.at(0) == '9' || s.at(1) == '9')cout << "Yes\n";
	else cout << "No\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pi acos(-1.0)
using namespace std;

double minn(double a,double b){
    return a<b?a:b;
}

int main(){
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    
    double deg1=(h*30+m*0.5);
    double deg2=m*6.0;
    
    double dif=fabs(deg1-deg2);
    dif=min(dif,360.0-dif);
    
    double power=pow(a,2.0)+pow(b,2.0)-2*a*b*cos(dif*pi/180.0);
    double c=sqrt(power);
    
    cout<<fixed<<setprecision(20)<<c<<"\n";
    return 0;
}

Measured memory_bytes: 4212
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f3f3f3f3f
//#define inf 0x3f3f3f3f
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define inv(x) Power(x, mod - 2)
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define N 100005

using namespace std;
typedef pair<int,int> Pair;
typedef long long ll;

const long double Pi = 3.14159265358979323846l;
const int mod = 1e9 + 7;
inline int add(int x, int y) { return (x += y) - (x >= mod ? mod : 0); }
inline void inc(int &x, int y) { (x += y) -= (x >= mod ? mod : 0); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline int Power(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1) res = mul(res, x);
		x = mul(x, x), y >>= 1;
	} return res;
}

template <class T> inline T	input() {
	T x; char ch; while (!isdigit(ch = getchar()));
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return x;
}

template <class T> inline void chkmin(T &x, T y) { x = x < y ? x : y; }
template <class T> inline void chkmax(T &x, T y) { x = x > y ? x : y; }

struct {
	inline operator int () { return input<int>(); }
	inline operator long long () { return input<long long>(); }
	template <class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

int n;
long long a[N], opt[N];
long long f[N][3];
char s[2];

int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; ++i) {
		scanf("%lld%s", a + i, s);
		opt[i + 1] = s[0] == '-' ? -1 : 1;
	}
	scanf("%lld", a + n), opt[1] = 1;

	f[0][1] = f[0][2] = -inf;
	for (int i = 1; i <= n; ++i) {
		if (opt[i] == 1) {
			f[i][0] = f[i - 1][0] + a[i];
			f[i][1] = max(f[i - 1][1] - a[i], f[i - 1][2] + a[i]);
			f[i][2] = f[i - 1][2] + a[i];
		} else {
			f[i][0] = f[i][1] = max(f[i - 1][0] - a[i], f[i - 1][1] + a[i]);
			f[i][2] = max(f[i - 1][2] - a[i], f[i - 1][1] + a[i]);
		}
	}

	printf("%lld\n", f[n][0]);
	return 0;
}


Measured memory_bytes: 4096
#/*
    AUTHOR:shivam51
    IIESTS
*/
#include<bits/stdc++.h>
  using namespace std;
  //
  #define add           accumulate
  #define ll            long long
  #define ff            first
  #define ss            second
  #define pb            push_back
  #define pob           pop_back
  #define pf            push_front
  #define pof           pop_front
  #define mp            make_pair
  #define vll           vector<ll>
  #define lb            lower_bound
  #define ub            upper_bound
  #define pll           pair<ll,ll>
  #define vpll          vector<pll>
  #define all(v)        v.begin(), v.end()
  #define rep(i,k,n)    for(int i=k;i<n;i++)
  #define hs            ios_base::sync_with_stdio(false);cin.tie(NULL);
  const ll mod=998244353;
  const ll MAX=1e5+10;
  //
  //
        int solve(){
                string str;
                cin>>str;
                ll cnt=0,sngl=0;
                rep(i,0,str.length()){
                        if(i==str.length()-1){
                                if(str[i]==str[i-1]&&sngl)
                                        break;
                                cnt++;
                        }
                        else{
                                if(sngl&&str[i]==str[i-1]){
                                        ++i;
                                        sngl=0;
                                }
                                else
                                        sngl=1;
                                ++cnt;
                                // cout<<i<<cnt<<" ";
                                // sngl=(sngl+1)%2;
                        }
                }
                cout<<cnt;
        }
    int main(){ 
                hs;
                ll t;
                // cout<<fixed<<setprecision(10);
                // cin>>t;
                t=1;
                while(t--){
                        solve();
    }
    return 0; 
}       


Measured memory_bytes: 720
#include <iostream>
#include <string>

using namespace std;
int main() {
    int n;
    cin >> n;
	string s;
	cin >> s;

	for (int i = 0; i < s.length(); i++) {
        s[i] = (s[i]+n)%26 + 52;
        if(s[i]<=64) s[i]+=26;
    }

	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

int main() {
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    int ans = 0;
    REP (i, 3001) {
        REP (j, 3001) {
            if (i * r + j * g <= n) {
                // cout << i << " " << j << endl;
                if ((n - i * r - j * g) % b == 0) {
                    // cout << i << " " << j << n - i * r + j * g << endl;
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef __int128 ll;
const int maxn=2e5+10;
const int mod=1e9+7;
inline __int128 read(){
   int X=0,w=0; char ch=0;
   while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
   while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
   return w?-X:X;
}
inline void print(__int128 x){
   if(x<0){putchar('-');x=-x;}
   if(x>9) print(x/10);
   putchar(x%10+'0');
}
int n;
ll f[maxn];
ll num[maxn];
ll ans,sum;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)f[i]=read(),num[i]=num[i-1]+f[i];
	for(int i=1;i<=n-1;i++)sum+=f[i]*(num[n]-num[i]);
	print(sum%mod);
	return 0;
}
/*
4
10000
10000
10000
10000
*/

Measured memory_bytes: 9836
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
const long mod = 1000000007;
long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }

int main() {

	long N; cin >> N;;
	cout << N * N * N << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;

    int max=0,second=0,count=0;

    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]>max){
            max=a[i];
        }
    }
    for(int i=0;i<n;i++){
        if(a[i]!=max&&a[i]>second){
            second=a[i];
        }
    }
    for(int i=0;i<n;i++){
        if(a[i]==max){
            count++;
        }
    }

    if(count>1){
        for(int i=0;i<n;i++){
            cout<<max<<endl;
        }
    }
    else {
        for(int i=0;i<n;i++){
            if(a[i]==max){
                cout<<second<<endl;
            }
            else{
                cout<<max<<endl;
            }
        }
    }
}


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

using namespace std;
using ll = long long;
using Pll = pair<ll, ll>;
constexpr ll MOD = 1000000007;

ll modpow(ll a, ll n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret = ret * a % MOD;
    a = a * a % MOD;
    n >>= 1;
  }
  return ret;
}

int main() {
  int N;
  cin >> N;
  map<Pll, Pll> mp;
  ll zero = 0;
  for (int i = 0; i < N; ++i) {
    ll l, r;
    cin >> l >> r;
    if (l < 0) {
      l = -l;
      r = -r;
    }
    if (l == 0 && r == 0) {
      zero++;
    } else {
      ll dv = abs(gcd(l, r));
      if (l == 0)
        mp[{0, 1}].first++;
      else if (r == 0)
        mp[{0, 1}].second++;
      else if (r > 0)
        mp[{l / dv, r / dv}].first++;
      else
        mp[{-r / dv, l / dv}].second++;
    }
  }
  ll ans = 1;
  for (auto p : mp)
    ans = ans * (modpow(2, p.second.first) + modpow(2, p.second.second) - 1) %
          MOD;
  cout << ((ans + zero - 1 + MOD) % MOD) << endl;
  return 0;
}

Measured memory_bytes: 19140
#include <bits/stdc++.h>
#include <time.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define ld          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define pi          3.14159265358979323

ll n, a, b, c, d;
string s;

bool ok(ll x, ll y)
{
       for(ll i=x; i<y; i++)
       {
              if(s[i]=='#' && s[i+1]=='#') return 0;
       }
       return 1;
}

bool good(ll x, ll y)
{
  for(ll i=x; i<=y; i++)
  {
    if(s[i-1]=='.' && s[i]=='.' && s[i+1]=='.')
      return 1;
  }
  return 0;
}


void solve()
{
       cin>>n>>a>>b>>c>>d>>s;
       a--, b--, c--, d--;
       if(!ok(a,c) || !ok(b,d)){
         cout<<"No\n";
         return;
       }
       
         if(d>c)
         {	
           if(ok(a, c) && ok(b, d))
           {
            cout<<"Yes\n";
            return;
           }
         }
        if(c>d){
          if(ok(a, c) && ok(b, d) && good(b,d)){
            cout<<"Yes\n";
            return;
          }
        }
  		cout<<"No\n";
}

int main()
{
       speed_up;
       //pre();
       ll T=1;
       //cin>>T;
       while(T--) solve();
	return 0;
}


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

using namespace std;

void hawawa(){
	string str;
	cin >> str;
	long long k;
	cin >> k;
	long long now = 0;
	for (auto&& i : str) {
		if (i == '1') {
			now++;
			continue;
		}
		else {
			if (k <= now) cout << "1\n";
			else cout << i << "\n";
			return;
		}
	}
	cout << "1\n";
}

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


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] A = new int[N];

        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }

        int[] pre = new int[N];
        while (K-- > 0) {
            for (int i = 0; i < N; i++) {
                pre[i] = 0;
            }
            for (int i = 0; i < N; i++) {
                int d = A[i];
                pre[Math.max(i-d,0)]++;
                if (i+d+1 < N) {
                    pre[i+d+1]--;
                }
            }
            boolean allN = true;
            int now = 0;
            for (int i = 0; i < N; i++) {
                now += pre[i];
                A[i] = now;
                if (A[i] != N) {
                    allN = false;
                }
            }
            if (allN) {
                break;
            }
        }

        StringBuilder ans = new StringBuilder();
        for (int i = 0; i < N; i++) {
            ans.append(A[i]).append(' ');
        }

        System.out.println(ans.toString());
    }
}


Measured memory_bytes: 63568
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int m, d;
    cin >> m >> d;

    int r = 0;
    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= d; j++) {
            int a = j / 10;
            int b = j % 10;
            if (a >= 2 && b >= 2 && a * b == i) r++;
        }
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 764
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;

int bfs(int stage[12][12]){

	int count = 0;
	for(int y=0;y<12;y++){
		for(int x=0;x<12;x++){
			if(stage[y][x]==0) continue;
			count++;
			queue<P> que;
			que.push(P(x,y));

			while(!que.empty()){
				int x = que.front().first;
				int y = que.front().second;

				que.pop();

				stage[y][x] = 0;

				for(int i=-1;i<=1;i++){
					for(int j=-1;j<=1;j++){
						if(i*j != 0 || (i==j && i==0)) continue;
						int dx = x + i;
						int dy = y + j;

						if(dx < 0 || dx >=12 || dy < 0 || dy >= 12) continue;
						if(stage[dy][dx]==0) continue;
						que.push(P(dx,dy));
					}
				}
			}
		}
	}
	return count;
}

int main(){
	string str;

	int stage[12][12];

	while(getline(cin,str)){
		if(str.empty()) continue;

		for(int y=0;y<12;y++){
			for(int x=0;x<12;x++){
				stage[y][x]=str[x]-'0';
			}
			getline(cin,str);
		}

		cout << bfs(stage) << endl;
	}
}

Measured memory_bytes: 7076
#include<iostream>
using namespace std;
struct T{int first,last;};
struct T ttt[200];
int n,ch[200],u,V[200][200],ti=1,a;
bool Discovery[200];
void search(int p){
    ttt[p].first=ti;ti++;
    int x;
    Discovery[p]=true;
    for(int i=1;i<=ch[p];i++){
        x=V[p][i];
        if(!Discovery[x]) search(x);
    }
    ttt[p].last=ti; ti++;
}
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a>>ch[i];
        Discovery[i]=false;
        for(int j=1;j<=ch[i];j++){
            cin>>V[i][j];
        }
    }
    for(int i=1;i<=n;i++){
        if(!Discovery[i]) search(i);
    }
    for(int i=1;i<=n;i++){
        cout<<i<<" "<<ttt[i].first<<" "<<ttt[i].last<<endl;
    }
    return 0;
}


Measured memory_bytes: 3172
import math
n=int(input())
for _ in range(n):
    l=[float(i) for i in input().split()]
    d=math.hypot(l[3]-l[0],l[4]-l[1])
    print([2,-2,1,0][[d<l[2]-l[5],d<l[5]-l[2],d<=l[2]+l[5],d>l[2]+l[5]].index(True)])
    


Measured memory_bytes: 5668
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;

#define inf int(0x3f3f3f3f)
#define mod int(1e9+7)
#define pi acos(-1.0)


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    ll sum=0;
    cin>>n;
    ll nn=n;
    while(nn)
    {
        sum+=nn%10;
        nn/=10;
    }
    if(n%sum==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}



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

typedef long long int ll;


int main(){
  ll x;
  cin>>x;
  ll i=0;
  ll amt=100;
  while(1){
    if(amt>=x){
      cout<<i<<endl;
      break;
    }
    amt*=1.01;
    i++;
  }

return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define crap ios_base::sync_with_stdio(0);cin.tie(0)
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define endl "\n"
#define int ll

using namespace std;
const int INF = 1e18L;
int n;
double A[3001];
double dp[3001][3001];

double solve(int index,int head){
	if(index==n){
		if(index-head<head){
			return 1;
		}
		else 
			return 0;
	}
	if(dp[index][head]!=-1) return dp[index][head];
	if(index-head>(n-1)/2) return 0;
	double a,b=0;

	a =  A[index]*solve(index+1,head+1);
	/*if(index-head+1<=(n-1)/2)*/ b = (1-A[index])*solve(index+1, head);
	

	return dp[index][head]=a+b;
}

int32_t main()
{
   
   
    crap;
    for(int i=0;i<=3000;i++){
    	for(int j=0;j<=3000;j++)
    		dp[i][j]=-1;
    }
    cin>>n;
    for(int i=0;i<n;i++) cin>>A[i];

    double ans = solve(0,0);//index and count of head
    cout<<fixed<<setprecision(9)<<ans<<endl;
   
}

Measured memory_bytes: 70784
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from fractions import gcd
def resolve():
    x1,y1,x2,y2=pin()
    a=y2-y1
    b=x2-x1
    x3=x2-a;y3=y2+b
    x4=x1-a;y4=y1+b
    print(x3,y3,x4,y4)
    
        
#%%submit!    
resolve()

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

int main(void) {
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  vector<vector<int>> G(N);
  rep(i, N - 1) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }

  const int64_t mod = 1e9 + 7;
  int64_t answer = K;
  queue<pair<int, int>> bfs;
  bfs.emplace(0, -1);
  while (!bfs.empty()) {
    int size = bfs.size();
    rep(i, size) {
      int u, from;
      tie(u, from) = bfs.front();
      bfs.pop();
      if (K < (int)G[u].size()) {
        cout << 0 << endl;
        return 0;
      }
      int col = (from == -1) ? K - 1 : K - 2;
      for (auto v : G[u]) {
        if (v == from) continue;
        answer *= col;
        answer %= mod;
        col--;
        bfs.emplace(v, u);
      }
    }
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 9916
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll dp[s.size()+1][13];
    rep(i,s.size()+1)rep(j,13)dp[i][j]=0;
    dp[0][0] = 1;
    rep(i, s.size())
    {
        rep(j, 13)
        {
            if (s[i] == '?')
            {
                rep(k, 10)
                {
                    ll g=(j*10 + k)%13;
                    dp[i + 1][g] += dp[i][j];
                    if(dp[i + 1][g]>=MOD)dp[i + 1][g]-=MOD;
                }
            }
            else
            {
                ll g=(j * 10 + (s[i] - '0'))%13;
                dp[i + 1][g] += dp[i][j];
                if(dp[i + 1][g]>=MOD)dp[i + 1][g]-=MOD;
            }
        }
    }
    cout << dp[s.size()][5] << endl;
}


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

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

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

  vector<char> ans(n);
  bool ok = false;
  for (int i = 0; i < 4; i++) {
    vector<char> tmp(n);
    if(i == 0) tmp[0] = tmp[1] = 'S';
    if(i == 1) tmp[0] = tmp[1] = 'W';
    if(i == 2) tmp[0] = 'S', tmp[1] = 'W';
    if(i == 3) tmp[0] = 'W', tmp[1] = 'S';
    for (int j = 1; j < n - 1; j++) {
      if(s[j] == 'o') {
        if(tmp[j] == 'S') {
          tmp[j + 1] = tmp[j - 1];
        }
        if(tmp[j] == 'W') {
          if(tmp[j - 1] == 'W') tmp[j + 1] = 'S';
          if(tmp[j - 1] == 'S') tmp[j + 1] = 'W';
        }
      }
      if(s[j] == 'x') {
        if(tmp[j] == 'W') {
          tmp[j + 1] = tmp[j - 1];
        }
        if(tmp[j] == 'S') {
          if(tmp[j - 1] == 'W') tmp[j + 1] = 'S';
          if(tmp[j - 1] == 'S') tmp[j + 1] = 'W';
        }
      }
    }

    bool flag = true;
    for (int j = 0; j < n; j++) {
      int pre = j - 1;
      int nxt = j + 1;
      if(j == 0) pre = n - 1;
      if(j == n - 1) nxt = 0;

      if(s[j] == 'o') {
        if(tmp[j] == 'S') {
          if(tmp[pre] != tmp[nxt]) flag = false;
        }
        if(tmp[j] == 'W') {
          if(tmp[pre] == tmp[nxt]) flag = false;
        }
      }
      if(s[j] == 'x') {
        if(tmp[j] == 'S') {
          if(tmp[pre] == tmp[nxt]) flag = false;
        }
        if(tmp[j] == 'W') {
          if(tmp[pre] != tmp[nxt]) flag = false;
        }
      }
    }
    if(flag) {
      for (int j = 0; j < n; j++) ans[j] = tmp[j];
      ok = true;
      break;
    }
  }
  if(ok) {
    for (auto it : ans) cout << it;
    cout << '\n';
  } else {
    cout << -1 << '\n';
  }
}

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

int main() {
	int a,b,c,d;
	cin >> a>>b>>c>>d;
	while(1){
		c-=b;
		if(c<=0){
			cout << "Yes" << endl;
			return 0;
		}
		a-=d;
		if(a<=0){
			cout << "No" << endl;
			return 0;
		}
		
	}
	
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_b() {
	ll n, m;
	ll x, y;
	//ll a, b, c;
	ll k;
	ll l;
	string s, t;
	ll l_ans = 0;
	float f_ans = 0;
	string s_ans;

	cin >> n >> l;

	vector<string> sl(n);
	rep(i, n) {
		cin >> sl[i];
	}

	sort(ALL(sl));

	rep(i, n) {
		cout << sl[i];
	}

	cout << "\n";
}

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

	solve_abc_b();

	return 0;
}


Measured memory_bytes: 3612
x,k,d = map(int,input().split())
if abs(x) / d >= k:
    print(abs(x) - d * k)
else:
    if (k - abs(x) // d) % 2 == 0:
        print(abs(abs(x) - d * (abs(x) // d)))
    else:
        print(abs(abs(x) - d * (abs(x) // d + 1)))

Measured memory_bytes: 9072
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int q = sc.nextInt();
    String s = sc.next();
    int[] c = new int[n];
    int count = 0;
    for (int i =0;i<n-1;i++){
      if ("AC".equals(s.substring(i,i+2))){
        count++;
      }
      c[i+1] = count;
    }
    for (int i = 0;i<q;i++){
      int l = sc.nextInt();
      int r = sc.nextInt();
      int ans = c[r-1]-c[l-1];
      System.out.println(ans);
    }
    sc.close();
  }
}

Measured memory_bytes: 68624
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define riverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
const int MOD = 1e9+7;

int main() {
	int N;
  	cin >> N;
  	vi a(N);
  	rep(i,N) cin >> a[i];
  	sort(a);
  	int ans;
	ans = a[N-1] - a[0];
  	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a;
	cin >> a;
	int mini = 1000;
	int f;
	int s;
	int t;
	for(int i = 0; i < a.size() - 2; i++){
		if(a[i] == '1')f = 1;
		if(a[i] == '2')f = 2;
		if(a[i] == '3')f = 3;
		if(a[i] == '4')f = 4;
		if(a[i] == '5')f = 5;
		if(a[i] == '6')f = 6;
		if(a[i] == '7')f = 7;
		if(a[i] == '8')f = 8;
		if(a[i] == '9')f = 9;

		if(a[i + 1] == '1')s = 1;
		if(a[i + 1] == '2')s = 2;
		if(a[i + 1] == '3')s = 3;
		if(a[i + 1] == '4')s = 4;
		if(a[i + 1] == '5')s = 5;
		if(a[i + 1] == '6')s = 6;
		if(a[i + 1] == '7')s = 7;
		if(a[i + 1] == '8')s = 8;
		if(a[i + 1] == '9')s = 9;

		if(a[i + 2] == '1')t = 1;
		if(a[i + 2] == '2')t = 2;
		if(a[i + 2] == '3')t = 3;
		if(a[i + 2] == '4')t = 4;
		if(a[i + 2] == '5')t = 5;
		if(a[i + 2] == '6')t = 6;
		if(a[i + 2] == '7')t = 7;
		if(a[i + 2] == '8')t = 8;
		if(a[i + 2] == '9')t = 9;

		int r = f * 100 + s * 10 + t;

		if(r > 753){
			mini = min(mini,r - 753);
		}
		else{
			mini = min(mini,753 - r);
		}
	}
	cout << mini << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())

mod = 10**9 + 7

li = [0]*(N+2)
li[0] = 0
li[1] = 1
for i in range(M):
    a = int(input())+1
    li[a] = -1

for i in range(2, N+2):
    if li[i] == -1:
        li[i] = 0
    else:
        li[i] = (li[i-1] + li[i-2]) % mod

print(li[-1])


Measured memory_bytes: 44120
let N = Int(readLine()!)!
var As: [Int] = readLine()!.split(separator: " ").map { Int($0)! }
As.sort(by: >)

var res: Int = As[0]

for i in 0 ..< N - 2 {
    res += As[1 + i / 2]
}
print(res)  // (๑•ૅㅁ•๑)

Measured memory_bytes: 21024
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

a, b, c, d = LI()

ans = max(a*c, a*d, b*c, b*d)
print(ans)

Measured memory_bytes: 10956
#include<iostream>
using namespace std;
int main() {
	int a, b, c;
	int i, j, k;
	int x;
	int sum = 0;
	cin >> a >> b >> c >> x;
	for (i = 0; i <= a; i++) {
		for (j = 0; j <= b; j++) {
			for (k = 0; k <= c; k++) {
				if (500 * i + 100 * j + 50 * k == x) {
					sum++;
				}
			}
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using ll = long long;
using PP = pair<ll, P>;
#define rep(i,n) for(int i = 0; i < n; i++)
const int mx = 100005;
const int md = 1e9+7;
int n, m, s[2], u, v, w;
ll dis[2][mx], comb[2][mx], tm, ans, a2;
vector<P> node[mx];
priority_queue<PP, vector<PP>, greater<PP>> pq;
int main(){
	scanf("%d%d", &n, &m);
	scanf("%d%d", s, s+1);s[0]--;s[1]--;
	rep(i,m){
		scanf("%d%d%d", &u, &v, &w);u--;v--;
		node[u].push_back(P{w,v});
		node[v].push_back(P{w,u});
	}
	rep(i,2){
		pq.push(PP{1, P{s[i],s[i]}}); comb[i][s[i]] = 1;
		while(!pq.empty()){
			PP tmp = pq.top(); pq.pop();
			int now = tmp.second.second;
			if(dis[i][now]){
				if(dis[i][now] == tmp.first) (comb[i][now] += comb[i][tmp.second.first]) %= md;
				continue;
			}
			dis[i][now] = tmp.first;
			comb[i][now] = comb[i][tmp.second.first];
			for(P it : node[now]) if(!dis[i][it.second]){
				pq.push(PP{tmp.first + it.first, P{now, it.second}});
			}
		}
	}
	rep(i,n) rep(j,2) (comb[j][i] *= comb[j][i]) %= md;
	rep(i,n){
		if(dis[0][i] + dis[1][i] == dis[0][s[1]]+1 && dis[0][i] == dis[1][i]){
			ans += comb[0][i]*comb[1][i]%md;
		}
		for(auto it: node[i]) if(it.second > i){
			ll w = it.first;
			rep(j,2){
				ll d[2] = {dis[j][i], dis[j^1][it.second]};
				if(d[0]+d[1]+w == dis[0][s[1]]+1 && d[0]<d[1]+w && d[1]<d[0]+w){
					(ans += comb[j][i]*comb[j^1][it.second]) %= md;
				}
			}
		}
	}
	printf("%lld\n", (comb[0][s[1]] - ans + md)%md);
}


Measured memory_bytes: 14200