akhauriyash/Code-Regression huggingface dataset:
#pragma GCC target ("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n;
    cin >> n;
    vector<long double> x(n);
    vector<string> u(n);
    rep(i, n) {
        cin >> x[i] >> u[i];
    }

    long double res = 0;

    rep(i, n) {
        res += x[i] * (u[i] == "JPY" ? 1 : 380000);
    }

    cout << fixed << setprecision(10) << res << endl;
    return 0;
}

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

using namespace std;

const long long MOD = 1e9+7;
int main() {
    ios_base::sync_with_stdio(false);
    cout.precision(12);
    cout << fixed;
    cin.tie(0);

    int n, k;
    cin >> n >> k;
    vector<int> pos;
    vector<int> neg;
    vector<int> v;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        v.push_back(x);
        if (x < 0) {
            neg.push_back(-x);
        } else {
            pos.push_back(x);
        }
    }
    sort(pos.begin(), pos.end());
    sort(neg.begin(), neg.end());
    long long ans = 1;
    if (k == n) {
        for (int i = 0; i < n; i++) {
            ans *= v[i];
            ans %= MOD;
        }
        ans = (ans + 2 * MOD) % MOD;
    } else if (k % 2 == 1 && neg.size() == n) {
        for (int i = 0; i < k; i++) {
            ans *= neg[i];
            ans %= MOD;
        }
        ans = (-ans + 2 * MOD) % MOD;
    } else {
        int rpos = pos.size();
        int rneg = neg.size();
        if (k % 2 == 1) {
            ans *= pos[rpos-1];
            ans %= MOD;
            rpos--;
            k--;
        }

        while (k > 0) {
            bool pp = true;
            if (rpos >= 2 && rneg >= 2) {
                long long cpos = 1LL * pos[rpos-1] * pos[rpos-2];
                long long cneg = 1LL * neg[rneg-1] * neg[rneg-2];
                if (cpos > cneg) {
                    pp = true;
                } else {
                    pp = false;
                }
            } else if (rpos >= 2) {
                pp = true;
            } else {
                pp = false;
            }
            if (pp) {
                ans *= pos[rpos-1];
                ans %= MOD;
                ans *= pos[rpos-2];
                ans %= MOD;
                rpos -= 2;
            } else {
                ans *= neg[rneg-1];
                ans %= MOD;
                ans *= neg[rneg-2];
                ans %= MOD;
                rneg -= 2;
            }
            k -= 2;
        }
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
  int *A;
  int H, i;

  scanf("%d",&H);
  A = malloc(sizeof(int)*(H+1));
  for(i = 1; i < H+1; i++) scanf("%d",&A[i]);

  for(i = 1; i < H+1; i++){
    printf("node %d: key = %d, ",i,A[i]);

    if(((i/2) >= 1) && ((i/2) < H)) printf("parent key = %d, ",A[i/2]);
    if(((i*2) > 1) && ((i*2) <= H)) printf("left key = %d, ",A[i*2]);
    if(((i*2+1) > 2) && ((i*2+1) <= H)) printf("right key = %d, ",A[i*2+1]);
    printf("\n");
  }
  
  free(A);
  
  return 0;
}


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

int main(){
string s, t, u;
  cin >> s;
  s.erase(s.end()-1);
int a = 1;
  
  while(a){
  if(s.size() % 2 == 1){
    s.erase(s.end()-1);
  }
   else{
   t = ""; u = "";  
   for(int i = 0;i < s.size() / 2;i++){
   t += s.at(i);
   }
   for(int i = s.size() / 2;i < s.size();i++){
   u += s.at(i);
   }
   if(t == u){
     cout << s.size() << endl;
     a = 0;
     }   
   else s.erase(s.end()-1);
   } 
  }
  
  return 0;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    if(a%2==0||b%2==0||c%2==0)cout << 0;
    else cout << min(a*b, min(a*c, b*c));
}

Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
LL A[100000];

LL ans = 0;

void solve(){
    //数値iの現れた回数をnum[i]とおく
    vector<LL> num(100001,0);
    for(int i=0;i<N;i++) num[A[i]]++;

    for(int i=1;i<=100000;i++){
        if(num[i]%2==1) num[i] = 1;
        else if(num[i]>0)num[i] = 2;
    }

    int numof_even = 0;
    for(int i=1;i<=100000;i++){
        if(num[i]>=1) ans++;
        numof_even += (num[i]==2);
    }
    if(numof_even%2==1) ans--;
}
 
int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> A[i];
 
    solve();

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

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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

/*
 * a+b = (a^b) + (a&b)*2, because a+b = a^b, a&b should be 0; meaning
 * a and b will not have the same bit with both 1.
 *
 * For any position i, if a+b result to 1 for i-th bit, there are 2
 * possibilities, ether a's bit is 1 or b's bit is 1. If a+b result
 * to 0, both a and b's i-th bit should be 0.
 */
/* a new prospective for counting pairs */

const int mod = 1e9+7;
const int maxn = 1e5+5;
int digit[maxn], dp[maxn][2];

int dfs(const int i, const bool limit)
{
    if (i == -1)
        return 1;
    int& ans = dp[i][limit];
    if (-1 == ans) {
        ans = 0;
        const int last = limit ? digit[i] : 1;
        FOR(d,0,last+1) {
            const int res = dfs(i-1, limit && d==last);
            if (d)   /* if a+b = 1, it a,b can be either 1,0 or 0,1 */
                ans += 2*res%mod;
            else
                ans += res;
            ans %= mod;
        }
    }
    return ans;
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    string L;
    while (cin >> L) {
        memset(dp,-1,sizeof(dp));
        int n = 0;
        FOR_ALLR(c,L)
            digit[n++] = *c-'0';
        cout << dfs(n-1,true) << endl;
    }
    return 0;
}


Measured memory_bytes: 7888
import Control.Monad
import Control.Applicative
import Data.List
import Data.Maybe (fromJust)

type Dice = [Int]

rot :: Dice -> Char -> Dice
rot d 'E' = [d!!3, d!!1, d!!0, d!!5, d!!4, d!!2]
rot d 'W' = [d!!2, d!!1, d!!5, d!!0, d!!4, d!!3]
rot d 'N' = [d!!1, d!!5, d!!2, d!!3, d!!0, d!!4]
rot d 'S' = [d!!4, d!!0, d!!2, d!!3, d!!5, d!!1]
rot _ _ = undefined

solve :: [[Int]] -> String
solve ([n]:dices) =
    let ls = [(a,b) | a<-dices,b<-dices, a/=b] in
    if (any id $ map equal ls) then
        "No"
    else
        "Yes"
    where
    equal (diceA,diceB) =
        let es = cycle "E" in
        let ns = cycle "N" in
        let cmdSets =   [ take a es ++ take b ns ++ take c es ++ take d ns
                        | a<-[1..4], b<-[1..4], c<-[1..4], d<-[1..4]]
        in
        eq cmdSets
        where
        eq [] = False
        eq (cmd:cmds) =
            if (foldl' rot diceB cmd == diceA) then
                True
            else
                eq cmds

main =
    putStrLn =<< solve . map (map read . words) . lines <$> getContents

Measured memory_bytes: 5332
//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
bool sortbysec(const pair<ll,ll>&a,const pair<ll,ll>&b)
{
    return (a.second<b.second);
}
const long double PI=(acos(-1));
const long double EPS=0.0000000001;
long double a,b,x;
long double f(long double a,long double b,long double x)
{
    long double ans;
    if(a*a*b/2.0<=x)
        ans=atan(2*(a*a*b-x)/(a*a*a));
    else
        ans=PI/2-atan(2*x/(a*b*b));
    return ans;
}
int main()
{
    cin>>a>>b>>x;
    cout<<fixed<<setprecision(10)<<f(a,b,x)*180.0/PI<<endl;
}



















Measured memory_bytes: 3792
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str;


    cin>>n>>a>>b;

    if((a*b)>=n)cout<<"Yes"<<endl;

    else cout<<"No"<<endl;


}



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

int main() {
  int N,M;
  scanf("%d %d", &N,&M);
  int k[M];
  int check[100];
  for (int i = 0; i < 100; ++i) check[i] = 0;

  int plus = 0;

  for (int i = 0; i < M; ++i) {
    scanf("%d", &k[i]);
    int count = k[i];
    while(count){
      cin >> check[plus];
      ++plus;
      --count;
    }
  }

  int p[M];
  for (int i = 0; i < M; ++i) {
    scanf("%d", &p[i]);
  }

  int pattern = pow(2.0,N);

  int swit[N];
  int count = 0;
  bool flug = true;
  int ans = 0;

  for(int x=0;x<pattern;x++){
    flug = true;
    for(int i=0;i<N;i++){
      if(x&(1<<i)){
        swit[i] = 1;
      }
      else swit[i] = 0;
    }
    int lpcount = 0;
    count = 0;
    for(int i=0;i<M;i++){
      lpcount = 0;
      for(int j=0;j<k[i];j++){
        int detect = check[count];
        lpcount += swit[detect-1];
        //cout << lpcount << endl;
        ++count;
      }
      if(lpcount%2 != p[i]){
        //cout << x << endl;
        //cout << i << endl;
        flug = false;
        break;
      }
    }
    if(flug) ++ans;
  }

  cout << ans << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int b[10000];
int a[10000];
int main()
{
    ios_base::sync_with_stdio(0);
    int n,k,q;
    cin>>n>>k>>q;
    int ret=1e9;
    for (int i=1;i<=n;i++)
        cin>>a[i],b[i]=a[i];
    sort(b+1,b+n+1);
    for (int i=1;i<=n;i++)
    {
        vector<int> tot;
        for (int j=1;j<=n;)
        {
            vector<int> cur;
            while(j<=n && a[j]>=b[i])
            {
                cur.push_back(a[j]);
                j++;
            }
            while(j<=n && a[j]<b[i])j++;
            int len=cur.size();
            int need = len-k+1;
            sort(cur.begin(),cur.end());
            for (int x=0;x<need;x++)
                tot.push_back(cur[x]);
        }
        sort(tot.begin(),tot.end());
        if (tot.size()>=q)
        {
            ret=min(ret,tot[q-1]-b[i]);
        }
    }
    cout<<ret<<endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

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


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

using namespace std;


int main() {
    int n;
    cin>>n;
    int num[n],count=0;
    for (int i = 0; i < n; ++i) {
        cin>>num[i];
    }
    sort(num,num+n);
    for (int j = 0; j < n;) {
        if(num[j]==num[j+1]){
            int cou=0;
            while(num[j+cou]==num[j]){
                cou++;
            }
            if(cou%2==1)count++;
            j=j+cou;
        }
        else{
            count++;
            j++;
        }
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 640
n,x = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
if a[0]>x:
  ans = a[0]-x
  a[0] = x
  
for i in range(1,n):
  if (a[i]+a[i-1])>x:
    ans += ((a[i]+a[i-1]))-x
    a[i]-=  ((a[i]+a[i-1]))-x
print(ans)

Measured memory_bytes: 85468
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

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

    ll A, B, C;
    cin >> A >> B >> C;
    if (A == B && B == C && A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
        cout << -1 << endl;
        return 0;
    }

    ll ans = 0;
    while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
        ll AA, BB, CC;
        AA = B / 2 + C / 2;
        BB = A / 2 + C / 2;
        CC = A / 2 + B / 2;
        A = AA, B = BB, C = CC;
        ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3608
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;

T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }

long mod = pow(10, 9) + 7;
long moda(long x, long y) { return (x + y) % mod; }
long mods(long x, long y) { return ((x + mod) - (y % mod)) % mod; }
long modm(long x, long y) { return (x * y) % mod; }

void main()
{
	auto N = RD!long;
	auto A = RDR.split.to!(long[]);
	A.sort();
	
	long last = -1, cnt;
	long[] ans;
	foreach_reverse (e; A)
	{
		if (e == last)
		{
			++cnt;
			if (cnt == 2)
			{
				ans ~= e;
				cnt -= 2;
			}
		}
		else
		{
			cnt = 1;
			last = e;
		}
		if (ans.length == 2) break;
	}

	writeln(ans.length != 2 ? 0 : ans[0] * ans[1]);
	stdout.flush();
}

Measured memory_bytes: 4404
#include <iostream>

using namespace std;

int main(){
  int n, r;
  int card[50];
  int cutp[50];
  int cutc[50];

  while(cin >> n >> r, n || r){
    for(int i=0; i<n; i++){
      card[i] = i+1;
    }
    for(int j=0; j<r; j++){
      int p, c;
      cin >> p >> c;
      for(int i=0; i<p-1; i++){
	cutp[i] = card[n-p+1+i];
      }
      for(int i=0; i<c; i++){
	cutc[i] = card[n-p+1-c+i];
      }
      
      for(int i=0; i<p-1; i++){
	card[n-p+1-c+i] = cutp[i];
      }
      for(int i=0; i<c; i++){
	card[n-c+i] = cutc[i];
      }
    }

    cout << card[n-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		String s = scan.next();
		
		String s1 = "";
		String s2 = "";
		
		String answer ="";
		
		
		
		for(int i = s.length();i>=2;i=i-2){
			String S = s.substring(0,i);
			
			s1 = S.substring(0, S.length()/2);
			s2 = S.substring(S.length()/2, S.length());
			
			
			if(s1.equals(s2)&&S.length()!=s.length()){
				answer =S;
				break;
			}
			
		}
		
		
		
		System.out.println(answer.length());
		
		
	}

}


Measured memory_bytes: 23124
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  string s;cin>>s;
  map<char,ll>M;
  for(int i=0;i<4;i++)M[s[i]]++;
  ll count=0;
  for(auto p:M){
    if(p.second==2)count++;
  }
  if(count==2)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<time.h>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include<cassert>
#include<cctype>
#include<iterator>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Edge=pair<int,ll>;
using Graph=vector<vector<ll> >;//ll or Edge
using Edge=pair<int,ll>;
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// g++ -o a a.cpp -Wall -lm -std=c++14

int main(){
   int n;cin>>n;
    VI a(n);
    int x=0;
    rep(i,n)cin>>a[i];
    rep(i,n)x^=a[i];
    rep(i,n){
        int s=x^a[i];
        cout<<s<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 4720
#include <iostream>
using namespace std;
int main(void){
    string t[] = {"SUN","MON","TUE","WED","THU","FRI","SAT","SUN"};
    string s;
    cin >> s;
    for(int i=0;;i++){
        if(s == t[i]){
            cout << 7-i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
 
using namespace std;
 
int main() {
    string str;
    cin >> str;
    if (str[0] != '7' && str[1] != '7' && str[2] != '7') {
        cout << "No";
    }
    else {
        cout << "Yes";
    }
    cout << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

long long pow_mod(long long n,long long k,long long m){
    if (k == 0){
        return 1;
    } else if (k % 2 == 1){
        return pow_mod(n,k-1,m)*n % m;
    } else {
        long long t = pow_mod(n,k/2,m);
        return t*t % m;
    }
}


int main(){
    int a,b;
    while (cin >> a >> b){
        //cin >> a >> b;
        cout << GCD(max(a,b),min(a,b)) << endl;
    }
}
  




Measured memory_bytes: 3084
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll a[555555];
queue<int> q;

int main(void){
	int n,i;
	ll b = 0ll,ans=0ll;
	string s;
	cin >> s;
	n = s.l_ength();
	if(s[0]=='<'){
		q.push(0);
	}
	if(s[n-1]=='>'){
		q.push(n);
	}
	for(i=1; i<n; ++i){
		if(s[i-1]=='>' && s[i]=='<'){
			q.push(i);
		}
	}
	while(!q.empty()){
		i = q.front();
		q.pop();
		if(i==0){
			if(s[0]=='<'){
				a[1] = max(a[1],a[0]+1);
				q.push(1);
			}
		}else if(i==n){
			if(s[n-1]=='>'){
				a[n-1] = max(a[n-1],a[n]+1);
				q.push(n-1);
			}
		}else{
			if(s[i-1]=='>'){
				a[i-1] = max(a[i-1],a[i]+1);
				q.push(i-1);
			}
			if(s[i]=='<'){
				a[i+1] = max(a[i+1],a[i]+1);
				q.push(i+1);
			}
		}
	}
	for(i=0; i<=n; ++i){
		ans += a[i];
	}
	cout << ans << endl;
	return 0;
}


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

string i2s(int n){
  stringstream a;
  a << n;
  return a.str();
}

int s2i(string s){
  stringstream a;
  int res;
  a << s;
  a >> res;
  return res;
}

int main(void){
  int n;
  string init_num;
  cin >> n;
  while(n--){
    cin >> init_num;
    string nums = init_num;
    int cnt = 0;
    while(1){
      if(s2i(nums) / 10 == 0){
	cout << cnt << endl;;
	break;
      }
      int nextnum = 0;
      for(int i=1; i < nums.length(); i++){
	int prenum, postnum;
	prenum = s2i(nums.substr(0, i));
	postnum = s2i(nums.substr(i, nums.length() - i));
	nextnum = max(nextnum, prenum * postnum);
      }
      cnt++;
      nums = i2s(nextnum);
      if(nums == init_num){
	cout << -1 << endl;
	break;
      }
    }
  }
  return 0;
}

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

int main() {
    int m, d; cin >> m >> d;
    int cnt = 0;
    for (int i = 1; i <= m; i++) for (int j = 1; j <= d; j++) {
        int d1 = j % 10, d10 = j / 10, mm = i;
        if (d1 >= 2 && d10 >= 2 && d1 * d10 == mm) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

const int INF = std::numeric_limits<int>::max();

int main() {
    int N;
    std::cin >> N;
    std::vector<int> dp(N + 1, INF);
    // dp[i] = 長さiの増加部分列のうち、末尾の最小値

    dp[0] = -1;
    for (int i = 0; i < N; ++i) {
        int a;
        std::cin >> a;
        auto itr = std::lower_bound(dp.begin(), dp.end(), a);
        *itr = std::min(*itr, a);
    }

    for (int i = N; i >= 0; --i) {
        if (dp[i] < INF) {
            std::cout << i << std::endl;
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 3100
n,a,b=gets.chomp.split(" ").map(&:to_i);
s=gets.chomp.chars

rank=1

yes=0
fyes=0

s.each do |s1|
  if yes < a + b && s1 == 'a'
    puts "Yes"
    yes+=1
  elsif yes < a + b && s1 == 'b'
    if fyes < b
      puts "Yes"
      yes+=1
      fyes+=1
    else
      puts "No"
    end
  else
    puts "No"
  end
  rank+=1
end



Measured memory_bytes: 22552
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
 
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if((abs(b-a)<=d && abs(c-b)<=d) || abs(c-a)<=d){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


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

int main()
{
    while(true){
        string S;
        cin >> S;
        if( S == "0")
            break;
        int sum = 0;
        for(auto& c : S){
            sum += c - '0';
        }
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3220
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    x, y = rli()
    if abs(x-y) <= 1:
        print("Brown")
    else:
        print("Alice")


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t;
    }
    return n*rep_jijo(n,x-1);
}

int main(){
    string s;
    cin >> s;
    int ans ;
    if(s=="SUN") ans =7;
    else if(s=="MON") ans =6;
    else if (s=="TUE") ans =5;
    else if (s=="WED") ans =4;
    else if (s=="THU") ans =3;
    else if (s=="FRI") ans =2;
    else ans =1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int k = 10001,N = 2000001;

int main(){
    int n;
    cin >> n;
    vector < int > A(N),B(N),C(k,0);
    //ソートしたい配列の読み込み
    for(int i = 1 ; i <= n ; i++ ) cin >> A[i];

    //上で読み込んだ配列の各々の整数値の個数を数え上げる    
    for(int j = 1 ; j <= n ; j++ ){
        C[A[j]]++;
    }

    //それぞれの整数値が配列のどこまで入るかを記録する配列
    for(int i = 1 ; i <= k ; i++ ){
        C[i] = C[i] + C[i-1];
    }

    //ソートした配列を格納する配列を作成
    for(int j = n ; j >= 1 ; j-- ){
        B[C[A[j]]] = A[j];
        C[A[j]] = C[A[j]] - 1;
    }

    for(int i = 1 ; i <= n ; i++ ){
        cout << ( i == 1 ? "" : " " ) << B[i];
    }

    cout << endl;
}


Measured memory_bytes: 18392
from fractions import gcd
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
c = Counter(a)
oc = []
b = 0
for i, v in c.items():
    if v == 1:
        oc.append(i)
    else:
        if b == 0:
            b = i
        else:
            b = gcd(b, i)

loc = len(oc)
if loc <= 1:
    print(b)
    exit()

c = [oc[0], oc[1]]
e = gcd(oc[0], oc[1])
if loc == 2:
    c.append(e)
for i in range(2, loc):
    g1 = gcd(e, oc[i])
    d = []
    for cc in c:
        g2 = gcd(cc, oc[i])
        if g2 > 1:
            d.append(g2)
    c = d
    if e > 1:
        c.append(e)
    if i == loc-1:
        c.append(g1)
    e = g1

if b >= 2:
    print(max([gcd(cc, b) for cc in c]))
elif b == 0:
    print(max(c))
else:
    print(1)

Measured memory_bytes: 16156
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


int main()
{

    int a,b,c,d,s;
    while(~scanf("%d%d%d%d",&a,&b,&c,&d))
    {
        if(a>b)
        {
            s=b*c+(a-b)*d;
        }
        else
        {
            s=a*c;
        }
        printf("%d\n",s);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
typedef long long ll;


int main() {
  ll N,n,K,x;
  cin>>N>>K;
  n=(N/K)*K;
  N-=n;
  x=N;
  vector<ll> data={N-1,N,N};
  while(1){
    if(min(data[0],min(data[1],data[2]))==data[1]){break;}
    x=abs(x-K);
    data[0]=data[1]; data[1]=data[2]; data[2]=x;
  }
  cout<<data[1]<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int m = sc.nextInt();
		int n = sc.nextInt();
		
		int diff = n - m;
		int sum = 0;
		for(int i=1;i<diff;i++) {
			sum += i;
		}
		
		System.out.println(sum - m);
		
	}

}

Measured memory_bytes: 23636
//#define _USE_MATH_DEFINES
//#include <cmath>

#include <iostream>
#include <vector>

using namespace std;

int N;
vector<vector<int>> B;
vector<vector<int>> C;



int calc(int M);

int main()
{
	cin >> N;

	B = vector<vector<int>>(N+1);
	C = vector<vector<int>>(N+1);

	for (int i = 1; i < N+1; i++) {
		int a;
		cin >> a;
		for (int j = 0; j < a; j++) {
			int x, y;
			cin >> x;
			cin >> y;

			if (y == 1) {
				B[i].push_back(x);
			}
			else {
				C[i].push_back(x);
			}
		}
	}

	int ans = 0;
	int M = 1 << N;
	for (int i = 0; i < M  ; i++) {
		ans = max(ans,calc(i));
	}

	cout << ans << endl;

	return 0;
}

int calc(int M)
{
	auto h = vector<bool>(N+1);
	int ret = 0;
	int m = M;
	for (int i = 1; i < N+1; i++) {
		h[i] = !(m % 2);
		m /= 2;

		if (h[i]) { ret++; }
	}

	for (int i = 1; i < N+1; i++) {
		if (!h[i]) {
			continue;
		}

		for (int j = 0; j < B[i].size(); j++) {
			if (h[B[i][j]] == false) {
				return 0;
			}
		}
		for (int j = 0; j < C[i].size(); j++) {
			if (h[C[i][j]] == true) {
				return 0;
			}
		}

	}



	return ret;
}


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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(ll i= (a); i < (ll)(b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    int N; cin >> N;
    vector<int> A(N + 1, 0);
    FOR(i, 1, N + 1) {
        cin >> A[i];
    }
    int i = 1;
    FOR(c, 1, N + 1) {
        i = A[i];
        if(i == 2) {
            cout << c << "\n";
            return 0;
        }
    }
    cout << -1 << "\n";
}

Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
#define rg register
#define ll long long 
inline ll read()
{
    ll x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')
        {
            f=-1;
        }
        c=getchar();
    } 
    while(c<='9'&&c>='0')
    {
        x=(x<<1)+(x<<3)+(c^48);
        c=getchar();
    }
    return x*f;
}
ll k,x;
int main()
{
	 k=read(),x=read();
	 for(rg int i=x-k+1;i<=x+k-1;++i)
	 {
	 	if(i>=-1000000&&i<=1000000)
	 	{
			cout<<i<<" ";
		 }
	 }
} 

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

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))

#define DIVUP(x, y) (((x) + ((y) - 1)) / (y))
#define DIVOFF(x, y) (((x) + ((y) / 2)) / (y))
#define REMAINDER(x, y) ((x) % (y))

int main() {
  int N, A, B; scanf("%d%d%d", &N, &A, &B);
  printf("%s\n", (B - (A + 1)) % 2 == 1 ? "Alice" : "Borys");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using pq = priority_queue<int>;
template<class T>
using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int under = (1 << 31);
int upper = under - 1;
ll UNDER = (1LL << 63);
ll UPPER = UNDER - 1;
const int MOD = 1e9 + 7;
const long double pi = 3.141592653589793;
int main() {
	int a, b;
	cin >> a >> b;
	puts((a<=b) ? "unsafe" : "safe");
	return 0;
}

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

//#define int long long
#define reps(i,s,n) for(ll (i)=(s);(i)<(ll)(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) reps(i,0,n+1)
#define repst(i,s,n) reps(i,s,n+1)
#define reprt(i,n,t) for(ll (i)=(n);(i)>=t;--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<n;++i){cout<<x[i]<<(i==n-1?'\n':' ');}}

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

// 1) kが偶数のとき
// 最初の整数がk/2以下である数列とk/2+1以上である数列の個数は等しいため、
// 求める数列は前者の一番最後 ∴ k/2の後にkがn-1個続く数列
// 2) kが奇数のとき
// 最初の整数が(k+1)/2-1以下の数列と(k+1)/2+1以上の数列の個数は等しいから最初の数は(k+1)/2で確定
// このグループの中で(k+1)/2がn個続く数列bの前後にある数列の個数の差はいくらか？
// bの前にある数列xについて、各要素x[i]をk+1-x[i]に置き換えると、xがbのprefixでない限り常にbの後ろの数列になる
// 逆にbの後ろにある数列yについても同じように置き換えると常にbの前の数列になる
// このことからbの前後にある数列はbのprefixを除いて1:1対応してることがわかる
// つまりbの前にはbのprefixの個数 ∴ n-1個だけ数列が多く存在するので、bを[(n-1)/2]==n/2回戻したものが答え

int k, n, b[300000];

signed main() {
	cin >> k >> n;
	if (k%2==0) {
		cout << k/2 << ' ';
		rep(i,n-1) cout << k << (i==n-2 ? '\n' : ' ');
		return 0;
	}
	fill(b,b+n,(k+1)/2);
	int l = n-1, m = n/2;
	while (m--) {
		if (b[l]==1) l--;
		else {
			b[l]--;
			reps(i,l+1,n) b[i] = k;
			l = n-1;
		}
	}
	rept(i,l) cout << b[i] << (i==l ? '\n' : ' ');
}

Measured memory_bytes: 3456
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int a[] = new int[N];
        a[0] = 1;
        int total = 0;
        for(int i =1; i < a.length; ++i){
            a[i] = a[i-1]+1;
            total += a[i];
        }
        System.out.println(total + a[0]);
    }
}

Measured memory_bytes: 35556
#include <iostream>
#include <algorithm>
#include <climits>
#include <cstring>
#include <unistd.h>
#include <cmath>
using namespace std;
int main(){
    int n;
    cin >> n;
    int fo[(int)1e5+5];
    int fe[(int)1e5+5];
    memset(fe, 0, sizeof(fe));
    memset(fo, 0, sizeof(fo));
    int mo1= INT_MIN, mo2= INT_MIN, me1= INT_MIN, me2 = INT_MIN;
    int vo1, vo2, ve1, ve2;
    for (int i = 0; i < n; ++i){
        int x;
        scanf("%d", &x);
        if (i % 2 == 0)
            fe[x]++;
        else
            fo[x]++;
    }
    for (int x = 0; x < (int)1e5+5; ++x){
        if (fe[x] >= me1){
            me2 = me1;
            ve2 = ve1;
            me1 = fe[x];
            ve1 = x;
        }
        else if (fe[x] > me2)
            me2 = fe[x], ve2 = x;
        if (fo[x] >= mo1){
            mo2 = mo1;
            vo2 = vo1;
            mo1 = fo[x];
            vo1 = x;
        }
        else if (fo[x] > mo2)
            mo2 = fo[x], vo2 = x;
    }
    int ans = INT_MAX;
    if (mo2 != INT_MIN){
        if (vo2 != ve2 && me2 != INT_MIN)
            ans = min(ans, n-mo2-me2);
        if (vo2 != ve1 && me1 != INT_MIN)
            ans = min(ans, n-mo2-me1);
    }
    if (mo1 != INT_MIN){
        if (vo1 != ve2 && me2 != INT_MIN)
            ans = min(ans, n-mo1-me2);
        if (vo1 != ve1 && me1 != INT_MIN)
            ans = min(ans, n-mo1-me1);
    }
    cout << ans;
    return 0;
}


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

int main(){
    int m, f, r;
    char grade;

    while(true) {
        cin >> m >> f >> r;

        if(m == -1 && f == -1 && r == -1) {
            break;
        } else if(m == -1 || f == -1) {
            grade = 'F';
        } else if(m + f >= 80) {
            grade = 'A';
        } else if(m + f >= 65) {
            grade = 'B';
        } else if(m + f >= 50) {
            grade = 'C';
        } else if(m + f >= 30) {
            grade = (r >= 50)?'C':'D';
        } else {
            grade = 'F';
        }

        cout << grade << endl;
    }
}



Measured memory_bytes: 3128
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	var array []int
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		line := scanner.Text()
		strs := strings.Split(line, " ")

		for _, s := range strs {
			x, _ := strconv.Atoi(s)
			array = append(array, x)
		}
	}

	sort.Sort(sort.IntSlice(array))

	for i, s := range array {
		var sep string
		if i == len(array)-1 {
			sep = "\n"
		} else {
			sep = " "
		}
		fmt.Printf("%v%v", s, sep)
	}
}



Measured memory_bytes: 1104
#include<bits/stdc++.h>
using namespace std;
int x[10],y[10];
double dist(int i,int j){
	double dx=x[i]-x[j];
	double dy=y[i]-y[j];
	return pow(dx*dx+dy*dy,0.5);
}
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x[i]>>y[i];
	}
	double sum=0.0;
	vector<int>v(n);
	for(int i=0;i<n;i++){
		v[i]=i+1;
	}
	do{
		for(int i=0;i<n-1;i++)sum+=dist(v[i],v[i+1]);
	}while(next_permutation(v.begin(),v.end()));
	int fact=1;
	for(int i=2;i<=n;i++){
		fact*=i;
	}
	cout<<fixed<<setprecision(10)<<sum/fact<<endl;
	return 0;
}

Measured memory_bytes: 640
use whiteread::parse_line;

fn main() {
    let s: String = parse_line().unwrap();
    let mut cnt = s.chars().filter(|&x| x == 'B').count();
    let mut ans = 0;
    let len = s.len();

    for (i, c) in s.chars().enumerate() {
        if c == 'B' {
            ans += (len - cnt) - i;
            cnt -= 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2324
#include<bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

string a, b, c, d;
char o;

void push_right() {
	d += o;
	o = b.back(); b.pop_back();
}
void push_down() {
	o = a.back(); a.pop_back();
}
int main() {
	while (cin >> a, a != "-") {
		d = "";
		cin >> b >> c;
		reverse(a.begin(), a.end());
		reverse(b.begin(), b.end());
		o = b.back(); b.pop_back();
		while (a.size() || b.size()) {
			if ((int)c.find(o) == -1)push_right();
			else push_down();
		}
		d += o;
		cout << d << endl;
	}
}

Measured memory_bytes: 3144
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

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

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

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "tmp.cpp"

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

  ll a, v;
  cin >> a >> v;
  ll b, w;
  cin >> b >> w;
  ll t;
  cin >> t;
  say((v - w) * t - abs(a - b) >= 0, "YES", "NO");
  return 0;
}


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

int main(){
    int i,r;
    cin >> i >> r;
    int mi = min(i,r);
    int ma = min(max(i,r),mi+4037);
    int ans = 1e9, num;
    for(int i = mi; i < ma; i++){
        for(int j = mi+1; j < ma+1; j++){
            num = ((i%2019)*(j%2019))%2019;
            if(num == 0){
                cout << 0 << endl;
                return 0;
            }
            else ans = min(ans, num);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_e
n = int(input())
nums = map(int, input().split())
MOD = 1000000007
ans = 1
cnt = [3 if i == 0 else 0 for i in range(n + 1)]

for num in nums:
    ans = ans * cnt[num] % MOD
    if ans == 0:
        break
    cnt[num] -= 1
    cnt[num+1] += 1

print(ans)


Measured memory_bytes: 83864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll dp[2005][2005][2];
int n,z[2],a[2005];
int main(){
	rep(i,2005) rep(a,2005) rep(j,2) {dp[i][a][0] = 1e18;dp[i][a][1] = -1e18;}
	cin>>n>>z[0]>>z[1];
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=0;i<=n;i++){
		if(i){
			dp[n+1][i][0] = abs(a[n]-a[i]);
			dp[n+1][i][1] = abs(a[n]-a[i]);
		}
		else{
			dp[n+1][i][0] = abs(a[n]-z[0]);
			dp[n+1][i][1] = abs(a[n]-z[1]);
		}
	}
//	cout<<dp[4][2][0]<<endl;
	for(int i=n;i>=1;i--){
		for(int j=0;j<i;j++){
			//dp[i][j][0] = max(dp[big][i-1][1])
			//dp[i][j][1] = min(dp[big][i-1][0])
			dp[i][j][0] = dp[i+1][i-1][1];
			dp[i][j][1] = dp[i+1][i-1][0];
		}
		if(i==1) {cout<<dp[1][0][0]<<endl; return 0;}
	//	cout<<dp[1][0][0]<<endl;
		for(int j=0;j<i;j++){
			dp[i][j][0] = min(dp[i][j][0],dp[i+1][j][0]);
			dp[i][j][1] = max(dp[i][j][1],dp[i+1][j][1]);
		}
	}
	//cout<<dp[1][0][0]<<endl;
}

Measured memory_bytes: 63104
def main():
    S = input()
    s_even = [S[i] for i in range(0, len(S), 2)]  # 偶数文字目のみを格納
    s_odd = [S[i] for i in range(1, len(S), 2)]  # 奇数文字目のみを格納
    if "L" in s_even: print("No"); return
    if "R" in s_odd: print("No"); return
    print("Yes")

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <stdio.h>
int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    if (a + b >= a - b && a + b >= a * b){
        printf("%d",a + b);
    }else if (a - b >= a + b && a - b >= a * b){
        printf("%d",a - b);
    }else{
        printf("%d",a * b);
    }
}


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

#define ll long long int

int main(){
    int k,x;
    cin >> k >> x;
    int left,right;
    left = max(x-k+1,-1000000);
    // right = x + k- (x-left+1);
    right = min(1000000,x+k-1);
    for(int i=left;i<=right;i++)
        cout << i << " \n"[i==right];

    return 0;
}

Measured memory_bytes: 256
n = int(input())
ln = list(input())

lr = []
lg = []
lb = []

for i in range(n):
    if ln[i] == "R":
        lr.append(i)
    elif ln[i] == "G":
        lg.append(i)
    else:
        lb.append(i)

ans = 0
ba = len(lb)

for i in lr:
    for j in lg:
        ta = ba
        if (i+j) % 2 == 0 and ln[(i+j) // 2] == "B":
            ta -= 1

        d = abs(j - i)
        df = max(j+d, i+d)
        dn = min(j-d, i-d)
        if df < n and ln[df] == "B":
            ta -= 1
        if dn > 0 and ln[dn] == "B":
            ta -= 1
        ans += ta

print(ans)

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

using namespace std;

int main(){

    string str;
    int cnt = 0;

    cin >> str;

    if(str[0]=='2') cnt++;
    if(str[1]=='2') cnt++;
    if(str[2]=='2') cnt++;
    if(str[3]=='2') cnt++;    

    
    cout << cnt << endl;
}

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

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    int a[m];
    long long sum = 0;
    for(int i = 0; i< m; i ++) cin >> a[i], sum += a[i];
    int ans = n-sum;
    if(ans >= 0) cout << ans << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 3624
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

# パスを計算
h,w,d = li()
grid = []
dic = {}
for i in range(h):
    row = list(li())
    for j in range(w):
        dic.update({row[j]: (i,j)})

dist = [0]*(h*w+1)

for i in range(d+1,h*w+1):
    dist[i] = dist[i-d] + abs(dic[i][0] - dic[i-d][0]) + abs(dic[i][1] - dic[i-d][1])
    
q = ni()
for _ in range(q):
    l,r = li()
    print(dist[r] - dist[l])

Measured memory_bytes: 22808