akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {

    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    private static final PrintWriter sysout = new PrintWriter(System.out, false);

    private static StringTokenizer buffer;

    private static String readLine() {
        buffer = null;
        try {
            return br.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    private static String read() {
        if (buffer == null || !buffer.hasMoreTokens()) {
            buffer = new StringTokenizer(readLine());
        }
        return buffer.nextToken();
    }

    private static int readInt() {
        return Integer.parseInt(read());
    }

    private static int[] readIntArray(int loop) {
        int[] result = new int[loop];
        for (int i = 0; i < loop; i++) {
            result[i] = readInt();
        }
        return result;
    }

    private static int[] splitInt() {
        String[] tmp = read().split("");
        int[] result = new int[tmp.length];
        for (int i = 0, n = tmp.length; i < n; i++) {
            result[i] = Integer.parseInt(tmp[i]);
        }
        return result;
    }

    private static long readLong() {
        return Long.parseLong(read());
    }

    private static double readDouble() {
        return Double.parseDouble(read());
    }

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

    private static void run() {
        int num = readInt();
        int[] array = readIntArray(num);
        boolean odd = false;
        int count = 0;
        while (true) {
            for (int i = 0; i < num; i++) {
                if (array[i] % 2 != 0) {
                    odd = true;
                }
            }
            if (odd) {
                break;
            }
            count++;
            for (int i = 0; i < num; i++) {
                array[i] /= 2;
            }
        }
        System.out.println(count);
    }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  
  for(int i=0; i<N; i++) cin >>A[i];
  sort(A.begin(), A.end());
  cout << A[N-1] - A[0] << endl;
}

Measured memory_bytes: 3624
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>


using namespace std;

int main(void) {
  int N,D;
  cin>>N>>D;
  vector<vector<int>>X(N,vector<int>(D));
  for(int i=0;i<N;i++){
      for(int j=0;j<D;j++){
          cin>>X[i][j];
      }
  }

  int ans=0;
  for(int i=0;i<N;i++){
      for(int j=i+1;j<N;j++){
          int a=0;
          for(int k=0;k<D;k++){
              int b=abs(X[i][k]-X[j][k]);
              a+=b*b;
          }

          bool flag=false;
          for(int k=0;k<=a;k++){
              if(k*k==a){
                  flag=true;
              }
          }
          if(flag){
              ans++;
          }
      }
  }

  cout<<ans<<endl;
}




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

using namespace std;

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

    // 考え方メモ
    // 具体例(1500,2000,1600,3,2)
    // Aピザ：1500, Bピザ：2000, Cピザ:1600, A -> A, B -> B, C -> 0.5A + 0.5B
    // XはAの枚数、YはBの枚数
    // Cは0.5枚 -> Cは偶数個 -> 2C
    // １つ当たりAとBそれぞれ買った時と2Cで買った時の値段がどちらが大きいか？ -> 場合分け

    int64_t minTotal = 0;
    if (2 * C >= A + B) {  // Cの方が高い場合 -> Cを使わない
        minTotal = A * X + B * Y;
    } else {  // Cの方が安い場合 -> 1. Cを買い、残りはA,Bそれぞれ買う or 2. Cのみで買う

        // パターン1：A, B, C の組み合わせ
        int minXY = min(X, Y);
        int64_t minTotal1 = A * (X - minXY) + B * (Y - minXY) + C * 2 * minXY;

        // パターン2：Cのみで買う
        int maxXY = max(X, Y);
        int64_t minTotal2 = C * 2 * maxXY;

        minTotal = min(minTotal1, minTotal2);
    }

    cout << minTotal << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = [int(si == "E") for si in input()]
a = [0] * (n + 1)
for i in range(n):
  a[i + 1] = a[i] + s[i]
ans = n
for i in range(n):
  ans = min(a[-1] - a[i + 1] + i - a[i], ans)
print(ans)

Measured memory_bytes: 17544
import collections
alpha=['a','b','c','d','e','f','g','h','i','j']
def a(n):
  if n==1:
    return ['a']
  else:
    box=[]
    alphan=alpha[:n+1]
    for i in a(n-1):
      kind=collections.Counter(i)
      for j in range(len(kind)+1):
        box.append(i+alpha[j])
  return box
for i in a(int(input())):
  print(i)

Measured memory_bytes: 19204
N, S = map(int,input().split())
A = list(map(int,input().split()))
mod = 998244353
dp = [[0 for j in range(S + 1)] for i in range(N + 1)]
dp[0][0] = 1
for i in range(N) : 
    for j in range(S + 1) : 
        dp[i + 1][j] += 2 * dp[i][j]
        dp[i + 1][j] %= mod 
        if j + A[i] <= S : 
            dp[i + 1][j + A[i]] += dp[i][j]
            dp[i + 1][j + A[i]] %= mod
print(dp[N][S])


Measured memory_bytes: 147872
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s; cin >> s;
	int len = s.size(); 
	int ans = 0;
	for(int i = 1; i < len; i++){
		ans += s[i] != s[i - 1];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
m = []

for i in range(0, 3):
    m.append([int(n) for n in input().strip().split(" ")])

ns = []
n = int(input().strip())

for i in range(0, n):
    ns.append(int(input().strip()))

for n in ns:
    for i in range(0, 3):
        for j in range(0, 3):
            if m[i][j] == n:
                m[i][j] = 0

import sys

for i in range(0, 3):
    if sum(m[i]) == 0:
        print('Yes')
        sys.exit(0)

for i in range(0, 3):
    if sum([m[0][i], m[1][i], m[2][i]])  == 0:
        print('Yes')
        sys.exit(0)


if sum([m[0][0], m[1][1], m[2][2]]) == 0 or sum([m[0][2], m[1][1], m[2][0]]) == 0:
    print('Yes')
    sys.exit(0)

print('No')

        
    




Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int p[110000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d",p+i);p[i]--;
	}
	int ret=0;
	int at=0;
	for(int i=0;i<110000;i++){
		if(at==1){
			printf("%d\n",ret);return 0;
		}
		ret++;
		at=p[at];
	}
	printf("-1\n");
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

const int MOD = 998244353;
const int MAX = 210000;

long long fac[MAX], finv[MAX], inv[MAX];

void comInit() {
	fac[0] = fac[1] = inv[1] = finv[0] = finv[1] = 1;
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

long long nCr(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

int main() {
	comInit();
	long long n, m, k; cin >> n >> m >> k;
	long long ans = 0, cnt = 1;
	for (int i = n - 1; i >= 0; --i) {
		if (i <= k) (ans += (m * cnt % MOD) * nCr(n - 1, i) % MOD) %= MOD;
		(cnt *= m - 1) %= MOD;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 8544
#include<stdio.h>
int main()
{
    int n,i,m,x;
    scanf("%d%d",&m,&n);
    if(m>n){
        x=m;m=n;n=x;
    }
    for(i=0;i<n;i++){
        printf("%d",m);
    }
    printf("\n");


}


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  string s;
  cin >> s;

  int ans = 0;
  stack<char> st;
  rep(i, s.size()) {
    if (st.empty()) {
      st.push(s[i]);
    } else {
      if (s[i] == st.top()) {
        st.push(s[i]);
      } else {
        st.pop();
        ans += 2;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    string S,T;
    cin >> S >> T;
    bool ans = true;
    int rs[26], rt[26];
    for(int i=0; i<26; ++i) {
        rs[i] = -1;
        rt[i] = -1;
    }
    for(int i=0; i<S.size(); ++i) {
        if(rs[S[i] - 'a'] == -1) {
            rs[S[i] - 'a'] = T[i] - 'a';
        } else if(T[i] - 'a' != rs[S[i] - 'a']) {
            ans = false;
            break;
        }
        if(rt[T[i] - 'a'] == -1) {
            rt[T[i] - 'a'] = S[i] - 'a';
        } else if(S[i] - 'a' != rt[T[i] - 'a']) {
            ans = false;
            break;
        }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define peintD(a) cout << setprecision(10) << ans << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n,m;

signed main(){
    string s;
    cin >> s;
    n = s.size();
    int tmp=0,ans=0;
    REP(i,n){
        if(s[i] == 'A'){
            tmp++;
        }
        else{
            if(s[i] == 'B' && s[i+1] == 'C'){
                ans += tmp;
                i++;
            }
            else{
                tmp = 0;
            }
        }
    }
    print(ans)

    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int n, A[50];

int solve(int i, int m)
{
	if(m == 0) return 1;
	if(i >= n) return 0;
	int res = solve(i+ 1, m) || solve(i + 1, m - A[i]);
	return res;
}

int main()
{
	int q, M, i;
	cin >> n;
	for(i = 0; i < n; i++) cin >> A[i];
	cin >> q;
	for(i = 0; i < q; i++) {
		cin >> M;
		if(solve(0, M)) cout << "yes" << endl;
		else
			cout << "no" << endl;
	}
	return 0;
}



Measured memory_bytes: 3136
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <utility>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#define rep(i,a,b) for(int i=(a);i<b;i++)
#define INF 1000000000
#define MAX_N 100000000
#define MAX 
using namespace std;
bool debug=false;

int main(){
  queue<string>str;
  queue<int> que;
  int n,q;
  cin>>n>>q;
  rep(i,0,n){
    string a;
    int b;
    cin>>a>>b;
    str.push(a);
    que.push(b);
  }
  long long time=0;
  while(que.size()){
    string s=str.front();str.pop();
    int a=que.front();que.pop();
    if(q>=a){
      time+=a;
      cout<<s<<" "<<time<<endl;
    }else{
      time+=q;
      str.push(s);
      que.push(a-q);
    }
  }
  return 0;
}

Measured memory_bytes: 5688
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
#include<limits.h>

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int IINF=INT32_MAX;
static const ll LINF=INT64_MAX;
static const ll mod=1e9+7;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const double pi=3.14159265358979323846;

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

double A,B,H,M;

double a,b,c,d,e;

int main(){
    cin>>A>>B>>H>>M;
    b=(double)30*H;
    c=(double)30*M/60;
    d=(double)b+c;
    e=(double)M*6;
    d=d/360*2*pi;
    e=e/360*2*pi;
    //cout<<d<<" "<<e<<endl;
    double ans=pow(A*cos(d)-B*cos(e),2)+pow(A*sin(d)-B*sin(e),2);
    printf("%.15f", sqrt(ans));

}

Measured memory_bytes: 4228
#include <bits/stdc++.h>
#define ll long long int
#define forr(i,n) for(int i=0;i<n;i++)

using namespace std;

const ll mod = 1e9 + 7;

ll fac[1001000] , Ifac[1010000];

ll poww(ll x, ll n){
    if(n==0) return 1LL;
    ll r = poww(x,n/2);
    r = (r*r)%mod;
    if(n&1) return (r*x)%mod;
    else return r;
}

ll nPr(ll m, ll n){
    ll up = fac[m];
    ll dn = Ifac[m-n];
    return (up*dn)%mod;
}

ll nCr(ll n, ll r){
    ll dn = (Ifac[r] * Ifac[n-r])%mod;
    return (dn * fac[n])%mod;
}

void sol(){
    ll minus = 1;
    ll n,m; 
    cin >> n >> m;
    ll ans=0;
    for(ll i=0;i<=n;i++){
        ll kk = nPr(m - i , n - i);
        kk = (kk*kk)%mod;
        kk  = ( kk * nPr(m,i) )%mod;
        ans = ( ans +  (minus * ( (nCr(n , i) * kk)%mod ) )%mod  )%mod;
        minus = -1LL*minus;
    //    cout << "t ";
      //  cout << ans;
    }
    if(ans<0) ans+= mod;
    cout << ans;
}

int main() {
    fac[0] = 1 , Ifac[0] = 1;
    for(ll i=1;i<=1000100;i++){
        fac[i] = (fac[i-1]*i)%mod;
        Ifac[i] = poww(fac[i] , mod-2);
    }
  //  cout << nCr(3,2) << " ";
    sol();
}


Measured memory_bytes: 19128
# coding: UTF-8

import numpy as np

X = int(input())


def make_prime(U):
    is_prime = np.zeros(U, np.bool)
    is_prime[2] = 1
    is_prime[3::2] = 1
    M = int(U ** 0.5) + 1
    for p in range(3, M, 2):
        if is_prime[p]:
            is_prime[p * p :: p + p] = 0
    return is_prime, is_prime.nonzero()[0]


# 'a.nonzero()'で配列の非ゼロ要素のインデックスを取り出せる
# a(a.nonzero())とするとaの非ゼロ要素を取り出せる

_, primes = make_prime(10 ** 5 + 10000)

large = primes[primes >= X]
answer = large.min()
print(answer)

Measured memory_bytes: 12856
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        var c = int.Parse(line[2]);
        Console.WriteLine((a == b && b != c) | (b == c && a != b) | (a == c && a != b) ? "Yes" : "No");
    }
}


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    int n, m;
    cin >> n >> m;

    vector<int> imos(n + 1);
    rep(i, m){
        int l, r;
        cin >> l >> r;
        ++imos[l - 1];
        --imos[r];
    }

    reps(i, n){
        imos[i] += imos[i - 1];
    }

    int ans = 0;
    rep(i, n){
        if(imos[i] == m){
            ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
using System;

class sample
{
		static void Main()
		{
				string input = Console.ReadLine();
				decimal H =long.Parse(input);
				long cnt =0;

				for(decimal i=H;i>=1;i=Math.Truncate(i/2))
				{
						cnt += 1;
				}

				cnt =Convert.ToInt64(Math.Pow(2,cnt));
				Console.WriteLine(cnt-1);
		}
}

						
						


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
using namespace std;
#define Fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(nullptr);                 \
    cout.tie(nullptr)
#define f(i, n) for (long long int i = 0; i < n; i++)
#define ll long long int
#define fo(i, a, b) for (long long int i = a; i <= b; i++)
#define w(t)  \
    int t;    \
    cin >> t; \
    while (t--)
#define vi vector<int>
#define vl vector<long long int>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long int>>
#define mii map<int, int>
#define umii unordered_map<int, int>
#define newl cout<<"\n"
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll inf = 1e9 + 7;
const ll modc = 998244353;
#define MAX 100002

ll maxi(ll a,ll b){
	if(a>=b)return a;
	return b;
}

ll mini(ll a,ll b){
	if(a>=b)return b;
	return a;
}


int main(){
	Fio;
	ll n,w;
	cin>>n>>w;
	ll val[n],wt[n];
	fo(i,0,n-1)cin>>wt[i]>>val[i];
	ll dp[n+1][w+1];
	fo(i,0,n){
		fo(j,0,w){
			if(i==0 || j==0)dp[i][j] = 0;
			else if(wt[i-1]<=j)dp[i][j] = maxi(val[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);
			else dp[i][j] = dp[i-1][j];
		}
	}
	cout<<dp[n][w];
	return 0;
}

Measured memory_bytes: 82504
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>

 
#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s
 
typedef long long ll;
 
using namespace std;

ll modd = 1000*1000*1000+7;

template<class T>
T fastpower(T a, long long n) {  // n must be >= 1
  if (n % 2 == 0) {  
      T halfpower = fastpower<T>(a, n/2);
      return (halfpower*halfpower) % modd;
  } else {
      if (n == 1) {  return a; } else {  
          T halfpower = fastpower<T>(a, n/2);
          return (((halfpower*halfpower)%modd)*a)%modd;
      }
  }
};


int main()   {

    ios_base::sync_with_stdio(false);

    cout.precision(17);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no

//    auto start = chrono::steady_clock::now()

//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readint(n);
        ll summ = 0, summ_sq = 0;
        forr(i,0,n) {
            readll(aa);
            summ += aa; summ %= modd;
            summ_sq += (aa*aa) % modd; summ_sq %= modd;
        }
        ll ret = (summ*summ) % modd;
        ret += (modd - summ_sq); ret %= modd;
        ret *= fastpower<ll>(2, modd-2); ret %= modd;

        cout << ret << endl;
    }

//    auto end = chrono::steady_clock::now();
//    cerr << chrono::duration_cast<chrono::milliseconds>(end - start).count() << endl;

    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<sstream>
#include<vector>
#include<cstdlib>
#include<map>
#define F first
#define S second


using namespace std;
typedef pair<int,int> P;


bool cmp(const P &p,const P &q){
  if(p.F != q.F)return p.F < q.F;
  return p.S > q.S; // iranai
}



int main(){
  string s;
  vector<P> vec;
  map<int,bool> exist;
  while(true){
    getline(cin,s,'\n');
    if(s.size() == 0)break;
    int pi;
    for(int i=0;i<s.length();i++)if(s[i] == ','){pi = i;break;}
    int A,B;
    A = (atoi)(s.substr(0,pi).c_str());
    B = (atoi)(s.substr(pi+1,s.length()-pi-1).c_str());
    vec.push_back(P(A,B));
    exist[A] = true;
  }


  vector<P> vec2;
  map<int,int> info;
  while(getline(cin,s,'\n')){
    int pi;
    for(int i=0;i<s.length();i++)if(s[i] == ','){pi = i;break;}
    int A,B;
    A = (atoi)(s.substr(0,pi).c_str());
    B = (atoi)(s.substr(pi+1,s.length()-pi-1).c_str());
    vec2.push_back(P(A,B));

    info[A]++;
  }

  

  for(int i=0;i<vec.size();i++){

  if(info[vec[i].F] > 0){

      info[vec[i].F]++;
    }
  }



  vector<P> rank;
  map<int,int>::iterator it = info.begin();
  while(it != info.end()){
    if((*it).S == 0){
      it++;
      continue;
    }

    rank.push_back(P((*it).F,(*it).S));
    it++;
  }

  sort(rank.begin(),rank.end(),cmp);
  for(int i=0;i<rank.size();i++){
    if(exist[rank[i].F])cout << rank[i].F << " " << rank[i].S << endl;
  }



  return 0;
}

Measured memory_bytes: 1196
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    double ans = 0;
    for(int i = 1; i <= n; i++) {
      int t = 0;
      int c = i;
      while(c < k) {
        c *= 2;
        t++;
      }
      ans += ((double)1 / ((double)n * (double)Math.pow(2, t)));
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
using ll = long long;
using namespace std;

int w[401];
vector<tuple<int, int, int>> v;
int dp[401]; //indexの番号 重さ 最大コストをもつ
int const MOD = 1e9 + 7;
int main(void)
{
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        int r, l, p;
        cin >> r >> l >> p;
        v.push_back(make_tuple(r, l, p));
    }

    int m;
    cin >> m;
    for (int i = 0; i < m; ++i)
        cin >> w[i];

    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j <= 393; ++j)
        {
            for (int k = get<0>(v[i]); k <= get<1>(v[i]); ++k)
            {
                if (j - k >= 0)
                {
                    dp[j] = max(dp[j], dp[j - k] + get<2>(v[i]));
                }
                else
                {
                    dp[j] = dp[j];
                }
            }
        }
    }

    bool ok = true;
    vector<int> ans;
    for (int i = 0; i < m; ++i)
    {
        if (dp[w[i]] == 0)
            ok = false;
        ans.push_back(dp[w[i]]);
    }
    if (!ok)
        cout << -1 << endl;
    else
    {
        for (auto e : ans)
            cout << e << endl;
    }
    return 0;
}


Measured memory_bytes: 3168
import itertools

n = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

R = map(lambda x: x + 1, range(n))

a = 0
b = 0
for i, X in enumerate(itertools.permutations(R)):
  if X == P: a = i
  if X == Q: b = i

if(a >= b): print(a - b)
else: print(b - a)

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

int main() {
  int n;
  cin >> n;
  vector<pair<int,int>>data(n);
  for(int i = 0;i < n;i++){
    cin >> data[i].first;
    data[i].second = i;
  }
  sort(data.begin(),data.end());
  for(int i = 0;i < n;i++){
    if(i != n-1){
      cout << data[i].second+1 << " ";
    }
    else{
      cout << data[i].second+1 << endl;
    }
  }
}


Measured memory_bytes: 1664
use std::cmp::min;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let t:u128 = read();
    let mut cnt = 0;
    let v:Vec<u128> = (0..n).map(|_| read()).collect();
    for i in 0..n-1 {
        cnt += min(t, v[i+1] - v[i]);
    }
    println!("{}", cnt + t);
}

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

int main(){
  int a,b,c,d,e,k; cin>>a>>b>>c>>d>>e>>k;
  int h,i,j,l,m,n,o,p,q,r;
  h=b-a;i=c-a;j=d-a;l=e-a;m=e-b;n=d-b;o=c-b;p=e-c;q=d-c;r=e-d;
  if(h<=k&&i<=k&&j<=k&&l<=k&&m<=k&&n<=k&&o<=k&&p<=k&&r<=k){
    cout<<"Yay!"<<endl;
  }
  else{
    cout<<":("<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	final static long MODULO = 1_000_000_000 + 7;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		long[][][] dp = new long[2][N + 2][N + 2];// [何日目][1を含む連結成分のサイズ][全体の訪れた町のサイズ]
		dp[0][1][1] = 1;
		for (int i = 0; i + 1 <= M; ++i) {
			dp[(i + 1) % 2] = new long[N + 2][N + 2];
			for (int j = 0; j <= N; ++j) {
				for (int k = j; k <= N; ++k) {
					dp[(i + 1) % 2][j][k] += dp[i % 2][j][k] * (k - j);
					dp[(i + 1) % 2][j][k] %= MODULO;
					dp[(i + 1) % 2][k][k] += dp[i % 2][j][k] * j;
					dp[(i + 1) % 2][k][k] %= MODULO;
					dp[(i + 1) % 2][j][k + 1] += dp[i % 2][j][k] * (N - k);
					dp[(i + 1) % 2][j][k + 1] %= MODULO;
				}
			}
		}
		System.out.println(dp[M % 2][N][N]);
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 78944
import java.util.*;
import java.io.*;
class Main{
  public static void main(String args[]){
    int n=readI(),count=0;
    int ar[]=new int[n];
    for(int i=0;i<n;i++){
      ar[i]=readI();
    }
    sortA(ar);
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
        if(ar[i]==ar[j]){continue;}
        for(int k=j+1;k<n;k++){
          if(ar[j]==ar[k]){continue;}
          if(ar[i]+ar[j]>ar[k]){
            count++;
          }
        }
      }
    }
    pl(count+"");
  }

  public static void sortA(int n[]){
    Arrays.sort(n);
  }

  static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  public static void pr(String str){
    System.out.print(str);
  }
  public static void pl(String str){
    System.out.println(str);
  }
  public static String read(){
    try{
      return ctos((char)br.read());
    }catch(IOException e){
      e.printStackTrace();
      return "";
    }
  }
  public static char readC(){
    try{
      return (char)br.read();
    }catch(IOException e){
      e.printStackTrace();
      return (char)-1;
    }
  }
  public static String readL(){
    try{
      return br.readLine();
    }catch(IOException e){
      e.printStackTrace();
      return "";
    }
  }
  public static String readS(){
    StringBuilder sb = new StringBuilder();
    while(true){
      try{
        int k = br.read();
        if(k==-1||(char)k==' '||(char)k=='\n'){break;}
        sb.append((char)k);
      }catch(IOException e){
        e.printStackTrace();
      }
    }
    return sb.toString();
  }
  public static long readLong(){
    return stol(readS());
  }
  public static long stol(String s){
    return Long.parseLong(s);
  }
  public static int readI(){
    return stoi(readS());
  }
  public static String[] readSs(){
    return readL().split(" ");
  }
  public static int[] readIs(){
    return stoi(readSs());
  }
  public static int stoi(String s){
    return Integer.parseInt(s);
  }
  public static int[] stoi(String s[]){
    int a[]=new int[s.length];
    for(int i=0;i<s.length;i++){
      a[i]=stoi(s[i]);
    }
    return a;
  }
  public static String itos(int i){
    return String.valueOf(i);
  }
  public static String[] itos(int[] a){
    String s[]=new String[a.length];
    for(int i=0;i<a.length;i++){
      s[i]=itos(a[i]);
    }
    return s;
  }
  public static String ctos(char c){
    return String.valueOf(c);
  }
  public static String cstos(char[] c){
    return new String(c);
  }
  public static char stoc(String s){
    return s.charAt(0);
  }
  public static char[] stocs(String s){
    return s.toCharArray();
  }
  public static int[] Itoi(Integer a[]){
    int[]result=new int[a.length];
    for(int i=0;i<a.length;i++){
      result[i]=a[i];
    }
    return result;
  }
}


Measured memory_bytes: 36928
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000000
#define infll 1000000000000000000ll
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define mpr make_pair
#define fi first
#define se second
#define pq priority_queue<int>
#define pqll priority_queue<ll>
#define up(x,y) (x<(y)?x=(y):0)
#define dn(x,y) (x>(y)?x=(y):0)
#define ad(x,y) (x=(x+(y))%mod)
#define mod 1000000007
#define N 200009
using namespace std;

int n,a[N],dp[N],sum[N];
int main(){
	scanf("%d",&n);
	int i;
	for (i=1; i<=n; i++){
		scanf("%d",&a[i]);
		if (a[i]==a[i-1]){ i--; n--; }	
	}
	dp[0]=1;
	for (i=1; i<=n; i++){
		ad(dp[i],dp[i-1]); ad(dp[i],sum[a[i]]);
		ad(sum[a[i]],dp[i-1]);
	}
	printf("%d\n",dp[n]);
	return 0;
}


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

int main() {
  int h, n;
  cin >> h >> n;
  vector<pair<int, int>> ab(n);
  for (int i = 0; i < n; i++) cin >> ab[i].first >> ab[i].second;
  vector<int> dp(h + 100000, 1000000000);

  dp[0] = 0;
  for (int i = 0; i < h + 10000; i++) {
    if (dp[i] < 0) continue;
    for (int j = 0; j < n; j++) {
      dp[i + ab[j].first] = min(dp[i + ab[j].first], dp[i] + ab[j].second);
    }
  }

  int ret = 1000000000;
  for (int i = h; i < h + 10000; i++) {
    ret = min(ret, dp[i]);
  }
  cout << ret;
  return 0;
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 1e6 + 10;
#define fi first
#define se second
#define pb push_back
char a[N];
int dp[2][N];
int main() {
    ios::sync_with_stdio(false);
    cin>>a+1;
    int n=strlen(a+1);
    dp[0][n]=a[n]-'0';
    dp[1][n]=1+(10-a[n]+'0');
//    cout<<dp[0][n]<<' '<<dp[1][n]<<endl;
    for(int i=n-1;i>=1;i--){
      dp[0][i]=min(dp[0][i+1]+a[i]-'0',dp[1][i+1]+(a[i]-'0'));
      dp[1][i]=min(dp[0][i+1]+1+(10-a[i]+'0'),dp[1][i+1]+9-(a[i]-'0'));
    }
    cout<<min(dp[0][1],dp[1][1])<<'\n';
    return 0;
}


Measured memory_bytes: 9088
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007
#define MINP 0x00FF

int main(int argc, char const *argv[])
{
	int n,h[107];
	int l = 0,r;
	int cnt = 0,min = MINP,flag = 1;
	scanf("%d",&n);
	for (int i = 0; i < n; ++i)	scanf("%d",&h[i]);

	while(l < n){
		min = MINP;
		flag = 1;
		if(h[l] == 0){
			++l;
			continue;
		}
		for (int i = l; (i < n && flag); ++i)
		{
			for (r = l; r < n; ++r)
			{
				if(h[r] == 0){
					flag = 0;
					break;
				}
			}
		}
		for (int i = l; i < r; ++i)
		{
			if(min > h[i])	min = h[i];
		}
		for (int i = l; i < r; ++i)
		{
			h[i] -= min;
		}
		cnt += min;
	}
	printf("%d\n", cnt);
}


Measured memory_bytes: 128
A, B, C = map(int, input().split())


s = 0
e, o = 0, 0
if A % 2 == 0:
    e += 1
else:
    o += 1

if B % 2 == 0:
    e += 1
else:
    o += 1

if C % 2 == 0:
    e += 1
else:
    o += 1

if (e, o) == (2, 1):
    s += 1
    if A % 2 == 0:
        A += 1
    if B % 2 == 0:
        B += 1
    if C % 2 == 0:
        C += 1
if (e, o) == (1, 2):
    s += 1
    if A % 2 != 0:
        A += 1
    if B % 2 != 0:
        B += 1
    if C % 2 != 0:
        C += 1

m = max((A, B, C))
print(int(s + ((m - A) + (m - B) + (m - C)) / 2))


Measured memory_bytes: 3192
#include <stdio.h>

int main(void)
{
    int N;
    char c;
    char Si, Sj;
    int i;
    int ctr = 1;
    
    
    scanf("%d%c", &N, &c);
    scanf("%c", &Si);
    
    
    for(i=1; i<N; i++)
    {
        scanf("%c", &Sj);
        
        if(Si != Sj)
        {
            ctr++;
        }
        Si = Sj;
    }
    
    
    printf("%d\n", ctr);
    
    
    //system("pause");
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <functional>
#include <map>
using namespace std;

long long N, K, sum;

int main() {
	cin >> N >> K;
	if (K == 0) {
		cout << N*N << endl;
		return 0;
	}
	for (int i = K + 1; i <= N; i++) {
		long long D = (N + 1) / i;
		long long E = D*(i - K);
		long long F = (N + 1) % i;
		long long G = max(0LL, F - K);
		sum += E + G;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val scan = Scanner(System.`in`)
    var a = scan.nextLine().toInt()
    var x = ArrayList<String>()
    for(i in 1..a)
    {
        var q = scan.nextLine()
        x.add(q)
    }
    var z = x.toSet()
    println(z.size)
}


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

using ll = long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

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

#define ALL(v) (v).begin(), (v).end()
#define CHMAX(a,b) a=max(a,b)
#define CHMIN(a,b) a=min(a,b)

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl

int n;
int r[1252], w[1252];
bool ok[2521];

int main(){
    while(true){
        scanf("%d",&n);
        if(n==0)break;
        REP(i,n)scanf("%d%d",r+i,w+i);
        int rsum = accumulate(r,r+n,0);
        int mx = *max_element(r,r+n);
        if(2*mx <= rsum){
            int ans = rsum + accumulate(w,w+n,0);
            printf("%d\n",ans);
        }else{
            int wsum = accumulate(w,w+n,0);
            int mxid = max_element(r,r+n)-r;
            int rest = 2*mx - rsum;
            fill(ok,ok+1252,false);
            ok[0] = true;
            REP(i,n)if(i != mxid){
                FORR(j,w[i],rest+1)ok[j] = ok[j] || ok[j-w[i]];
            }
            int go = 0;
            REP(i,rest+1)if(ok[i])go=i;
            int ans = 2*mx + (wsum-go);
            printf("%d\n",ans);
        }
    }
    return 0;
}


Measured memory_bytes: 3176
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const long long MOD = 998244353;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())
constexpr auto PI = 3.14159265358979323846264338327950L;
long long N;
void dfs(long long cur,int use,long long &counter) {
    // 数列の長さが N に達したら打ち切り
    if (cur > N) {
        // 処理
        return;
    }
    if(use == 0b111)++counter;

    dfs(cur * 10 + 7 , use | 0b001,counter);
    dfs(cur * 10 + 5 , use | 0b010,counter);
    dfs(cur * 10 + 3 , use | 0b100,counter);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> N;
    long long res=0;
    dfs(0,0,res);
    cout << res <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int dp[100005];
signed main() {
    int N,K;
    cin >> N >> K;
    vector<int>A(N);
    for(int i = 0; i < N; i++) {
        dp[i] = INF;
    }
    dp[0] = 0;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        for(int j = 1; j <= K; j++) {
            if(i >= j) {
                dp[i] = min(dp[i],dp[i-j]+abs(A[i]-A[i-j]));
            } 
        }
    }
    cout << dp[N-1] << endl;
}



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

int main(){
int i = 0;
for(i = 1;i <= 200;i++){
int a = -1;int b = -1;
cin >> a >> b;
if(a < 0){
break;
}
else if(a + b < 10){
cout << 1 << endl;
}
else if(a + b < 100){
cout << 2 << endl;
}
else if(a + b < 1000){
cout << 3 << endl;
}
else if(a + b < 10000){
cout << 4 << endl;
}
else if(a + b < 100000){
cout << 5 << endl;
}
else if(a + b < 1000000){
cout << 6 << endl;
}
else {
cout << 7 << endl;
}
}
    return 0;
}

Measured memory_bytes: 1160
def main():
  s=input()
  x = s.find("C")
  y = s.find("F")
  if x<0 or y<0:
    print("No")
    return 0
  while x<len(s):
    if s[x]=="F":
      print("Yes")
      return 0
    x+=1
  print("No")
  

    
main()


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	std::vector<int> x(3);
	int res = 1;
	for (int i = 0; i < n; i++) {
		int a = ri();
		int cnt = 0;
		for (int j = 0; j < 3; j++) if (x[j] == a) {
			if (!cnt) x[j]++;
			cnt++;
		}
		res = (int64_t) res * cnt % 1000000007;
	}
	std::cout << res << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int N, ans[4], count = 0;
    scanf("%4d", &N);
    ans[0] = N % 10;
    ans[1] = (N / 10) % 10;
    ans[2] = (N / 100) % 10;
    ans[3] = (N / 1000) % 10;
    for(int i = 1; i < 4; i++){
        if(ans[i] == ans[i - 1]) count++;
        else count = 0;
        if(count >= 2) break;
    }
    if(count >= 2) printf("Yes");
    else printf("No");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<string>
#include<cctype>
#include<cmath> 
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
 
int main(){
  int N,M,ans;
  string S;
  cin >> S;
  
  ans=S.size();

  cout << S[0] << ans-2 << S[S.size()-1] << endl;



  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t x){
	if(was_output)cout << " ";
	was_output = true;
	cout << x;
}

void outendl(){
	was_output = false;
	cout << endl;
}

int main(){
	int n;
	cin >> n;
	ll ans = 0;
	vector<int> line(n);
	foreach(i, line)cin>>i;
	rep(i, n){
		for(int j=i+1;j<n;++j){
			ans += line[i] * line[j];
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
x=[1,3,5,7,8,10,12]
y=[4,6,9,11]
z=[2]
a,b=map(int,input().split())
if (a in x and b in x) or (a in y and b in y) or (a in z and b in z):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9108
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#define _GLIBCXX_DEBUG
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    vector<string> vec(N);
    for (int i=0;i<N;i++){
        cin >> vec.at(i);
    }
    sort(vec.begin(), vec.end());
    string S = vec.at(0);
    int c = 1;
    int x = 0;
    
    for (int i = 0; i < N-1; i++) {
        if (vec.at(i+1) == S){
        c ++;
        }
        else {
        S = vec.at(i+1);
        c = 1;
        }
        x = max(c, x);
    }
    int y = 0;
    S = vec.at(0);
    
    for (int i = 0; i < N; i++) {
        if (vec.at(i) == S)
        y ++;
        else {
        S = vec.at(i);
        y = 1;
        }
        if (y == x){
        cout << vec.at(i) << endl;
        }
    }
}
// 模範解答そのまま
// 全く分からなかった。

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

int n;
int B[105];
vector<int>ans;

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", B + i);
    for (int i = n - 1; i >= 0; i--)
        for (int j = i; j >= 0; j--)
            if (B[j] == j + 1) {
                ans.push_back(B[j]);
                for (int k = j; k < i; k++)
                    B[k] = B[k + 1];
                break;
            }
    if ((int)ans.size() < n)
        printf("-1\n");
    else
        for (int i = n - 1; i >= 0; i--)
            printf("%d\n", ans[i]);
}


Measured memory_bytes: 256
// Author: getharshkumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    string s, t;
    cin >> s >> t;
    cout << t << s;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string.h>
#include<map>
#include<set>
#define maxn 200005
#define lson (now<<1)
#define rson ((now<<1)|1)
#define mid ((nl+nr)>>1)
using namespace std;
typedef long long ll;
int main()
{
	for(int i=1;i<=5;i++)
	{
		int x;
		cin>>x;
		if(x==0)
		{
			printf("%d\n",i);
			return 0;
		}
	}
}

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

int main() {

  int N, A;
  cin >> N;
  
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  bool B;
  B = true;
  
  while (B == true) {
    for (int i = 0; i < N; i++) {
      
      if (vec.at(i) % 2 != 0) {
        B = false;
        break;
      }
    }

    if (B) {
      A++;
      for (int i = 0; i < N; i++) {
        vec.at(i) /= 2;
      }
    }
  }
  cout << A << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#define INF 100000000000
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef pair<ll, double> PD;
int n;
vector<int> a(200000);
vector<int> b(200000);

int main() {
	ll n, mod;
	cin >> n >> mod;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	vector<ll> sum(n + 1);
	for (int i = 0; i < n; i++) {
		sum[i + 1] = (sum[i] + a[i] - 1 + mod) % mod;
	}
	ll ans = 0;
	map<ll, ll> mp;
	for (int i = 0; i <= n; i++) {
		mp.insert(P(sum[i], 0));
		if (i>=mod) {
			mp[sum[i - mod]]--;
		}
		ans += mp[sum[i]];
		mp[sum[i]]++;
	}
	cout << ans << endl;
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }
#define double long double
const double PI = acos(-1);
#define rad_to_deg(rad) (((rad)/2/PI)*360)
const double EPS = 1e-10; //問題ごとに変更
signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	double a, b, x; cin >> a >> b >> x;
	double ans;
	if (x >= a * a*b / 2) {
		double y = a * a*b - x;
		y /= a;
		ans=atan(2 * y / a / a);
	}
	else {
		x = x / a;
		ans = PI/2-atan(2 * x / b / b);
	}
	cout << rad_to_deg( ans) << endl;
	return 0;

	auto f = [&](double th) {
		if (atan2(a, b) > th + EPS) {
			dump(1);
			double z = a * a*b;
			double e = tan(th)*a;
			z -= a / 2 * a * e;
			dump(z, e);
			return z >= x + EPS;
		}
		else {
			dump(2);
			double s = PI / 2 - th;
			double e = b * tan(s);
			double z = b / 2 * e*a;
			dump(z, e);
			return z >= x + EPS;
		}
	};

	double l = 0;
	double r = PI / 2;
	loop(1000) {
		double m = (l + r) / 2;
		bool flag = f(m);
		dump(rad_to_deg(m), flag);
		if (flag) {
			l = m;
		}
		else {
			r = m;
		}
	}
	l = 360 * l / (2 * PI);
	cout << l << endl;

	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var ps [3]int
	for i := range ps {
		var p int
		fmt.Scan(&p)
		ps[i] = p
	}
	sort.Ints(ps[:])
	fmt.Println(ps[0] + ps[1])
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <vector>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=200000000000005LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<P,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
struct edge{
	char x;
	int y;
	bool operator<(const edge& e)const{
		return x<e.x;
	}
	bool operator>(const edge& e)const{
		return x>e.x;
	}
};

struct road{ll cost;int to;};
int n,m,k;
int a[10]={10000,2,5,5,4,5,6,3,7,6};
vector<edge> v;
int dp[10005]={};
bool b[10]={};

char t;

void reg(int l,int d){
	dp[0]=0;
	rep(i,0,l){
		rep(j,0,d){
			if(i+v[j].y<=l){
				dp[i+v[j].y]=max(dp[i+v[j].y],dp[i]+1);
			}
		}
	}
}
int main() {
	memset(dp,-1,sizeof(dp));
	cin>>n>>m;
	rep(i,0,m){
		cin>>t;
		v.push_back(edge{t,a[t-'0']});
	}
	sort(v.rbegin(),v.rend());
	reg(n,m);
//	cout<<dp[n]<<endl;
	int i=0;
	string ans="";
	while(n>0){
		if(n-v[i].y<0){
			i++;
			continue;
		}
		if(dp[n-v[i].y]==dp[n]-1){
			ans+=v[i].x;
			n-=v[i].y;
		}else{
			i++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256