akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <cstring>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define ret0 return 0;
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


signed main() {
    ll n;
    string s;
    cin >> n >> s;
    if (s.size()%2 != 0){
        cout<<"No";
        ret0;
    }
    rep (i, s.size()/2) {
        if (s[i] != s[i+s.size()/2]) {
            cout<<"No";
        ret0;
        }
    }
    cout << "Yes";
    return 0;
}



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

int main(){
    int n;
    cin >> n;
    vector<int> a(n+1);
    rep(i, n ) cin >> a[i];
    a[n] = -1;
    int cnt = 1;
    int ans = 0;
    rep(i, n+1) {
        if ( a[i] == a[i+1] ) {
            ++cnt;
        }
        else {
            ans += cnt / 2;
            cnt = 1;
        }
//        cout << cnt << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 15 13:34:38 2020

@author: NEC-PCuser
"""

K, S = map(int, input().split())

count = 0
for i in range(K + 1):
    if S - i > 2 * K or S - i < 0:
        continue
    elif S - i <= K:
        count += (S - i + 1)
    else:
        for j in range(S - i + 1):
            if S - i - j > K or j > K:
                continue
            count += 1

print(count)
            

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

using ipair = pair<int,int>;

int INF = 1e9+7;

using ipair = pair<int,int>;
bool operator>(const ipair a,const ipair b){return a.first > b.first;}

int main(){

  int N;
  cin >> N;

  vector<int> a(N+1);
  vector<int> b(N+1);
  rep(i, N){
    cin >> a[i+1];
  }

  for(int i=N; i>=1; i--){
    int sum = 0;
    for(int j=i*2; j<=N; j+=i){
      sum ^= b[j];
    }
    b[i] = sum^a[i];
  }

  vector<int> vect;
  for(int i=1; i<=N; i++){
    if(b[i]) vect.push_back(i);
  }

  cout << vect.size() << endl;

  rep(i, vect.size()){
    printf("%d%c", vect[i], i+1==vect.size()?'\n':' ');
  }

  return 0;
}


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

int main(){
  int n;
  cin >> n;
  map<string,int> name;
  string s;
  vector<string> new_s;
  rep(i,n){
    cin >> s;
    if(name[s]==0)new_s.push_back(s);
    name[s]++;
  }

  int max=0;
  rep(i,new_s.size()){
    if(name[new_s[i]]>max)max=name[new_s[i]];
  }
  vector<string> max_s;
  rep(i,new_s.size()){
    if(name[new_s[i]]==max)max_s.push_back(new_s[i]);
  }

  sort(max_s.begin(),max_s.end());
  rep(i,max_s.size()){
    cout << max_s[i] << endl;
  }
}

Measured memory_bytes: 37480
#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

def main():
    n = int(input())
    p = list(map(int, input().split()))

    mi = 1000000000
    cnt = 0
    for i in range(n):
        if p[i] <= mi:
            cnt += 1
        if mi > p[i]:
            mi = p[i]
    print(cnt)

main()

Measured memory_bytes: 24772
#include<stdio.h>
int main(){
   int i,j,k,h,a[3];
   int b;
   int A,B,C;
   int N;

   scanf("%d",&N);
   for(h=0;h<N;h++){ 
   for(i=0;i<3;i++){
     scanf("%d",&a[i]);
   }

   for(j=0;j<3;j++){
     for(k=j+1;k<3;k++){
       if(a[j]<a[k]){
         b=a[j];
         a[j]=a[k];
         a[k]=b; 
       }
     }
   }
   
   A=a[0]*a[0];
   B=a[1]*a[1];
   C=a[2]*a[2];

   if(A==B+C){
     printf("YES\n");
   }

   else{
     printf("NO\n");
   }
   }

return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define M 1000000007
#define fr(i,a,b) for(i=a;i<=b;i++)
using namespace std;

int main() {
	int n,k,i,j,last,first;
cin>>n>>k;
int a[n+1];
int prefix[n+1][k+1],dp[n+1][k+1];
fr(i,1,n)cin>>a[i];
fr(i,0,n){dp[i][0]=prefix[i][0]=1;}
fr(i,1,k){dp[0][i]=0;}
fr(i,1,k){prefix[0][i]=1;}
fr(i,1,n){
	 fr(j,1,k){
	 	last=j-a[i]-1>=0?prefix[i-1][j-a[i]-1]:0;
	 	first=prefix[i-1][j];
	 	dp[i][j]=(first-last+M)%M;
	 	prefix[i][j]=(prefix[i][j-1]+dp[i][j])%M;
	 }
}
cout<<dp[n][k]<<endl;
	return 0;
}

Measured memory_bytes: 79104
package main

import (
        "fmt"
        "math"
)

func main() {
        var n int
        fmt.Scanf("%d", &n)
        fmt.Printf("%d\n", resolve(n))
}

func resolve(n int) int {
        min := math.MaxInt64
        lim := int(math.Sqrt(float64(n)))
        for i := 1; i <= lim; i++ {
                if n%i == 0 {
                        a, b := i, n/i
                        v := f(a, b)
                        if min > v {
                                min = v
                        }
                }
        }
        return min
}
func f(a, b int) int {
        return digits(max(a, b))
}
func max(a, b int) int {
        if a > b {
                return a
        }
        return b
}

func digits(n int) (d int) {
        return digitsWithBase(n, 10)
}
func digitsWithBase(n int, b int) (d int) {
        tmp := n
        for tmp > 0 {
                d++
                tmp /= b
        }
        return
}

Measured memory_bytes: 512
#include<stdio.h>
#include<math.h>
int checkcan(long can)
{
  long m=floor(sqrt(can));
  if (m*m==can) return 1;
  return 0;
}
int main()
{
  int i,j,k,n,d,x[10][10];
  long can=0,dem=0;
  scanf("%d%d", &n, &d);
  for (i=0; i<n; i++)
    for (j=0; j<d; j++)
       scanf("%d", &x[i][j]);
  for (i=0; i<n; i++)
    { 
       for (k=i+1; k<n; k++)
         {
           can=0;
           for (j=0; j<d; j++)
             {
               can += (x[i][j]-x[k][j])*(x[i][j]-x[k][j]);
             }
           if (checkcan(can)==1) dem++;
         }
    }
  printf("%ld", dem);
  return 0;
}

Measured memory_bytes: 128
import math
import random
from operator import itemgetter
import re
import sys
from itertools import accumulate
from collections import defaultdict
from collections import deque
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
input = sys.stdin.readline
N,M= map(int,input().split())
if N>9 or M>9:
    print(-1)
else:
    print(N*M)

Measured memory_bytes: 6684
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int main() {
	lint N, Q;
	cin >> N >> Q;

	vector<vector<lint>>A(N);

	rep(i, Q) {
		lint a;
		cin >> a;
		if (a == 0) {
			lint t;
			cin >> t;
			lint x;
			cin >> x;
			A[t].push_back(x);
		}
		else if (a == 1) {
			lint t;
			cin >> t;
			rep(j, A[t].size()) {
				cout << A[t][j];
				if (j != A[t].size()-1) {
					cout << ' ';
				}
			}
			cout << endl;
		}
		else if (a == 2) {
			lint t;
			cin >> t;
			if (!A[t].empty()) {
				A[t].clear();
			}
		}
	}
}




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

#define ll long long
#define pb push_back
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cerr << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);

void solve() {
    char ch;
    cin >> ch;
    int x = ch - 'A';
    if(x >= 0 && x <= 25) {
        cout << 'A';
    }
    else cout << 'a';
}

int main() {
    int t = 1;
    //cin >> t;
    // Please remember to uncomment for taking test cases
    for(int i = 1; i<=t; i++) {
        solve();
    }
    return 0;
}


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

using namespace std;

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

	map<int, int> f;

	for (int x = 1; x <= N; ++x) {
		int y = x;
		for (int i = 2; i * i <= y; ++i) {
			while (y % i == 0) {
				++f[i];
				y /= i;
			}
		}
		if (y != 1) {
			++f[y];
		}
	}

	int ans = 0;
	vector<int> v;
	for (const auto &e : f) {
		if (e.second >= 2) {
			v.push_back(e.first);
		}
	}

	for (int a : v) {
		if (f[a] >= 74) {
			++ans;
		}
		for (int b : v) {
			if (a != b) {
				if (f[a] >= 2 && f[b] >= 24) {
					++ans;
				}
				if (f[a] >= 4 && f[b] >= 14) {
					++ans;
				}
			}
			if (a < b) {
				for (int c : v) if (c != a && c != b) {
					if (f[a] >= 4 && f[b] >= 4 && f[c] >= 2) {
						++ans;
					}
				}
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
#define LL long long
#define Num 1000000007
// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

bool eval(int num)
{
    bool hoge = false;
    if (num == 0)
        return true;
    if (num >= 4)
    {
        hoge = eval(num - 4);
        if (hoge)
            return true;
    }
    if (num >= 7)
    {
        hoge = eval(num - 7);
        if (hoge)
            return  true;
    }
    return false;
}

int main()
{

    int n;
    cin >> n;
    if (eval(n))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
main :: IO ()
main = do
  l1 <- getLine
  l2 <- getLine
  let a = map read $ words l2 :: [Integer]
  print $ f 1 a

f y [] = if y > 10^18 then -1 else y
f y (x:xs) = if y > 10^18 then (if 0 `elem` xs then 0 else -1) else f (y*x) xs


Measured memory_bytes: 64072
n = [input() for _ in range(int(input()))]
m = [input() for _ in range(int(input()))]

l = n.copy()
l.extend(m)
l = set(l)

prize = [n.count(cand_i) - m.count(cand_i) for cand_i in l]
print(max(0, max(prize)))

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int main(void) {
    int N;
    cin>>N;
    vector<pair<Int,Int> > AB;

    for(int i = 0;i < N;i++) {
        Int a,b;
        cin>>a>>b;
        AB.push_back({b,a});
    }
    
    Int c = 0;
    sort(AB.begin(),AB.end());
    for(auto u: AB) {
        if(u.second+c > u.first) {
            cout<<"No"<<endl;

            return 0;
        }
        c += u.second;
    }

    cout<<"Yes"<<endl;

    return 0;
}





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

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

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif


void solve(ll N, ll M, vector<ll> a, vector<ll> b) {
    vector<pair<ll, ll> > es;
    for (int i = 0; i < a.size(); i++) {
        es.push_back({b[i], a[i]});
    }
    sort(es.begin(), es.end());
    ll mx = -1;
    int c = 0;
    for (int i = 0; i < es.size(); i++) {
        if (mx < es[i].second) {
            mx = es[i].first - 1;
            c++;
        }

    }

    cout << c << endl;
}


void main_(istream &cin) {
    ll N;
    ll M;
    cin >> N;
    cin >> M;
    vector<ll> b(M - 1 + 1);
    vector<ll> a(M - 1 + 1);
    for (int i = 0; i <= M - 1; i++) {
        cin >> a[i];
        cin >> b[i];
    }
    solve(N, M, a, b);
}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}





Measured memory_bytes: 5620
#include<iostream>

using namespace std;
int main(){
    int cards[4][13];
    char ch;
    int i,j,k,l,m,x,n;
    for(l=0;l<4;l++){
        for(m=0;m<13;m++){
            cards[l][m]=0;
        }
    }
    cin >> n;
    for(i=0;i<n;i++){
        cin >> ch >> x;
        if(ch=='S'){
            cards[0][x-1] = 1;
        }
        if(ch=='H'){
            cards[1][x-1] = 1;
        }
        if(ch=='C'){
            cards[2][x-1] = 1;
        }
        if(ch=='D'){
            cards[3][x-1] = 1;
        }
    }
    for(j=0;j<4;j++){
        for(k=0;k<13;k++){
            if(cards[j][k]!=1){
                if(j==0){
                    cout << "S " << k+1 << endl;
                }
                if(j==1){
                    cout << "H "<< k+1 << endl;
                }
                if(j==2){
                    cout << "C " << k+1 << endl;
                }
                if(j==3){
                    cout << "D " << k+1 << endl;;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3088
use std::io::{BufRead, Write};
use std::io;

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut s = String::new();
    input.read_line(&mut s).unwrap();
    let _: usize = s.trim().parse().unwrap();
    s.clear();
    input.read_line(&mut s).unwrap();
    let a: Vec<u64> = s.split_whitespace().map(|s| s.parse().unwrap()).collect();
    writeln!(output, "{}", {
        let result: u64 = a.iter().max().unwrap() - a.iter().min().unwrap();
        result
    })
            .unwrap();
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v: Vec<u8> = Vec::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }
    #[test]
    fn case1() {
        test("4
2 3 7 9\n",
             "7\n");
    }
    #[test]
    fn case2() {
        test("8
3 1 4 1 5 9 2 6\n",
             "8\n");
    }
}



Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <unordered_map>
using namespace std;
unordered_map<int,int> mp;
int N ,M, A[200020], B [200020];
#define rep(i,n) for(int i=0;i<n;i++)
int main(void)
{
  int a,b,chk=0;
  cin >> N >> M;
  rep(i,M) {
    cin >> a >> b;
//    cout << a << " " << b << " " << mp[a] << " " << mp[b] << endl;
    if(a==1) {
      if(mp[b]==N) {
          chk=1;
      }
      mp[b]=1;
    }
    if(b==N) {
      if(mp[a]==1){
        chk=1;
      }
      mp[a]=N;
    }
    if(chk==1) {
      puts("POSSIBLE");
      return 0;
    }
  }
  puts("IMPOSSIBLE");
}








Measured memory_bytes: 8520
#include<stdio.h>
#define MaxSize 2000
int A[MaxSize];
int n;
int solve(int i, int m) {
	if (m == 0) return 1;
	if (i > n)return 0;

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

	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &A[i]);
	}
	scanf("%d", &q);
	for (int i = 0; i < q; i++) {
		scanf("%d", &m);
		if (solve(0, m))
			printf("yes\n");
		else
			printf("no\n");
	}
	return 0;
}

Measured memory_bytes: 2692
#include<bits/stdc++.h>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main()
{
    int n,m;
    cin >> n >> m;
    int s[m];
    char c[m];
    F(i,0,m) cin >> s[i] >> c[i];

    int start;
    if(n==1) start=0;
    else start=pow(10,n-1);
    int end=pow(10,n);

    for(int i=start;i<end;++i){
        bool f=true;
        string str=to_string(i);

        F(j,0,m){
            if(str[s[j]-1] != c[j]){
                f=false;
            }
        }

        if(f){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> v(N);
  for (int& x : v) cin >> x;
  const int n = min(N, K);
  int ans = -2e9;
  for (int a = 0; a <= n; a++) {
    for (int b = 0; a + b <= n; b++) {
      const int c = K - a - b;
      vector<int> t;
      for (int i = 0; i < a; i++) t.push_back(v[i]);
      for (int i = 0; i < b; i++) t.push_back(v[N - i - 1]);
      sort(t.begin(), t.end());
      int s = 0;
      for (int& x : t) s += x;
      for (int i = 0; i < c && i < t.size() && t[i] < 0; i++) s -= t[i];
      ans = max(ans, s);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()

signed main() {
	int n, a;
	std::cin >> n >> a;
	std::vector<int> x(n);
	rep(i,n) std::cin >> x[i];
	std::vector<std::vector<std::vector<int> > > dp(n+1, std::vector<std::vector<int> >(50*50+1,std::vector<int>(n+1,0)));
	dp[0][0][0] = 1;
	for(int i=0;i<n;i++) {
		for(int j=0;j<=50*50;j++) {
			for(int k=0;k<n;k++) {
				if(dp[i][j][k]==0) continue;
				dp[i+1][j+x[i]][k+1] += dp[i][j][k];
				dp[i+1][j][k] += dp[i][j][k];
			}
		}
	}
	int count = 0;
	for(int j=1;j<=n;j++) {
		count+=dp[n][j*a][j];
	}
	print(count);

	return 0;
}


Measured memory_bytes: 56064
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	string s;
	cin >> s;
	if (s.find("YAKI") == 0)
		Yes();
	else
		No();

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
   int x, y;
   int i,cnt = 0;

   scanf("%d %d",&x, &y);

   while(i <= x) {
      if(y == 2*i + 4*(x-i)) {
         cnt = 1;
      }
      i++;
   }

   if(cnt == 1) {
      printf("Yes");
   } else {
      printf("No");
   }

   return 0;
}

Measured memory_bytes: 1736
import sys
from heapq import heappop, heappush
from operator import itemgetter
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9 + 7
INF = float('inf')

def sol():
    N = int(input())

    for i in range(1, 101):
        if N % i == 0:
            M = N // i
            if 1 <= M <= 9 and 1 <= i <= 9:
                print('Yes')
                return
    print('No')


sol()

Measured memory_bytes: 3444
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define db long double
# define scn(x) scanf("%I64d",&x)
# define scan(x) scanf("%d",&x)
# define print(x) printf("%d ",x)
# define prnt(x) printf("%I64d ",x);
# define eol printf("\n")
# define IOS ios_base :: sync_with_stdio(0)
# define pe "Possible"
# define ie "Impossible"
# define halt(...) {fo << (__VA_ARGS__) << '\n';exit(0);}
# define rep1(n) for (int qwerty = 1;qwerty <= n;++qwerty)
# ifdef CF
# define DEBUG
# endif // CF
# ifdef DEBUG
# define pp(n) cerr << #n << " = " << n << '\n'
# define ppp(v) for (auto it : v) cerr << it << ' ';cerr << '\n'
# define aprint(x,y,z) for (int i = x;i <= y;++i) cerr << z[i] << ' ';cerr << '\n'
# else
# define pp(n) ;
# define ppp(v) ;
# define aprint(x,y,z);
# endif // DEBUG
# define rep(n) for (int i = 1;i <= n;++i)
const int mod = 1e9 + 7;
int s[1 << 20];
int main(void)
{
    # ifdef CF
    freopen("input","r",stdin);
    # endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n;
    fi>>n;n <<= 1;
    for (int i = 1;i <= n;++i)
        fi>>s[i];
    sort(s+1,s+1+n);
    int ans = 0;
    for (int i = 1;i < n;i += 2)
        ans += s[i];
    fo << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <queue>

using namespace std; 

typedef pair<int,int> P;

int W,H;

bool pass[900][900];

//スタートからの距離
int d[50][50];

//上下左右
const int dw[4]={0,0,-1,1};
const int dh[4]={-1,1,0,0};

const int INF=10000;

int main(){

	int n;
	while(cin>>n,n){
		long long res=0;
		vector<long long> sum;
		sum.push_back(0);
		for(int i=1;i<=n;i++) sum.push_back(i+sum[i-1]);
/*
		for(int i=0;i<sum.size();i++){
			cout<<sum[i]<<" ";
		}
		cout<<endl;
*/
		for(int i=2;i<sum.size();i++){
			for(int j=i;j<sum.size();j++){
				if(sum[j]-sum[j-i]==n){res++; break;}
			}
		}

		cout<<res<<endl;

	}

	return 0;
}

Measured memory_bytes: 1232
import collections

N = int(input())
a = []
for i in range(N):
  a.append(str(input()))
a = collections.Counter(a)
b = max(a.values())
max_k_list = [kv[0] for kv in a.items() if kv[1] == b]
max_k_list = sorted(max_k_list)
for i in max_k_list:
  print(i)

Measured memory_bytes: 35572
N = int(input())
B = list(map(int,input().split()))

A = [0]*N
A[0] = B[0]
A[1] = B[0]
for i in range(1,N-1):
    A[i] = min(B[i-1],B[i])
A[N-1] = B[N-2]

print(sum(A))


Measured memory_bytes: 3060
package main

import (
    "fmt"
)

func main(){
    var H, N int
    fmt.Scan(&H, &N)

    A := make([]int, N)

    for i:=0; i<N; i++{
        fmt.Scan(&A[i])
    }

    for i:=0; i<N; i++{
        H -= A[i]
    }

    if H<=0{
        fmt.Println("Yes")
    }else{
        fmt.Println("No")
    }
    
    
}


Measured memory_bytes: 5504
x1,y1,x2,y2 = map(int,input().split())
x3 = x2-(y2-y1)
y3 = y2+(x2-x1)
x4 = x1-(y2-y1)
y4 = y1+(x2-x1)
print(x3,y3,x4,y4)

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

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;

struct edge {
    i64 from, to, cost;
    edge(i64 from, i64 to) : from(from), to(to), cost(1) {}
    edge(i64 from, i64 to, i64 cost) : from(from), to(to), cost(cost) {}
};
using Graph = vector<vector<edge>>;

constexpr i64 INF = std::numeric_limits<i64>::max();
constexpr i64 SINF = std::numeric_limits<i64>::max() / 10;
const i64 dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
//const i64 dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//const i64 dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//const i64 dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

#define rep(i, n) for(i64 i = 0; i < n; ++i)

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

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    vector<tuple<i64, i64, i64>> v;
    i64 n;
    cin >> n;
    rep(i, n){
        i64 a, b, c;
        cin >> a >> b >> c;
        vector<i64> t = {a, b, c};
        sort(t.begin(), t.end());
        v.emplace_back(t[0], t[1], t[2]);
    }
    sort(v.begin(), v.end());
    i64 ans = 0;
    rep(i, n){
        if(i != 0 && v[i] == v[i - 1]) ++ans;
    }
    cout << ans << endl;
}

// 1 2 1 2


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

constexpr int MAX_N = 100100;
constexpr long long INF = 1e18;

int main() {
    int n, k;
    cin >> n >> k;
    vector<long long> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    
    long long dp[MAX_N];
    fill(dp, dp + MAX_N, INF);
    dp[0] = 0;
    
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < min(n, i + k + 1); j++) {
            dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
        }
    }
    
    cout << dp[n-1] << '\n';
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int selectionSort(int* list, int size);

int main() {
	int n, * a;
	scanf("%d", &n);
	a = malloc(n * sizeof(int));

	for (int i = 0; i < n; i++)
		scanf("%d", a + i);

	int count = selectionSort(a, n);

	for (int i = 0; i < n; i++)
		printf("%d%c", *(a + i), i < n - 1 ? ' ' : '\n');
	printf("%d\n", count);

	return 0;
}

int selectionSort(int* list, int size) {
	int count = 0;
	for (int i = 0; i < size; i++) {
		int min = INT_MAX, index = i, temp = 0;
		for (int j = i; j < size; j++) {
			if (list[j] < min) {
				min = list[j];
				index = j;
			}
		}
		if (index != i) {
			temp = list[i];
			list[i] = list[index];
			list[index] = temp;
			count++;
		}
	}
	return count;
}


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

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

  int ans = 0;
  for( char c : w ){
    ans ^= c;
  } 

  std::cout << ( (!ans)? "Yes" : "No" ) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

const ll MOD = 1000000007LL;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

template<typename T = ll> class UnionFind {
public:
	UnionFind( T n ) { rep( i, n ) { par[i] = i; siz[i] = 1; } }
	T find( T x ) { if ( x == par[x] ) return ( x ); else return( par[x] = find( par[x] ) ); }
	void unite( T x, T y ) { T xx = find( x ); T yy = find( y ); if ( xx == yy ) return;
		if ( siz[xx] <= siz[yy] ) swap( xx, yy ); par[yy] = xx; siz[xx] += siz[yy]; }
private:
	vector<T> par, siz;
};

template<typename T = ll> T binpow( T a, T b, T m = MOD ) {
	T res = 1;
	while ( b > 0 ) { if ( b & 1 ) res = res * a % m;
		a = a * a % m; b >>= 1; }
	return ( res );
}


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

	cout << ( 180 * ( N - 2 ) ) << endl; 

	return ( 0 );
}


Measured memory_bytes: 888
package main

import (
	"fmt"
)

func main() {

	var t string
	fmt.Scan(&t)

	for i := 0; i < len(t); i++ {
		if string(t[i]) == "P" || string(t[i]) == "D" {
			fmt.Print(string(t[i]))
		} else {
			fmt.Print("D")
		}
	}
}


Measured memory_bytes: 6260
#include <stdio.h>

int main() {
  int number_n, number_m, point_x, point_y, max_x, min_y, temp, i;
  scanf("%d %d %d %d", &number_n, &number_m, &point_x, &point_y);
  max_x = point_x;
  min_y = point_y;
  for(i = 0; i < number_n; i++) {
    scanf("%d", &temp);
    if(max_x < temp) max_x = temp;
  }
  for(i = 0; i < number_m; i++) {
    scanf("%d", &temp);
    if(min_y > temp) min_y = temp;
  }
  if(max_x < min_y) {
    printf("No War\n");
  } else {
    printf("War\n");
  }
  return 0;
}


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

const int mod = 1e9 + 7;


int main(){
	int a, b;
	cin >> a >> b;
	if (a == 1)a += 50;
	if (b == 1)b += 50;
	if (a > b)cout << "Alice" << endl;
	else if (a < b)cout << "Bob" << endl;
	else cout << "Draw" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    ll N;
    cin >> N;
    vector<Pll> ball(N);
    ll uppermax=0,uppermin=INF,lowermax=0,lowermin=INF;
    ll maxid,minid;
    rep(i,N){
        ll x,y;
        cin >> x >> y;
        if (x<y) swap(x,y);
        if (chmax(uppermax,x)) maxid=i;
        chmin(uppermin,x);
        chmax(lowermax,y);
        chmin(lowermin,y);
        ball[i]=Pll(x,y);
    }
    ll ans=(uppermax-uppermin)*(lowermax-lowermin);
    ll restmin=INF;
    rep(i,N){
        if (i==maxid) continue;
        if (chmin(restmin,ball[i].second)) minid=i;
    }
    if (ball[minid].second<lowermin){
        cout << ans << endl;
        return 0;
    }
    ll a=ball[maxid].second,b=ball[minid].first;
    ll rangemin=min(a,b),rangemax=max(a,b);
    vector<Pll> outofrange;
    ll newrangemin=rangemin,newrangemax=rangemax;
    rep(i,N){
        if (i==maxid||i==minid) continue;
        ll x=ball[i].first,y=ball[i].second;
        if (!(rangemin<=x&&x<=rangemax)&&!(rangemin<=y&&y<=rangemax)){
            chmin(newrangemin,x);
            chmax(newrangemax,y);
        }
    }
    rangemin=newrangemin,rangemax=newrangemax;
    rep(i,N){
        if (i==maxid||i==minid) continue;
        ll x=ball[i].first,y=ball[i].second;
        if (!(rangemin<=x&&x<=rangemax)&&!(rangemin<=y&&y<=rangemax)){
            outofrange.push_back(Pll(x,y));
        }
    }
    sort(outofrange.begin(),outofrange.end());
    reverse(outofrange.begin(),outofrange.end());
    int s=outofrange.size();
    if (s==0){
        cout << min(ans,(uppermax-lowermin)*(rangemax-rangemin)) << endl;
        return 0;
    }
    outofrange.push_back(Pll(rangemax,rangemin));
    ll Left=rangemin;
    rep(i,s){
        ll Right=outofrange[i+1].first,y=outofrange[i].second;
        chmin(Left,y);
        chmin(ans,(uppermax-lowermin)*(Right-Left));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
import sys
import bisect
input = sys.stdin.readline

a,b,q = map(int,input().split())

ans = 10**100

s = [-ans] + [int(input()) for i in range(a)] + [ans]
t = [-ans] + [int(input()) for i in range(b)] + [ans]
#x = [int(input()) for i in range(q)]


ans = 10**100

for i in range(q):
    x = int(input())
    ans = 10**100
    s_idx = bisect.bisect_left(s,x)
    t_idx = bisect.bisect_left(t,x)
    s_idx -= 1
    t_idx -= 1
    #print(x[i],s_idx,t_idx)
    for j in s[s_idx+0],s[s_idx+1]:
        for k in t[t_idx+0],t[t_idx+1]:
            ans = min(ans,abs(x - j) + abs(j - k),abs(x - k) + abs(j - k))
            
    print(ans)

Measured memory_bytes: 75228
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<> a(n);
  for (int i = 0; i < n - 1; ++i) {
    int u, v, x; cin >> u >> v >> x;
    a[u] ^= x;
    a[v] ^= x;
  }
  V<> c(16);
  for (int i = 0; i < n; ++i) {
    ++c[a[i]];
  }
  c[0] = 0;
  int res = 0;
  for (int i = 0; i < 16; ++i) {
    res += c[i] >> 1;
    c[i] &= 1;
  }
  while (accumulate(begin(c), end(c), 0)) {
    int k = count_if(begin(c), end(c), [](int x) { return x; });
    if (k < 3) {
      assert(k == 2);
      ++res;
      break;
    }
    [&] {
      for (int i = 0; i < 16; ++i) if (c[i]) {
        for (int j = i + 1; j < 16; ++j) if (c[j]) {
          if (c[i ^ j]) {
            c[i] = c[j] = c[i ^ j] = 0;
            res += 2;
            return;
          }
        }
      }
      for (int i = 0; i < 16; ++i) if (c[i]) {
        for (int j = i + 1; j < 16; ++j) if (c[j]) {
          c[i] = c[j] = 0;
          ++c[i ^ j];
          ++res;
          return;
        }
      }
    }();
  }
  cout << res << '\n';
}

Measured memory_bytes: 640
# Aizu Problem 00151: Grid
#
import sys, math, os, bisect

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def grid_length(n, grid):
    L = 0
    for row in grid:
        L = max(L, max([len(_) for _ in row.split('0')]))
    for c in range(n):
        col = ''.join([grid[r][c] for r in range(n)])
        L = max(L, max([len(_) for _ in col.split('0')]))
    for row in range(-n, 2 * n):
        diag = ''.join([grid[row+c][c] for c in range(n) if 0 <= row + c < n])
        L = max(L, max([len(_) for _ in diag.split('0')]))
        diag = ''.join([grid[row-c][c] for c in range(n) if 0 <= row - c < n])
        L = max(L, max([len(_) for _ in diag.split('0')]))
    return L

while True:
    n = int(input())
    if n == 0:
        break
    grid = [input().strip() for _ in range(n)]
    print(grid_length(n, grid))

Measured memory_bytes: 7884
import java.util.ArrayList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	@SuppressWarnings("unchecked")
	private void run() {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			int m = scanner.nextInt();
			if ((n | m) == 0)
				break;
			List<Edge>[] lists = new ArrayList[n];
			for (int i = 0; i < n; i++) {
				lists[i] = new ArrayList<Edge>();
			}
			for (int i = 0; i < m; i++) {
				int from = scanner.nextInt() - 1;
				int to = scanner.nextInt() - 1;
				int cost = scanner.nextInt();
				lists[from].add(new Edge(to, cost));
				lists[to].add(new Edge(from, cost));
			}
			int g = n - 1;
			PriorityQueue<Edge> pq = new PriorityQueue<Edge>();
			pq.offer(new Edge(0, 0, 2));
			boolean[][] b = new boolean[3][n];
			b[0][0] = true;
			while (!pq.isEmpty()) {
				Edge edge = pq.poll();
				if (edge.to == g && edge.ticket != 1) {
					System.out.println(edge.cost);
					break;
				}
				if (b[edge.ticket][edge.to])
					continue;
				b[edge.ticket][edge.to] = true;

				for (Edge e : lists[edge.to]) {
					if (edge.ticket == 1) {
						pq.offer(new Edge(e.to, edge.cost, 0));
					} else {
						if (edge.ticket == 2) {
							pq.offer(new Edge(e.to, edge.cost, 1));
						}
						pq.offer(new Edge(e.to, edge.cost + e.cost, edge.ticket));
					}
				}
			}
		}
	}

	class Edge implements Comparable<Edge> {
		int to, cost, ticket;

		public Edge(int to, int cost, int ticket) {
			super();
			this.to = to;
			this.cost = cost;
			this.ticket = ticket;
		}

		public Edge(int to, int cost) {
			super();
			this.to = to;
			this.cost = cost;
		}

		@Override
		public String toString() {
			return "Edge [to=" + to + ", cost=" + cost + ", ticket=" + ticket
					+ "]";
		}

		@Override
		public int compareTo(Edge o) {
			if (this.cost == o.cost)
				return o.to - this.to;
			return this.cost - o.cost;
		}

	}
}

Measured memory_bytes: 33684
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int main(){
    int k,a,b;
    cin>>k>>a>>b;
    cout<<((b/k-(a-1)/k>=1)?"OK":"NG")<<endl;
    return 0;
}

Measured memory_bytes: 3636
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repr(i,a,b) for(int i=a,i > b;--i)
#define mm(lamb, tttt) memset(lamb, tttt, sizeof lamb)

#define null NULL
#define eps 0.000000001
#define mod 1000000007
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define sz(V) (ll)V.size()
#define _ <<" "<<

#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <iterator>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <limits.h>
#include <iomanip>
#include <cctype>
#include <numeric>
#include <complex>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef pair <double, double> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<int> vii;

ll a[301][301];
bool road[301][301];
int main(){
	int n;
	cin>>n;
	rep(i,0,301) rep(j,0,301) road[i][j]=1;
	rep(i,0,n) rep(j,0,n) cin>>a[i][j];
	rep(i,0,n)
		rep(j,0,n)
			rep(k,0,n){
				if(k==j || k==i ) continue;
				if(a[i][j] > a[i][k]+a[k][j]){
					cout<<-1<<endl;
					return 0;
				}
				if(a[i][j] == a[i][k]+a[k][j]) road[i][j]=false;
			}
	ll ans=0;
	rep(i,0,n)
		rep(j,0,n){
			if(road[i][j]) ans+=a[i][j];
		}		
	cout<<ans/2<<endl;	
}



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

using namespace std;

const int N = 1e3 + 5, M = 1e6 + 6, OO = 0x3f3f3f3f;

long long x, last, init = 100, cnt;
int main()
{
	cin >> x;
	while(init < x && init > last)
	{
		last = init;
		init += (init / 100);
		++cnt;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3584
def search(pat, s):
    """find a pattern 'pat' in a ring shaped text 's'
    len(s) >= len(p) and both s and p consists of lowercase characters.

    >>> search('a', 'a')
    True
    >>> search('advance', 'vanceknowledgetoad')
    True
    >>> search('advanced', 'vanceknowledgetoad')
    False
    """
    return pat in s + s


def run():
    s1 = input()
    s2 = input()

    if search(s2, s1):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    run()



Measured memory_bytes: 5572
#include <stdio.h>
#include <math.h>

int main(){
  int n, y, b, t, i, res;
  double p, r;
  while(scanf("%d", &n) && n){
    scanf("%d", &y);
    p = 0;
    for(i = 0; i < n; ++i){
      scanf("%d%lf%d", &b, &r, &t);
      if(t == 2 && p < pow(1 + r / 100, y)){
        res = b; p = pow(1 + r / 100,y);}
      else if(t == 1 && p < 1 + y * r / 100){
        res = b;p = 1 + y * r / 100; }
    }

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

Measured memory_bytes: 720
#include<cstdio>
typedef long long ll;
const int N=2e5+3,K=19,M=924844033,G=5;
inline int Pow(int a,int m){int s=1;for(;m;m>>=1)m&1?s=(ll)s*a%M:0,a=(ll)a*a%M;return s;}
struct edge{int v,nxt;}g[N+N];
int n,f[N],invf[N],b[N],siz[N],head[N],k,t0[1<<K],t1[1<<K],rev[1<<K];
inline void Insert(int u,int v){g[++k]=(edge){v,head[u]};head[u]=k;}
void Dfs(int u,int fa){
	int v;
	siz[u]=1;
	for(int i=head[u];i;i=g[i].nxt)if((v=g[i].v)!=fa)
	  Dfs(v,u),siz[u]+=siz[v];
	if(fa)b[siz[u]]++,b[n-siz[u]]++; 
}
inline void Init(int K){
	for(int i=0;i<(1<<K);i++)rev[i]=rev[i>>1]>>1|(i&1)*(1<<K-1);
}
inline void Ntt(int*a,int f,int K){
	int tmp,tmp1,omega;
	for(int i=0;i<(1<<K);i++)if(i<rev[i])tmp=a[i],a[i]=a[rev[i]],a[rev[i]]=tmp;
	for(int k=1;k<(1<<K);k<<=1){
	  omega=Pow(G,f>0?M/2/k:M-1-M/2/k);
	  for(int i=0;i<(1<<K);i+=k+k)
		for(int j=0,s=1;j<k;j++,s=(ll)s*omega%M)
		  tmp=a[i+j],tmp1=(ll)a[i+k+j]*s%M,
		  a[i+j]=(tmp+tmp1)%M,a[i+k+j]=(tmp-tmp1+M)%M;
	  }
	if(f<0){
	  tmp=Pow(1<<K,M-2);
	  for(int i=0;i<(1<<K);i++)
		a[i]=(ll)a[i]*tmp%M;
	}
}
int main(){
	int u,v;
	scanf("%d",&n);
	f[0]=1;
	for(int i=1;i<=n;i++)f[i]=(ll)f[i-1]*i%M;
	invf[n]=Pow(f[n],M-2);
	for(int i=n;i;i--)invf[i-1]=(ll)invf[i]*i%M;
	for(int i=1;i<n;i++)scanf("%d%d",&u,&v),Insert(u,v),Insert(v,u);
	Dfs(1,0);
	for(int i=1;i<=n;i++)t0[i]=(ll)b[i]*f[i]%M;
	for(int i=0;i<=n;i++)t1[i]=invf[n-i];
	for(k=1;(1<<k)<=n+n;k++);
	Init(k);
	Ntt(t0,1,k),Ntt(t1,1,k);
	for(int i=0;i<(1<<K);i++)t0[i]=(ll)t0[i]*t1[i]%M;
	Ntt(t0,-1,k);
	for(int k=1;k<=n;k++)printf("%lld\n",((ll)n*f[n]%M*invf[k]%M*invf[n-k]%M-(ll)invf[k]*t0[n+k]%M+M)%M);
	return 0;
}

Measured memory_bytes: 23168
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-04-12 15:24:34
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  string s; cin >> s;
  int64 k; cin >> k;

  if (s[0] == '1') {
    int pos = 0;
    for (int i = 0; i < (int)s.size(); ++i) {
      if (s[i] != '1') {
        pos = i; break;
      }
    }
    debug(pos);
    if (k - 1 < pos) {
      cout << 1 << endl;
    } else {
      cout << s[pos] << endl;
    }
  } else {
    cout << s[0] << endl;
  }

  return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }

    int ans = 0;
    while (true) {
        int idx = 0;
        for (int i = 0; i < n; i++) {
            if (h[idx] < h[i]) idx = i;
        }
        if (h[idx] == 0) break;
        for (int i = idx + 1; i < n; i++) {
            if (h[i] != h[idx]) break;
            h[i]--;
        }
        h[idx]--;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256