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

int Max = 100001;


void dfs(int v, vector<vector<int>> &ar ,vector<int> &dp, vector<int> &vis ){
    vis[v] = 1;
    
    for(int c : ar[v]){
        
        if(vis[c] == 0){
            dfs(c, ar, dp, vis);
        }
        
        dp[v] = max(dp[v] , 1+dp[c]);
    }
    
    return;
}
int main() {
  
     int n,m;
     cin>>n>>m;

vector<vector<int>> ar(n+1);
vector<int> vis(n+1,0);
vector<int> dp(n+1,0);
     
     int a,b;
     for(int i=0; i<m ; i++){
         cin>>a>>b;
         ar[a].push_back(b);
     }
     
     for(int i=1; i<=n; i++){
         if(vis[i] == 0){
             dfs(i, ar, dp, vis);
         }
     }
     
     int ma =0;
     for(int i=1; i<=n ; i++){
         ma = max(ma, dp[i]);
     }
     
     cout<<ma<<endl;
    return 0;
}



Measured memory_bytes: 12856
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int main()
{
	int x,nw=0,ans=0; cin>>x;
	while(1)
	{
		nw+=x; if(nw>=360) nw-=360;
		ans++; if(nw==0) break;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3620
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 1000000007
#define mxval 1e9 + 7
#define grt [](auto x,auto y){return x>y;}
#define pii pair<int,int>
/*********VARIABLE****************/
using namespace std;
int i,j,n,m,k,l,q,t,a,b,sum[3],tot[3],cnt[3];
/*********FUNCTIONS**************/
int powom(int a,int b) {
    int result = 1;
    while (b > 0) {
        if (b & 1)
            result = result * a;
        a = a * a;
        b >>= 1;
    }
    return result;
}
/***********MAIN**************/
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n;
	vector<int> v(n);
	for(auto &x : v){
		cin>>x;
	}
	int ans = 0;
	for(int i=0;i<(n-1);i++){
		for(int j=i+1;j<n;j++){
			ans += v[i]*v[j];
		}
	}
	cout<<ans;
	return 0;
}
//.........

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define cs const
#define re register
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define fi first
#define se second
#define bg begin
cs int RLEN=1<<20|1;
inline char gc(){
    static char ibuf[RLEN],*ib,*ob;
    (ib==ob)&&(ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
    return (ib==ob)?EOF:*ib++;
}
inline int read(){
    char ch=gc();
    int res=0;bool f=1;
    while(!isdigit(ch))f^=ch=='-',ch=gc();
    while(isdigit(ch))res=(res+(res<<2)<<1)+(ch^48),ch=gc();
    return f?res:-res;
}
template<class tp>inline void chemx(tp &a,tp b){a<b?a=b:0;}
template<class tp>inline void chemn(tp &a,tp b){a>b?a=b:0;}
cs int mod=1e9+7;
inline int add(int a,int b){return (a+=b)>=mod?(a-mod):a;}
inline int dec(int a,int b){a-=b;return a+(a>>31&mod);}
inline int mul(int a,int b){static ll r;r=1ll*a*b;return (r>=mod)?(r%mod):r;}
inline void Add(int &a,int b){(a+=b)>=mod?(a-=mod):0;}
inline void Dec(int &a,int b){a-=b,a+=a>>31&mod;}
inline void Mul(int &a,int b){static ll r;r=1ll*a*b;a=(r>=mod)?(r%mod):r;}
inline int ksm(int a,int b,int res=1){for(;b;b>>=1,Mul(a,a))(b&1)&&(Mul(res,a),1);return res;}
inline int Inv(int x){return ksm(x,mod-2);}
inline int fix(int x){return (x<0)?x+mod:x;}
cs int N=1005,M=22;
int f[M][N],c[N][N];
int n,K,a[M];
int main(){
	#ifdef Memoria
	freopen("lx.in","r",stdin);
	#endif
	n=read(),K=read();
	for(int i=1;i<=K;i++)a[i]=read();
	for(int i=0;i<=n;i++){
		c[i][0]=c[i][i]=1;
		for(int j=1;j<i;j++)
		c[i][j]=add(c[i-1][j-1],c[i-1][j]);
	}
	f[0][0]=1;
	for(int i=1;i<=K;i++)
	for(int j=0;j<=n;j++)
	for(int k=0;k<=j;k++)if(a[i]>=j-k){
		Add(f[i][j],mul(f[i-1][k],mul(c[n-k][j-k],c[n-j+k][a[i]-j+k])));
	}
	cout<<f[K][n]<<'\n';
}


Measured memory_bytes: 4352
#include <iostream>

void swap(int*, int*);

using namespace std;

int main(){
	int i, n, A[100000], cnt = -1;
	
	cin >> n;
	for(i=0;i<n;++i)cin >> A[i];
	for(i=0;i<n;++i){
		if(A[i] <= A[n-1]){
			cnt++;
			swap(&A[cnt], &A[i]);
		}
	}
	
	for(i=0;i<n;++i){
		if(i == cnt) cout << "[";
		cout << A[i];
		if(i == cnt) cout << "]";
		if(i != n-1) cout << " ";
	}
	cout << "\n";
	
	return 0;
}

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


Measured memory_bytes: 3472
n,k = map(int,input().split())
x = list(map(int,input().split()))
mint = 10000000000
for i in range(n-k+1):
    l = x[i]
    r = x[i+k-1]
    if l > 0:
        t = r
    elif r < 0:
        t = -l
    else:
        t = min((2*r-l),r-2*l)
    mint = min(t,mint)
print(mint)


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

const ll INF = 1LL << 60;

ll S, W;
int main() {
    cin >> S >> W;
    if (S <= W) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,t,a;
  cin >> n >> t >> a;
  
  vector<double> h(n);
  for (double &x:h){
    cin >> x;
    x = t - x*0.006;
  }
  
  double min = abs(a-h.at(0));
  int nmin = 1;
  for (int i = 0; i<n; i++){
    if(abs(a-h.at(i)) < min){
      min = abs(a-h.at(i));
      nmin = i+1;
    }
  }
  cout << nmin << endl;
  return 0;
}
     

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int n,l,cnt=0,sum,ans=1000000,cnt1;
  cin >> n >> l;
  for(int i=1; i<=n; i++) {
    cnt+=l+i-1;
  }
  sum=cnt;
  for(int i=1; i<=n; i++) {
    cnt=sum;
    cnt-=l+i-1;
    if(ans>abs(cnt-sum)) {
    ans=abs(cnt-sum);
    cnt1=cnt;
    }
  }
  cout << cnt1 << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;

public class Main {

	public static final int BIG_NUM = 2000000000;
	public static final int MOD = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			String input[] = br.readLine().split("\\s+");

			BigInteger A = new BigInteger(input[0]);
			BigInteger B = new BigInteger(input[1]);

			BigInteger ans;

			ans = A.divide(B);
			System.out.println(ans);

		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
	}
}




Measured memory_bytes: 24884
#include <cstdio>
#include <vector>
using namespace std;

int main() {
	int n;
	int i,max=-1;
	int C[100001] = {0};
	vector<int> A,B;
	scanf("%d",&n);
	A.resize(n);
	B.resize(n);
	C[0]=0;
	for(i=0; i<n; ++i) {
		scanf("%d",&A[i]);
		max=(max<A[i]?A[i]:max);
	}
	for(i=0; i<=max; ++i) {
		C[i]=0;
	}
	for(i=0; i<n; ++i) {
		++C[A[i]];
	}
	for(i=1; i<=max; ++i) {
		C[i]=C[i]+C[i-1];
	}
	for(i=n-1; i>=0; --i) {
		B[C[A[i]]-1] = A[i];
		--C[A[i]];
	}
	for(i=0; i<n-1; ++i) {
		printf("%d ",B[i]);
	}
	printf("%d\n",B[n-1]);
	return 0;
}

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

int main() {
  char str1[52];
  string S;
  int N;
  int Nans = 0;
  strcpy(str1, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXY");
  cin >> N;
  Nans = N % 26;
  cin >> S;
  int si = S.size();
  for (int i = 0; i < si; i++) {
    for (int j = 0; j < 26; j++) {
      if (S[i] == str1[j]) {
        // cout << S[i];
        cout << str1[j + Nans];
        break;
      }
    }
  }
  return 0;
}
// g++ lo.cpp
// ./a.exe

Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXNEED=100000;
const int MOD=1000000007;

int need,a,b,c;

int inv[2*MAXNEED+1];
int fac[2*MAXNEED+1];
int ifac[2*MAXNEED+1];
int choose(int n,int k) { if(k<0||k>n) return 0; return (ll)fac[n]*ifac[k]%MOD*ifac[n-k]%MOD; }

int Apw[MAXNEED+1];
int Bpw[MAXNEED+1];

int dp[2*MAXNEED+1];


int solve() {
	inv[1]=1; FORE(i,2,2*MAXNEED) inv[i]=(ll)(MOD-MOD/i)*inv[MOD%i]%MOD;
	fac[0]=1; FORE(i,1,2*MAXNEED) fac[i]=(ll)fac[i-1]*i%MOD;
	ifac[0]=1; FORE(i,1,2*MAXNEED) ifac[i]=(ll)ifac[i-1]*inv[i]%MOD;

	dp[0]=0; FORE(i,1,2*MAXNEED) dp[i]=(ll)(100+(ll)(a+b)*dp[i-1]%MOD)*inv[100-c]%MOD;
	//printf("dp:"); REPE(i,2*need) printf(" %d",dp[i]); puts("");

	int ret=0;
	REP(rep,2) {
		int A=(ll)a*inv[a+b]%MOD;
		int B=(ll)b*inv[a+b]%MOD;
		Apw[0]=1; FORE(i,1,need) Apw[i]=(ll)Apw[i-1]*A%MOD;
		Bpw[0]=1; FORE(i,1,need) Bpw[i]=(ll)Bpw[i-1]*B%MOD;

		FORE(total,need,2*need-1) {
			//printf("rep=%d, total=%d: %d*%d*%d*%d\n",rep,total,choose(total-1,need-1),Apw[need],Bpw[total-need],dp[total]);
			int cur=(ll)choose(total-1,need-1)*Apw[need]%MOD*Bpw[total-need]%MOD*dp[total]%MOD;
			ret=(ret+cur)%MOD;
		}
		swap(a,b);
	}
	return ret;
}

void run() {
	scanf("%d%d%d%d",&need,&a,&b,&c);
	printf("%d\n",solve());
}

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


Measured memory_bytes: 4096
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll n, x, ans = 0;
	std::cin >> n >> x;
	vll a(n);
	rep(i, 0, n) {
		std::cin >> a[i];
		if (a[i] > x) {
			ans += a[i] - x;
			a[i] = x;
		}
	}

	rep(i, 1, n) {
		ll tmp = a[i - 1] + a[i] - x;
		if (tmp>0) {
			if (a[i] < tmp) {
				a[i] =0;
			}
			else {
				a[i] -=tmp;
			}
			ans += tmp;
		}
	}
	outn(ans);
	return 0;
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    public static void main (String [] args) throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        //--------------------------START CODING HERE-----------------------------
        String line =f.readLine();
        if(line.matches("[a-z]"))
            out.print("a");
        else
            {
                out.print("A");
            }

        out.close();
    }
}

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


int main(){
    int n;
    cin >> n;
    string w, v;
    vector<string> si(n);
    for (int i = 0; i < n; i++){
        cin >> w;
        si[i] = w;
        if (i > 0){
            v = si[i - 1];
            for (int j = 0; j < i; j++){
                if (si[i] == si[j]){
                    cout << "No" << endl;
                    return 0;
                }
            }
            if (w[0] != v[v.size()-1]){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DEBUG if(0)
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	DEBUG cout << a << " " <<  b << endl;
	string a1 = "", b1 = "";
	for(int i = 0; i < a; i++) b1 += (b + '0');
	for(int i = 0; i < b; i++) a1 += (a + '0');
	DEBUG cout << a1 << endl <<  b1 << endl;
	cout << (a1 < b1 ? a1 : b1) << endl;
	return 0;
}


Measured memory_bytes: 256
// JAI SHREE RAM
#pragma GCC optimize("O3")
typedef long long int ll;
typedef unsigned long long int ull;
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define sz(a) int((a).size())
#define forn(i, n) for (int i = 0; i < (n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
#define loop for(int i=0;i<n;i++)
#define max3(a,b,c) max(a,max(b,c))
#define max4(a,b,c,d) max3(a,max(b,c),d)
#define max5(a,b,c,d,e) max4(a,max(b,c),d,e)
#define min3(a,b,c) min(a,min(b,c))
#define min4(a,b,c,d) min3(a,min(b,c),d)
#define min5(a,b,c,d,e) min4(a,min(b,c),d,e)
#define sec second
#define fir first
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repe(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
// #define all(a) (a).begin(),(a).end()
#define vec vector<int>
#define M_PI           3.14159265358979323846  /* pi */
#define pb push_back
#define pii pair<int,int>
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fast
	string s,t;
	cin>>s>>t;
	char c=*(--t.end());
	s=s+c;
	bool ok=true;
	for(int i=0;i<s.length();i++)
	if(s[i]!=t[i])
	{
		ok=false;
		break;
	}
	if(ok)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

vector<ll> divisors(ll n) {
  vector<ll> D;
  for (ll i=1; i*i<=n; i++) {
    if (n%i==0) {
      D.push_back(i);
      if (i*i!=n) D.push_back(n/i);
    }
  }
  return D;
}

int main() {
  ll n; cin >> n;
  set<ll> S;
  auto D = divisors(n);
  for (auto d: D) {
    ll m = n;
    if (d == 1) continue;
    while (m%d==0) m /= d;
    if (m==1) {
      S.insert(d);
      continue;
    }

    auto D2 = divisors(m-1);
    for (auto d2: D2) {
      if (d2 == 1) continue;
      if (d == d2) S.insert(d2);
    }
  }

  auto D3 = divisors(n-1);
  for (auto &&d3: D3) {
    if (d3 == 1) continue;
    S.insert(d3);
  }
  cout << S.size() << endl;
  return 0;
}


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

int gcd(int a, int b) {
    if(a < b)
        return gcd(b, a);
    int r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

int main() {
    int n;
    cin >> n;
    int a[n];
    int maxA = 0;
    rep(i, n) {
        cin >> a[i];
        maxA = max(maxA, a[i]);
    }
    int gcd1[n];
    int gcd2[n];
    gcd1[0] = a[0];
    gcd2[n - 1] = a[n - 1];
    for (int i = 1; i < n; i++) {
        gcd1[i] = gcd(gcd1[i - 1], a[i]);
    }
    for (int i = n - 2; i >= 0; i--) {
        gcd2[i] = gcd(gcd2[i + 1], a[i]);
    }
    int maxGcd = 0;
    rep(i, n) {
        int v;
        if (i == 0) {
            v = gcd2[1];
        } else if (i == n - 1) {
            v = gcd1[n - 2];
        } else {
            v = gcd(gcd1[i - 1], gcd2[i + 1]);
        }
        maxGcd = max(maxGcd, v);
    }
    cout << maxGcd << endl;
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N; i >= 0; i--)
#define PI 3.1415936535//ここ

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;}

char upper(char c){
    if('a' <= c && c <= 'z'){
        c = c - ('a' - 'A');
    }
    return c;
}

char lower(char c){
    if('A' <= c && c <= 'Z'){
        c = c + ('a' - 'A');
    }
    return c;
}

const ll INF = 1000000000;

//input
int A,B;


//processing


//dpTable
int dp[100050];

int main(){
    cin >> A >> B;
    cout << A * B << endl;
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		String n = scanner.nextLine();
		long result = 0;
		String[] fizzList = new String[Integer.parseInt(n)];

		for(int i = 1; i <= Integer.parseInt(n); i++) {
			if(i % 3 == 0 && i % 5 ==0) {
				fizzList[i - 1] = "FizzBuzz";
			}else if(i % 3 == 0){
				fizzList[i - 1] = "Fizz";
			}else if(i % 5 == 0){
				fizzList[i - 1] = "Buzz";
			}else {
				fizzList[i - 1] = String.valueOf(i);
				result += i;
			}
		}

		System.out.println(result);

	}

}


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

using namespace std;
#define int long long
typedef long long ll;

std::vector<std::string> split(const std::string &str, char sep)
{
    std::vector<std::string> v;
    std::stringstream ss(str);
    std::string buffer;
    while( std::getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

signed main() {
    string s;
    cin >> s;
    if (s.length() == 3) reverse(s.begin(), s.end());
    cout << s << endl;
}



Measured memory_bytes: 256
#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>

using namespace std;

typedef long long ll;


#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)

#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)

class Point {
 public:
  double x, y;

  Point(double x = 0, double y = 0): x(x), y(y) {}

  Point operator + (Point p) { return Point(x+p.x, y+p.y); }
  Point operator - (Point p) { return Point(x-p.x, y-p.y); }
  Point operator * (double a) { return Point(a*x, a*y); }
  Point operator / (double a) { return Point(x/a, y/a); }

  double norm() { return x*x+y*y; }
  double abs() { return sqrt(norm()); }

  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator == (const Point &p) const {
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};

typedef Point Vector;
typedef vector <Vector> Polygon;

class Segment {
 public:
  Point p1, p2;

  Segment(Point p1 = Point(), Point p2 = Point()): p1(p1), p2(p2) {}
};
typedef Segment Line;

double norm(Vector a) {
  return a.x*a.x+a.y*a.y;
}

double abs(Vector a) {
  return sqrt(norm(a));
}
// ?????????|a||b|cos
double cross(Vector a, Vector b) {
  return a.x*b.y-a.y*b.x;
}
// ?????????|a||b|sin
double dot(Vector a, Vector b) {
  return a.x*b.x+a.y*b.y;
}

// ??´???l??¨???p????????¢
double getDistanceLP(Line l, Point p) {
  return abs(cross(l.p2-l.p1, p-l.p1))/abs(l.p2-l.p1);
}

// ?°???±:??´???s???p?????????????????????????????¨?????????????????????
Point project(Segment s, Point p) {
  Vector base = s.p2-s.p1;
  double r = dot(p-s.p1, base)/norm(base);
  return s.p1+base*r;
}

class Circle {
 public:
  Point c;
  double r;
  Circle(Point c = Point(), double r = 0.0): c(c), r(r) {}
};

double arg(Vector p) { return atan2(p.y, p.x); }
Vector polar(double a, double r) { return Point(cos(r)*a, sin(r)*a); }

// ???c1??¨???c2??????????????????:???????????°???????????¨???1?????§???????????´????????????2?????¨?????????
// ??????????????¨????????¶
pair<Point, Point> getCrossPoints(Circle c1, Circle c2) {
  double d = abs(c1.c-c2.c);
  double a = acos((c1.r*c1.r+d*d-c2.r*c2.r)/(2*c1.r*d));
  double t = arg(c2.c-c1.c);
  return make_pair(c1.c+polar(c1.r, t+a), c1.c+polar(c1.r, t-a));
}

int main() {
  Circle c1, c2;
  cin >> c1.c.x >> c1.c.y >> c1.r;
  cin >> c2.c.x >> c2.c.y >> c2.r;
  pair<Point, Point> ans = getCrossPoints(c1, c2);
  if (ans.second < ans.first) swap(ans.second, ans.first);
  cout << fixed << setprecision(20)
       << ans.first.x << " " << ans.first.y << " "
       << ans.second.x << " " << ans.second.y << endl;
}

Measured memory_bytes: 1340
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <iomanip>
using namespace std;
typedef long long int ll;
int gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int main(void){
    ll n , d  ;
    ll ans ,temp;
    cin >> n >> d ;
    ll a[n + 1] ;
    a[n] = d ;
    for(ll i = 0 ; i < n ; i ++){
        cin >> a[i] ;
    }

    sort(a , a + n+1) ;
    if(n == 1){
        ans = a[1] - a[0] ;
        cout << ans << endl;
    }else{
    ll b[n] ;
    for(ll j = 0 ; j < n ; j++){
        b[j] = a[j+1] - a[j] ; 
    }

    sort( b , b + n );
    
    ans = gcd(b[0] , b[1]) ;
    for(ll k = 0 ; k < n-3 ; k++){
         temp = gcd(ans , b[k+2]) ;
         ans = temp ;
    }
    
    cout << ans << endl;
    }
    return 0;
}

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

#define ll long long
//~ #define endl '\n'

void solve(){
	int r; cin>>r;
	cout<<r * r<<endl;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t = 1;// cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3624
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

long solve(int n)
{
  long sum = 0;
  for (int i = 1; i <= n; ++i) {
    if (i % 3 && i % 5) sum += i;
  }
  return sum;
}

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

  std::cout << std::setprecision(20);
  std::cout << solve(n) << std::endl;
}


Measured memory_bytes: 3636
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    visited_x = [0]*(10**5+1)
    visited_y = [0]*(10**5+1)
    adj_x = [[] for _ in range(10**5+1)]
    adj_y = [[] for _ in range(10**5+1)]

    # 二部グラフにおける隣接点
    for _ in range(n):
        x, y = map(int, input().split())
        adj_x[x].append(y)
        adj_y[y].append(x)

    res = 0
    for x in range(1, 10**5+1):
        if visited_x[x] or not adj_x[x]:
            continue
        visited_x[x] = 1
        vx = 1
        vy = 0
        #[x座標, 軸の方向]
        d = deque([[x, 0]])
        while d:
            v, axis = d.popleft()
            if axis == 0:
                for nv in adj_x[v]:
                    if visited_y[nv]:
                        continue
                    visited_y[nv] = 1
                    vy += 1
                    d.append([nv, 1])
            else:
                for nv in adj_y[v]:
                    if visited_x[nv]:
                        continue
                    visited_x[nv] = 1
                    vx += 1
                    d.append([nv, 0])
        res += vx * vy

    print(res-n)

if __name__ == '__main__':
    main()

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


int main() {
  int X, N;
  cin >> X >> N;

  vector<int> p(N);
  rep(i, N) cin >> p[i];

  if (N == 0){
    cout << X << endl;
    return 0;
  }

  vector<int> arr(201, 0);
  rep(i, N) arr[X - p[i] + 100] = 1;

  P ans;
  ans.first = 1000;
  ans.second = 1000;

  rep(i, 201){
    if(arr[i] == 0) {
      if (ans.first >= abs(i - 100)) {
        ans.first = abs(i - 100);
        ans.second = X - i + 100;
      }
    }
  }
  
  cout << ans.second << endl;
  return 0;
}


Measured memory_bytes: 3640
from collections import deque

dis_x = [1, 0, -1, 0]
dis_y = [0, 1, 0, -1]

h, w = map(int, input().split())
s = ["#{}#".format(input()) for _ in range(h)]
h += 2
w += 2

s = ["#" * w] + s + ["#" * w]

# 最終的な最大値
res_opt = -2

# 各ループ開始
for h_i in range(h):
  for w_i in range(w):
    if s[h_i][w_i] != '#':
      # BFS開始
      visited = [ [-1] * w for _ in range(h) ]
      visited[h_i][w_i] = 0
      queue = deque([(h_i, w_i)])
      
      while queue:
        y, x = queue.popleft()
        
        # 上下4マスに対して
        opt = 0
        for i in range(4):
          
          dx, dy = dis_x[i], dis_y[i]
          if s[y+dy][x+dx] == '.' and visited[y+dy][x+dx] == -1:
            visited[y+dy][x+dx] = visited[y][x] + 1
            opt = max(opt, visited[y+dy][x+dx])
            queue.append((y+dy, x+dx))
        res_opt = max(res_opt, opt)

print(res_opt)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  ll N,K;
  cin >> N >> K;
  vi A(N);
  vi F(N);
  rep(i,N) {
    cin >> A[i];
  }
  rep(i,N) {
    cin >> F[i];
  }
  sort(rng(A));
  sort(rng(F));
  reverse(rng(F));
  ll l = -1,r = LINF;
  while(l+1 < r) {
    ll mid = (l+r)/2;
    ll k = 0;
    rep(i,N) {
      k += max(0ll,A[i]- mid/F[i]);
    }
    if(k <= K) {
      r = mid;
    } else {
      l = mid;
    }
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
using namespace std;
int main()
{
	char a,b;
    cin>>a>>b;
    if (a==b)
    cout<<"H"<<endl;
    else
    cout<<"D"<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int n; cin >> n;
    int jud = n;
    int dig = 0;

    while(n != 0){
        dig += n%10;
        n /= 10;
    }

    if(jud %dig == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <sstream>
#include <fstream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <string>
#include <queue>
#include <bitset>
using namespace std;

#define int long long
#define FOR(i, a, b) for (int i = (a), _##i = (b); i <= _##i; ++i)
#define FORD(i, a, b) for (int i = (a), _##i = (b); i >= _##i; --i)
#define REP(i, a) for (int i = 0, _##i = (a); i < _##i; ++i)
#define REPD(i,n) for(int i = (n)-1; i >= 0; --i)

#define DEBUG(X) { cerr << #X << " = " << (X) << endl; }
#define PR(A, n) { cerr << #A << " = "; FOR(_, 1, n) cerr << A[_] << ' '; cerr << endl; }
#define PR0(A, n) { cerr << #A << " = "; REP(_, n) cerr << A[_] << ' '; cerr << endl; }

#define sqr(x) ((x) * (x))
#define ll long long
#define double long double
typedef pair<int, int> II;
#define __builtin_popcount __builtin_popcountll
#define SZ(x) ((int)(x).size())
#define ALL(a) (a).begin(), (a).end()
#define MS(a,x) memset(a, x, sizeof(a))
#define next ackjalscjaowjico
#define prev ajcsoua0wucckjsl
#define y1 alkscj9u20cjeijc
#define left lajcljascjljl
#define right aucouasocjolkjl
#define y0 u9cqu3jioajc

#define TWO(X) (1LL<<(X))
#define CONTAIN(S,X) ((S) & TWO(X))

int rand16() {
    return rand() & (TWO(16) - 1);
}
int my_rand() {
    return rand16() << 15 | rand16();
}

double safe_sqrt(double x) { return sqrt(max((double)0.0, x)); }
int GI(int& x) { return scanf("%lld", &x); }

const int MN = 100111;
int deg[MN];

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout << (fixed) << setprecision(9) << boolalpha;
    int n, m;
    while (cin >> n >> m) {
        memset(deg, 0, sizeof deg);
        FOR(i,1,m) {
            int u, v; cin >> u >> v;
            ++deg[u]; ++deg[v];
        }
        bool can = true;
        FOR(i,1,n) if (deg[i] % 2) can = false;
        cout << (can ? "YES" : "NO") << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <climits>
#include <bitset>
#include <cmath>

#define MOD 1000000007

using namespace std;

typedef long long ll;

typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<vl> vvl;
typedef vector<vi> vvi;

typedef pair<ll, ll> pll;
typedef pair<int, int> pi;

typedef vector<pll> vpl;
typedef vector<pi> vpi;

typedef queue<ll> ql;
typedef queue<int> qi;

template <class T>
void printv(vector<T> vc) {
    for (auto e: vc) cout << e << " ";
    cout << endl;
}

template <class T>
void printvv(vector<T> vvc) { 
    for (auto vc: vvc) {
        for (auto e: vc) cout << e << " ";
        cout << endl;
    }
}

template <class T>
void printvp(vector<pair<T, T> > vp) {
    for (auto pT: vp) cout << pT.first << " " << pT.second << endl;
}

int main() {
    int n, l;
    cin >> n >> l;
 
    vector<string> vs(n);
    for (int i = 0; i < n; i++) {
        cin >> vs[i];
    }
 
    sort(vs.begin(), vs.end());
    for (auto word: vs) cout << word;
    cout << endl;
 
    return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

D = INT()
if D == 22:
	print("Christmas Eve Eve Eve")
elif D == 23:
	print("Christmas Eve Eve")
elif D == 24:
	print("Christmas Eve")
else:
	print("Christmas")


Measured memory_bytes: 4012
mod=10**9+7
L=input()

m3=1
m3_list=[]
for i in range(len(L)):
  m3_list.append(m3)
  m3 = (3*m3)%mod                   
m3_list.reverse()
  
sum=0
cnt_2=1
for i in range(len(L)):  
  if L[i] == "1":
    #sum += cnt_2*(3**(len(L)-i-1))
    sum += cnt_2*m3_list[i]
    sum %= mod
    cnt_2 = (cnt_2*2)%mod
    
sum += cnt_2
sum %= mod
print(sum)

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


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

    int odd,even;
    if(n%2==0)even=n/2, odd=n/2;
    else even=n/2, odd=n/2+1;

    cout<<even*odd<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int n,m;
ll ans=0;
P p[100001];
void Solve(){
    cin>>m>>n;
    for(int i=0;i<m;i++) cin>>p[i].first>>p[i].second;
    sort(p,p+m);
    int j=0;
    while(n){
        if(p[j].second>=n){
            ans+=p[j].first*n;
            n=0;
        }
        else{
            ans+=p[j].second*p[j].first;
            n-=p[j].second;
            j++;
        }
    }
    cout<<ans<<endl;
}
int main(){
    Solve();
    return 0;
}

Measured memory_bytes: 1792
a,b,c,x,y=list(map(int,input().split()))
mxy=min([x,y])
Mxy=max([x,y])
mab=min([a,b])
ans=0
if 2*c<a+b:
	ans+=2*c*mxy
	if x<y:
		ans+=b*(y-mxy)
	else:
		ans+=a*(x-mxy)
else:
	ans=a*x+b*y

if ans>2*c*Mxy:
	ans=2*c*Mxy

print(ans)

Measured memory_bytes: 3064
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.List (unfoldr)
import Control.Monad
import Control.Monad.ST
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Builder as BSB
import System.IO (stdout)
import Data.Monoid

warshallFloyd1 :: Int -> U.Vector (Int, Int, Int) -> V.Vector (U.Vector Int)
warshallFloyd1 !n !edges = runST $ do
  !arr <- V.replicateM n (UM.replicate n (10^9+1))
  U.forM_ edges $ \(a,b,c) -> do
    UM.unsafeWrite (arr `V.unsafeIndex` a) b c
    UM.unsafeWrite (arr `V.unsafeIndex` b) a c
  forM_ [0..n-1] $ \a -> do
    UM.unsafeWrite (arr `V.unsafeIndex` a) a 0
  flip V.imapM_ arr $ \ !k !a_k -> do
    V.forM_ arr $ \ !a_i -> do
      !a_ik <- UM.unsafeRead a_i k
      forM_ [0..n-1] $ \j -> do
        a_kj <- UM.unsafeRead a_k j
        UM.unsafeModify a_i (min (a_ik + a_kj)) j
  V.mapM U.unsafeFreeze arr

warshallFloyd2 :: Int -> Int -> V.Vector (U.Vector Int) -> V.Vector (U.Vector Int)
warshallFloyd2 !n !l !graph = runST $ do
  !arr <- V.replicateM n (UM.replicate n (10^9+1))
  forM_ [0..n-1] $ \a -> do
    let !a_a = arr `V.unsafeIndex` a
    let !g_a = graph `V.unsafeIndex` a
    flip U.imapM_ g_a $ \b v -> do
      when (v <= fromIntegral l) $ do
        UM.unsafeWrite a_a b 1
    UM.unsafeWrite a_a a 0
  flip V.imapM_ arr $ \ !k !a_k -> do
    V.forM_ arr $ \ !a_i -> do
      !a_ik <- UM.unsafeRead a_i k
      forM_ [0..n-1] $ \j -> do
        a_kj <- UM.unsafeRead a_k j
        UM.unsafeModify a_i (min (a_ik + a_kj)) j
  V.mapM U.unsafeFreeze arr

main = do
  [n,m,l] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  edges <- U.replicateM m $ do
    [a,b,c] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    return (a-1,b-1,c)
  let !w1 = warshallFloyd1 n edges
      !w2 = warshallFloyd2 n l w1
  q <- readLn
  queries <- U.replicateM q $ do
    [s,t] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    return (s,t)
  BSB.hPutBuilder stdout $ mconcat [ BSB.intDec (if d > 10^9 then -1 else d - 1) <> BSB.char7 '\n' | (s,t) <- U.toList queries, let d = w2 `V.unsafeIndex` (s-1) `U.unsafeIndex` (t-1) ]


Measured memory_bytes: 7676
// 参考
// https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r"ant
obe
rec
" => r"abc",

r"edu
cat
ion
" => r"ean"
}

use std::cmp;
use std::collections::HashSet;
use std::f32::MAX;

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        c1: String,
        c2: String,
        c3: String
    }

    let a1: Vec<char> = c1.chars().collect();
    let a2: Vec<char> = c2.chars().collect();
    let a3: Vec<char> = c3.chars().collect();
    let mut ans: Vec<char> = Vec::new();
    ans.push(a1[0]);
    ans.push(a2[1]);
    ans.push(a3[2]);

    ans.into_iter().collect()
}


Measured memory_bytes: 4352
import java.util.Scanner


object Main {
  def read() = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val a = for (_ <- 0 until n) yield sc.nextLong()
    (n, a)
  }

  def solve(n: Int, a: IndexedSeq[Long]): Long = {
    val minAbs = a.map(Math.abs).min
    val cntMinus = a.count(n => n < 0)
    if (cntMinus % 2 == 0) a.map(Math.abs).sum
    else a.map(Math.abs).sum - 2 * minAbs
  }


  def solve2(n: Int, a: IndexedSeq[Long]): Long = {
    // .tail.init:headとlastを除去
    val (resultDPPlus, resultDPMinus) = a.tail.init.foldLeft((a(0), -a(0))) {
      case ((dpPlus, dpMinus), ae) =>
        val nextDPPlus = Math.max(dpPlus + ae, dpMinus - ae)
        val nextDPMinus = Math.max(dpPlus - ae, dpMinus + ae)
        (nextDPPlus, nextDPMinus)
    }

    Math.max(resultDPPlus + a.last, resultDPMinus - a.last)
  }

  def main(args: Array[String]): Unit = {
    val (n, a) = read()
    println(solve2(n, a))
  }
}

Measured memory_bytes: 62828
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
int main(){
  	int N;
  	cin >> N;
  	ll A[N];
  	for(int i=0;i<N;i++){
  		cin >> A[i];
  	}
  	sort(A, A+N);

  	for(int i=0;i<N-1;i++){
  		if(A[i]==A[i+1]){
  			cout << "NO" <<endl;
  			return 0;
  		}
  	}
  	cout << "YES" <<endl;
    
  	return 0;
}













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

using namespace std;

int main()
{
    long long N, D, x, y, cnt = 0;
    cin >> N >> D;

    for (long long i = 0; i < N; i++) {
        cin >> x >> y;
        if (sqrtl(x * x + y * y) <= D) cnt++;
    }

    cout << cnt << endl;
}

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

using namespace std;

int main(int argc, char const *argv[]) {
  string o, e, p;
  cin >> o >> e;
  if (o.size()==e.size()) {
    for (size_t i = 0; i < o.size(); i++) {
      p.push_back(o[i]);
      p.push_back(e[i]);
    }
  }
  else {
    for (size_t i = 0; i < e.size(); i++) {
      p.push_back(o[i]);
      p.push_back(e[i]);
    }
    p.push_back(o[o.size()-1]);
  }
  cout << p << endl;
  return 0;
}


Measured memory_bytes: 256
open System

let readInt () = stdin.ReadLine() |> int

let a500 = readInt ()
let b100 = readInt ()
let c50 = readInt ()
let x = readInt ()

[ for a in [ 0 .. a500 ] do
    for b in [ 0 .. b100 ] do
        for c in [ 0 .. c50 ] do
            yield a * 500 + b * 100 + c * 50 ]
|> List.map (fun sum -> if sum = x then 1 else 0)
|> List.sum
|> printfn "%d"

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define pb push_back
#define fst first
#define snd second
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

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


main(){
  int n,k; cin >> n >> k;
  ll ans = 0;

  FOR(i,1,n+1){ // b
    if(i <= k) continue;
    //cout << i;
    ans += ll(n / i) * (i - k);
    //cout << ans;
    if(k != 0)
      ans += max((n%i) - k + 1,0);
    else ans += max((n%i)-k,0);
    //cout << ans << endl;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c=0,d,e,f,g,h,k,n,m,t,pre=0;
int main(){
    ios_base::sync_with_stdio(false);
    string s;
    cin>>s;
    n=s.size();
    int a1=0,a2=0;
    for(int i=0;i<n;i++){
        if((i+1)&1){
            if(s[i]=='0');
            else a1++;

            if(s[i]=='1');
            else a2++;
        }
        else{
            if(s[i]=='0');
            else a2++;

            if(s[i]=='1');
            else a1++;
        }
    }
    cout<<min(a1,a2)<<endl;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;

int main(){
    int X, A, B; cin >> X >> A >> B;

    if(X >= B - A && B - A <= 0) {
        cout << "delicious" << endl;
    } else if(X >= B - A && B - A > 0){
        cout << "safe" << endl;
    } else {
        cout << "dangerous" << endl;
    }
}

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

typedef long long ll;
const ll INF = 1LL<<60, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define m_p make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,j,ans=INF;
    cin >> n;
    REP(i,1,1e6+1){
        if(n%i==0){
            j = n / i;
            ans = min(ans,i+j-2);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int w,h,n,x[105],y[105],a[105];
int s1=0,s2,s3=0,s4;
int main(){	
	cin>>w>>h>>n;
	s2=w;
	s4=h; 
	for(int i=1;i<=n;i++)
	{
		cin>>x[i]>>y[i]>>a[i];
		if(a[i]==1&&s1<x[i]) s1=x[i];
		if(a[i]==2&&s2>x[i]) s2=x[i];
		if(a[i]==3&&s3<y[i]) s3=y[i];
		if(a[i]==4&&s4>y[i]) s4=y[i];
	}
	w=s2-s1;
	h=s4-s3;
	if(w<=0||h<=0) cout<<0;
	else cout<<w*h; 
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=(n)-1;i>=0;--i)
#define REPI(i,a) for(typeof((a).begin()) i=(a).begin();i!=(a).end();++i)
#define REPIR(i,a) for(typeof((a).rbegin()) i=(a).rbegin();i!=(a).rend();++i)
#define FOR(i,a,b) for(typeof(a) i=a;i!=(b);++i)
#define CLEAR(a,v) memset(a,v,sizeof(a))
#define SORT(a) sort(a,a+sizeof(a)/sizeof(a[0]))
#define ALL(v) (v).begin(),(v).end()
#define MP make_pair
#define PB push_back
using namespace std;

typedef vector<int> VI;
typedef long long int LL;

int main(){
  LL N, sum = 0;
  cin >> N;
  VI A, B, C;
  REP(i,N){
    int a;
    cin >> a;
    A.PB(a);
    sum += a;
  }
  LL pt = N * (N+1) / 2;
  int ret = 1;
  if(sum % pt != 0){
    ret = 0;
  }else{
    sum /= pt;
    REP(i,N){
      int prev = (i + N - 1) % N;
      LL diff =  sum - A[i] + A[prev];
      if(diff < 0 || diff % N != 0){
        ret = 0;
        i = N;
      }
    }
  }
  cout << (ret == 1 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 892
import java.util.Scanner;
	
	public class Main {
		public static void main(String[] args) {
			// TODO 自動生成されたメソッド・スタブ
			Scanner sc = new Scanner(System.in);
			char[] s = sc.next().toCharArray();
			if (Character.isUpperCase(s[0])) {
				System.out.println("A");
			} else {
				System.out.println("a");
			}
		}
	}


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

int main() {
	int k;
	cin >> k;
	int i = 1;
	vector<bool> v(k);
	int r = 7 % k;
	if (r == 0) {
		cout << 1 << endl;
		return 0;
	}
	v[r] = true;
	while (true) {
		r = (r * 10 + 7) % k;
		i++;
		if (r == 0) {
			cout << i << endl;
			return 0;
		}
		if (v[r]) {
			cout << -1 << endl;
			return 0;
		}
		v[r] = true;
	}
	return 0;
}


Measured memory_bytes: 3696
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    s = input()
    t = input()

    sl = list(s)
    sl.sort()
    st = list(t)
    st.sort(reverse=True)

    if sl < st:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


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

bool kaibun(string s1){
    string s2 = s1;
    reverse(s2.begin(),s2.end());
    //cout << s2 << endl;
    if(s1==s2) return true;
    return false;
}
 
int main() {
    string s;
    cin >> s;
    bool ok1,ok2,ok3;
    int n;
    n = s.size();
    //回文チェック
    ok1 = kaibun(s);
    //if(ok1) cout << "yes1" << endl;

    //前半回文チェック
    string s2=s;
    s2.erase(s2.begin()+(n-1)/2,s2.end());
    ok2 = kaibun(s2);
    //if(ok2) cout << "yes2" << endl;
    
    //後半回文チェック
    string s3=s;
    s3.erase(s3.begin(),s3.end()-(n-1)/2);
    ok3 = kaibun(s3);
    //if(ok3) cout << "yes3" << endl;
    
    if(ok1 && ok2 && ok3) {
        cout << "Yes" << endl;
        return 0;
    }else{
        cout << "No" << endl;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i<(n);i++)
#define fore(i,a) for(auto &i:a)
#define debug(a,b) cout << "debug : " << a << " , "<< b << endl
using ll=long long;
const ll INF=1LL<<60;
const ll mod=1E9+7;


int main(){
	int n;
	cin >> n;
	if(n%10==0||n%10==1||n%10==6||n%10==8)cout << "pon";
	else if(n%10==3)cout << "bon";
	else cout << "hon";
}


Measured memory_bytes: 3624