akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <string>

using namespace std;

typedef long long LL;

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ALL(a)  (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define dump(x)  cerr << #x << " = " << (x) << endl;

int main() {
  int n;
  string *S;
  cin >> n;
  S = new string[n];
  REP(i, n) {
    cin >> S[i];
  }

  map<char, int> m, m_temp;

  REP(i, n) {
    if (i == 0) {
      for(auto c:S[i]) {
        m[c] += 1;
      }
      continue;
    } else {
      for(auto c:S[i]) {
        m_temp[c] += 1;
      }
      for(auto p:m_temp) {
        char c = p.first;
        if (m[c] > m_temp[c]) { m[c] = m_temp[c]; }
      }
      for(auto p:m) {
        char c = p.first;
        if (m[c] > m_temp[c]) { m[c] = m_temp[c]; }
      }
      m_temp.clear();
    }
  }

  string result;
  for (auto p:m) {
    REP(i, p.second) { result.push_back(p.first); }
  }
  sort(ALL(result));

  cout << result << endl;
  
  return 0;
}

Measured memory_bytes: 256
from collections import deque
n=int(input())
yaku=deque([])
for i in range(1,int(n**0.5)+1):
    if n%i==0:
        yaku.append(i)
        yaku.append(n//i)
yaku=list(sorted(set(yaku)))[1:]
ans=0
for i in yaku:
    if n//(i-1)==n%(i-1):
        ans+=i-1
print(ans)

Measured memory_bytes: 4212
import fractions
a,b,c,d=map(int,input().split())

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def amari(x,y):
    return x//y if x%y==0 else x//y+1

cnum=b//c-amari(a,c)+1
dnum=b//d-amari(a,d)+1
cdnum=b//lcm(c,d)-amari(a,lcm(c,d))+1

print(b-a+1-cnum-dnum+cdnum)

Measured memory_bytes: 5048
a,b,c=gets.split.map &:to_i
rad = ( c * Math::PI/ 180.0 ) # 度->ラジアン変換
p Math.sin(rad)*a*b*0.5
p a+b+Math.sqrt((a**2+b**2)-2*a*b*Math.cos(rad))
p b*Math.sin(rad)


Measured memory_bytes: 6948
import scala.io.{StdIn => in}

object Main extends App {
  var Array(a, b) = in.readLine.split(" ").map(_.toInt)

  val ans = (0 until 2)./:(0,a,b) {
    case ((acc,a,b), _) => {
      val m = a max b
      val (na,nb) = if(m == a) (a-1,b) else (a,b-1)
      (acc+m, na, nb)
    }
  }._1

  println(ans)
}

Measured memory_bytes: 25416
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> b(n);
    rep(i,n-1) cin >> b[i];
    ll ans = b[0];
    rep(i,n-2) ans += min(b[i], b[i+1]);
    ans += b[n-2];
    cout << ans << endl;
    return 0;
}


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

MOD = 10**9 + 7


class ModInt:
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x) if isinstance(other, ModInt) else
            ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x) if isinstance(other, ModInt) else
            ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x) if isinstance(other, ModInt) else
            ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    def __pow__(self, other):
        return (
            ModInt(pow(self.x, other.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(self.x, other, MOD))
        )

    __radd__ = __add__

    def __rsub__(self, other):
        return (
            ModInt(other.x - self.x) if isinstance(other, ModInt) else
            ModInt(other - self.x)
        )

    __rmul__ = __mul__

    def __rtruediv__(self, other):
        return (
            ModInt(
                other.x * pow(self.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(other * pow(self.x, MOD - 2, MOD))
        )

    def __rpow__(self, other):
        return (
            ModInt(pow(other.x, self.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(other, self.x, MOD))
        )


f = [ModInt(1)]
for i in range(1, 2 * N + 1):
    f.append(f[-1] * i)


def cmb(n, k):
    return f[n] / (f[k] * f[n - k])


c = ModInt(100 - C)
pa = A / c
pb = B / c
ec = 100 / c

ans = sum(
    cmb((N - 1) + i, i) * (N + i) * ec * (pa**N * pb**i + pa**i * pb**N)
    for i in range(N)
)
print(ans)


Measured memory_bytes: 66524
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
const int mod=1000000007 ;

void solve(){
	
	int n ;
	cin>>n ;

	vector<int> a(n) ;

	for(int i=0;i<n;i++){
		cin>>a[i] ;
	}	
	
	int ans=0 ;
	int x=0 ;

	for(int i=0;i<n;i++){
		ans=(ans+(ll)a[i]*x)%mod ;
		x=(x+a[i])%mod  ;
	}

	cout<<ans;

}
int main(){
	
	int y ;

	y=1 ;
	//cin>>y ;

	while(y--)
	{	
		solve() ;
	}

}

Measured memory_bytes: 3996
#include <iostream>

using namespace std;

#define mods 1000000007

long repeatExp(long long n,long long k){
    long long res = 1;
    while(k > 0){
        if(k&1)res = res * n % mods;
        n = n*n % mods;
        k = k >> 1;
    }
    return res % mods;
}

long comb(int n,int x){
    long long xx = 1;
    long long y = 1;
    for(int i=0;i<x;++i){
        xx = (xx * (n-i)) % mods;
        y = (y * (i+1)) % mods;
    }
    return (xx * repeatExp(y,mods-2)) % mods;
}

int main(){
    int n,a,b;
    cin >> n >> a >> b;
    long res = (repeatExp(2,n) - 1) % mods;
    long ka = comb(n,a) % mods;
    long kb = comb(n,b) % mods;
    long tmp = (res - ka - kb) % mods;
    if(tmp < 0)cout << tmp + mods << endl;
    else cout << tmp << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll C[100007];

int main(){
  ll N,K,R,S,P,ans=0;
  string T;
  cin >> N >> K >> R >> S >> P >> T;
  rep(i,T.size()){
    bool win;
    if(i<K){
      win = 1;
      C[i]=1;
    }
    else{
      if(T[i]==T[i-K] &&  C[i-K]==1){
        win = 0;
      }
      else{
        win = 1;
        C[i]=1;
      }
    }

    if(win){
      if(T[i]=='r'){
        ans+=P;
      }
      if(T[i]=='s'){
        ans+=R;
      }
      if(T[i]=='p'){
        ans+=S;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1280
import java.io.*;
class Main{
  public static void main(String[] args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] three_number = br.readLine().split(" ");
    int a = Integer.parseInt(three_number[0]);
    int b = Integer.parseInt(three_number[1]);
    int c = Integer.parseInt(three_number[2]);
    if(a<b && b<c){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}



Measured memory_bytes: 24480
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i<n;i++)
using ll = long long;
const int mod = 1e9+7;
using namespace std;
struct mint
{
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a){
        if((x += a.x) >= mod) x-= mod;
        return *this;
    }
    mint& operator-=(const mint a){
        if((x += mod-a.x) >= mod) x-= mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x *= a.x)%= mod;
        return *this;
    }
    mint operator+(const mint a)const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a)const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a)const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t)const{
        if(!t)return 1;
        mint a = pow(t>>1);
        a *= a;
        if(t&1) a*= *this;
        return a;
    }
    mint inv() const{
        return pow(mod-2);
    }
    mint& operator/=(const mint a){
        return (*this) *= a.inv();
    }
    mint operator/(const mint a)const {
        mint res(*this);
        return res/=a;
    }
};
mint f(int n){
    if( n ==0 )return 1;
    mint x= f(n/2);
    x*=x;
    if (n%2==1) x*=2;
    return x;
}
mint choose(int n, int a){
    mint x =1, y=1;
    rep(i,a){
        x *= n-i;
        y *= i+1;
    }
    return x/y;
}
int main(){
    int n,a,b;
    cin>>n>>a>>b;
    mint ans = f(n)-1;
    ans -= choose(n,a);
    ans -= choose(n,b);
    cout<<ans.x<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> as(N);
  for (int i; i < N; i++) {
    cin >> as.at(i); 
  }
  sort(as.begin(), as.end());
  reverse(as.begin(), as.end());
  int suma, sumb;
  for (int i; i < N; i++) {
    if (i % 2 == 0) {
      suma += as.at(i);
    } else {
      sumb += as.at(i);
    }
  }
  cout << suma - sumb << endl;
}

Measured memory_bytes: 256
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

constexpr int64_t DIV1097 = 1000000007LL;

using namespace std;

int main()
{
    std::string S;
    std::cin >> S;

    int64_t L = S.size();

    int64_t c = 0;

    int64_t i = 0;
    int64_t j = L-1;
    while (i < j) {
        if (S[i] != S[j]) {
            if (S[i] == 'x') {
                ++i;
                ++c;
            }
            else if (S[j] == 'x') {
                --j;
                ++c;
            }
            else {
                std::cout << -1 << std::endl;
                return 0;
            }
        }
        else {
            ++i;
            --j;
        }
    }

    std::cout << c << std::endl;

    return 0;
}


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

using namespace std;

int main(){
  string S, T;
  cin >> S >> T;
  int ans = 0;
  for (int i=0; i<3; i++){
    if (S[i] == T[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPD(i,n) for(int i=(n)-1;i>=0;--i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=(b);--i)
#define TLE() cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms.\n";
const ll MOD = 1E9+7;
const ll IINF = 1E18;
const int INF = 1e9;
const double EPS = 1E-9;
const double PI = atan(1.0) * 4.0;
template<class T> T getbit(T s, int i) {return s>>i&1;}
template<class T> void flipbit(T& s, int i) {s^=(1LL<<i);}
constexpr int cntbit(ll x) {return __builtin_popcountll(x);}
constexpr int lg2(ll x) {return __lg(x);} // return int(log2(x))
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 
ll fpow(ll a,ll p){ll res=1LL;while(p){if(p&1LL) res=res*a%MOD;a=a*a%MOD;p>>=1LL;} return res;}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n,m;
	cin>>n>>m;
	vector<pair<int,int>> v;
	priority_queue<int> q;
	REP(i,n){
		int a,b;
		cin>>a>>b;
		v.pb(mp(a,b));
	}
	sort(all(v));
	int j=0;
	ll res=0;
	REPD(i,m){
		while(j<n&&v[j].fi<=m-i){
			q.push(v[j].se);
			++j;
		}
		if(!q.empty()){
			res+=q.top();
			q.pop();
		}
	}
	cout<<res<<'\n';
}



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

using namespace std;

typedef long long ll;
double PI = 3.14159265359;

int main(void) {

	double a, b, h, m;
	
	cin >> a >> b >> h >> m;

	double l_x, l_y, s_x, s_y;

	l_x = a * cos((m / 30)*PI);
	l_y = a * sin((m / 30)*PI);

	s_x = b * cos(((m + 60*h) / 360)*PI);
	s_y = b * sin(((m + 60 * h)/360)*PI);

	double lon;

	lon = sqrt((pow(l_x-s_x,2))+ (pow(l_y - s_y, 2)));

	printf("%.12lf",lon);

	return 0;
}

Measured memory_bytes: 4072
#include <cstdio>
using namespace std;
typedef long long ll;
const int mod=1000000007;
ll mod_pow(ll x,ll n){
  ll res=1;
  if(n==0) return 1;
  if(n>0){
  res=mod_pow(x,n/2);
    if(n%2==0){
      res=(res*res)%mod;
    }
    else{
      res=(((res*res)%mod)*x)%mod;
    }
  }
  return res;
}
int main(){
  int n,m;
  scanf("%d%d",&n,&m);
  printf("%d\n",mod_pow(n,m));
  return 0;
}

Measured memory_bytes: 2756
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

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

    X-= A;

    while(true){
        if(X >= B){
            X -= B;
        }else
        {
            break;
        }
        
    }

    cout << X << endl;
    
}

Measured memory_bytes: 3544
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if((a==1&&b==1)||(c==1))cout<<"Open"<<endl;
    else cout<<"Close"<<endl;
    return 0;
}

Measured memory_bytes: 1156
/* Coached by Dukkha */
#include <stdio.h>

#define A 100000

int main() {
	static int kk[A + 1];
	int n, a, ans;

	scanf("%d", &n);
	while (n--) {
		int a;

		scanf("%d", &a);
		kk[a]++;
		kk[a + 1]++;
		if (a > 0)
			kk[a - 1]++;
	}
	ans = 0;
	for (a = 0; a <= A; a++)
		if (ans < kk[a])
			ans = kk[a];
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using namespace boost::multiprecision;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPI(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define ALL(x) (x).begin(),(x).end()


int main () {
  long long x;
  cin >> x;

  long long n = (x/100);
  long long amari = (x%100);

  if((amari % 5) == 0 && (amari / 5) <= n) {
    cout << 1 << endl;
  }
  else if((amari % 5) != 0 && ((amari / 5) + 1) <= n) {
    cout << 1 << endl;
  }
  else {
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		int h = sc.nextInt();
		int m = sc.nextInt();
		int p = sc.nextInt();
		int n = sc.nextInt();
		int k = sc.nextInt()+1;

		int b[] = new int[h + 1];

		for (int i = 0; i < n; i++) {
			b[h - sc.nextInt()] = sc.nextInt();
		}

		double[][] dp = new double[m][k];
		dp[p - 1][0] = 1;
		for (int i = 0; i < h; i++) {
			double dp2[][] = new double[m][k];
			if (b[i] != 0) {
				for (int j = 0; j < m; j++) {
					for (int s = 0; s < k; s++) {
						if (b[i] == j) {
							dp2[j][s] = dp[j - 1][s];
						} else if (b[i] == j + 1) {
							dp2[j][s] = dp[j + 1][s];
						} else {
							dp2[j][s] = dp[j][s];
						}
					}
				}
			} else {
				for (int j = 0; j < m; j++) {
					for (int s = 0; s < k; s++) {
						dp2[j][s] = dp[j][s];
					}
				}
				for (int j = 0; j < m; j++) {
					for (int s = 0; s < k - 1; s++) {
						for (int q = 1; q < m; q++) {
							if (q == j) {
								dp2[j][s + 1] += dp[j - 1][s];
							} else if (q == j + 1) {
								dp2[j][s + 1] += dp[j + 1][s];
							} else {
								dp2[j][s + 1] += dp[j][s];
							}
						}
					}
				}
			}
			dp = dp2;
//			System.out.println(Arrays.deepToString(dp));
//			System.out.println("--");
		}
		double sum = 0;
		double max = 0;
		for(int i =0 ; i < m;i++){
			sum += dp[i][k-1];
			max = Math.max(dp[i][k-1],max );
		}
		System.out.println(max/sum);
	}

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

Measured memory_bytes: 15000
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 999999999
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define Vecpr vector<pair<lli,lli>>
int main() {
  lli N,A;
  cin >> N>>A;
  if(N>A)Out(N-1);
  else Out(N);
}


Measured memory_bytes: 256
N, M = map(int, input().split())
ab_s = [list(map(int, input().split())) for _ in range(M)]
bridges = [0] * N
ab_s = sorted(ab_s, key=lambda x: x[1])
for ab in ab_s:
    if bridges[ab[1]-1] - bridges[ab[0]-1] == 0:
        for i in range(ab[1]-1, N):
            bridges[i] += 1
print(bridges[-1])


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

using namespace std;
typedef long long ll;

int main(){
	ll n;
	cin>>n;
	ll a,b;
	cin>>a>>b;
	ll ans = n % (a+b);
	if(ans ==0) cout<<(n/(a+b) )* a<<endl;
	else if(ans > 0&& ans<a){
		cout<<(n/(a+b))*a + (n-n/(a+b)*(a+b))<<endl;
	}
	else if(ans >= a){
		cout<<(n/(a+b))*a + a<<endl;
	}
	return 0;
} 

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

using namespace std;

typedef long long ll;

ll mod_pow(ll x,ll n,ll mod){
  if(n == 0) return 1;
  ll res = mod_pow(x * x % mod,n / 2,mod);
  if(n & 1) res = res * x % mod;
  return res;
}

ll mod_mul(ll a,ll b,ll mod){
  if(b == 0){ return 0LL; }
  ll res = mod_mul((a+a)%mod,b/2,mod);
  if(b & 1){ res = (res + a) % mod; }
  return res;
}

bool miller_rabin(ll N){
  if(N == 2){ return true; }
  if(N % 2 == 0 || N <= 1){
    return false;
  }
  int a[] = {2,3,5,7,11,13,17,-1};
  ll s = 0,d = N-1;
  while(d % 2 == 0){
    s++;
    d >>= 1;
  }
  for(int i = 0 ; a[i] != -1 && a[i] < N ; i++){
    int x = mod_pow(a[i],d,N);
    if(x != 1){
      int j;
      for(j = 0 ; j < s ; j++){
        if(x == N-1){ break; }
        x = mod_mul(x,x,N);
      }
      if(j == s){ return false;}
    }
  }
  return true;
}

int main(){
  int T,N,ans = 0;
  cin >> T;
  while(T--){
    cin >> N;
    ans += miller_rabin(N);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, ans = 0;
    cin >> N;
    REP(i, 4) {
        if (N % 10 == 2) ans++;
        N /= 10;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()
#define var(t, ...) t __VA_ARGS__;in,__VA_ARGS__;

void Calc();
int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
template<class A>int comp(A a, A b) { return a < b ? 1 : b < a ? -1 : 0; }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/


void Calc() {

  int n = in;
  auto a = in.Array(n);

  int x = -1;
  int cnt = 0;
  int now = a[0];
  for (auto& i : a) {
    err(now, i);
    if (now == i)continue;
    if (now < i) {
      now = i;
      if (x == -1) {
        x = 1;
      }
      else if (x == 1) {
        continue;
      }
      else {
        x = -1;
        cnt++;
      }
    }
    else {
      now = i;
      if (x == -1) {
        x = 0;
      }
      else if (x == 0) {
        continue;
      }
      else {
        x = -1;
        cnt++;
      }
    }
  }
  cout << (1 + cnt) << endl;
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
from collections import defaultdict
n = int(input())
a_cnt = defaultdict(int)
a_list = [0 for _ in range(n)]
for i in range(n):
    num = int(input())
    a_cnt[num] += 1
    a_list[i] = num

a_sort = sorted(a_cnt.keys(), reverse=True)

largest_num = a_sort[0]
if len(a_sort) == 1:
    second_num = largest_num
else:
    second_num = a_sort[1]

if a_cnt[largest_num] == 1:
    for num in a_list:
        if largest_num == num:
            print(second_num)
        else:
            print(largest_num)
else:
    for _ in a_list:
        print(largest_num)

Measured memory_bytes: 67020
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n;
  vector<string> s(n);
  set<string> s_set;
  REP(i, n) {
    cin >> s[i];
    s_set.insert(s[i]);
  }
  sort(ALL(s));
  cin >> m;
  vector<string> t(m);
  REP(i, m) cin >> t[i];
  sort(ALL(t));

  int ans = 0;
  for(auto s_i : s_set) {
    auto low_1 = lower_bound(ALL(s), s_i);
    auto up_1 = upper_bound(ALL(s), s_i);
    auto low_2 = lower_bound(ALL(t), s_i);
    auto up_2 = upper_bound(ALL(t), s_i);
    ans = max(ans, (int)(up_1 - low_1) - (int)(up_2 - low_2));
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i = x; i < (int)(n); i++)
#define rep_ll(i,x,n) for(ll i = x; i < (ll)(n); i++)
using namespace std;
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;
const long double PI = (acos(-1));
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, -1, 0, 1};
ll mod = 1000000007;
int main(){
    int a;
    cin >> a;
    cout << a+a*a+a*a*a;
}

Measured memory_bytes: 3624
N = int(input())
A = list(map(int, input().split(' ')))

if A.count(0):
    print(0)
else:
    ans = 1
    for i in range(N):
        ans *= A[i]
        if ans > 10 ** 18:
            break

    if ans > 10 ** 18:
        print(-1)
    else:
        print(ans)

Measured memory_bytes: 83640
/*
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_10_A&lang=jp
*/
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(s,e) for(int i=s;i<e;i++)
ll A[44];
ll Fibo(int n){
  if(n==0 || n==1) return 1;
  if(A[n]!=0) return A[n];
  A[n-1]=Fibo(n-1);
  return A[n-1]+A[n-2];
}
int main(){
  int n;
  cin>>n;
  A[0]=A[1]=1;
  cout<<Fibo(n)<<"\n";
}



Measured memory_bytes: 3080
while True:
    n,k = map(int,input().split())
    if n == 0 and k == 0:break
    a = [int(input())for _ in range(n)]
    s = sum(a[0:k])
    ss = [s]
    for i in range(k,n):
        s = s+a[i]-a[i-k]
        ss.append(s)
    print(max(ss))


Measured memory_bytes: 11708
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using stkll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

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

    ll a, b, c, k;
    cin >> a >> b >> c >> k;

    ll ans = 0;
    if(k <= a) ans = k;
    else if (k <= a + b) ans = a;
    else ans = a - (k - a - b);
    cout << ans << endl;
}



Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <functional>
#include <sstream>
#include <complex>
#include <climits>
using namespace std;

#define REP(i,a,n) for(int i=(a);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define EPS 1e-8

int main(){
	int t,data[10],A,B;
	scanf("%d",&t);
	while(t--){
		rep(i,10)scanf("%d",data+i);
		A = B = 0;
		int j;
		bool f = true;
		for(j=0; j<10; j++){
			if( A<data[j] && B<data[j] ){
				if( A<B ){
					B = data[j];
				}else{
					A = data[j];
				}
			}else if( A<data[j] ){
				A = data[j];
			}else if( B<data[j] ){
				B = data[j];
			}else{
				f = false; break;
			}
		}
		puts(f ? "YES" : "NO" );
	}
	return 0;
}

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


typedef long long ll;
struct NT{
  vector<bool>isprime;

  ll mod_mult(ll a, ll b, ll m) {
    ll res = 0;
    ll exp = a % m;
    while (b) {
      if (b & 1) {
        res += exp;
        if (res > m) res -= m;
      }
      exp <<= 1;
      if (exp > m) exp -= m;
      b >>= 1;
    }
    return res;
  }

  ll mod_exp(ll a, ll b, ll m) {
    ll res = 1;
    ll exp = a % m;
    while (b) {
      if (b & 1) res = mod_mult(res, exp, m);
      exp = mod_mult(exp, exp, m);
      b >>= 1;
    }
    return res;
  }

  bool miller_rabin(ll n, ll times) {
    if (n < 2) return false;
    if (n == 2) return true;
    if (!(n & 1)) return false;
    ll q = n-1;
    int k = 0;
    while (q % 2 == 0) {
      k++;
      q >>= 1;
    }
    for (int i = 0; i < times; i++) {
      ll a = rand() % (n-1) + 1;
      ll x = mod_exp(a, q, n);
      if (x == 1) continue;
      bool found = false;
      for (int j = 0; j < k; j++) {
        if (x == n-1) {
          found = true;
          break;
        }
        x = mod_mult(x, x, n);
      }
      if (found) continue;
      return false;
    }
    return true;
  }

  ll pollard_rho(ll n, int c) {
    ll x = 2;
    ll y = 2;
    ll d = 1;
    while (d == 1) {
      x = mod_mult(x, x, n) + c;
      y = mod_mult(y, y, n) + c;
      y = mod_mult(y, y, n) + c;
      d = __gcd((x-y >= 0 ? x-y : y-x), n);
    }
    if (d == n) return pollard_rho(n, c+1);
    return d;
  }
};

int sum;

int main(){
  NT N;
  ll n;
  cin>>n;
  while(n--){
    ll a;
    scanf("%ld",&a);
    if(N.miller_rabin(a,10))sum++;
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 3220
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	float r;
	cin >> r;
	float p;
	p = r *2* 3.14159265;
	cout << p << endl;
	return 0;
}


Measured memory_bytes: 3764
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


n,k = LI()

ans = 0
for i in range(1,n+1):
    tmp = i
    x = 1/n
    while tmp < k:
        tmp *= 2
        x *= 0.5
    ans += x
print(ans)

Measured memory_bytes: 39152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<n; i++)
#define pb push_back
#define int long long
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int H, N;
int A[1010], B[1010];
int dp[10010];

signed main() {
    //cin.tie(0); ios::sync_with_stdio(false);
    cin >> H >> N;
    rep(i, N) cin >> A[i] >> B[i];
    rep(i, H+1) dp[i] = 1000000000000;
    dp[0] = 0;
    rep(i, H+1) rep(j, N) {
        int k = min(H, i+A[j]);
        dp[k] = min(dp[k], dp[i]+B[j]);
    }
    cout << dp[H] << endl;
}

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

int main(){
	int N;
  cin >> N;
  N %= 10;
	if(N == 2 || N == 4 || N ==5 || N ==7 || N == 9){
      cout << "hon" << endl;
    }else if(N == 0 || N == 1 || N == 6 || N == 8){
      cout << "pon" << endl;
    }else{
      cout << "bon" << endl;
    }
return 0;
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest._600problems
{
    class ARC098_E
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            int[] nkq = ReadInts();
            int n = nkq[0];
            int k = nkq[1];
            int q = nkq[2];
            int[] array = new int[n + 1];
            int[] readArray = ReadInts();
            for (int i = 0; i < n; i++) array[i] = readArray[i];
            array[n] = 0;

            int res = int.MaxValue;
            for (int i = 0; i < n; i++)
            {
                var tempList = new List<int>();
                var valList = new List<int>();
                for (int j = 0; j <= n; j++)
                {
                    if (array[j] < array[i])
                    {
                        tempList.Sort();
                        for (int l = 0; l < tempList.Count - k + 1; l++)
                        {
                            valList.Add(tempList[l]);
                        }

                        tempList = new List<int>();
                    }
                    else
                    {
                        tempList.Add(array[j]);
                    }
                }

                valList.Sort();
                if (valList.Count >= q)
                {
                    res = Min(res, valList[q - 1] - valList[0]);
                }
            }

            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 43832
/*
author : bisma
@ copy from bisma template 1.0

*/
#include<bits/stdc++.h>
#include<algorithm>
#include <assert.h>
using namespace std;
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define ll long long
#define sum(a,b) a=a+b
#define repn(a,b,c) for(int a = b ; a>=c ; a--)
#define mem(a,b) memset(a,b,sizeof(a))
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pii pair <int, int>
#define pll pair <long long, long long >
#define plp pair <int, pll >
#define pb push_backs

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

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

void faster(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}

ll pfx[(int)1e5 + 10];

int main(){
	faster();

	string s;
	ll q;
	ll n;
	cin>>n>>q>>s;

	ll loop = s.size()-1;


	mem(pfx, 0);

	rep(i,1,loop){
		if(s[i] == 'C' && s[i-1] == 'A'){
			pfx[i] = pfx[i-1] + 1;
		}else{
			pfx[i] = pfx[i-1];
		}

	//	cout<<i<<" "<<pfx[i]<<endl;
	}

	rep(i,1,q){
		ll l , r;
		cin>>l>>r;

		l--;
		r--;
		
		cout<<pfx[r]-pfx[l]<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1872
import sys

if __name__ == "__main__":
    para_list1 = list(map(int, input().split()))
    H = para_list1[0]
    W = para_list1[1]

    para_list2 = list(map(int, input().split()))
    h = para_list2[0]
    w = para_list2[1]

    print(H*W-h*W-w*H+h*w)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
  char str[20];
  int i=0,j=0;
  for(i=0;i<20;i++){
    str[i]=getchar();
    if(str[i]=='\n') break;
  }

  for(j=1;j<=i;j++){
    printf("%c",str[i-j]);
  }
  printf("\n");
  return 0;
}

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

int main(){
  long long A[101][101], B[101][101], C[101][101];
  int n, m, l;

  cin >> n >> m >> l;

  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> A[i][j];
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= l; j++) cin >> B[i][j];


  for (int i = 1; i <= n; i++){
    for (int j = 1; j <= l; j++){
        C[i][j] = 0;
      for (int k = 1; k <= m; k++){
        C[i][j] += A[i][k]*B[k][j];
      }
    }
  }
  
  for (int i = 1; i <= n; i++){
    for (int j = 1; j <= l; j++){
      if(j != 1) cout << " ";
      cout << C[i][j];
    }
    cout << endl;
  }

return 0;
}

Measured memory_bytes: 3344
N,A,B = map(int,input().split())
sum_li = []
for i in range(N+1):
    s = str(i)
    array = list(map(int, s))
    temp = sum(array)
    if (temp>=A)&(temp<=B):
        sum_li.append(i)
ans = sum(sum_li)
print(ans)

Measured memory_bytes: 3424
#include<bits/stdc++.h>
#define pf printf
#define sc(x) scanf("%d", &x)
#define scs(x) scanf("%s", x)
#define scl(x) scanf("%lld", &x)
#define mst(a,x) memset(a, x, sizeof(a))
#define rep(i,s,e) for(int i=s; i<e; ++i)
#define dep(i,e,s) for(int i=e; i>=s; --i)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 3e5 + 5;
const int mod = 1e9 + 7;
int solve(){
    string s; cin>>s;
    rep(i,0,3) if(s[i]=='7') return pf("Yes\n");
    return pf("No\n");
}
int main(){
    /* int _; sc(_); while(_--) */ solve();
}

Measured memory_bytes: 3720
#include<iostream>
#include<cstdlib>
#include<utility>
#include<tuple>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<queue>
#include<deque>
#include<bitset>
#include<cmath>
#include<map>
using namespace std;
using ll = long long int;
const ll mod = 1e9 + 7;

int main() {

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

	int i;
	for (i = 0; i < s.size(); i++) {
		s[i] += n;
		if (s[i] > 90) s[i] -= 26;
	}

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n;
  vector<int> l;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int tmpl;
    cin >> tmpl;
    l.push_back(tmpl);
  }
  int counter = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      for (int k = j + 1; k < n; k++) {
        if (l[i] == l[j] || l[j] == l[k] || l[k] == l[i]) {
          // skip
        } else {
          if (l[i] + l[j] > l[k] && l[j] + l[k] > l[i] && l[k] + l[i] > l[j]) {
            counter++;
          }
        }
      }
    }
  }
  cout << counter << endl;
  return 0;
}

Measured memory_bytes: 3620
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed 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")
}

const MODS: [i64; 3] = [1000000007i64, 1000000009i64, 37582157i64];
const BASES: [i64; 3] = [37582157i64, 1000000007i64, 997i64];
fn ok(cnt: usize, s: &Vec<char>, t: &Vec<char>) -> bool {
    'outer_loop: for _iter in 0..3 {
        let m = MODS[_iter];
        let b = BASES[_iter];
        let mut target_hash = 0;
        let mut high = 1;
        for _ in 0..cnt {
            for i in 0..t.len() {
                target_hash = (target_hash * b + t[i] as u8 as i64) % m;
                high = (high * b) % m;
            }
        }
        let len = cnt * t.len();
        let target_hash = target_hash;
        let mut used = 0;
        let mut hash = 0;
        loop {
            for i in 0..s.len() {
                hash = (hash * b + s[i] as u8 as i64) % m;
                used += 1;
                if used > len {
                    let pos = (i + s.len() * len - len) % s.len();
                    hash = (hash - s[pos] as u8 as i64 * high + m * m) % m;
                }
                if used >= len && hash == target_hash {
                    continue 'outer_loop;
                }
            }
            if used >= len * 2 && used >= s.len() * 3 {
                break;
            }
        }
        return false;
    }
    return true;
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<char>>();
    let t = read::<String>().chars().collect::<Vec<char>>();
    let mut l = 0;
    let mut r = s.len() * 3 / t.len() + 3;
    if ok(r, &s, &t) {
        println!("-1");
        return;
    }
    while r - l > 1 {
        let mid = (l + r) / 2;
        if ok(mid, &s, &t) {
            l = mid;
        } else {
            r = mid;
        }
    }
    println!("{}", l);
}


Measured memory_bytes: 11956
#include <iostream>
#include <map>

using namespace std;

int main() {
	string str;
	map<string, int> m;
	string pop_s, len_s;
	int pop=0, len=0;
	while (cin >> str) {
		m[str]++;
		if (m[str]>pop) {
			pop = m[str];
			pop_s = str;
		}
		if (str.length()>len) {
			len = str.length();
			len_s = str;
		}
	}
	cout << pop_s << " " << len_s << endl;
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int main() {
    string s;
    cin >> s;

    if (s.size() == 2) {
        cout << 0 << endl;
        return 0;
    }

    for (int i = s.size() - 1; i >= 0; --i) {
        string ss = s.substr(0, i);
        if (ss.size() % 2 == 1) continue;
        int m = ss.size() / 2;
        for (int j = 0; j < m; j++) {
            if (ss[j] != ss[m + j]) break;
            if (j == m - 1) {
                cout << ss.size() << endl;
                return 0;
            }
        }
        if(i == 0) cout << 0 << endl;

    }

    return 0;
}

Measured memory_bytes: 256
import itertools
ABCD=list(input())
calc=["+","-"]*3
conb=set(itertools.permutations(calc, 3))

for c in conb:
    total=int(ABCD[0])
    for n,i in enumerate(c):
        if(i=='+'):
            total+= int(ABCD[n+1])
        else:
            total-=int(ABCD[n+1])
    if(total==7):
        print("{0}{1}{2}{3}{4}{5}{6}=7".format(ABCD[0],c[0],ABCD[1],c[1],ABCD[2],c[2],ABCD[3]))
        break


Measured memory_bytes: 3064
fun main(args: Array<String>) {
    val input = readLine()!!.split(" ").map { it.toInt() }
    val goal = input[1]
    var current = 1
    var count = 0

    while (goal > current) {
        current += input[0] - 1
        count += 1
    }

    print(count)
}

Measured memory_bytes: 37616
# D - Good Grid

from collections import defaultdict
import itertools

N, C = map(int, input().split())
D = [[0] * C for _ in range(C)]
for i in range(C):
    D[i] = list(int(d) for d in input().split())

# MOD3の世界で0,1,2ごとに、最初の値の数をカウントしておく
dict_c = [defaultdict(int) for _ in range(3)]
for i in range(N):
    c = list(int(x) for x in input().split())
    for j in range(N):
        dict_c[(i+j)%3][c[j]-1] += 1

# ここからは全探索。
# 0, 1, 2の各配列に対して、全ての色を試す(C**3)
list_C = list(range(C))
ans = 10**18
for (p, q, r) in itertools.permutations(list_C, 3):
    tmp = 0
    for i, j in enumerate((p, q, r)):
        for m, n in dict_c[i].items():
            tmp += D[m][j] * n
    ans = min(ans, tmp)

print(ans)

Measured memory_bytes: 9612
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] =  new int[n];
		int sum =0;
		for (int i=0;i<n;i++) {
			a[i] = sc.nextInt();
		}
		for (int i=0;i<a.length;i++) {
			for (int j=i+1;j<a.length;j++) {
				sum +=a[i]*a[j];
			}
		}
		System.out.println(sum);
	}
}

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

constexpr int MAXN = 1e3 + 3;
constexpr double down = 0.996;

int n, cnt[10004][3], vis[3], res; //r g b
string s;

map<char, int>h;

signed main() {
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> s;
	h['R'] = 0, h['G'] = 1, h['B'] = 2;
	s = " " + s;
	for (int i = n; i >= 1; i--) {
		char c = s[i];
		int num = h[c];
		for (int j = 0; j < 3; j++) {
			if (j != num) cnt[i][j] = cnt[i + 1][j];
			else cnt[i][j] = cnt[i + 1][j] + 1;
			//cout << cnt[i][j] << " ";
		}
		//cout << endl;
	}
	for (int i = 1; i <= n - 2; i++) {
		for (int j = i + 1; j <= n - 1; j++) {
			memset(vis, 0, sizeof(vis));
			if (s[i] == s[j]) continue;
			vis[h[s[i]]] = vis[h[s[j]]] = true;
			int lst;
			for (int t = 0; t < 3; t++)
				if (!vis[t]) lst = t;
			res += cnt[j + 1][lst];
			int delta = j - i;
			if (delta + j > n) continue;
			if (h[s[delta + j]] == lst) res--;
		}
	}
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 3760
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	int d = a / b;
	int r = a % b;
	cout << d << " " << r << " ";
	cout << fixed;
	cout << setprecision(20) << (double)a / (double)b << endl;
}


Measured memory_bytes: 3260
#include<stdio.h>

int main(){
  long h;
  long w;
  long x;
  long y;
  double s = 0;
  int flag = 0;
  scanf("%ld %ld %ld %ld",&w,&h,&x,&y);
  s = (double)h*w/2;
  if(w%2==0&&h%2==0&&x==w/2&&y==h/2){
    flag = 1;
  }
  printf("%.12lf %d",s,flag);
  return 0;
}
         
  
    

Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()


int main() {
  int n, k;
  cin >> n >> k;
  vector<bool> flag(n, false);
  rep(i, k) {
    int d;
    cin >> d;
    rep(j, d) {
      int a;
      cin >> a;
      a--;
      flag[a] = true;
    }
  }
  int cnt = 0;
  rep(i, n) {
    if (!flag[i]) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3632
uses
  SysUtils,
  Classes;
  
 procedure MainProc;
	var
		text : string;
		strlist : TStringList;
		cracker : Integer;
		person : Integer;
	begin
	ReadLn(text);
	strlist := TStringList.Create;
	try
		strlist.Delimiter := ' ';
		strlist.DelimitedText := text;
		cracker := StrToInt(strlist.Strings[0]);
		person := StrToInt(strlist.Strings[1]);
		finally
			FreeAndNil(strlist);
			end;
	if (cracker mod person) = 0 then
		WriteLn(0)
	else
		WriteLn(1);
	end;
  
begin
MainProc;
end.


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(v)    begin(v), end(v)
#define in        []{lint n; cin>>n; return n;}()

int main() { cin.tie(0); ios::sync_with_stdio(false);
    int N = in, W = in, MX = N*1000;

    vector<lint> dp( MX+1, INT64_MAX/2 );
    dp[0] = 0;
    rep( i, N ) {
        int w = in, v = in;
        for( int j=MX; j>=v; j-- ) {
            dp[j] = min( dp[j], dp[j-v]+w );
        }
    }

    int ans = 0;
    rep( i, MX+1 ) if( dp[i] <= W ) ans = i;
    cout << ans << "\n";
}


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

const int N = 100005;

int n, a[N], r;

int main(){
    scanf("%d", &n);
    for(int i = 0; i < n; i++) scanf("%d", a + i);
    sort(a, a + n);
    for(int i = 0; i < n - 1; i++){
        if(abs(a[n - 1] - 2 * a[i]) < abs(a[n - 1] - 2 * r)) r = a[i];
    }
    printf("%d %d\n", a[n - 1], r);
}

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

using namespace std;

void solve() {
  
  int time[5];
  int sum=0;
  int dis[5];
  for(int i=0;i<5;i++) {
    cin >> time[i];
    sum += time[i];
    dis[i] = (10 - time[i] % 10) % 10;
    sum += dis[i];
  }
  
  sum -= *max_element(dis, dis+5);
  
  cout << sum << endl;
  
  return;
  
}

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

Measured memory_bytes: 256
<?php
$list = explode(' ', trim(fgets(STDIN)));
$k = $list[0];
$a = $list[1];
$b = $list[2];
if ($k >= $a) {
    $remain = $k- $a + 1;
    $dev = $remain %2 == 0 ? $remain / 2 : ($remain - 1) / 2;
    if ($b > $a && ($b - $a) * $dev + ($remain % 2) > $remain) {
        echo ($b - $a) * $dev + ($remain % 2) + $a;
    } else {
        echo $k + 1;
    }
} else {
    echo $k + 1;
}



Measured memory_bytes: 4604
#! /usr/bin/env ruby

st = STDIN.read.chomp

min_abs = nil
i = 0
while i < st.length - 2
  a = ((st[i] + st[i + 1] + st[i + 2]).to_i - 753).abs
  if min_abs == nil || a < min_abs 
    min_abs = a
  end
  i = i + 1
end

puts min_abs


Measured memory_bytes: 1788