akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int N = 100010, INIT_VALUE = 0;
struct Tree{
    int sum;
    int left, right;
};
vector<Tree>nodes(4*N);
int getSum(int root, int left, int right){
    if(left <= nodes[root].left and right >= nodes[root].right){
        return nodes[root].sum;
    }
    int mid = (nodes[root].left + nodes[root].right) >> 1;
    if(right <= mid){
        return getSum(2*root, left, right);
    }
    if(left > mid){
        return getSum(2*root+1, left, right);
    }
    return getSum(2*root, left, mid) + getSum(2*root+1, mid+1, right);
}
void update(int root, int index, int x){
    if(nodes[root].left == nodes[root].right){
        nodes[root].sum += x;
        return;
    }
    int mid = (nodes[root].left + nodes[root].right) >> 1;
    if(index <= mid){
        update(2*root, index, x);
    }
    else{
        update(2*root+1, index, x);
    }
    nodes[root].sum = nodes[root*2].sum + nodes[root*2+1].sum;
}
void createTree(int root, int left, int right){
    nodes[root].left = left;
    nodes[root].right = right;
    if(left == right){
        nodes[root].sum = INIT_VALUE;
        return;
    }
    int mid = (left + right) >> 1;
    createTree(root*2, left, mid);
    createTree(root*2+1, mid+1, right);
    nodes[root].sum = nodes[root*2].sum + nodes[root*2+1].sum;
}
int main(){
    int n, q;
    scanf("%d %d", &n, &q);
    createTree(1, 1, n);
    for(int i = 0; i < q; i++){
        int com;
        scanf("%d", &com);
        if(com == 1){// getSum(s, t)
            int s, t;
            scanf("%d %d", &s, &t);
            cout << getSum(1, s, t) << endl;
        }
        else{// update(index, x)
            int index, x;
            scanf("%d %d", &index, &x);
            update(1, index, x);
        }
    }
    return 0;
}



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

int main(){
    int n, k, x;
    double p;
    double ans = 0;
    cin >> n >> k;
    for(int i = 1; i <= n; i++){
        x = i;
        p = 1.0 / n;
        while(x < k){
            p *= 0.5;
            x *= 2;
        }
        ans += p;
    }
    cout << fixed << setprecision(10) << ans << endl;
}


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

int n;
vector<long long> a, b, v;

long long solve();

int main() {
  cin >> n;
  a.resize(n);
  for (auto& p : a) cin >> p;
  b.resize(n);
  for (auto& p : b) cin >> p;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long res = 0, cnt = 0;
  for (int i = 0; i < n; ++i)
    if (a[i] > b[i])
      v.push_back(a[i] - b[i]);
    else if (a[i] < b[i]) {
      cnt += b[i] - a[i];
      ++res;
    }
  sort(v.begin(), v.end(), greater<long long>());
  for (auto p : v)
    if (cnt) {
      cnt -= min(cnt, p);
      ++res;
    }
  if (cnt > 0) return -1;
  return res;
}

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

int main(){

	int a, b;
	char op;

	cin >> a >> op >> b;

	while(op != '?'){
		if(op == '+') cout << a + b << endl;
		if(op == '-') cout << a - b << endl;
		if(op == '*') cout << a * b << endl;
		if(op == '/') cout << a / b << endl;

		cin >> a >> op >> b;
	}

	return 0;
}


Measured memory_bytes: 3096
'use strict'

// 比較関数の作成
function compare(a,b) {
  let r = 0;

  if(a.city < b.city){
  r = -1;
  }
  else if(a.city > b.city){
    r = 1;
  }
  else if(a.point < b.point){
  r = 1;
  }
  else if(a.point > b.point){
  r = -1;
  }
  return r;
}
function Main(input) {
  let x = input.split('\n');
  let N = x.shift();
  let array = [];
  for(let i = 0; i < N; i++){
  let tmp = x[i].split(' ');
   	array.push({id:i+1, city:tmp[0], point:parseInt(tmp[1])}) 
  }
  array.sort(compare);
  array.forEach(element=>{
    console.log(element.id);
  });
  
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define INF 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

int n;
double a[110], sum, diff;

int main(){
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a[i];
		sum += a[i];
	}
	diff = 1000;
	int memo = 1;
	sum /= n;
	for(int i=0;i<n;i++){
		if(diff > abs(sum-a[i])){
			diff = abs(sum-a[i]);
			memo = i;
		}
	}

	cout << memo << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

const int Maxn = 100000 + 5;

long long dp[Maxn];
long long site[Maxn];
int N;

int main()
{
    cin >> N;
    for (int i = 0; i < N; i++)
        cin >> site[i];
    dp[N - 1] = 0;
    dp[N - 2] = abs(site[N - 2] - site[N - 1]);
    for (int i = N - 3; i >= 0; i--)
        dp[i] = min(dp[i + 1] + abs(site[i] - site[i + 1]), dp[i + 2] + abs(site[i] - site[i + 2]));
    cout << dp[0] << endl;
    //system("PAUSE");
}

Measured memory_bytes: 5196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef priority_queue<long long> prque;
#define ain(i,n,a) for(long long i=0;i<(long long)(n);i++){cin>>a[i];}
#define aout(i,n,a) for(long long i=0;i<(long long)(n);i++){if(i){cout<<" ";}cout<<a[i];if(i==n-1){cout<<endl;}}
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define vsort(v) sort((v).begin(),(v).end())
#define vrsort(v) sort((v).rbegin(),(v).rend())
#define vreverse(v) reverse((v).begin(),(v).end())
#define pf(a) push_front(a)
#define pb(a) push_back(a)
#define INF 1998021900
#define MOD 1000000007
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //input
  ll n;cin>>n;vll a(n);
  rep(i,n){
    cin>>a[i];
    if(a[i]%2==0){
      if((a[i]%3)&&(a[i]%5)){cout<<"DENIED"<<endl;return 0;}
    }
  }
  //caricurate
  cout<<"APPROVED"<<endl;
  //output
}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define zeroes(x) memset(x,0,sizeof(x))
typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll maxn=100000;
bool comp(pll a,pll b)
{
    if(a.ff==b.ff)
        return a.ss>b.ss;
    return a.ff<b.ff;
}
pll t[4*maxn];
    vpll a(100000+1);
void build(ll id,ll l,ll r)
{
  if(l>r)
    return ;
  if(l==r)
    {
      t[id]={a[l].ss,l};
      
      return ;
    }

  ll mid=(l+r)>>1;

  build(2*id,l,mid);
  build(2*id+1,mid+1,r);
  if(t[2*id].ff>t[2*id+1].ff)
    t[id]=t[2*id];
    else
        t[id]=t[2*id+1];


}
void update(ll id,ll l,ll r,ll k,ll val)
{
    if(k<l||k>r||l>r)
        return ;
    if(l==r&&l==k)
        {
            t[id]={val,k};
            return ;
        }

    ll mid=(l+r)>>1;

    update(2*id,l,mid,k,val);
    update(2*id+1,mid+1,r,k,val);
    if(t[2*id].ff>t[2*id+1].ff)
    t[id]=t[2*id];
    else
        t[id]=t[2*id+1];


}

pll counter(ll id,ll l,ll r,ll lq,ll rq)
{
    if(l>r||l>rq||lq>r||lq>rq)
        return {0LL,0LL};
    if(lq<=l&&r<=rq)
        return t[id];
    ll mid=(l+r)>>1;

    pll x=counter(2*id,l,mid,lq,rq),y=counter(2*id+1,mid+1,r,lq,rq);
        if(x.ff>y.ff)
        {
            return x; 
        }
        else
            return y;
}

int main()
{		
	
    IOS
    ll n,m;
    cin>>n>>m;
    a.resize(n+1);
    for(ll i=1;i<=n;i++)
    {
        cin>>a[i].ff>>a[i].ss;
    }


    sort(a.begin()+1,a.end(),comp);
    build(1,1,n);
    ll ans=0;
    ll j=1;
    for(ll i=1;i<=m;i++)
    {
        while(j<=n&&a[j].ff<=i)
            j++;
        j--;
        
        pll y=(counter(1,1,n,1,j));
        if(y.ff==-mod)
            break;
        ans+=y.ff;

        update(1,1,n,y.ss,-mod);
    }


    cout<<ans<<endl;






}


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

sho_deg = h*0 + m*6 #6(deg/m)
lon_deg = h*30 + m*0.5 #0.5(deg/m)

deg_dif = abs(sho_deg-lon_deg)

print((a**2 + b**2-2*a*b*math.cos(deg_dif/180*math.pi))**0.5)

Measured memory_bytes: 62536
#include<bits/stdc++.h>
#define ll          long long int
#define ull         unsigned long long int
#define pb(x)       push_back(x)
#define pob()		pop_back()
#define sort(a)     sort(a.begin(),a.end())
#define done        return 0

#define toUp(ch)    toupper(ch)
#define isUp(ch)    isupper(ch)  //prototype int isupper(int ch)
#define toLow(ch)   tolower(ch)
#define isLow(ch)   islower(ch)
#define isX(ch)     isxdigit(ch) //hexadecimal digits (0-9 && a-f && A-F)
#define isN(ch)     isdigit(ch)  //decimal digits(0-9)
#define isS(ch)     isspace(ch)  //whitespace
#define isP(ch)     ispunct(ch)  //check punctuations !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~.
#define isPr(ch)    isprint(ch)  //check \n \t \b
#define isA(ch)     isalpha(ch)  //alphabets
#define AtoN(ch)    atol(ch)     // string to integer
#define AtoF(ch)    atof(ch)     //string to double
//https://stackoverflow.com/questions/5590381/easiest-way-to-convert-int-to-string-in-c
//https://www.geeksforgeeks.org/converting-strings-numbers-cc/

/*----------[ string to integer ]--------------
string str;  int x=0;
stringstream demo(str);
demo >> x;
cout<< x <<endl;
*/

/*----------[ integer to string ]--------------
string name;  int x=345;
stringstream demo;
demo << x;
name=demo.str();
cout<< name <<endl;
*/
using namespace std;

int main()
{
    ll n,m,s=0,i;
    cin>>n>>m;
    for(i=n-1;i>0;i--)s+=i;
    for(i=m-1;i>0;i--)s+=i;
    cout<<s<<endl;
    done;
}


Measured memory_bytes: 256
import fractions
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

N,X=map(int, input().split())
Towns=list(map(int, input().split()))
dist=[]
for i in Towns:
    dist.append(abs(i-X))

print(gcd(*dist))

Measured memory_bytes: 16304
import java.util.*;

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

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
        }

        List<Integer> list = new ArrayList<>();
        list.add(a[0]);
        for (int i = 1; i < n; i++) {
            int j = binarySearch(list, a[i]);
            if (j == -1) {
                list.add(0, a[i]);
            } else {
                list.set(j, a[i]);
            }
        }
        System.out.println(list.size());
    }

    static int binarySearch(List<Integer> list, int i) {
        int ok = -1, ng = list.size();
        while (Math.abs(ok - ng) > 1) {
            int mid = (ok + ng) / 2;
            if (list.get(mid) < i) {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        return ok;
    }
}

Measured memory_bytes: 52112
#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);
  while (true) {
    int n; cin >> n;
    if (!n) break;
    V<> x(n), y(n), r(n), c(n); for (int i = 0; i < n; ++i) cin >> x[i] >> y[i] >> r[i] >> c[i], --c[i];
    int bit = ~(~0 << n);
    V<bool> b(1 << n);
    int res = 0;
    auto dfs = [&](const auto& dfs) -> void {
      if (b[bit]) return;
      b[bit] = true;
      res = max(res, n - __builtin_popcount(bit));
      VV<> idx(4);
      for (int i = 0; i < n; ++i) if (bit >> i & 1) {
        bool ok = true;
        for (int j = 0; j < i; ++j) if (bit >> j & 1) {
          if ((x[j] - x[i]) * (x[j] - x[i]) + (y[j] - y[i]) * (y[j] - y[i]) < (r[i] + r[j]) * (r[i] + r[j])) {
            ok = false;
            break;
          }
        }
        if (ok) idx[c[i]].push_back(i);
      }
      for (auto&& v : idx) if (v.size() >= 2) {
        for (int i : v) for (int j : v) if (i < j) {
          bit &= ~(1 << i);
          bit &= ~(1 << j);
          dfs(dfs);
          bit |= 1 << i;
          bit |= 1 << j;
        }
      }
    };
    dfs(dfs);
    cout << res << '\n';
  }
}


Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define maxn 56
int n,ave;
int a[2560];
ll dp[56][56][2600];
ll ans=0;
int main()
{
    scanf("%d%d",&n,&ave);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    dp[0][0][0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=i;j>=0;j--)
        {
            for(int k=ave*n+1;k>=0;k--)
            {
                dp[i][j][k]+=dp[i-1][j][k];
                if(j>=1&&k>=a[i-1])
                    dp[i][j][k]+=dp[i-1][j-1][k-a[i-1]];//---
            }
        }
    }
    for(int i=1;i<=n;i++)ans+=dp[n][i][ave*i];//---
    printf("%lld\n",ans);
}


Measured memory_bytes: 57600
#include <bits/stdc++.h>
//#include <iostream>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;

int main() {
    int N,x; cin>>N>>x;
    if(x==1||x==2*N-1){
        cout<<"No"<<endl;
        return 0;
    }

    if(N==2){
        cout<<"Yes"<<endl;
        cout<<"1\n2\n3"<<endl;
        return 0;
    }

    vector<int> ans(2*N-1,0);
    ans[N-1]=x;
    if(x==2){
        ans[N]=x-1;
        ans[N+1]=x+1;
        ans[N-2]=x+2;
        int itr=0;
        for (int i = 5; i <= 2 * N - 1; ++i) {
            while(ans[itr]!=0){
                ++itr;
            }
            ans[itr]=i;
            ++itr;
        }
    }else{
        ans[N]=x+1;
        ans[N+1]=x-2;
        ans[N-2]=x-1;
        int itr=0;
        for (int i = 1; i <= 2 * N - 1; ++i) {
            if(i>=x-2&&i<=x+1){
                continue;
            }
            while(ans[itr]!=0){
                ++itr;
            }
            ans[itr]=i;
            ++itr;
        }
    }
    cout<<"Yes"<<endl;
    for (int i = 0; i < 2*N-1; ++i) {
        cout<<ans[i]<<endl;
    }


    return 0;
}


Measured memory_bytes: 2304
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    a, b, c = MAP()
    print(c, a, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5972
#include<bits/stdc++.h>
using namespace std;
#define con continue
#define bk break
#define LL long long
#define db double
#define pt cout<<'\n'
#define ms(a, b) memset((a), (b), sizeof(a))
#define mp make_pair
#define endl '\n'
int inf=2147483647;const long long ll =9223372036854775807,ninf=1000000000;const double eps = 1e-6; const long long nll =223372036854775807;
#define sz size()
#define len(X) strlen(X)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ULL unsigned long long
#define de cout<<"test"<<endl;
#define st system("pause");
#define M_PI 3.1415926
LL A[100005]={};
int main()
{
    LL a,b,c;
    while(cin>>a>>b>>c){
        for(int i=0;i<a;i++){
            cin>>A[i];
        }
        b-=c;
        LL l=1,r=1000000000,ans=inf;
        while(l<=r){
            LL mid=(l+r)/2;
            LL cnt=0;
            for(int i=0;i<a;i++){
             if(A[i]- (mid*c )>0){
                LL tmp=A[i];
                tmp-=(mid*c);
                cnt+=tmp/b;
                if(tmp%b)
                    cnt++;
             }
            }
            if(cnt<=mid){
                    ans=min(ans,mid);
                r=mid-1;
            }
            else{
                l=mid+1;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


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

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

    long long i = 0;
    long long maxv = 0;
    while(i < 3){
        if(s[i] == 'R'){
            long long length = 0;
            while(i < 3 and s[i] == 'R'){
                length++;
                i++;
            }
            maxv = max(maxv, length);
        }
        i++;
    }
    cout << maxv << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279

#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ld INF = 1e9+123;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}

int main(){
    int H,W,N;
    cin>>H>>W>>N;
    VEC2(int,a,H,0);
    int c=0;
    REP(i,N){
        int t;
        cin>>t;
        REP(j,t){
            if((c/W)%2==0){
                a[c/W].push_back(i+1);
            }else{
                a[c/W].insert(a[c/W].begin(),i+1);
            }
            c++;
        }
    }
    REP(i,H){
        REP(j,W){
            cout<<a[i][j]<<" ";
        }
        cout<<endl;
    }
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
  int n;
  cin>>n;
  vector<int> a(n);
  REP(i,n) cin>>a[i];

  map<int,int> cnt;
  REP(i,n) cnt[a[i]]++;
  int ans=0;
  for(auto e:cnt){
    if(e.first==e.second) continue;
    if(e.first>e.second) ans+=e.second;
    else ans+=e.second-e.first;
  }
  cout<<ans<<endl;

  return 0;
}

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

int H, W, N, p[609][609], q[609][609];

int vals(int px, int py) {
	px = min(px, 2 * N);
	py = min(py, 2 * N);
	if (px < 0 || py < 0) return 0;
	return p[px][py];
}

int valm(int px, int py) {
	if (px < 0 || py < 0 || px > 2 * N || py > 2 * N) return 0;
	return q[px][py];
}

int range_sum(int px, int py, int qx, int qy) {
	return vals(qx, qy) + vals(px - 1, py - 1) - vals(px - 1, qy) - vals(qx, py - 1);
}

int main() {
	cin >> H >> W; N = max(H, W);
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			char c; cin >> c;
			if (c == '#') { p[i + j][i - j + N] = 1; q[i + j][i - j + N] = 1; }
		}
	}
	for (int i = 0; i <= 2 * N; i++) {
		for (int j = 1; j <= 2 * N; j++) p[i][j] += p[i][j - 1];
	}
	for (int i = 0; i <= 2 * N; i++) {
		for (int j = 1; j <= 2 * N; j++) p[j][i] += p[j - 1][i];
	}

	long long ans = 0;
	for (int i = 0; i <= 2 * N; i++) {
		for (int j = 0; j <= 2 * N; j++) {
			int S = min({ i, j, 2 * N - i, 2 * N - j });
			for (int k = 1; k <= S; k++) {
				int V1 = valm(i - k, j - k) * valm(i - k, j + k) * range_sum(i + k, j - k, i + k, j + k);
				int V2 = valm(i + k, j - k) * valm(i + k, j + k) * range_sum(i - k, j - k, i - k, j + k);
				int V3 = valm(i - k, j - k) * valm(i + k, j - k) * range_sum(i - k + 1, j + k, i + k - 1, j + k);
				int V4 = valm(i - k, j + k) * valm(i + k, j + k) * range_sum(i - k + 1, j - k, i + k - 1, j - k);
				ans += (V1 + V2 + V3 + V4);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

using ll = long long;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)
//fixed << setprecision(20)

int main(){
	int a,b;
	cin >> a >> b;
	if(a >= 13)cout << b << endl;
	else if(a >= 6)cout << b / 2 << endl;
	else cout << 0 << endl; 
	return 0; 
}

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

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    if(s>="a" && s<="z") cout << 'a';
    else if(s>="A" && s<="z") cout << 'A'; 
    
    return 0;
}


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

inline long long read(){
    long long s = 0, w = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9'){
        if (ch == '-') w = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9'){
        s = s * 10 + ch - '0';
        ch = getchar();
    }
    return s * w;
}

int n, ans;

int main(){
    n = read();
    for (int i = 1; i <= n-1; i++){
        ans += (n/i);
        if (n % i == 0)
            ans--;
    }
    printf("%d\n", ans);
    return 0;
}

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

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    char s;
    cin >> s;
    char g = (char) tolower(s);
    if (g == s){
        cout<< "a\n";
    }
    else{
        cout<< "A\n";
    }


    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1000000;
struct D{
	int tID;
	int p[10];	//the number of incorrect problems
	int c;		//the number of correct problems
	int x;		//penalty points
};

bool rank( const D &a, const D &b ){
	return a.c == b.c ? (a.x == b.x ? a.tID < b.tID : a.x < b.x) : a.c > b.c;
}

int main(){
	int T, P, R;
	while( cin >> T >> P >> R && T ){
		vector< D > data(T);
		for( int i = 0; i < T; i++ ){
			data[i].tID = i + 1;
		}
		for( int i = 0; i < R; i++ ){
			int tID, pID, t;
			string m;
			cin >> tID >> pID >> t >> m;
			if( m == "CORRECT" ){
				if( data[tID-1].p[pID-1] != inf ){
					data[tID-1].c++;
					data[tID-1].x += t + data[tID-1].p[pID-1] * 1200;
					data[tID-1].p[pID-1] = inf;
				}
			}else{
				data[tID-1].p[pID-1]++;
			}
		}
		sort( data.begin(), data.end(), rank );
		for( int i = 0; i < T; i++ ){
			cout << data[i].tID << " " << data[i].c << " " << data[i].x << endl;
		}
	}
}

Measured memory_bytes: 1248
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}
	public Main(){
		new A().doIt();
	}
	class A{
		void doIt(){
			int V = sc.nextInt();
	        int E = sc.nextInt();
	 
	        ArrayList<Edge> array = new ArrayList<Edge>();
	        for (int i = 0; i < E; i++) {
	            int s = sc.nextInt();
	            int t = sc.nextInt();
	            int w = sc.nextInt();
	            array.add(new Edge(s, t, w));
	            array.add(new Edge(t, s, w));
	        }
	        System.out.println(kruskal(array,V));
		}
		int kruskal(ArrayList<Edge> edgelist, int nodesize) {
		    int m = edgelist.size();
		    Collections.sort(edgelist);
		    UnionFind uf = new UnionFind(nodesize);
		    int res = 0;
		    for(int i = 0 ; i < m; i++){
		        Edge e = edgelist.get(i);
		        if(! uf.same(e.from, e.to)){
		            uf.unite(e.from, e.to);
		            res += e.cost;
		        }
		    }
		    return res;
		}
		class Edge implements Comparable<Edge>{
		    int from,to, cost;
		    public Edge(int from, int to, int cost) {
		        this.from = from; this.to = to; this.cost = cost;
		    }
		    public int compareTo(Edge o) {
		        return this.cost - o.cost;
		    } 
		}
		class UnionFind{
			int [] par, rank; // par -> rootnumber, rank -> height 
			int num; // ?????¨???????????????????????°
			public UnionFind(int n) {
				par = new int[n];
				rank = new int[n]; for(int i=0;i<n;i++){
					par[i] = i;
		            //rank[i] = 0;
				}
				num=n; 
			}
			int find(int x){ //?????????????????????????????¢??? 
				if(par[x] == x)return x;
				else return par[x] = find(par[x]);
			}
			void unite(int x, int y){ //????????????
				x = find(x);
				y = find(y);
				if(x == y) return ;
				if(rank[x] < rank[y]) par[x] = y;
				else{
					par[y] = x;
					if(rank[x] == rank[y]) rank[x]++;
				}
				num--; 
			}
			boolean same(int x, int y){ //????????????????????????????????¨?????????????????? 
				return find(x) == find(y);
			} 
		}
		
	}
}

Measured memory_bytes: 115060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

int main() {
  ll n;
  cin >> n;
  V<ll> x(n), y(n);
  rep(i, n) cin >> x[i] >> y[i];

  map<P, int> m;
  rep(j, n) rep(i, j) {
    ll dx = x[i] - x[j];
    ll dy = y[i] - y[j];
    m[{dx, dy}]++;
    dx = x[j] - x[i];
    dy = y[j] - y[i];
    m[{dx, dy}]++;
  }
  int ans = n;
  multiset<P> p;
  rep(i, n) p.insert({x[i], y[i]});

  for (auto e : m) {
    ll a = e.first.first;
    ll b = e.first.second;
    if (a == 0 && b == 0) continue;

    auto tp = p;
    auto top = tp.begin();
    int c = tp.size();
    while (tp.size() > 0) {
      ll x = (*top).first + a;
      ll y = (*top).second + b;
      tp.erase(top);
      auto itr = tp.find({x, y});
      if (itr != tp.end()) {
        top = itr;
        c--;
      } else {
        top = tp.begin();
      }
    }
    ans = min(ans, c);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main()
{
    int A , B ,C;
    cin>> A >> B >> C;
    if(A == B){
        cout << C << endl;
    }
    else if(A == C){
        cout << B <<endl;
    }
    else{
        cout << A << endl;
    }
    return 0;
}


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

long min(long a,long b)
{
 if(a<=b) return a;
 else{
     return b;
 }
}

void f(void)
{
 exit(0);
}

// テンプレートすべき
bool judge(vector<pair<int,int>> v,pair<int,int> k)
{
 int n=v.size();
 for(int i=0;i<n;i++){
     if(v[i]==k) return true;
 }
 return false;
}

int main()
{
 int n,m; cin >> n >> m;
 vector<vector<long>> dist;
 vector<pair<int,int>> Edges;
 vector<pair<int,int>> EDGES;
 dist.resize(n);
 long INF=pow(10,11);
 for(int i=0;i<n;i++){
     dist[i].assign(n,INF);
     dist[i][i]=0;
 }
 for(int i=0;i<m;i++){
     int u,v;
     cin >> u >> v;
     u-=1;
     v-=1;
     dist[u][v]=1;
     dist[v][u]=1;
     pair<int,int> e=make_pair(u,v);
     pair<int,int> e_=make_pair(v,u);
     Edges.push_back(e);
     EDGES.push_back(e);
     EDGES.push_back(e_);
 }
 int ans=0;
 for(int p=0;p<m;p++){
     pair<int,int> e=Edges[p];
     int u=e.first;
     int v=e.second;
     dist[u][v]=INF;
     dist[v][u]=INF;
     for(int k=0;k<n;k++){
         for(int i=0;i<n;i++){
             if(dist[i][i]<0){
                 cout << "NEGATIVE CYCLE" << endl;
                 f();
              }
              for(int j=0;j<n;j++){
                  dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
               }
         }
      }
      if(dist[u][v]==INF) ans++;

      if(p!=m-1){
          for(int i=0;i<n;i++){
              for(int j=0;j<n;j++){
                  if(judge(EDGES,make_pair(i,j))){
                      dist[i][j]=1;
                      dist[j][i]=1;
                   }
                   else if (i==j){
                       dist[i][i]=0;
                   }
                   else{
                       dist[i][j]=INF;
                   }
              }
          }
      }
 }
 cout << ans << endl;
 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[200],cnt[200];
int main(){
	int n;
	bool flag=true;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	sort(a,a+n);
	if(a[0]==a[1]){
		for(int i=2;i<n;i++){
			cnt[a[i]-a[0]]++;
		}
		for(int i=1;i<=a[0]-1;i++){
			if(cnt[i]<2) flag=false;
		}
		if(a[n-1]>a[0]+a[0]-1) flag=false;
		if(cnt[0]) flag=false;
	}
	else{
		for(int i=1;i<n;i++){
			cnt[a[i]-a[0]]++;
		}
		for(int i=1;i<=a[0];i++){
			if(cnt[i]<2) flag=false;
		}
		if(a[n-1]>a[0]+a[0]) flag=false;
	}
	if(flag) puts("Possible");
	else puts("Impossible");
	return 0;
}

Measured memory_bytes: 256
def main():
  
  n,k=map(int,input().split())
  a=list(map(int,input().split()))
  
  count=lambda arr,now:sum(element<now for element in arr)
  
  ans=0
  prime=10**9+7
  
  for i in range(n):
    left=count(a[:i],a[i])
    right=count(a[i+1:],a[i])
    res=(k-1)*k//2*(right+left)+right*k
    ans+=res%prime
    
  print(ans%prime)

if __name__=="__main__":
  main()

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

using namespace std;

using ll = long long;

int main(void){
    ll s = 0;

    cin >> s;

    ll x[3] = {0,(ll)10e8,0};
    ll y[3] = {0,       1,0};

    x[2]=(ll)10e8-(s%(ll)10e8);
    x[2] %= (ll)10e8;
    y[2]=(s+x[2])/(ll)10e8;

    for(int i=0; i<3; i++){
        cout << x[i] << " " << y[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define INF 0x3f3f3f3f3f3f3f3f
#define PI acos(-1.0)
#define MOD 1000000007
//#define eps 1e-10
#define R freopen("555input.txt","r",stdin);
#define W freopen("555output.txt","w",stdout);
#define N 105
#define M 16000
int i,j,n,T,ii,loc;
LL a[6],mi;
LL ans;
int main()
{
    
    for(i=0;i<4;i++)
    {
        scanf("%d",&a[i]);
        a[i]*=(1<<(3-i));
    }
    scanf("%d",&n);
        mi=INF;
        for(i=0;i<4;i++)
        {
            if(mi>a[i]){mi=a[i];loc=i;}
        }
        if(loc!=3||n%2==0)ans=n*a[loc]/2;
        else{
        for(i=0,mi=INF;i<3;i++)
        {
            if(mi>a[i]){mi=a[i];loc=i;}
        }
        ans=n/2*a[3]+a[loc]/2;
        }
        cout<<ans;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
using Graph = vector<vector<int>>;
using Graph_Wei = vector<vector<pair<int,int>>>;
using ll = long long;
const long long INF = 1LL<<60; // 仮想的な無限大の値
vector<bool> seen;

Graph G;

int solve(ll a,ll b,ll c){

    for(int i=0;i < 1000;i++){

        if(a & 1) return i;
        if(b & 1) return i;
        if(c & 1) return i;

        ll ta,tb,tc;
        ta = (b + c)/2;
        tb = (a + c)/2;
        tc = (a + b)/2;

        a = ta;
        b = tb;
        c = tc;

    }
    return -1;
}

int main() {

    int MAX = 100000;
    int n;
    vector<int> nums(MAX,1);
    nums[0] = 0;
    nums[1] = 0;

    //エラトステネス
    for(int i=2;i < MAX;i++){

        if(!nums[i]) continue;
        for(int j = i +i;j <= MAX;j += i){
            nums[j] = 0;
        }
    }

    //累積和
    //素数は２始まり
    vector<int> a(MAX,0);
    for(int i = 0;i < MAX;i++){
        if(nums[i] % 2 == 0) continue;//偶数を弾く
        if(nums[i] && nums[(i + 1)/2]) a[i] = 1;
    }

    //
    vector<int> s(MAX + 1,0);
    for(int i = 0;i < MAX;i++){
        s[i+1] = s[i] + a[i];
    }

    int Q;
    cin >> Q;
    for(int q = 0;q < Q;q++){
        int l,r;
        cin >> l >> r;
        r++;
        cout << s[r] - s[l] << endl;
    }



    return 0;

}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
 
using namespace std;
 
int main()
{
	long long n;
	cin>>n;
	long long cnt=1;
	if(n>2)cnt++;
	for(long long i=2;i*i<n;i++){
		if((n-1)%i==0){
			cnt++;
			if((n-1)/i!=i)
				cnt++;
		}
	}
	for(long long i=2;i*i<n+1;i++){
		if(n%i==0){
			long long cur=n;
			while(cur%i==0)cur/=i;
			if(cur%i==1)cnt++;
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn._

object Main extends App {

  val Array(n,m) = readLine().split(" ").map(_.toInt)
  val A = Array.fill(n)(readLine().split(" ").map(_.toInt))
    .map(_.drop(1).map(_ -1))

  def solve() = {
    val ans = Array.fill(m)(0)
    A.foreach { list =>
      list.foreach { num =>
        ans(num) += 1
      }
    }
    ans.count(_ == n)
  }
  println(solve())

}



Measured memory_bytes: 54892
#include <bits/stdc++.h>
#include <iomanip>
 
using namespace std;
 
typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PLDLD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VB;
 
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
 
const LD eps=1e-10;
const long long INFLL=(LL)(1e9)*(LL)(1e9);
const int INF=1e9;
 
template<class T>
void chmin(T& a, const T b)
{
	if(a>b)
		a=b;
}
template<class T>
void chmax(T& a, const T b)
{
	if(a<b)
		a=b;
}
 
const LL pow(const LL p, const LL q)
{
	LL t=1;
	for(int i=0;i<q;i++)
		t*=p;
	return t;
}

template <typename T>
struct has_iter
{
	private:
		template <typename U>
		static constexpr true_type check(typename U::iterator*);
		template <typename U>
		static constexpr false_type check(...);

	public:
		static constexpr bool value = decltype(check<T>(nullptr))::value;
};

template<typename T, typename U = typename T::iterator>
void print(const T& container)
{
		auto&& first=begin(container), last=end(container);
		auto&& back=prev(last);
		for(auto e=first; e!=last; e=next(e))
			cout<<*e<<" \n"[e==back];
}

extern void* enabler;
template<typename Head, typename enable_if<!has_iter<Head>::value>::type*& = enabler>
void print(const Head& head)
{
	cout<<head<<endl;
}

template<typename Head, typename... Tail>
void print(const Head& head, const Tail&... tail)
{
	cout<<head<<" ";
	print(tail...);
}

void io_speedup()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
}

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

template<typename T>
vector<T> read(int n)
{
	vector<T> t(n);
	cin>>t;
	return t;
}

template<typename T>
T read()
{
	T t;
	cin>>t;
	return t;
}


int main()
{
	int a,b;
	cin>>a>>b;
	a--;
	b--;
	print(100,100);
	REP(j,100)
	{
		if(j<50)
		{
			REP(i,100)
			{
				if(j%2==0)
					cout<<'.';
				else if(i%2==0)
				{
					if(b>0)
					{
						cout<<'#';
						b--;
					}
					else
					{
						cout<<'.';
					}
				}
				else
					cout<<'.';
			}
			cout<<endl;
		}
		else
		{
			REP(i,100)
			{
				if(j%2==0)
					cout<<'#';
				else if(i%2==0)
				{
					if(a>0)
					{
						cout<<'.';
						a--;
					}
					else
					{
						cout<<'#';
					}
				}
				else
					cout<<'#';
			}
			cout<<endl;
		}
	}
}


Measured memory_bytes: 256
n,m=map(int,input().split())
L=[list(map(int,input().split())) for i in range(m)]

if m==1:
  print(L[0][1]-L[0][0]+1)
else:
  l=[]
  r=[]
  for item in L:
    l.append(item[0])
    r.append(item[1])
  x=max(l)
  y=min(r)
  if y>=x:
    print(y-x+1)
  else:
    print(0)

Measured memory_bytes: 29092
module Main where

    import Debug.Trace
    import Data.List
    
    solve :: Int -> Int -> Int -> Int -> Int -> String
    solve w h x y r = if x + r <=w && x - r >= 0 && y + r <=h && y - r >= 0
                        then "Yes" else "No"  
       
    readLine:: IO [Int]
    readLine = fmap (map read . words) getLine
    
    main :: IO() 
    main = do
        [w, h, x, y, r] <- readLine
        let ans = solve w h x y r
        putStrLn ans
    


Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<l_l> vpl;
typedef vector<string> vs;
typedef pair<l_l,ll> lll;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=1;i<=(n);i++)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-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;
}
ll n,q,N;
vl node;
void init(){
    N=1;
    while(N<n)N*=2;
    node.resize(2*N-1,0);
}
void add(ll ind,ll x){
    ind+=N-1;
    node[ind]+=x;
    while(ind){
        ind=(ind-1)/2;
        node[ind]=node[2*ind+1]+node[2*ind+2];
    }
}
ll get_sum(ll l,ll r,ll bottom=0,ll top=-1,ll pos=0){
    if(top<0)top=N;
    if(l<=bottom&&top<=r)return node[pos];
    if(r<=bottom||top<=l)return 0ll;
    ll mid=(bottom+top)/2;
    ll vl=get_sum(l,r,bottom,mid,2*pos+1);
    ll vr=get_sum(l,r,mid,top,2*pos+2);
    return vl+vr;
}
int main(){
    cin>>n>>q;
    init();
    rep(i,q){
        ll query,x,y;cin>>query>>x>>y;
        if(query)cout<<get_sum(x-1,y)<<endl;
        else add(x-1,y);
    }
    //cout<<node[3]<<endl;
    return 0;
}


Measured memory_bytes: 4944
#ITP_9_C
taro = 0
hanako = 0
for i in range(int(input())):
    x, y = input().split()
    if x > y:
        taro+=3
    elif x < y:
        hanako+=3
    else:
        taro+=1
        hanako+=1
print(str(taro) + ' ' + str(hanako))


Measured memory_bytes: 5596
using System;
using System.Linq;

namespace C {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            Console.WriteLine(a.Sum() - N);
        }
    }
}


Measured memory_bytes: 13424
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
sys.setrecursionlimit(500*500)
import itertools
from collections import Counter,deque

def main():
    n = int(input())
    a = int(input())
    b = int(input())
    c = int(input())
    d = int(input())
    e = int(input())

    ans = (math.ceil(n/min(a,b,c,d,e)))+4
    print(ans)


if __name__=="__main__":
    main()


Measured memory_bytes: 65356
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    ans = int(N ** 0.5) ** 2
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9428
#include <stdio.h>
#include <stdlib.h>



int main()
{
    long int n;
    long int a,b;
    long int s,s1,s2;
    scanf("%ld %ld %ld",&n,&a,&b);
    //
    if(a>b||n<1||(n==1&&a!=b)||a>1000000000||b>1000000000||n>1000000000)
        printf("0");
    else
    {
        s1=a*(n-1)+b;
        s2=a+b*(n-1);
        s=s2-s1+1;
        printf("%ld",s);
    }

    return 0;
}


Measured memory_bytes: 128
import numpy as np
D = int(input())
C = np.array(input().split(), dtype=int)
S = tuple(tuple(map(int, input().split())) for _ in range(D))

last = np.ones(26, dtype=int)

for s in S:
    s = np.array(s)
    tmp = s + C * last
    i = np.argmax(tmp)
    last[i] = 0
    last += 1
    print(i + 1)

Measured memory_bytes: 27672
/**
*    created: 25.07.2020 21:00:23
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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;}
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dx2[8]={0, 1, 0, -1, 1, 1,-1, -1};
const int dy2[8]={1, 0,-1, 0, 1, -1, 1, -1};
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n; cin >> n;
    if (400 <= n && n < 600) cout << 8 << endl;
    if (600 <= n && n < 800) cout << 7 << endl;
    if (800 <= n && n < 1000) cout << 6 << endl;
    if (1000 <= n && n < 1200) cout << 5 << endl;
    if (1200 <= n && n < 1400) cout << 4 << endl;
    if (1400 <= n && n < 1600) cout << 3 << endl;
    if (1600 <= n && n < 1800) cout << 2 << endl;
    if (1800 <= n && n < 2000) cout << 1 << endl;
    return 0;
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

signed main()
{
	int n, k;
	string s;
	cin >> n >> k >> s;
	s[k-1] -= 'A'-'a';
	cout << s << endl;

	return 0;
}


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

a = len(s)
b = len(t)
#最小の文字列となるためには前にaを固めたほうが良いため後ろから入れる
for i in range(a-b,-1,-1):
    t_kamo = s[i:i+b]
    count = 0
    for j in range(b):
        if t_kamo[j] == t[j] or t_kamo[j] == "?":
            count += 1
    if count == b:
        #replaceメソット(リストには使えない,strに直接使う？)
        #条件分で記述
        ans = "".join(s[:i]+t+s[i+b:])
        print(ans.replace("?","a"))
        sys.exit()
        #ans = []"a" if "?" for i in ans]
        #print("join.(ans)")でもいけるはず
        
print("UNRESTORABLE")
            
    

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

using namespace std;
int main(void){
	
	int n; cin>>n; 
	int a[n];
	for(int i=0; i<n; i++) cin>>a[i];
	
	int count =0;
	int ans=0;
	for(int i=1; i<n; i++){
		
		count=1; int j=i;
		while(j<n && a[j] == a[j-1]){
			count++; j++;
		}
		
		if(count > 1){
			ans += ((count/2));
		}
		i = j;
	}
	cout<<ans;
	
	return 0;
	
}


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

int main() {

    // input from txt （提出時にこの箇所は削除すること）
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    
    int N;
    cin >> N;
    set<string> S;
    for(int i=0; i<N; i++){
        string T;
        cin >> T;
        S.insert(T);
    }
    
    cout << S.size() << endl;
    
}

Measured memory_bytes: 19204
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}
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, K, Q;
    cin >> N >> K >> Q;
    vl a(N, 0);
    vl point(N, 0);
    rep(i, 0, Q) {
        int a;
        cin >> a;
        --a;
        ++point[a];
    }

    rep(i, 0, N) {
        if (K - (Q - point[i]) > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 2176
#include<cstdio>
using namespace std;
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	if(a>10){
	 printf("%d",b);
	 return 0;
}
else {
	b+=100*(10-a);
	printf("%d",b);
}
return 0;
} 

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define fi first
#define se second
#define show(x) cerr<<#x<<"="<<x<<"\n"
typedef long long ll;
using namespace std;
//const ll MOD=(ll)1e9+7;
//const ll inf=(ll)1e14;
const int dy[]={1,0,-1};
const int dx[]={1,0,-1};
int n,m,h,w;
string s;
bool a[30];

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1=freopen("in","r",stdin);
  //stream2=freopen("out","w",stdout);
  if(stream1==NULL)return 0;
  //if(stream2==NULL)return 0;
#endif
  cin>>s;
  n=(int)s.size();
  if(n==26){
    vector<string> v;
    for(int i=n-1;i>=0;i--){
      for(int j=i-1;j>=0;j--){
        if(s[i]>s[j]){
          char tmp=s[i];
          string t=s.substr(0,j);
          t+=tmp;
          v.push_back(t);
        }
      }
    }
    sort(v.begin(),v.end());
    if((int)v.size()==0)
      cout<<-1<<endl;
    else cout<<v[0]<<endl;
  }else{
    for(int i=0;i<n;i++){
      a[s[i]-'a']=1;
    }
    for(int i=0;i<26;i++){
      if(!a[i]){s+=(char)('a'+i);break;}
    }
    cout<<s<<endl;
  }
#ifdef LOCAL_DEFINE
  cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}





Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int n,d,x;
  cin >> n >> d >> x;
  int p[d][n];
  int i,j,k;
  for(i=0;i<d;i++){
    for (j = 0; j < n; j++) {
      cin >> p[i][j];
    }
  }

  for(i=1;i<d;i++){
    int dp[x+1]={};
    for(j=0;j<n;j++){
      for(k=p[i-1][j];k<=x;k++){
        if(p[i][j]>p[i-1][j])dp[k]=max(dp[k],dp[k-p[i-1][j]]+p[i][j]-p[i-1][j]);
      }
    }
    int ret=0;
    for(j=0;j<=x;j++)ret=max(ret,dp[j]);
    x+=ret;
  }
  cout << x << endl;
  return 0;
}



Measured memory_bytes: 3152
#include <iostream>//数据输入输出流
#include <cstring>//字符串操作函数
#include <cstdio>//C的输入输出
#include <cstdlib>//定义杂项函数及内存分配函数
#include <cmath>//C中的数学函数
#include <string>//c++中的string类 他不能用strcpy等c函数去操作
#include <vector>//STL vetor
#include <list>//STL list
#include <map>// STL map
#include <queue>// STL queue
#include <stack>//sTL stack
#include <bitset>//bitset可按位定义串
//比如：bitset <1000> all;定义一个1000位的串
#include <algorithm>//STL各种算法 比如 swap sort merge max min 比较
#include <numeric>//常用数字操作 一般和algorithm搭配使用
#include <functional>//STL定义运算函数（代替运算符）
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define LOCAL
#define zeros(a,n) memset(a,0,(n)*sizeof(a[0]))
const int modn = 1e9+7;
int mod(int x) { return x<0?x+modn:x<modn?x:x-modn; }
//inv [ i ] = (modn - modn/i)*inv[ modn%i ] %modn;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    LL a, b;
    cin>>a>>b;
    LL c = a%b;
    cout<<min(c, abs(c-b))<<endl;
    return 0;
}



Measured memory_bytes: 256