akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;


int main()
{
    IOS
    ll n;
    cin>>n;
    cout<<n*n*n<<endl;
    return 0;
}


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

int main(){
  int n; cin>>n;
  vector<string> s(n);
  vector<int> t(n);
  for(int i=0; i<n; ++i)cin>>s[i]>>t[i];
  string x; cin>>x;

  int e=0;
  for(int i=0; i<n; ++i)if(x==s[i]){e=i; break;}

  int ans=0;
  for(int i=e+1; i<n; ++i)ans+=t[i];
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int map[50][50];
int h,w;

void dfs(int y,int x){
  int i,dx[] = {0,1,1,1,0,-1,-1,-1} , dy[] = {-1,-1,0,1,1,1,0,-1};
  map[y][x] = 0;
  for(i=0;i<8;i++){
    int sx = x+dx[i], sy = y+dy[i];
    if(sx<0 || sy<0 || w<=sx || h<=sy)continue;
    if(!map[sy][sx])continue;
    dfs(sy,sx);
  }
}


int main(void){
    int i,j,ans;

  while(scanf("%d %d",&w,&h) && (w||h)){
    for(i=0;i<h;i++)
      for(j=0;j<w;j++)scanf("%d",&map[i][j]);

    ans = 0;
    for(i=0;i<h;i++)
      for(j=0;j<w;j++)
	if(map[i][j]){
	  dfs(i,j);
	  ans++;
	}

    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 0
/*やったぜ。　投稿者：変態糞土方 (8月16日（水）07時14分22秒)

昨日の8月15日にいつもの浮浪者のおっさん（60歳）と先日メールくれた汚れ好きの土方のにいちゃん

（45歳）とわし（53歳）の3人で県北にある川の土手の下で盛りあったぜ。

今日は明日が休みなんでコンビニで酒とつまみを買ってから滅多に人が来ない所なんで、

そこでしこたま酒を飲んでからやりはじめたんや。

3人でちんぽ舐めあいながら地下足袋だけになり持って来たいちぢく浣腸を3本ずつ入れあった。

しばらくしたら、けつの穴がひくひくして来るし、糞が出口を求めて腹の中でぐるぐるしている。

浮浪者のおっさんにけつの穴をなめさせながら、兄ちゃんのけつの穴を舐めてたら、

先に兄ちゃんがわしの口に糞をドバーっと出して来た。

それと同時におっさんもわしも糞を出したんや。もう顔中、糞まみれや、

3人で出した糞を手で掬いながらお互いの体にぬりあったり、

糞まみれのちんぽを舐めあって小便で浣腸したりした。ああ～～たまらねえぜ。

しばらくやりまくってから又浣腸をしあうともう気が狂う程気持ちええんじゃ。

浮浪者のおっさんのけつの穴にわしのちんぽを突うずるっ込んでやると

けつの穴が糞と小便でずるずるして気持ちが良い。

にいちゃんもおっさんの口にちんぽ突っ込んで腰をつかって居る。

糞まみれのおっさんのちんぽを掻きながら、思い切り射精したんや。

それからは、もうめちゃくちゃにおっさんと兄ちゃんの糞ちんぽを舐めあい、

糞を塗りあい、二回も男汁を出した。もう一度やりたいぜ。

やはり大勢で糞まみれになると最高やで。こんな、変態親父と糞あそびしないか。

ああ～～早く糞まみれになろうぜ。

岡山の県北であえる奴なら最高や。わしは163*90*53,おっさんは165*75*60、や

糞まみれでやりたいやつ、至急、メールくれや。

土方姿のまま浣腸して、糞だらけでやろうや。*/
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define llMIN numeric_limits<long long>::min()
#define intMIN numeric_limits<int>::min()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double
int main(void){
  int n,m;
  cin>>n>>m;
  vi a(m);
  rep(i,m){
    cin>>a[i];
  }
  vi numneed={intMAX,2,5,5,4,5,6,3,7,6};
  sort(a.begin(),a.end());
  vi dp=vi(n+1,intMIN);
  dp[0]=0;
  rep(i,n){
    int tmpmax=intMIN;
    rep(j,m){
      if((i+1)-numneed[a[j]]>=0){
        tmpmax=max(dp[i+1-numneed[a[j]]]+1,tmpmax);
      }
    }
    dp[i+1]=tmpmax;
  }
  vi finalans(dp[n],-1);
  int tmpn=n;
  rep(j,dp[n]){
  //cout<<"f "<<j<<" ";
    rep(i,m){
      if(tmpn-numneed[a[i]]>=0){
        if(dp[tmpn-numneed[a[i]]]==dp[tmpn]-1){
          finalans[j]=a[i];
        }
      }
    }
    tmpn-=numneed[finalans[j]];

  }
  rep(i,dp[n]){
    cout<<finalans[i];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#https://atcoder.jp/contests/abc151/submissions/9485142
#最小包含問題
#三分探索(二次元)
def distance(x1, y1, x2, y2)
  dx = x1 - x2
  dy = y1 - y2
  Math.sqrt(dx ** 2 + dy **2 )
end

def f(x, y)
  max = 0
  XY.each do |a, b|
    max = [max, distance(x, y, a, b)].max
  end
  max
end

def g(x)
  l = 0
  r = 1000
  80.times do
    cl = (l * 2 + r)/3.0
    cr = (l + r * 2)/3.0
    if f(x, cl) > f(x, cr)
      l = cl
    else
      r = cr
    end
  end
  f(x, l)
end

def main()
  l = 0
  r = 1000
  80.times do
    cl = (l * 2 + r)/3.0
    cr = (l + r * 2)/3.0
    if g(cl) > g(cr)
      l = cl
    else
      r = cr
    end
  end
  puts sprintf("%.12f", g(l))
end

N = gets.to_i
XY = N.times.map{gets.split.map(&:to_i)}
main()

Measured memory_bytes: 3836
#include <bits/stdc++.h>
 
using namespace std;
 
 int main()
 {
     int N, tmp, count = 0;
     int min = INT_MAX;
     int begin = 0, end;
     vector<int> vec;

     cin >> N;

     for (int i = 0; i < N; i++) {
         cin >> tmp;
         vec.push_back(tmp);
     }

    while(true) {
        begin = 0;
        for (int i = 0; i < N+1; i++) {
            if (vec[i] != 0 && i != N) {
                if (min > vec[i]) {
                    min = vec[i];
                }
            } else {
                end = i;
                for (int i = begin; i < end; i++) {
                    vec[i] = vec[i] - min;
                }
                if ((end - begin) > 0) {
                    count += min;
                }
                //cout << " end:" << end << " begin:" << begin << " min:" << min << endl;
                begin = i+1;
                min = INT_MAX;
            }
        }
        if (accumulate(vec.begin(), vec.end(), 0) == 0) {
            break;
        }
        /*
        for (const auto& e : vec) {
            cout << e << " ";
        }
        cout << endl;
        */
    }


    cout << count << endl;
    return 0;
 }
        
   

Measured memory_bytes: 256
package main
import "fmt"
func main() {
  var n,x int
  fmt.Scan(&n,&x)
  if x == 1 || x == 2*n-1 {
    fmt.Println("No")
    return
  }
  fmt.Println("Yes")
  if x < n {
    for i:=x+1;i<=n;i++ {
      fmt.Println(i)
    }
    for i:=1;i<=x;i++ {
      fmt.Println(i)
    }
    for i:=n+1;i<=2*n-1;i++ {
      fmt.Println(i)
    }
  }
  if x == n {
    for i:=1;i<2*n;i++ {
      fmt.Println(i)
    }
  }
  if x > n {
    for i:=1;i<=n-1;i++ {
      fmt.Println(i)
    }
    for i:=x;i<=2*n-1;i++ {
      fmt.Println(i)
    }
    for i:=n;i<=x-1;i++ {
      fmt.Println(i)
    }
  }
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n,k;
  cin>>n>>k;
  while(true){
    if(n/k==0){
      chmin(n,abs(n-k));
      break;
    }
    ll a=n/k;
    n-=k*a;
  }
  cout<<n<<'\n';
  return(0);
}


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

typedef long long LL;
typedef long double LD;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    rep(i, 3){
        if(s[i] == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3640
import sys
import math

def isPrime(num):
    if num < 2: return False
    elif num == 2: return True
    elif num % 2 == 0: return False
    for i in range(3, math.floor(math.sqrt(num))+1, 2):
        if num % i == 0:
            return False
    return True

def callIsPrime(input_num):
    numbers = []
    for i in range(1, input_num):
        if isPrime(i):
            numbers.append(i)
    return numbers


def main():
    
    input = sys.stdin.readline
    x = int(input())
    primes = callIsPrime(x+1000)
    ans = [i for i in primes if i>=x]
    print(min(ans))


if __name__ == "__main__":
    main()



Measured memory_bytes: 9360
#include "bits/stdc++.h"
#define REP(i, n, N) for(ll i=(n); i < N; i++)
#define p(s) cout << (s) << endl
#define p2(a, b) cout << (a) << ' ' << (b) << endl
using namespace std;
typedef long long ll;
int main() {
    string s;

    while(1){
        getline(cin,s);
        if(s.size()==1)break;
        stack<char> stk;
        stk.push('?');
        bool flag=true;
        REP(i,0,s.size()){
            if(s[i]=='(') stk.push('(');
            if(s[i]=='[') stk.push('[');
            if(s[i]==')') {
                if (stk.top() == '(') {
                    stk.pop();
                } else {
                    flag=false;
                    break;
                }
            }
            if(s[i]==']') {
                if (stk.top() == '[') {
                    stk.pop();
                } else {
                    flag= false;
                    break;
                }
            }
        }
        if(flag && stk.size()==1){
            p("yes");
        }else{
            p("no");
        }
    }

    return 0;
}


Measured memory_bytes: 3212
X, N = map(int, input().split())
p = list(map(int, input().split()))

p.sort()
def main():
    l = [True for _ in range(100)]
    for x in p:
        l[x-1] = False
    diff = 0
    while True:
        if X-1 -diff < 0:
            print(0)
            return
        elif l[X-1 -diff]:
            print(X -diff)
            return
        elif X-1 +diff >= 100:
            print(101)
            return
        elif l[X-1 +diff]:
            print(X +diff)
            return
        diff += 1

main()

Measured memory_bytes: 61812
import sys
input=sys.stdin.readline

n = int(input())

d = 0
tmp = n
while tmp > 0:
    tmp //= 10
    d += 1

if d <= 1:
    print(n)
else:
    if str(n).count("9") == d:
        print(9*d)
    elif str(n)[0] != "9" and str(n)[1:].count("9") == d-1:
        print(int(str(n)[0])+9*(d-1))
    else:
        print(9*(d-1) + n//(10**(d-1)) -1)



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

#define f first
#define s second
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int>
#define px pair<db, db>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define input(a) for (auto& el : a) cin >> el;
#define output(a) cout << '!'; for (auto& el : a) cout << el << ' '; cout << '\n'; cout.flush();
#define sz(el) int(el.size())
#define sq(a) ((a) * (a))
#define xll bitset<128>
#define xmin(a,b) a = min(a, b)
#define xmax(a,b) a = max(a, b)
#define sun(a) sort(all(a)); a.resize(unique(all(a)) - a.begin());
/**/  /// extra
//#define forn(i,n) for (int i = 0; i < n; ++i)
//#define rforn(i,n) for (int i = n - 1; i >= 0; --i)
#define bn '\n'
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vll vector<vl>
//#define G vector<vector<pii>>
#define GVE vector<vector<edge>>
#define usi unordered_set<int>
#define usp set<pii>
/**/

using namespace std;

const int INF = 1'000'000'017;
const ll LLINF = 1'000'000'000'000'000'017LL;
const ld inf = 1.0 / 0.0;
const ld eps = 1e-9;
const int MOD = 1e9 + 7;

//mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

//uniform_int_distribution<int> uid(l, r); [l, r]
//int x = uid(rng);

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;
    for (int i = 0; i < n - 1; ++i) {
        int x = n - 1 - i;
        for (int i = 1; i <= x; ++i) {
            cout << __builtin_ctz(i & -i) + 1 << ' ';
        }
        cout << '\n';
    }
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int     main(void)
{
    int i, x;
    
    i = 1;
    while (i <= 10000)
    {
        scanf("%d", &x);
        
        if (x == 0)
        {
            break;
        }
        
        printf("Case");
        printf(" ");
        printf("%d:", i);
        printf(" ");
        printf("%d\n", x);
        
        i++;
    }
    return (0);
}


Measured memory_bytes: 2040
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int ans = 7;
    if(s.equals("MON")) ans = 6;
    if(s.equals("TUE")) ans = 5;
    if(s.equals("WED")) ans = 4;
    if(s.equals("THU")) ans = 3;
    if(s.equals("FRI")) ans = 2;
    if(s.equals("SAT")) ans = 1;
    System.out.println(ans);
  }
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;

#define CONTAINS(v, x) (find(v.begin(), v.end(), x) != v.end())
#define FIND(v, x) find(v.begin(), v.end(), x)

int main() {
#define int long long int
  int n;
  cin >> n;
  vector<int> v(5);
  string march = "MARCH";
  string s;
  for (int i = 0; i < n; i++) {
    cin >> s;
    if (CONTAINS(march, s[0])) {
      v[FIND(march, s[0]) - march.begin()]++;
    }
  }

  ll ans = 0;
  for (int i = 0; i < 3; i++) {
    for (int j = i + 1; j < 4; j++) {
      for (int k = j + 1; k < 5; k++) {
        ans += v[i] * v[j] * v[k];
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int a,b;
    char op;
    while (1)
    {
    scanf("%d %c %d\n",&a,&op,&b);
    if (op=='?'){break;}
    else if(op=='+'){
        printf("%d\n",a+b);}
    else if(op=='-'){
        printf("%d\n",a-b);}
    else if(op=='*'){
        printf("%d\n",a*b);}
    else if(op=='/'){
        printf("%d\n",a/b);}
    else{break;}
    
}


 
    
    return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int i = 0;
    string s;
    cin >> s;
    cout << s.at(i++);
    cin >> s;
    cout << s.at(i++);
    cin >> s;
    cout << s.at(i++) << endl;
}


Measured memory_bytes: 256
X,N=map(int,input().split())
if N>0:
	p=list(map(int,input().split()))
	p=set(p)
else:
    p=set()
for i in range(1000):
    if X-i not in p:
        print(X-i)
        break
    if X+i not in p:
        print(X+i)
        break

Measured memory_bytes: 61700
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#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 aFOR(i, V) for (auto i : V)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
#define INF 1'000'000'007 // 10^9 + 7
#define MOD 1'000'000'007 // 10^9 + 7
#define lINF 1'000'000'000'000'000'007 // 10^18 + 7
// ------------------------------

int main() {
    int K;
    cin >> K;
    REP(i, K) {
        cout << "ACL";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3548
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

string s;

int main() {
  //
  cin >> s;
  int ans = 0;
  int res = 0;
  rep(i, 0, 3) {
    if (s[i] == 'R') {
      ans++;
      chmax(res, ans);
    } else {
      ans = 0;
    }
  }
  cout << res;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define endl '\n'
#define inf (ll)(1e18+5)
#define maxn 3000001
#define mod (ll)(1e9+7)
#define int ll
 
using namespace std;
 
void io(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}

int n,m,l,r,x,y,z,a,b,c,mn=inf,mx=-inf,w,sum=0;
int ar[maxn];
double dp[3005][3005];
double p[3005];

int32_t main(){
io();
IOS;    
		cin>>n;
		for(int i=1;i<=n;i++)cin>>p[i];
		dp[0][0]=1.0;
		for(int i=1;i<=n;i++){
			dp[i][0]=dp[i-1][0]*(1.0-p[i]);
		}
		for(int i=1;i<=n;i++){
			dp[0][i]=0.0;
		}

		for(int i=1;i<=n;i++){
			for(int j=1;j<=i;j++){
				dp[i][j] = dp[i - 1][j] * (1.0 - p[i]) + dp[i - 1][j - 1] * p[i];
			}
		}

		double ans=0;
		for(int j=n/2+1;j<=n;j++){
			ans+=dp[n][j];
		}
		cout<<fixed<<setprecision(10)<<ans<<endl;



        

        


        
    
        
        
                


 
        
 
 
 
        
 
 
 
 
        
        
 
        
        
 
    
    
    
    
 
 
       
 
 
 
 
      
   
 
 
 
 
}

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

#ifdef DEBUG
    #include "debug.h"
    #define dump(...)                                                              \
        DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
                << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
                << endl                                                            \
                << "    ",                                                         \
            dump_func(__VA_ARGS__)
#else
    #define dump(...)
#endif


// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<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);
}

//////////////////

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

#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
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 (a>b) { a=b; return 1; } return 0; }

//*
#define mod 1000000007 /*/
#define mod 998244353 //*/

typedef pair<int, int> P;
#define INF (1LL<<60)

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

struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;

void solve(){
    int N, X, T;
    cin >> N >> X >> T;
    cout << T*((N+X-1)/X) << endl;
}


signed main(){
    cout << fixed << setprecision(18);
//    cerr << fixed << setprecision(18);
    solve();
}


Measured memory_bytes: 3544
#include<bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace  std ;
typedef long l ;
typedef long long ll ;
typedef vector<int>vi ;
typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
long long power(long long k , long long n , long long m=1e9+7)
{
    long long res = 1;
    while(n)
    {
        if(n%2!=0)
        {
            res = (res*k)%m ;
        }
        k = (k*k)%m ;
        n = n/2 ;
    }
    return(res) ;
}
long long fact(long long n , long long m = 1e9+7)
{
    long long a = 1 ;
    if(n==0 || n==1)
    {
        return(1) ;
    }
    while(n>0)
    {
        a = (a%m * n%m)%m ;
        n-- ;
    }
    return(a) ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    std::cout.unsetf ( std::ios::floatfield );//this and next line for floating precision upto 6
    std::cout.precision(10);
    ll a,b,c,d,e,x,i,j,n,t,m,k,y;
    double p,q,r,w,u ;
    string str = "",str1 = "" ;
    ll a1,a2,b1,b2 ;
  	cin>>n>>m ;
  	bool likes = false ;
  	c = 0 ;
  	vll arr(m+1,0) ;
  	for(i=0 ; i<n ; i=i+1)
  	{
		cin>>k;
		for(j=0 ; j<k ; j=j+1)
		{
			cin>>a ;
			arr[a]++ ;		
		}		
	}
	for(i=0 ; i<m+1 ; i=i+1)
	{
		if(arr[i]==n)
		{
			c++;
		}
	}
	cout<<c ;
}

Measured memory_bytes: 256
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
# fractions.gcd() を用いること
# math.log2()はatcoderでは対応していない．留意せよ．

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    n = int(input().strip())
    a = list(map(int, input().strip().split()))
    a.sort()

    # a[n//2-1] < k <=  a[n//2:n]
    print(a[n//2] - a[n//2-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 74372
///
// File:  c.cpp
// Author: ymiyamoto
//
// Created on Thu Oct  5 18:04:39 2017
//

#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

static bool dislikes[10];

int32_t main()
{
  uint32_t N, K;
  cin >> N >> K;

  for (uint32_t i = 0; i < K; i++) {
    uint32_t val;
    cin >> val;
    dislikes[val] = true;
  }

  for (uint32_t i = N;; i++) {
    string str = to_string(i);
    bool found = true;
    for (uint32_t i = 0; i < str.size(); i++) {
      if (dislikes[str[i] - '0']) {
        found = false;
      }
    }
    if (found) {
      cout << str << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

template<class T> inline void checkmin(T &a,const T &b){if(b<a) a=b;}
template<class T> inline void checkmax(T &a,const T &b){if(b>a) a=b;}

const int inf=1e9+10;
const int maxn=17;

ll dp[1<<maxn],a[maxn][maxn]; 
int n;

int main(){
	cin>>n;
	for(int i=0;i<n;i++) for(int j=0;j<n;j++) cin>>a[i][j];
	for(int mask=0;mask<(1<<n);mask++){
		vector <int> v;
		for(int i=0;i<n;i++) if(mask&(1<<i)) v.pb(i);
		for(int i=0;i<v.size();i++) for(int j=i+1;j<v.size();j++)
			dp[mask]+=a[v[i]][v[j]];
	}
//	cout<<dp[5]<<" "<<dp[2]<<endl;
	for(int msk=0;msk<(1<<n);msk++){
		int x=-1;
		for(int i=0;i<n;i++)  if(msk&(1<<i)){
			x=i; break;
		}
		if(x==-1) continue;
		int msk2=((1<<n)-1)^msk,msk3=0,flag=0;
		for(int i=n-1;i>=0;i--){
			if(!(msk2&(1<<i))) flag=1;
		//	cout<<(msk&(1<<i))<<" "<<flag<<endl;
			if(flag&&(!(msk2&(1<<i)))) msk3|=(1<<i);
		}
	//	cout<<msk2<<" "<<msk3<<endl;
		for(int msk4=msk3;msk4;msk4=(msk4-1)&msk3){
			checkmax(dp[msk],dp[msk4]+dp[msk^msk4]);	
		}
	}
	cout<<dp[(1<<n)-1]<<endl;
	return 0;
}


Measured memory_bytes: 768
//Littleboy123 Template 1.0

#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long int ll;
typedef unsigned long long int ull;

#define FOR(a,b,c) for(ll (a)=(b);(a)<(c);++(a))
#define FORE(a,b,c) for(ll (a)=(b);(a)<=(c);++(a))
#define FORN(a,b,c) for(ll (a)=(b);(a)>(c);--(a))
#define FORNE(a,b,c) for(ll (a)=(b);(a)>=(c);--(a))
#define COUT(a) cout << (a) << '\n'
#define MEM(a,b) memset((a), (b), sizeof((a)));
#define nl '\n'
#define fi first
#define se second
#define mp make_pair
#define pb push_back

void init(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

//End of template

int main(){
	init();
	int n;
	cin >> n;
	ll arr[n];
	ll total = 0;
	FOR(i, 0, n){
		cin >> arr[i];
		total += arr[i];
	}
	ll ans[n];
	ll before = 0;
	ll sum = 0;
	ll copy;
	ans[1] = 0;
	FOR(i, 1, n){
		//copy = before;
		before = -1*before + 2*arr[i];
		sum += before;
		if(i == n-1){
			ans[0] = before;
		}
		else
			ans[i+1] = before;
	}
	//cout << total << ' ' << sum << endl;
	int x = (total-sum)/2;
	FOR(i, 1, n+1){
		if(i == n){
			ans[0] += 2*x;
		}
		else{
			if(i & 1){
				ans[i] += 2*x;
			}
			else{
				ans[i] -= 2*x;
			}
		}
	}
	FOR(i, 0, n){
		cout << ans[i];
		if(i == n-1)
			cout << nl;
		else
			cout << ' ';
	}
	return 0;
}


Measured memory_bytes: 2944
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    double x1 = (double)n/1.08;
    double x2 = (int)x1;
    if(x1==x2){
      System.out.println((int)x1);
    }else{
      int ans = (int)((int)(x2+1) * 1.08);
      if(ans==n){
        System.out.println((int)(x2+1));
      }else{
        System.out.println(":(");
      }
    }

  }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD=998244353;
using  P=pair<ll,ll>;
vector<long long> fact, fact_inv, inv;
void init_nCk(ll n) {
    fact.resize(n + 5);
    fact_inv.resize(n + 5);
    inv.resize(n + 5);
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < n + 5; i++) {
        fact[i] = fact[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }
}
ll nCk(ll n,ll k) {
    assert(!(n < k));
    assert(!(n < 0 || k < 0));
    return fact[n] * (fact_inv[k] * fact_inv[n - k] % MOD) % MOD;
}
ll mod_pw(ll x,ll y) {
  ll tmp=x;
  ll res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
int main(){
  ll N,M,K,ans=0;
  cin>>N>>M>>K;
  init_nCk(N-1);
  for(ll i=0;i<=K;i++){
    ans+=((nCk(N-1,i)*mod_pw(M-1,N-i-1))%MOD)*M;
    ans%=MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 7904
#define _CRT_SECURE_NO_WARNINGS

#pragma GCC optimize("O3")

#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>
#include <cstring>
#include <numeric>
#include <set>
#include <queue>
#include <deque>
#include <array>
#include <string>
#include <cmath>
#include <random>
#include <ctime>
#include <map>
#include <functional>
#include <bitset>
#include <complex>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>

#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define pb push_back

using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using ld = long double;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int h, n;
	cin >> h >> n;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		sum += x;
	}
	if (sum >= h) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
using Data = pair<ll, vector<int>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 50;
struct edge { ll from; ll to; ll cost; };
typedef tuple<ll, ll, ll>T;
typedef pair<int, int>pint;

ll col[101010];
vector<ll>eeven[101010];
vector<ll>eodd[101010];
void dfs(int n) {
	fore(x,eeven[n]) {
		if (col[x] == -1) {
			col[x] = col[n];
			dfs(x);
		}
	}
	fore(x, eodd[n]) {
		if (col[x] == -1) {
			col[x] = !col[n];
			dfs(x);
		}
	}
}

int main() {
	ll n;
	cin >> n;
	memset(col,-1,sizeof(col));
	rep(i, 0, n - 1) {
		ll u, v, w;
		cin >> u >> v >> w;
		u--, v--;
		if (w % 2 == 0) {
			eeven[u].pb(v);
			eeven[v].pb(u);
		}
		else {
			eodd[u].pb(v);
			eodd[v].pb(u);
		}
	}
	col[0] = 0;
	dfs(0);

	rep(i, 0, n) {
		cout << col[i] << endl;
	}


	return 0;
}

Measured memory_bytes: 11904
#include<iostream>
#include<vector>

using namespace std;

int main(){
  int N,M,C; cin >> N >> M >> C; int cnt = 0;
  vector<int> B(M);
  for(int i = 0;i  < M; i++){
    cin >> B[i];}
  for(int j = 0; j < N;j++){
    int sum = 0;//和は毎回初期化
    for(int k = 0; k < M ;k++){
      int a ; cin >> a; sum += a * B[k];}
    if( sum + C > 0){ cnt++;} //j番目は正解 
  }
  
  cout << cnt << endl;
  
  return 0;}
      

Measured memory_bytes: 256
local n,k=io.read("n","n","l")
local s=io.read()
local counter=0
for i=1,n-1 do
    if s:byte(i)~=s:byte(i+1) then
        counter=counter+1
    end
end
print(n-1-(counter-2*k>0 and counter-2*k or 0))

Measured memory_bytes: 2888
"""
B - Nice Shopping
"""
a_list = []
b_list = []

a, b, m = map(int, input().split(' '))
a_list = [int(i) for i in input().split(' ')]
b_list = [int(i) for i in input().split(' ')]
m_list = []
for i in range(m):
    m_list.append([int(i) for i in input().split(' ')])

# print(a_list, b_list, m_list)
a_min = min(a_list)
b_min = min(b_list)
ode = a_min + b_min

for indirim in m_list:
    yeni_ode = a_list[indirim[0]-1] + b_list[indirim[1]-1] -indirim[2]
    if yeni_ode < ode:
        ode = yeni_ode

print(ode)

Measured memory_bytes: 32620
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int N = Integer.parseInt(sc.next());
        
        boolean[] isSitting = new boolean[100001];
        
        for(int i=0; i<N; i++){
            int l = Integer.parseInt(sc.next());
            int r = Integer.parseInt(sc.next());
            
            for(int j=l; j<=r; j++){
                if(isSitting[j] == false){
                    isSitting[j] = true;
                }
            }
        }
        int ans = 0;
        for(int i=1; i<isSitting.length; i++){
            if(isSitting[i]){
                ans++;
            }
        }
        
        System.out.println(ans);
    }
}

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

int main(){
  
  int X;
  cin >> X;
  vector<bool> expo(X+1);
  expo[1] = 1;
  for(int b=2;b<=X;b++){
    int v =b*b;
    while(v <= X){
      expo[v] = 1;
      v *= b;
    }
  }
  for(int i=X;i>=1;i--){
    if(expo[i]){
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb emplace_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
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 A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> ostream& operator<<(ostream &os,const vector<vector<T>> &v) {
    ITR(u,begin(v),end(v))ITR(w,begin(*u),end(*u))os<<*w<<(w==end(*u)-1?"\n":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed;
// cout << setprecision(10) << val;

bool check_month(string b) {
  int t = stoi(b);
  if (1 <= t && t <= 12) return true;
  return false;
}

string s;
signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  
  cin >> s;
  string bef = s.substr(0, 2), aft = s.substr(2, 2);
  int bef_ok = check_month(bef), aft_ok = check_month(aft);
  if (bef_ok && aft_ok) cout << "AMBIGUOUS";
  else if (!bef_ok && !aft_ok) cout << "NA";
  else if (!bef_ok) cout << "YYMM";
  else if (!aft_ok) cout << "MMYY";
  cout << endl;
  return 0;
}




Measured memory_bytes: 256
S = input()
T = input()

len_S = len(S)
len_T = len(T)

ans = 9999



for n in range(len_S - len_T +1):
  part_S = S[n:n+len(T)]
  cnt = 0
  for t in range(len(T)):
    if T[t] != part_S[t]:
      cnt += 1
  if cnt < ans:
    ans = cnt
print(ans)

Measured memory_bytes: 9120
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int h,w,A[2001][2001]={0},ans=0;
    cin>>h>>w;
    string s[20000];
    rep(i,h) cin>>s[i];
    rep(i,h){
        int a=0,b=0;
        rep(j,w){
            if(s[i][j]=='.') b++;
            else{
                for(int k=a;k<b;k++) A[i][k]+=b-a;
                a=b+1,b=a;
            }
        }
        if(s[i][w-1]=='.') for(int k=a;k<b;k++) A[i][k]+=b-a;
    }
    rep(i,w){
        int a=0,b=0;
        rep(j,h){
            if(s[j][i]=='.') b++;
            else{
                for(int k=a;k<b;k++) A[k][i]+=b-a;
                a=b+1,b=a;
            }
        }
        if(s[h-1][i]=='.') for(int k=a;k<b;k++) A[k][i]+=b-a;
    }
    rep(i,h)rep(j,w) ans=max(ans,A[i][j]-1);
    cout<<ans;
}

Measured memory_bytes: 20096
#include <iostream>
#include <limits.h>
using namespace std;

int main(void){
    long long n, k = 0;
    cin >> n;
    while ((k * (k + 1)) / 2 < n) k++;
    for (int i = 1; i <= k; i++) {
        if ((k * (k + 1)) / 2 - n != i) cout << i << endl;
    }
}


Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-

N, M = map(int, input().split())
gp = [['0' for _ in range(N)] for _ in range(M)]
for i in range(M):
    ksl = list(map(int, input().split()))
    for s in ksl[1:]:
        gp[i][N-s] = '1'
for i in range(M):
    gp[i] = ''.join(gp[i])
pl = list(map(int, input().split()))
res = 0
for sw in range(2**N):
    for i,g in enumerate(gp):
        ing = int(g, 2)
        swing = sw & ing
        #print("sw:%d, ing:%d, swing:%d"%(sw, ing, swing))
        fsw = format(sw, 'b').zfill(N)
        fing = format(ing, 'b').zfill(N)
        fswing = format(swing, 'b').zfill(N)
        #print("fsw:%s, fing:%s, fswing:%s"%(fsw, fing, fswing))
        if fswing.count('1') % 2 != pl[i]:
            break
    else:
        #print(fsw)
        res += 1
print(res)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define forn(i,b) for(int i=0 ; i< b ;i++)
#define for1(i,b) for(int i=1 ; i<=b ;i++)
#define reps(i,a,b) for(int i=a ; i< b.length() ;i++)
typedef long long ll;
#define MOD 1000000007



using namespace std;

int main()
{
  ll A,B,K,tmp;
  cin>>A>>B>>K;
  if (A>K){
    A-=K;cout<<A<<" "<<B;
  }else if (A<K){
   tmp=K-A; A=0;B-=tmp;
    if(B<=0){B=0;}
    cout<<A<<" "<<B;
  }
  else {
    A-=K;
    cout<<A<<" "<<B;
  }


  return 0 ;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline

n=int(input())
dp=[[0]*3  for _ in range(n)]
a,b,c=map(int,input().split())
dp[0]=[a,b,c]
for i in range(1,n):
    a,b,c=map(int,input().split())
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a
    dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b
    dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c
print(max(dp[n-1]))


Measured memory_bytes: 54636
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define rep(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define irep(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define rrep(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

const int MOD = 1e9 + 7;

int main() {
    long long n, a, b;
    cin >> n >> a >> b;
    if (a > b || (n == 1&&a!=b))
        cout << 0 << endl;
    else
        cout << a + (n - 1)*b - b - (n - 1)*a + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
     public static void main(String[] args) {
          Scanner scan = new Scanner(System.in);
          int a = scan.nextInt();
          int b = scan.nextInt();
          
          int c = a/b;
          int d = a%b;
          
          String s = String.format("%.5f", 1.0*a/b);

          System.out.println(c + " " + d + " " + s);
     }
}

Measured memory_bytes: 26400
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
namespace mp = boost::multiprecision;// 任意長整数型
using bint = mp::cpp_int;// 仮数部長が32の浮動小数点数型
using real32 = mp::number<mp::cpp_dec_float<32>>;// 仮数部長が1024の浮動小数点数型
using real1024 = mp::number<mp::cpp_dec_float<1024>>;// ついでに有理数型
using rat = boost::rational<bint>;
*/
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
ll n;
vector<ll> a;
int main(){ //srand((unsigned)time(NULL));
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = n-1; i >= 0; i--) {
    cout << a[i] << (i == 0 ? "":" ");
  }
  cout << endl;
}



Measured memory_bytes: 3108
#include<stdio.h>

int main()
{
  short x,y;
  int s,i,a,b,max;
  int n,m,p,q,r;

  while(1){
    max = 0;
    scanf("%hd %hd %d",&x,&y,&s);

    if(x == 0 && y == 0 && s == 0){
      break;
    }

    for(i = 1;i <= s/2;i++){
      n = i * (100+x) / 100;
      m = s - n;
      p = m * 100 / (100+x);

      while(1){
        p++;
        q = p * (100+x) / 100;

	if(n + q != s){
          p--;
	  break;
	}
      }

      r = p * (100+x) / 100;

      if(n + r == s){
	a = i * (100+y) / 100;
	b = p * (100+y) / 100;
	if(a+b > max){
          max = a + b;
	}
      }
    }

    printf("%d\n",max);
  }

  return 0;
}

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


int main(){
    int n;
    long long min = 1000000;
    long long max = -1000000;
    long long sum = 0;
    long long a;
    
    
    
    cin >> n;
    
    
    for(int i = 0; i < n; i++){
        cin >> a;
        if (a < min) min = a;
        if (a > max) max = a;
        sum += a;
    }
    
    
    cout << min << " " << max << " " << sum << endl;

    
    return 0;
    
}

Measured memory_bytes: 3096
#include <iostream>
#include <string.h>

int main() {
  using namespace std;
  ios_base::sync_with_stdio(false);

  int n, x, y;
  cin >> n >> x >> y;
  
  //short d[ (n-1) * (n-2) / 2 ];
  //auto *p = d;
  short d[n];
  memset(d, 0, n<<1);
  for (int a = 1 ; a < n ; a++) {
    for (int b = a + 1 ; b <= n ; b++) {
      // a -> b
      int d1 = b - a;
      int d2 = abs(a - x) + 1 + abs(b - y);
      d[min(d1,d2)]++;
      //cout << a << " -> " << b << " : " << min(d1,d2) << endl;
    }
  }
  
  for (int k = 1 ; k < n ; k++) {
    cout << d[k] << '\n';
  }
}


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

vector<int> mizuyari(int l, int r, vector<int> h){
    if (r != -1) {
        for(int i = l; i < r; i++)
        {
            h.at(i)--;
        }
    }
    else
    {
        for(int i = l; i < h.size(); i++)
        {
            h.at(i)--;
        }
    }
    return h;
}

int main()
{
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++)
        cin >> h.at(i);
    int index = 0, index0 = 0, count = 0;
    while (true)
    {
        for (int i = 0; i < n; i++)
        {
            if (h.at(i) != 0)
            {
                index = i;
                break;
            }
            else if (i == n - 1) {
                cout << count << endl;
                return 0;
            }
        }

        for(int i = index + 1; i <= n; i++)
        {
            if (i == n) {
                index0 = -1;
                break;
            }
            else if (h.at(i) == 0){
                index0 = i;
                break;
            }
        }
        h = mizuyari(index, index0, h);
        count++;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main()
{
    vector<string> s(3);
    rep(i, 3) cin >> s[i];
    rep(i, 3) cout << s[i][0];
    cout << endl;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
p = list(map(int,input().split()))
summ = sum(p[i] for i in range(K))
sum_list = [summ]
maximum = 0

for i in range(N - K):
    summ += p[i + K] - p[i]
    sum_list.append(summ)

maximum = max(sum_list)

print("{}".format((maximum + K) / 2))

Measured memory_bytes: 24804
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <map>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
#define MOD 1000000007
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> p;
typedef vector<int> vi;
typedef map<string,int> ms;
int n,d,x,ans=0,eat,eatday;
vi a(105);
int main(int argc,char const* argv[])
{
  cin >> n >> d >> x;
  ans=x;
  for(int i=0;i<n;i++)
    {
      cin >> a[i];
    }
  for(int i=0;i<n;i++)
    {
      eatday=1;
      eat=0;
      while(d>=eatday)
	{
	  eatday+=a[i];
	  eat++;
	}
      ans+=eat;
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n, a, b = map(int, input().split())
total = 0
for i in range(1, n+1):
  total_digit = 0
  j = i
  while j > 0:
    total_digit += j % 10
    j //= 10
    if j == 0:
      if total_digit >= a and total_digit <= b:
        total += i
      break
    
print(total)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>

using namespace std;

int dp[3010][3010] = {0};
const int MOD = 998244353;

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

    vector<int> a(N+1);

    for(int i=1; i<=N; ++i){
        cin >> a[i]; 
    }

    //init 
    dp[0][0] =1;
    for(int i=1; i<=N; ++i){
        for(int j=0; j<=S; ++j){
            dp[i][j] = dp[i-1][j] *2;
            dp[i][j] %= MOD;
        }
        for(int j=0; j<=S; ++j){
            if(j + a[i] <= S){
                dp[i][j + a[i]] += dp[i-1][j];
                dp[i][j + a[i]] %= MOD;
            }
        }
    }

    cout << dp[N][S] << endl;;

}

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

typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;


//===

const ll mod = static_cast<ll>(1e9 + 7);



int main() {
	int n, a;
	cin >> n >> a;
	if (n < a) {
		cout << 0 << endl;
	}
	else {
		cout << 10 << endl;
	}
}

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

using namespace std;

using ll = long long;

//pair : first=V,second=length
using Graph = std::vector<std::vector<std::pair<ll, ll>>>;

enum Color {
    Unvisited,
    Black,
    White,
};

void dfs(const Graph &graph, std::vector<Color> &colors, const ll index, const ll dist) {
    for (const auto &n : graph[index]) {
        if (colors[n.first] != Unvisited) { continue; }
        if ((dist + n.second) % 2 == 0) {
            colors[n.first] = Black;
        } else {
            colors[n.first] = White;
        }
        dfs(graph, colors, n.first, dist + n.second);
    }
}

int main() {
    ll N;
    cin >> N;

    Graph graph(N);

    {
        ll u, v, w;
        for (ll i = 0; i < N - 1; ++i) {
            cin >> u >> v >> w;
            --u;
            --v;
            graph[u].emplace_back(std::make_pair(v, w));
            graph[v].emplace_back(std::make_pair(u, w));
        }
    }

    std::vector<Color> colors(N, Unvisited);
    dfs(graph, colors, 0, 0);

    for (const auto &c : colors) {
        cout << (c == White ? 0 : 1) << endl;
    }

    return 0;
}

Measured memory_bytes: 9600
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <string>
#include <cstdio>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstring>
#include <tuple>
#include <utility>
#include <list>
#include <cmath>
#include <unordered_map>

using namespace std;

typedef long long LL;
typedef vector<int> Array;
typedef pair<int, int> P;

const int INF = 1 << 29;
const LL MOD = 100000;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define all(c) (c).begin(), (c).end()

struct edge{ int to, cost; edge(int t, int c) :to(t), cost(c){} };

int dxk[] = { 1, 1, 1, 0, -1, 0 };
int dxg[] = { 0, 1, 0, -1, -1, -1 };
int dy[] = { -1, 0, 1, 1, 0, -1 };


int main()
{
	//FILE* fp_out = freopen("result.txt", "w", stdout);
	const int MOD = 10007;
	int n;
	unordered_map<char, int> table;
	table['J'] = 1;
	table['O'] = 2;
	table['I'] = 4;
	while (cin >> n && n)
	{
		vector<int> seki(n + 1);
		rep(i, n)
		{
			char c; cin >> c;
			seki[i + 1] = table[c];
		}
		
		vector<vector<int>> dp(n + 1, vector<int>(8));
		dp[0][table['J']] = 1;
		rep(i, n)
		{
			rep(j, 8)//from
			{
				rep(k, 8) if (dp[i][j] && (j & k) && (k & seki[i + 1]))
				{
					dp[i + 1][k] = (dp[i + 1][k] + dp[i][j]) % MOD;
				}
			}
		}
		cout << accumulate(all(dp[n]), 0) % MOD << endl;
	}
	return 0;
}

Measured memory_bytes: 1288