akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(vs) vs.begin(), vs.end()
using ii = pair<int, int>;
using ll = long long;

int32_t main(){
	ios::sync_with_stdio(0);
	ll x;
	cin >> x;
	ll ans = (x/500)*1000;
	ans += ((x%500)/5)*5;
	cout << ans << endl;
}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

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

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

    char c;
    cin>>c;
    cout<<char(c+1)<<endl;
}

Measured memory_bytes: 256
def is_prime(n): 
  i = 2
  while i * i <=n:
    if n % i == 0:
      return False
    i += 1
  return True

n = int(input())
data = []
[data.append(int(input())) for i in range(n)]

check = [is_prime(d) for d in data]
print(sum(check))

Measured memory_bytes: 8048
#include<iostream>
#include<stdio.h>
#include<math.h>

using namespace std;

int main(void){

    double r, p;

    cin >> r;

    p = acos(-1);
    
    printf("%.7lf %.7lf",pow(r,2) * p,2 * p * r);

return 0;

}

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

using namespace std;

const string a = "apple";
const string p = "peach";

int main()
{
    string inp;

    while (getline(cin, inp)) {
        string::size_type pos_a, pos_p;

        pos_a = inp.find(a);
        pos_p = inp.find(p);

        for ( ; pos_a != string::npos || pos_p != string::npos; ) {
            if (pos_a < pos_p) {
                inp.replace(pos_a, a.length(), p);
                pos_a = inp.find(a, a.length() + pos_a);
            }
            else {
                inp.replace(pos_p, p.length(), a);
                pos_p = inp.find(p, p.length() + pos_p);
            }
        }
        cout << inp << endl;        
    }

    return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ll long long
using namespace std;


int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep (i, n) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
 int alice = 0;
 int bob = 0;
 rep (i, n) {
   if (i % 2 == 0) {
     alice += a.at(i);
   }
   if (i % 2 == 1) {
     bob += a.at(i);
   }
 }
 cout << alice - bob << endl;
}



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

int K, X;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> K >> X;
  int min = X - K + 1;
  int max = X + K - 1;
  
  if (min <= -1000000) {
    for (int i = -1000000; i <= max; i++) {
      cout << i << ' ';
    }
  } 
  else if (max >= 1000000) {
    for (int i = min; i <= 1000000; i++) {
      cout << i << ' ';
    }
  } 
  else {
    for (int i = min; i <= max; i++) {
      cout << i << ' ';
    }
  }
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
const ll inf = 1e9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const ll MAX = 1e7 + 20;
#define fast ios_base:: sync_with_stdio( false ); cin.tie(0); cout.tie(0);
#define eb              emplace_back
#define em              emplace
#define pb              push_back
#define Mp              make_pair
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep1(i,n)       for(int i=1;i<=n;i++)
#define rrep(i,a,n)     for(int i=a;i<=n;i++)
#define per(i,n,a)      for(int i=n;i>=a;i--)
#define pf(n)           printf("%lld",n)
#define pfi(n)          printf("%d",n)
#define sp              printf(" ")
#define ln              "\n"

template< class T > T gcd(T a, T b)
{
    return (b != 0 ? gcd<T>(b, a%b) : a);
}
template< class T > T lcm(T a, T b)
{
    return (a / gcd<T>(a, b) * b);
}
char y[1000],z[1000];
int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast

    ll a,b,c,d;
    string x;
    cin>>a;
    cin>>x;
    if(a%2!=0)
    {
        cout<<"No"<<endl;
        return 0;
    }
    else
    {
        int l=0;
        for(int i=0; i<a/2; i++)
        {
            y[l]=x[i];
            l++;
        }
        l=0;
        for(int i=a/2; i<a; i++)
        {
            z[l]=x[i];
            l++;
        }
        //cout<<y<<" "<<z<<endl;
        if(strcmp(y,z)==0)
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }
    }
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
        int n;
        scanf("%d", &n);
        for(int i=1; i<=n; i++){
                if(i%3==0) printf(" %d", i);
                else{
                        int x = i;
                        while(x){
                                if(x%10==3){
                                        printf(" %d", i);
                                        break;
                                }
                                x /= 10;
                        }
                }
        }
        puts("");
        return 0;
}


Measured memory_bytes: 2120
import java.io.*;
import java.util.*;

public class Main {
    Scanner sc;
    Main() {
        sc = new Scanner(System.in);
    }
    int m, n;
    String[] remark;
    boolean[] users;
    int cur_user;
    int user_count;
    boolean init() {
        m = sc.nextInt();
        n = sc.nextInt();
        if (m == 0 && n == 0) return false;
        remark = new String[n];
        for (int i = 0; i < n; i++) {
            remark[i] = sc.next();
        }
        cur_user = 0;
        user_count = m;
        users = new boolean[m];
        for (int i = 0; i < m; i++) users[i] = true;
        return true;
    }
    void pass() {
        for (int i = cur_user+1; ; i++) {
            if (i == m) i -= m;
            if (users[i]) {
                cur_user = i;
                break;
            }
        }
    }
    void drop() {
        users[cur_user] = false;
        user_count--;
        pass();
    }
    String fizzbuzz(int n) {
        if (n % 15 == 0) return "FizzBuzz";
        if (n % 5  == 0) return "Buzz";
        if (n % 3  == 0) return "Fizz";
        return String.valueOf(n);
    }
    boolean correct(int i, String s) {
        return s.equals(fizzbuzz(i));
    }
    void print_exist() {
        boolean start = true;
        for (int i = 0; i < m; i++) {
            if (users[i]) {
                if (!start) 
                    System.out.print(" ");
                System.out.print(i+1);
                if (start) start = false;
            }
        }
        System.out.println("");
    }
    void run() {
        while (init()) {
            for (int i = 1; i <= n; i++) {
                if (correct(i, remark[i-1]))
                    pass(); 
                else 
                    drop();
                if (user_count == 1) break;
            }
            print_exist();
       }
    }
    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 16000
object Main extends App {
  val abk = scala.io.StdIn.readLine()
  val abkArray = abk.split(" ").map(_.toLong).toVector
  val a = abkArray(0)
  val b = abkArray(1)
  val k = abkArray(2)
  if (a >= k) {
    println((a - k) + " " + b)
  } else if (a + b >= k) {
    println("0 " + (a + b - k))
  } else {
    println("0 0")
  }
}

Measured memory_bytes: 27324
#include<iostream>

int main()
{
    int W, H, x, y, r;
    int _W, _H; 

    //仮想的な長方形を考えて、中心がその内部にあるか判定

    std::cin>>W>>H>>x>>y>>r;

    _W = W - r;
    _H = H - r;
    if((r<=x & x<=_W) & (r<=y & y<=_H))
    {
        std::cout<<"Yes"<<std::endl;
    }
    else
    {
        std::cout<<"No"<<std::endl;
    }
    
    return 0;
}


Measured memory_bytes: 3116
#include <stdio.h>

main(void){
int n,l;
int Lingo[200];
int smart=0;
int sum=0;
int temp=0;
int sa1=0;
int sa2=0;
scanf("%d %d",&n,&l);

for(int i=1;i<=n;i++){
	Lingo[i]=l+i-1;
	sum+=Lingo[i];
}

for(int j=1;j<=n;j++){
	temp=sum;
	temp-=l+j-1;
	sa1=sum-temp;
	sa2=sum-smart;
	if(sa1<0){
		sa1=(-1)*sa1;
	}
	if(sa2<0){
		sa2=(-1)*sa2;
	}
	if(sa1<sa2){
		smart=temp;
	}	
}

printf("%d",smart);

}

Measured memory_bytes: 128
import math
a,b,h,m = map(int,input().split())

ka = 2*math.pi*(h/12+(m/60)/12)
kb = 2*math.pi*(m/60)

k = ka - kb
if k >= math.pi:
    k = 2*math.pi - k

print(math.sqrt(b**2+a**2-2*a*b*math.cos(k)))

Measured memory_bytes: 9568
from collections import *
a,b,n = map(int,input().split())
ans = a*n//b - a*(n//b)
mb = (n//b)*b-1
if(mb > 0):
	ans = max(ans,a*mb//b - a*(mb//b))
mbb = min(n,b-1)
ans = max(ans,a*mbb//b - a*(mbb//b))
print(ans)


Measured memory_bytes: 64900
#include<stdio.h>
int main(void){

   int n,m,a,aa=0,i;
   
   scanf("%d%d",&n,&m);
   for(i=0; i<m; i++){
      scanf("%d",&a);
      aa+=a;
   }
   
   if(n<aa) printf("-1");
   else     printf("%d",n-aa);
   
   return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <stdio.h>

using namespace std;

int n;
int a[305];
double memo[305][305][305];

double calc(int i, int j, int k)
{
	if(memo[i][j][k] > -0.5) return memo[i][j][k];
	if(i+j+k == 0) return 0;
	
	double tmp = n;
	if(i > 0) tmp += i*calc(i-1, j, k);
	if(j > 0) tmp += j*calc(i+1, j-1, k);
	if(k > 0) tmp += k*calc(i, j+1, k-1);
	return memo[i][j][k] = tmp / (i+j+k);
}

int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	int cnt[4] = {0, 0, 0, 0};
	for(int i = 1; i <= n; i++) cnt[a[i]]++;
	
	for(int i = 0; i <= n;i++){
		for(int j = 0; j <= n; j++){
			for(int k= 0; k <= n; k++){
				memo[i][j][k] = -1;
			}
		}
	}
	
	printf("%.11f\n", calc(cnt[1], cnt[2], cnt[3]));
	return 0;
}

Measured memory_bytes: 219520
A, B, C, X, Y = map(int, input().split())

min_price = A * X + B * Y

if A + B > 2 * C:
    while X > 0 and Y > 0:
        X = X - 1
        Y = Y - 1
        min_price -= A + B - 2 * C

if X > 0 and A > 2 * C:
    while X > 0:
        X = X - 1
        min_price -= A - 2 * C

if Y > 0 and B > 2 * C:
    while Y > 0:
        Y = Y - 1
        min_price -= B - 2 * C

print(min_price)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
 
struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;
 
template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}
 
template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==(int)v.size()?"":" ");
    return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is,pair<T1,T2>&p){
    is>>p.first>>p.second;
    return is;
}

template<typename T>
istream &operator>>(istream &is,vector<T>&v){
    for(T &x:v)is>>x;
    return is;
}


signed main(){
    int n;cin>>n;
    vector<ll> v(n);
    cin>>v;
    // set<tuple<ll,ll,ll>> st;
    int ans=0;
    rep(i,n){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                vector<ll>w;
                w.push_back(v[i]);
                w.push_back(v[j]);
                w.push_back(v[k]);
                sort(ALL(w));
                if(w[0]+w[1]>w[2] and w[0]!=w[1] and w[1]!=w[2] and w[2]!=w[0]){
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3620
n=int(input())
dic={0:'a',1:'b',2:'c',3:'d',4:'e',5:'f',6:'g',7:'h',8:'i',9:'j'}
ans=[['a',1]]
for i in range(1,n):
  tmp=[]
  for prev,val in ans:
    for j in range(val+1):
      if j!=val:
        tmp.append([prev+dic[j],val])
      else:
        tmp.append([prev+dic[j],val+1])
  ans=tmp
ans=sorted(ans,key=lambda x:x[0])
for i in range(len(ans)):
  print(ans[i][0])

Measured memory_bytes: 25716
import java.util.Scanner;

public class Main {
    public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);
        while(true){
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a==0&&b==0) break;
        for(int i=0;i<a;i++){
            for(int j=0;j<b;j++){
                System.out.print("#");
            }
            System.out.println("");
        }
        System.out.println("");
    }
        sc.close();
    }
}


Measured memory_bytes: 34704
import math

N, M = map(int,input().split())
a = 10**9 + 7


if abs(N - M) >= 2:
    print(0)
    exit()
elif abs(N-M) == 1:
    ans = math.factorial(N)*math.factorial(M) % a
else:
    ans = 2*math.factorial(N)*math.factorial(M) % a

print(ans)


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

#define rep(i, N) for (int i = 0; i < N; i++)
const int intinf = numeric_limits<int>::max();

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

void solve()
{
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    vector<int> ans(N);
    rep(i, N) ans[A[i] - 1] = i + 1;

    rep(i, N) cout << ans[i] << " ";
    cout << endl;
}

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

Measured memory_bytes: 1664
<?php
//$N = trim(fgets(STDIN));
list($N,$K) =  explode(" ",trim(fgets(STDIN)));
list($R,$S,$P) =  explode(" ",trim(fgets(STDIN)));
$T = trim(fgets(STDIN));
//$A =  explode(" ",trim(fgets(STDIN)));

$sum = 0;
$out = array();
for($i=0;$i<$N;$i++) {
  switch($T[$i]) {
    case "r":
      if (isset($out[$i-$K]) && $out[$i-$K]=="p") {
        if (isset($T[$i+$K])) {
          $out[]=getBetterSign($i,getWinSign($i+$K));
        }
        else {
          $out[]="r";
        }
      }
      else {
        //K回先で勝った方がお得な時は違うものを出した方がいい
        if (isset($t[$i+$K]) && getScore($i+$K)>$P) {
            $out[]=getLoseSign($i+$K);
        }
        else {
          $sum += $P;
          $out[]="p";
        }
      }
      break;
    case "s":
      if (isset($out[$i-$K]) && $out[$i-$K]=="r") {
        if (isset($T[$i+$K])) {
          $out[]=getBetterSign($i,getWinSign($i+$K));
        }
        else {
          $out[]="s";
        }
      }
      else {
        if (isset($t[$i+$K]) && getScore($i+$K)>getScore($i)) {
            $out[]=getLoseSign($i+$K);
        }
        else {
          $sum += getScore($i);
          $out[]=getWinSign($i);
        }
      }
      break;
    case "p":
      if (isset($out[$i-$K]) && $out[$i-$K]=="s") {
        if (isset($T[$i+$K])) {
          $out[]=getBetterSign($i,getWinSign($i+$K));
        }
        else {
          $out[]="p";
        }
      }
      else {
        if (isset($t[$i+$K]) && getScore($i+$K)>getScore($i)) {
            $out[]=getLoseSign($i+$K);
        }
        else {
          $sum += getScore($i);
          $out[]=getWinSign($i);
        }
      }
      break;
  }
}
//var_dump($out);
printf("%d\n",$sum);

//勝った時のスコア
function getScore($pos)
{
  global $T,$R,$S,$P;
  switch($T[$pos]) {
    case "r":
      return $P;
    case "s":
      return $R;
    case "p":
      return $S;
  }
}
function getLoseSign($pos)
{
  global $T;
  switch($T[$pos]) {
    case "r":
      return "s";
    case "s":
      return "p";
    case "p":
      return "r";
  }
}
function getWinSign($pos)
{
  global $T;
  switch($T[$pos]) {
    case "r":
      return "p";
    case "s":
      return "r";
    case "p":
      return "s";
  }
}
//勝てないときは次勝てるように出す
function getBetterSign($pos,$nextwinsign)
{
  global $T;
  switch($T[$pos]) {
    case "r":
      if ($nextwinsign=="r") return "s";
      return "r";
    case "s":
      if ($nextwinsign=="s") return "p";
      return "s";
    case "p":
      if ($nextwinsign=="p") return "r";
      return "p";
  }
}


Measured memory_bytes: 10872
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string a;
    cin>>a;
    if(a.at(0)==a.at(1)&&a.at(0)==a.at(2)){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
}

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


int main() {
    int N;
    cin >> N;
    int score = 0;
    for(int i = 1; i <= N; i++){
        score += i;
        if(score == N){
            for(int j = 1; j<= i; j++){
                cout << j << endl;
            }
            return 0;
        }else if(score > N){
            int ps = score - N;
            for(int j = 1; j <= i; j++){
                if(j != ps){
                    cout << j << endl;
                }
            }
            return 0;
        }
    }
}


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

using namespace std;
char str[100001];
int main()
{
    int n, k;
    int cnt=0;
    scanf("%d %d\n",&n,&k);
    for (int i=0;i<n;i++) {
        scanf("%c",&str[i]);
        if (i>=1&&str[i]==str[i-1]) cnt++;
    }
    printf("%d",min(cnt+2*k,n-1));
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int L; cin>>L;
  bitset<20> B(L);
  int memo;
  REP(i,1,20){
    if(B.test(20-i)){
      memo=20-i;
      break;
    }
  }
  cout<<memo+1<<" "<<2*memo+B.count()-1<<endl;
  rep(i,0,memo){
    cout<<i+1<<" "<<i+2<<" "<<0<<endl;
    cout<<i+1<<" "<<i+2<<" "<<(1ll<<i)<<endl;
  }
  int sum=(1ll<<memo);
  rep(i,0,memo){
    if(B.test(i)){
      cout<<i+1<<" "<<memo+1<<" "<<sum<<endl;
      sum+=(1ll<<i);
    }
  }
  }



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

using namespace std;

typedef long long ll;

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

	string s;
	cin >> s;

	int ans = 700;
	rep(i, 3) if(s[i] == 'o') ans += 100;

	cout << ans << endl;

}


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

long long int gcd(long long int a, long long int b) {
	if (b == 0)
		return a;
	return gcd(b, a%b);
}

int main() {
	long long int a, b;
	while (cin >> a >> b) {
		long long int g = gcd(max(a, b), min(a, b));
		long long int l = a * b / g;

		cout << g << " " << l << endl;
	}
	return 0;
}

Measured memory_bytes: 3000
S = gets.chomp + 'X'

result = Array.new(S.length - 1) { 0 }

e = 0
o = 0
last = nil
rt = nil
0.upto(S.size - 1) do |i|
  if last == 'L' && S[i] == 'R' || S[i] == 'X'
    if rt.even?
      result[rt] = e
      result[rt + 1] = o
    else
      result[rt] = o
      result[rt + 1] = e
    end

    rt = nil
    e = 0
    o = 0
  elsif last == 'R' && S[i] == 'L'
    rt = i - 1
  end

  last = S[i]

  if i.even?
    e += 1
  else
    o += 1
  end
end

puts result.join(' ')

Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  ll n,m;
  cin>>n>>m;
  ll x= (n)/4;
	x= x*4;
	if(m<n+12){
		ll z=n;
		rep(i,n+1,m+1){
			z^=i;
		}
		cout<<z<<endl;
	}
	else{
		ll ans=0;
		// cout<<n<<" "<<x<<endl;
		rep(i,n,x+4){
			ans^=i;
		}
		// cout<<ans<<endl;
		x= (m/4);
		x=x*4;
		rep(i,x,m+1) ans^=i;
		cout<<ans<<endl;
	}
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


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

int main(){
    string S,T;
    cin >>S>>T;
    int A,B;
    cin>>A>>B;
    string U;
    cin>>U;

    if(S==U){
        A--;
    }else if(T==U){
        B--;
    }
    cout<<A<<" "<<B<<endl;

}

Measured memory_bytes: 256
/**
 *      AGC 10 A
 *      author  : kyomukyomupurin
 *      created : 2018-10-08 21:06:24
**/

#include <algorithm>
#include <array>
#include <cassert>
#include <climits>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#define int64 long long
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    // 奇数が偶数個あればよい

    int N; cin >> N;
    int A[N] = {};
    for (auto i = 0; i < N; ++i) {
        cin >> A[i];
    }

    int countOdd = 0;

    for (auto i = 0; i < N; ++i) {
        if (A[i] % 2 == 1) ++countOdd;
    }

    countOdd %  2 == 0 ? cout << "YES" << endl : cout << "NO" << endl;
     
    return 0;
}

Measured memory_bytes: 640
import java.util.*;
public class Main {

    public static void main(String[] args) {
     
        Scanner entrada=new Scanner(System.in);
        int A=entrada.nextInt();
        int B=entrada.nextInt();
        int C=entrada.nextInt();
       int variable=0;
       int count=0;
       
     if(A<=B){
        while(variable+A<=B){
            
            variable+=A;  
            count++;
           
        }
    
       if(count>C){
           System.out.println(C);
           
       }else if(count==C){
           
           System.out.println(count);
       }
       else if(count<C){
         
           System.out.println(count);
       }
     }else if(A>B){
         System.out.println("0");
     }     
    
        
    }
    
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
using namespace std::chrono; 
#define ll long long
#define fo(i,v,e) for(v=i;v<e;v++)
#define pb(x) push_back(x)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fi first 
#define se second
#define vl vector<ll>
#define vi vector<int>
#define vb vector<bool>
#define all(v) v.begin(),v.end()
#define sz(x) (int)x.size()
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x);
#else
#define deb(x...)
#endif

vector<ll> sieveOfErthnosis(ll n)
{
    vector<bool>flag(n+5,false);
    vector<ll>primes;
    for(int i=2;i*i<=n;i++)
    {
        if(!flag[i])
        {
            for(int j=i*i;j<=n;j+=i)
            {flag[j]=true;}
        }
    }
    for (int  i = 2; i < n+1; i++)
    {
        if(!flag[i])primes.pb(i);
    }
    return primes;
}
void solve()
{
   ll x,y,p,a,b,m,i,j;cin>>a>>b>>m;
   vl arr(a),brr(b);
   fo(0,i,a)cin>>arr[i];
   fo(0,i,b)cin>>brr[i];
   ll ans = INT_MAX;
   fo(0,i,m)
   {
       cin>>x>>y>>p;x--;y--;
       ans = min(ans,(arr[x]+brr[y]-p));
   }
   sort(all(arr));
   sort(all(brr));
   ans = min(ans,arr[0]+brr[0]);
   cout<<max(ans,0ll);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    #endif
    auto start = high_resolution_clock::now(); 
    int T = 1;  
    // cin>>T;
	while(T--)
	{
		solve();
	}
    auto stop = high_resolution_clock::now(); 
	auto duration = duration_cast<microseconds>(stop - start); 
    #ifndef ONLINE_JUDGE
	// cout << "time taken : "<<duration.count()<<" ms" << endl;
     #endif
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(){
	int T[5],X,count = 0,ans = 0;
  	
  	for(int i = 0;i<=4;i++){
    	cin >> T[i];
      	//cout << T[i] << endl;
    }
  	cin >> X;
  	//cout << X;
  	for(int i = 0;i<=4;i++){
    	for(int j = 0;j<=4;j++){
        	ans = T[j] - T[i];
          	if(X<ans){	
          		count = 1;
            }
        }
    }
  	if(count == 0){
    	cout << "Yay!";
    }
     else{
     	cout << ":(";
     }
}

Measured memory_bytes: 256
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
dict = defaultdict(int)
ans = 0
for k in range(N):
    a = A[k]
    ans += dict[a]
    dict[a] += 1

for k in range(N):
    a = A[k]
    print(ans - dict[a] + 1)


Measured memory_bytes: 88652
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>

using namespace std;

const int MAX = 333;
string board[MAX];
const int INF = 1e9;
int H, W;

int memo[MAX][MAX][MAX];
int dp[MAX][MAX];

int calc(int c, int l, int r) {
	int& ret = memo[c][l][r];
	if (ret >= 0) return ret;
	if (l*r == 0) return ret = 0;
	return ret = calc(c, l-1, r-1) + (board[l-1][c] == board[r-1][c+1]);
}

int dfs(int col, int lh, int rh) {
	int& ret = dp[lh][rh];
	if (ret >= 0) return ret;
	ret = INF;
	if (lh*rh == 0) return ret = 0;
	return ret = min(calc(col, lh, rh) + dfs(col, lh-1, rh), calc(col, lh, rh) + dfs(col, lh, rh-1));
}

int solve(int col) {
	memset(dp, -1, sizeof(dp));
	return dfs(col, H, H);
}

int main() {
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		cin >> board[i];
	}
	memset(memo, -1, sizeof(memo));
	int ans = 0;
	for (int i = 0; i < W-1; i++) {
		ans += solve(i);
	}
	cout << ans << endl;
	return 0;
}

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

#define pb push_back
#define F first
#define S second
#define rep(i,n) for(int i = 0; i < (n); i++)

using ll = long long;
using ld = long double;
using ul = unsigned long long;
using ii = pair<int, int>;
#define Mosta     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ReadFile            freopen("input.in","r",stdin)
#define WriteFile           freopen("output.txt","w",stdout)
const ll mod7 = 1000000007,mod = 1000000000,OO = 0x3f3f3f3f;
const ld EPS = 1e-7;
double Pi=acos(-1);
const ld rad=Pi/180.0;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll nCr (ll n,ll m)
{
        return(m == 0)?1:n*nCr(n-1,m-1)/m;
}
/*****************************************************/

int main()
{
    int n , h , ans = 0;

    cin >> n >> h;
    int aMx = INT_MIN;
    vector<ii> vec;
    vector<int> thro;

    for(int i = 0; i < n; ++i){
        int a , b;
        cin >> a >> b;
        aMx = max(aMx , a);
        vec.pb(make_pair(a , b));
    }

    for(int i = 0; i < (int) vec.size(); ++i){
        if(vec[i].second > aMx)
            thro.pb(vec[i].second);
    }

    sort(thro.begin() , thro.end() , greater<int>());

    for(int i = 0; i < (int) thro.size(); ++i){
        if(h > 0){
            h -= thro[i];
            ans++;
        }else{
            cout << ans << "\n";
            return 0;
        }
    }

    ans += (h + (aMx - 1)) / aMx;

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 1908
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;
#define MAX_HEIGHT 100
#define MAX_WIDTH 100
#define MAX_NUM (MAX_HEIGHT * MAX_WIDTH)

static uint32_t color_matrix[MAX_HEIGHT * MAX_WIDTH];

int32_t main()
{
  uint32_t H, W;
  cin >> H >> W;

  uint32_t N;
  cin >> N;
  uint32_t count = 0;
  for (uint32_t i = 0; i < N; i++) {
    uint32_t num;
    cin >> num;
    for (uint32_t j = 0; j < num; j++) {
      color_matrix[count] = i + 1;
      count++;
    }
  }

  for (uint32_t i = 0; i < H; i++) {
    for (uint32_t j = 0; j < W; j++) {
      if (j != 0) cout << " ";
      if (i % 2 == 0) {
        cout << color_matrix[i * W + j];
      } else {
        cout << color_matrix[i * W + W - 1 - j];
      }
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 384
inline fun <T> T.also(block: (T) -> Unit): T { block(this); return this }

fun Int.divCeil(a: Int) = (this + a - 1) / a

fun main(args: Array<String>) {
    val (N, H) = readLine()!!.split(" ").map{ it.toInt() }
    val damages = (1..N).map { readLine()!!.split(" ").map{ it.toInt() }.let{ Pair(it[0], it[1])} }

    val normalDamageMax = damages
            .map { it.first }.max()!!
    val throwDamageSorted = damages
            .map { it.second }
            .filter { it > normalDamageMax }
            .sortedDescending()
    val throwDamageSum = throwDamageSorted.sum()

    print(if (throwDamageSum < H) {
        throwDamageSorted.size + (H - throwDamageSum).divCeil(normalDamageMax)
    } else {
        var partSum = 0
        throwDamageSorted.takeWhile { b ->
            (partSum < H).also {
                partSum += b
            }
        }.size
    })
}

Measured memory_bytes: 64600
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

void bubble_sort(vector<uint32_t> &vec)
{
  for (uint32_t i = 1; i < vec.size(); i++) {
    for (uint32_t j = vec.size() - 1; j >= i; j--) {
      if (vec[j] > vec[j - 1]) {
        swap(vec[j], vec[j - 1]);
      }
    }
  }
}

int32_t main()
{
  uint32_t k, n;

  cin >> n >> k;

  vector<uint32_t> vec;

  for (uint32_t i = 0; i < n; i++) {
    uint32_t val;
    cin >> val;
    vec.push_back(val);
  }

  bubble_sort(vec);

  uint32_t total = 0;
  for (uint32_t i = 0; i < k; i++) {
    total += vec[i];
  }

  cout << total << endl;

  return 0;
}


Measured memory_bytes: 256
s = list(input())
t = list(input())

ls = len(s)
lt = len(t)
n = ls - lt + 1
l = []

cnt = 0
for i in range(n):
    for j in range(lt):
        if t[j] != s[i + j]:
            cnt += 1
    l.append(cnt)
    cnt = 0
    
print(min(l))

Measured memory_bytes: 9060
i,o,t,j,l,s,z = map(int,input().split())
ans1 = o + ((i-1)//2)*2 + ((j-1)//2)*2 + ((l-1)//2)*2
if i*j*l >= 1:
    ans1 += 3
ans2 = o + (i//2)*2 + (j//2)*2 + (l//2)*2
ans = max(ans1,ans2)
print(ans)

Measured memory_bytes: 3064
// AtCoder Beginner Contest 122 - Problem C: GeT AC (https://atcoder.jp/contests/abc122/tasks/abc122_c)
#include <bits/stdc++.h>

using namespace std;
using ii = pair<int, int>;

vector<int> solve(int N, int Q, const string& S, const vector<ii>& qs)
{
    vector<int> xs(N + 1, 0), ps(N + 1, 0);

    for (int i = 1; i < N; ++i)
        if (S[i - 1] == 'A' and S[i] == 'C')
            xs[i + 1] = 1;

    for (int i = 1; i <= N; ++i)
        ps[i] = ps[i - 1] + xs[i];

#ifdef DEBUG
    cout << "S = " << S << '\n';

    cout << "xs = ";
    for (int i = 1; i <= N; ++i)
        cout << xs[i] << (i == N ? '\n' : ' ');

    cout << "ps = ";
    for (int i = 1; i <= N; ++i)
        cout << ps[i] << (i == N ? '\n' : ' ');
#endif

    vector<int> ans(Q);

    for (int i = 0; i < Q; ++i)
    {
        auto L = qs[i].first;
        auto R = qs[i].second;

        ans[i] = ps[R] - ps[L];
    }

    return ans;
}

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

    int N, Q;
    cin >> N >> Q;

    string S;
    cin >> S;

    vector<ii> qs(Q);

    for (int i = 0; i < Q; ++i)
        cin >> qs[i].first >> qs[i].second;

    auto ans = solve(N, Q, S, qs);

    for (auto x : ans)
        cout << x << '\n';

    return 0;
}


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

const int maxn=100005;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        string s;
        cin>>s;
        int cnt=0;
        int ans=0;
        for(int i=0;i<3;i++)
        {
            if(s[i]=='R')
            {
                cnt++;
            }
            else
            {
                cnt=0;
            }
            ans=max(cnt,ans);
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
struct SlideMax {
    deque<Int> A;
    Int value() {
        return A.empty() ? -1e18 : A[0];
    }
    void push(Int x) {
        while (!A.empty() && A.back() < x) A.pop_back();
        A.push_back(x);
    }
    void pop(Int x) {
        if (x == A.front()) A.pop_front();
    }
};
int main() {
    int N, M, K; cin >> N >> M >> K;
    vector<Int> A(N); for (auto &a : A) cin >> a;
    vector<Int> B(A);
    for (int i = 1; i < K; i++) {
        SlideMax sm;
        for (int j = 0; j < M; j++) sm.push(B[N-1-j]);
        for (int j = N-1; j >= 0; j--) {
            sm.pop(B[j]);
            if (j-M >= 0) sm.push(B[j-M]);
            B[j] = sm.value() + (i+1) * A[j];
        }
    }
    cout << *max_element(begin(B), end(B)) << '\n';
    return 0;
}

Measured memory_bytes: 1920
def main():
    S = input()
    N = len(S)
    if N == 1:
        print(S)
    elif all("9" == s for s in S):
        print(N*9)
    elif all("9" == s for s in S[1:]):
        print(int(S[0]) + 9*(N-1))
    elif S[0] == "1":
        print(9*(N-1))
    else:
        print((int(S[0])-1) + 9*(N-1))


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
const int N=2e5+5;
const int MOD=1e9+7;
ll a[N];
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

    int n;
    cin >> n;
    for(int i=1;i<=n;++i)    cin >> a[i];
    sort(a+1,a+1+n);
    ll ans,dis=1e18;
    ll pos=upper_bound(a+1,a+n,a[n]/2)-a;
    for(int i=1;i<=n-1;i++){
        if(a[n]%2==0){
            if(abs(a[i]-a[n]/2)<dis)    ans=a[i],dis=abs(a[i]-a[n]/2);
        }
        else{
            if(abs(a[i]-a[n]/2)<dis)    ans=a[i],dis=abs(a[i]-a[n]/2);
            if(abs(a[i]-a[n]/2-1)<dis)    ans=a[i],dis=abs(a[i]-a[n]/2-1);
        }
    }
    cout << a[n] <<" "<<ans<<endl;

    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int n, m; cin >> n >> m;
    vector<set<int>> a(n);
    rep(i, n) {
        int k; cin >> k;
        rep(j, k) {
            int x; cin >> x;
            a[i].insert(x);
        }
    }
    set<int> res;
    res = a[0];
    rep(i, n - 1) {
        auto tmp = res;
        res.clear();
        set_intersection(tmp.begin(), tmp.end(),
                         a[i + 1].begin(), a[i + 1].end(),
                         inserter(res, res.end()));
    }
    cout << res.size() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(void){
  string s;cin>>s;
  int ans=0;
  rep(i,4)ans+=s.at(i)=='+'?1:-1;
  cout<<ans<<endl;
  return 0;
}

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

int main(){
  int A,B;
  cin >> A;
  for (int i = (int)(A / 1.1); i <= A; i++){
    B = i * 1.08;
    if (A == B) {
      cout << i << endl;
      break;
    }
    else if(A == i) cout << ":(" << endl;
  }
  
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll INF = (int)1e16;
const int MOD = (int)1e9 + 7;

int main(void){
    int N; 
    cin >> N;
    vector<int> a(3*N);
    for(int i = 0; i < 3*N; i++) cin >> a[i];

    priority_queue<int, vector<int>, greater<int>> que0;
    priority_queue<int> que1;
    vector<ll> sum0(N+1, 0), sum1(N+1, 0);

    for(int i = 0; i < N; i++){
        que0.push(a[i]);
        sum0[0] += a[i];
    }
    for(int i = N; i < 2*N; i++){
        que0.push(a[i]);
        sum0[i-N+1] = sum0[i-N] + a[i] - que0.top();
        que0.pop();
    }

    for(int i = 2*N; i < 3*N; i++){
        que1.push(a[i]);
        sum1[N] += a[i];
    }
    for(int i = 2*N-1; i >= N; i--){
        que1.push(a[i]);
        sum1[i-N] = sum1[i-N+1] + a[i] - que1.top();
        que1.pop();
    }

    ll res = sum0[0] - sum1[0];
    for(int i = 1; i <= N; i++){
        // printf("i = %d: sum0[i] = %d, sum1[i] = %d\n", i, sum0[i], sum1[i]);
        res = max(res, sum0[i] - sum1[i]);
    }

    cout << res << '\n';
  
    return 0;
}

Measured memory_bytes: 4088
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

    const size_t strlen = s.length();

    std::string end = s.substr(strlen - 1, 1);

    if (end == "s")
    {
        s = s + "es";
    }
    else
    {
        s = s + "s";
    }

    cout << s << endl;
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


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

    vector<int> L(N);

    REP(i,N) cin >> L[i];

    int ans = 1;
    int d = 0;
    for(auto l:L){
        d += l;
        if(d > X) break;
        ans++;
    }

    pl(ans)


    return 0;

}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll n, m;
	ll a = 1;
	ll sum;
	ll ans = 0;

	cin >> n >> m;

	REP(i, m) {
		a = a * 2;
	}

	sum = (n - m) * 100 + m * 1900;

	ans = sum * a;

	cout << ans << endl;
}

Measured memory_bytes: 256
# ABC111C - /\/\/\/
from collections import Counter


def main():
    N, *V = map(int, open(0).read().split())
    even, odd = Counter(V[::2]).most_common(2), Counter(V[1::2]).most_common(2)
    if even[0][0] != odd[0][0]:  # replace except the modes of both parities
        ans = N - even[0][1] - odd[0][1]
    else:
        if len(even) == 1 or len(odd) == 1:
            ans = N // 2  #  replace half of the sequence
        else:  # replace smaller pair of even no.1 & odd 2 / even 2 & odd 1
            ans = N - max(even[0][1] + odd[1][1], even[1][1] + odd[0][1])
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 15460
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, m, q = map(int, input().split())
abcd = [0] * q
for i in range(q):
    abcd[i] = list(map(int, input().split()))

def dfs(seq):
    if len(seq) == n:
        yield seq
        return

    if len(seq) == 0:
        _max = 1
    else:
        _max = seq[-1]

    for i in range(_max, m+1):
        new_seq = seq.copy()
        new_seq.append(i)
        yield from dfs(new_seq)

ans = 0
for s in dfs([]):
    tmp = 0
    for a, b, c, d in abcd:
        if s[b-1] - s[a-1] == c:
            tmp += d
    ans = max(ans, tmp)

print(ans)


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



int main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

      int t;
      double sum=0.00;
      cin>>t;
      while(t--)
      {
          double n;
          cin>>n;
          sum=sum+(1/n);
      }
       printf("%.5f",(1/sum));
       return 0;



}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

int main(){
  int n;
  int a,b;
  cin>>n;
  if(n==1){
    cout<<"Hello World";
  }else{
    cin>>a>>b;
    cout<<a+b;
  }
  return 0;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  
  bool is_satisfied= true;
  vector<char> guess(N, 'X');
  for(int i=0; i<M; i++){
    int s;
    char c;
    cin >> s >> c;
    s--; // 1-indexed -> 0-indexed
    if(N > 1 && s==0 && c=='0'){
      is_satisfied= false;
      break;
    }
    else if(guess.at(s)=='X'){
      guess.at(s)= c;
    }
    else if(guess.at(s)!=c){
      is_satisfied= false;
      break;
    }
  }

  if(is_satisfied){
    if(guess.at(0)=='X'){
      if(N==1){
        cout << '0';
      }
      else{
        cout << '1';
      }
    }
    else{
      cout << guess.at(0);
    }
    for(int i=1; i<N; i++){
      if(guess.at(i)=='X'){
        cout << '0';
      }
      else{
        cout << guess.at(i);
      }
    }
    cout << endl;
  }
  else{
    cout << -1 << endl;
  }
}

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

int x,y;
string a[110];
bool okx[110],oky[110];

int main(){
    cin >> x >> y;
	for(int i=0;i<x;i++){
		cin >> a[i];
	}
	for(int i=0;i<x;++i){
		for(int j=0;j<y;++j){
			if(a[i][j]=='#'){
				okx[i]=true;
				oky[j]=true;
			}
		}
	}
	for(int i=0;i<x;++i){
		if(okx[i]){
			for(int j=0;j<y;++j){
				if(oky[j]) cout << a[i][j];
			}
			cout << endl;
		}
	}
}

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

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

  int sosu[55] = {11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431,\
 461, 491, 521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031,\
 1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381};

  for(int i=0;i<n;i++){
    cout << sosu[i] << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#define P 1000000007

using namespace std;

typedef long long ll;

ll h[111], Mn[111][111], Sm[111][111], SS[111][111], n, F[111];

ll powmod(ll x, ll y = P - 2, ll p = P) {
    ll ans = 1;
    while(y) {
        if(y & 1) ans = ans * x % p;
        x = x * x % p;
        y >>= 1;
    }
    return ans;
}

int main() {
    scanf("%lld", &n);
    for(int i = 1; i <= n; i++) scanf("%lld", &h[i]);
    h[0] = (h[n + 1] = 1);
    for(int i = 1; i <= n; i++) {
        Mn[i][i] = h[i], Sm[i][i] = h[i], SS[i][i] = h[i];
        for(int j = i + 1; j <= n; j++) Mn[i][j] = min(Mn[i][j - 1], h[j]), Sm[i][j] = Sm[i][j - 1] + h[j], SS[i][j] = SS[i][j - 1] + max(h[j] - h[j - 1], 0ll);
    }
    F[0] = 1;
    for(int i = 1; i <= n; i++) {
        F[i] = F[i - 1] * 2 % P;
        for(int j = 1; j <= i; j++) {
            int r = Mn[j][i], l = max(h[i + 1], h[j - 1]) + 1;
            if(l <= r) F[i] = (F[i] + 2 * F[j - 1] * (powmod(2, SS[j][i] - l + 1) - powmod(2, SS[j][i] - r))) % P;
        }
    }
    printf("%lld\n", (F[n] % P + P) % P);
    return 0;
}


Measured memory_bytes: 384
k = int(input())
snuke = [1, 2, 3, 4, 5, 6, 7, 8, 9]
for i in range(1, 150):
    for j in range(1, 17):
        snuke.append(int(str(i)+str(10**j-1)))
snuke = list(set(snuke))
snuke.sort()
ans = []
m = (10**17-1)/(9*17)
for s in snuke[::-1]:
    t = sum(map(int, list(str(s))))
    if m>=s/t:
        ans.append(s)
        m = s/t
ans = list(reversed(ans))
print(*ans[:k], sep = '\n') 

Measured memory_bytes: 40944