akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define inf 1<<29
#define linf (1e16)
#define eps (1e-8)
#define Eps (1e-12)
#define mod 1000000007
#define pi acos(-1.0)
#define phi (1.0+sqrt(5.0))/2.0
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define pld(a) printf("%.10Lf\n",(ld)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define Unique(v) v.erase(unique(all(v)),v.end())
#define equals(a,b) (fabs((a)-(b))<eps)
#define track(); cout<<"#############"<<endl;
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<pii> vpi;

typedef struct node{
  struct node *l=NULL;
  struct node *r=NULL;
  int key=0;
  int pri=0;
}Node;

Node* RightRotate(Node *t){
  Node *s=t->l;
  t->l=s->r;
  s->r=t;
  return s;
}

Node* LeftRotate(Node *t){
  Node *s=t->r;
  t->r=s->l;
  s->l=t;
  return s;
}

Node* ins(Node* t,int key,int pri){
  if(t==NULL){
    t=(Node*)malloc(sizeof(Node));
    t->l=NULL;
    t->r=NULL;
    t->key=key;
    t->pri=pri;
    return t;
  }
  if(key==t->key)return t;
  if(key<t->key){
    t->l = ins(t->l,key,pri);
    if(t->pri < t->l->pri)t=RightRotate(t);
  }
  else {
    t->r = ins(t->r,key,pri);
    if(t->pri < t->r->pri)t=LeftRotate(t);
  }
  return t;
}

bool find(Node *t,int key){
  if(t==NULL)return false;
  if(t->key==key)return true;
  if(key<t->key)return find(t->l,key);
  return find(t->r,key);
}

Node* del(Node *t,int key){
  if(t==NULL)return NULL;
  if(key==t->key){
    if(t->l==NULL && t->r==NULL){
      return NULL;
    }
    else if(t->l==NULL){
      t=LeftRotate(t);
    }
    else if(t->r==NULL){
      t=RightRotate(t);
    }
    else {
      if(t->l->pri >t->r->pri)
        t=RightRotate(t);
      else 
        t=LeftRotate(t);
    }
    return del(t,key);
  }

  if(key<t->key)
    t->l = del(t->l,key);
  else 
    t->r = del(t->r,key);
  return t;
}

void inorder(node *t){
  if(t->l != NULL)inorder(t->l);
//  cout<<" "<<t->key;
  printf(" %d",t->key);
  if(t->r != NULL)inorder(t->r);
}

void preorder(node *t){
  printf(" %d",t->key);
  //cout<<" "<<t->key;
  if(t->l != NULL)preorder(t->l);
  if(t->r != NULL)preorder(t->r);
}

int main()
{
  int n,a,b;
  string s;
  Node *t=NULL;
  cin>>n;
  FOR(i,0,n){
    cin>>s;
    if(s=="insert"){
      cin>>a>>b;
      t=ins(t,a,b);
    }
    else if(s=="find"){
      cin>>a;
      if(find(t,a))cout<<"yes"<<endl;
      else cout<<"no"<<endl;
    }
    else if(s=="delete"){
      cin>>a;
      t=del(t,a);
    }
    else {
      inorder(t);
      cout<<endl;
      preorder(t);
      cout<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 9516
#include <cstdio>
#include <cmath>

using namespace std;
int main()
{

    //input : N M
    int N, M;
    scanf("%d %d", &N, &M);

    //main of program
    double X;
    int T = 1900*M + 100*(N-M);    //一回の実行にかかる時間
    double p_ok = pow(0.5, M);     //全てのケースで正解する確率
    double p_ng = 1 - p_ok;        //どれかのケースで失敗する確率
    // double p_k_path = pow(p_ng, k-1) * p_ok; //k回目の試行ですべてのケースに正解する確率
    //期待値は Σ(p_k_path * T*k) = T*p_ok* Σ(k * pow(p_ng,k-1) ) = T*p_ok /p_ng * Σ(k * pow(p_ng,k) )
    //無限級数の公式を用いて値を出すと
    //Σ(k * pow(p_ng,k) ) = p_ng / pow(1-p_ng, 2)

    X = T*p_ok / pow(1-p_ng, 2);
    printf("%d",(int)X);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

int main(){
  int a, b;
  cin >> a >> b;

  int c[3];
  c[0] = a + b;
  c[1] = a - b;
  c[2] = a * b;

  SORT(c, 3);

  cout << c[2] << endl;
 }


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

void solve(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max({a*c,a*d,b*c,b*d}) << "\n";
        
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t =1;
    while(t--)
        solve();
    return 0;
}



Measured memory_bytes: 3648
/*In the name of ALLAH, Most Gracious, Most Merciful*/
#include<bits/stdc++.h>

#define ll                      long long int
#define ull                     unsigned long long int
#define PI                      2*acos(0.0)
#define sqr(x)                  (x)*(x)
#define EPS                     10E-10
#define MOD                     1000000007
#define longlimit               92233720368547758
#define infinity                (1<<28)
#define setbits                 __builtin_popcount
#define zerobits                __builtin_ctzll
#define pb(a)                   emplace_back(a)
#define mp                      make_pair
#define ff                      first
#define ss                      second
#define gcd(a, b)               __gcd(a,b)
#define lcm(a, b)               ((a)*(b))/gcd(a,b)
#define watch(x)                cout << (#x) << " is " << (x) << endl
#define TEST_CASES(t)           ll t;cin>>t;while (t--)
#define all(a)                  (a.begin()),(a.end())
#define UNIQUE(X)               (X).erase(unique(all(X)),(X).end())
#define DELETE(X)               (X).erase (remove (all(X)),(X).end())
#define SORT_UNIQUE(c)          (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
using namespace std;

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

   ll n,sum=0;
   cin>>n;
   for (ll i=1;i<=n;i++)
       if ((i%3==0) or (i%5==0))continue;
       else sum+=i;

    cout<<sum<<endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <atcoder/dsu>
using namespace std;
using namespace atcoder;

int main()
{
  int n, q;
  cin >> n >> q;
  dsu G(n);
  for (int qi = 0; qi < q; qi++)
  {
    int t, u, v;
    cin >> t >> u >> v;
    if (t == 0)
    {
      G.merge(u, v);
    }
    else
    {
      cout << (G.same(u, v) ? 1 : 0) << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3944
#include <stdio.h>

#define N_max 100

int main(int argc, char const *argv[]) {
  int N;
  int A[N_max];
  int i, j;    //カウンタ
  //入力
  scanf("%d", &N );
  for ( i = 0; i < N; i++) {
    scanf("%d", &A[i] );
  }
  //シェルソート(降順)
  int t;
  for ( i = 1; i < N; i++) {
    for ( j = i-1; j >= 0; j--) {
      if ( A[j] < A[j+1] ) {
        t = A[j];   A[j] = A[j+1];   A[j+1] = t;
      }
      else
      break;
    }
  }
  //絶対値の計算
  int answer;
  answer = A[0] - A[N-1];
  //出力
  printf("%d\n", answer );
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int mod=2e5+5;
typedef long long ll;
ll sum=0,ans;
int A[mod];
bool cmp(int x,int y)
{
    return x<y;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&A[i]);
        A[i]-=i;
        sum+=(A[i]);
    }
    //ll l=0,r=0;
    sort(A+1,A+1+n,cmp);
   for(int i=1;i<=n;i++)
   {
      ans+=fabs(A[i]-A[(n+1)/2]);//减去中位数而已。。。
   }
   printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int N=256;
const int maxn=2e5+5;
int a[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        scanf("%d",&a[i]);
    int maxx=0;
    ll ans=0;
    for(int i=0; i<n; i++)
    {
        maxx=max(a[i],maxx);
        if(a[i]<maxx)ans+=maxx-a[i];
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 4604
#include <iostream>

using namespace std;

int main(){
    int n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    
    string s;
    cin>>s;
    bool last = false;
    int dots = 0;
    bool ok = false;
    bool reached = false;
    for(int i=min(a,b)-1;i<max(c,d);i++){

        
        if(s[i]=='.'){
            last = true;
        }else{
            if(last){
                last= false;
            }else{
                cout<<"No"<<endl;
                return 0;
            }
        }
        
    }
    if(c>d){
        for(int i=b-1;i<d;i++){
            if(i-1>=0 && i+1<n && s[i-1] == '.' && s[i] == '.' && s[i+1] == '.'){
                ok = true;
            }
        }
        if(!ok){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 640
fun main(args: Array<String>) {
    val q = readLine()!!.toInt()
    val elements = mutableListOf<Int>()
    (1..q).forEach {
        val x = readLine()!!.split(" ").map(String::toInt)
        when(x[0]) {
            0 -> elements.add(x[1])
            1 -> println(elements[x[1]])
            2 -> elements.removeAt(elements.lastIndex)
        }
    }
}


Measured memory_bytes: 107816
#include <stdio.h>
#include <string.h>
int main() {
	char s[1001];
	scanf("%s", s);
	char a = s[0];
	if ('a' <= a && a <= 'z') {
		printf("a\n");
	} else {
		printf("A\n");
	}
	return 0;
}

Measured memory_bytes: 1612
n, m = map(int, input().split())

g = [[] for _ in range(1005)]

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

vis = [0] * 1005


def dfs(x, p):
    if vis[x]:
        return []
    p.append(x)
    vis[x] = 1
    for v in g[x]:
        if v in p:
            return p
        t = dfs(v, p)
        if len(t):
            return t
    p.pop()
    return []


t = []
for i in range(1, 1 + n):
    t = dfs(i, [])
    if len(t):
        print(0)
        exit(0)

print(-1)






Measured memory_bytes: 44392
N, M, K = [int(_) for _ in input().split()]


def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod


mod = 10**9 + 7  #出力の制限
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  #逆元テーブル
inverse = [0, 1]  #逆元テーブル計算用テーブル

for i in range(2, N * M + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)


def count(n, m):
    ret = 0
    for d in range(1, n):
        ret += d * (n - d) * m**2
    return ret


ans = cmb(N * M - 2, K - 2, mod)
ans *= count(N, M) + count(M, N)
ans %= mod
print(ans)


Measured memory_bytes: 27024
n = int(input())
a = list(map(int, input().split()))


# whether we can make wood
m = [1]

flag = True

for i in range(n+1):
    if m[i] < a[i]:
        flag = False
        break
    elif i < n:
        m.append((m[i] - a[i]) * 2)

# count nodes

s = 0

if not flag:
    s = -1

else:
    u = 0

    for i in reversed(range(n+1)):
        s += min(a[i] + u, m[i])
        u += a[i]

print(s)

Measured memory_bytes: 674440
#include<stdio.h>
int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<=0||a>=10||b<=0||b>=10)
	{
		printf("-1");
		return 0;
	}
	else
	{
		printf("%d",a*b);
		return 0;
	}
}


Measured memory_bytes: 128
from collections import deque


n = int(input())
info = [list(map(int, input().split())) for i in range(n)]
info = sorted(info, reverse=True)
MOD = 998244353

dp = [0] * (n + 1)
dp[0] = 1
q = deque([])

for i in range(n):
    # 起動しない場合
    dp[i + 1] += dp[i]
    
    # 起動する場合
    x, d = info[i]
    l, r = x, x + d
    num = 1
    while True:
        if not q:
            q.append((l, num))
            break
        tmp_l, tmp_num = q.pop()
        if r > tmp_l:
            num = tmp_num + num
        else:
            q.append((tmp_l, tmp_num))
            q.append((l, num))
            break
    num = q[-1][1]
    dp[i + 1] += dp[i + 1 - num]
    dp[i + 1] %= MOD
    
print(dp[-1])  

Measured memory_bytes: 86744
#include <iostream>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;

#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return(0)
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(e, elem) for(auto& (e) : (elem))
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define all(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e);
using ll = long long;
using ull = unsigned long long;

int main() {
    FAST;

    string s;
    cin >> s;

    if(s[2] == s[3] && s[4] == s[5]){
        println("Yes");
    }else{
        println("No");
    }
}

Measured memory_bytes: 256
# 計算量 O(NC) = O(3 * 10 ** 6)
import sys
input = sys.stdin.readline

N, C = map(int, input().split())

# 入力
lst = [[0] * (10 ** 5 + 10) for _ in range(C + 1)]

for _ in range(N):
    s, t, c = map(int, input().split())
    lst[c][s] += 1
    lst[c][t + 1] -= 1

#番組ごとに毎分必要かどうかを判断する
for i in range(1, C + 1):
    for j in range(1, 10 ** 5 + 10): #いもす法で計算
        lst[i][j] += lst[i][j - 1]
    for j in range(1, 10 ** 5 + 10): #重なっている時 = 連続して使う時
        lst[i][j] = min(1, lst[i][j])

for j in range(1, 10 ** 5 + 10):
    for i in range(1, C + 1):
        lst[i][j] += lst[i - 1][j]

print (max(lst[-1]))


Measured memory_bytes: 67036
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll n, i, m, ans = LLONG_MAX, x, j;
    cin >> n >> m >> x;
    ll a[n][m], c[n];
    for(i = 0; i < n; i++)
    {
        cin >> c[i];
        for(j = 0; j < m; j++)
            cin >> a[i][j];
    }
    for(i = 0; i < (1 << n); i++)
    {
        ll cost = 0;
        vll know(m);
        for(j = 0; j < n; j++)
        {
            if(i & (1 << j))
            {
                for(ll k = 0; k < m; k++)
                    know[k] += a[j][k];
                cost += c[j];
            }
        }
        for(auto p: know)
            if(p < x)
                cost = -1;
        if(cost >= 0)
            ans = min(cost, ans);
    }
    if(ans == LLONG_MAX)
        ans = -1;
    cout << ans << endl;
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
using LL = long long;
using VI = vector<int>;

int main()
{
  LL X; cin >> X;
  LL money = 100;
  int year = 0;
  while(money < X) {
    money += money/100;
    year++;
  }
  cout << year;
}

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

int count_digit(long long n) {
  int ans = 1;
  while (n /= 10) {
    ans++;
  }
  return ans;
}

int main(void) {
  long long N;
  cin >> N;
  int ans = INT_MAX;
  for (long long i = 1; i * i <= N; i++) {
    if (N % i != 0) continue;
    long long A = i;
    long long B = N / i;
    ans = min(ans, max(count_digit(A), count_digit(B)));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb1 push_back
#define mod 1000000007LL
#define INF 1234567890

const int maxn = 2e5 + 10;


//initialization here
//

map<pair<ll, ll>, int> m;
//
//initialization finish


// your function is here
//



//
// your function finished



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

	// your code is here
	//
	int n, k, x, y; cin >> n >> k >> x >> y;

	if (n <= k) Print(n*x);
	else Print(k*x + (n - k)*y);

	//
	// your code finished



	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int a,b,c; cin>>a>>b>>c;
	bool ok=true;
	if(a==b && b==c)ok=0;
	if(a!=b && b!=c && a!=c)ok=0;
	if(ok) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	
	return 0;
}

Measured memory_bytes: 3612
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

struct sector{
	int begin,end,label;
	sector(int begin,int end,int label):begin(begin),end(end),label(label){}
};

int main(){
	int n;
	while(cin>>n,n){
		list<sector> sectors;
		REP(i,n){
			char command;
			cin>>command;
			int l,s;
			switch(command){
			case 'W':
				{
					cin>>l>>s;
					int left=0;
					int total=0;
					if(sectors.size()==0){
						sectors.push_back(sector(0,s-1,l));
					}else{
						for(list<sector>::iterator it=sectors.begin();it!=sectors.end();it++){
							if(left<it->begin){
								if(total+it->begin-left>=s){
									it=sectors.insert(it,sector(left,s-total+left-1,l));
									total+=s-total+left;
									break;
								}else{
									int right=it->begin-1;
									it=sectors.insert(it,sector(left,right,l));
									total+=right-left+1;
									left=it->end+1;
								}
							}else{
								if(it->end>=left){
									left=it->end+1;
								}
							}
						}
						if(total<s){
							sectors.push_back(sector(left,left+s-total-1,l));
						}
					}
				}
				break;
			case 'D':
				{
					cin>>l;
					for(list<sector>::iterator it=sectors.begin();it!=sectors.end();){
						if(it->label==l){
							it=sectors.erase(it);
							if(it==sectors.end())break;
						}else{
							it++;
						}
					}
				}
				break;
			case 'R':
				{
					cin>>l;
					int label=-1;
					for(list<sector>::iterator it=sectors.begin();it!=sectors.end();it++){
						if(it->begin<=l&&l<=it->end){
							label=it->label;
							break;
						}
					}
					cout<<label<<endl;
				}
				break;
			}
		}
		cout<<endl;
	}

}

Measured memory_bytes: 1352
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b

signed main(){
	int n;
	string s;
	cin>>n;
	int ans=n%1000;
	if(n%1000!=0){
		ans=1000-(n%1000);
	}
	cout<<ans;
		
	
	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
ll h, w, ca, cb, ans;
bool v[405][405];
char a[405][405];

void f(ll p, ll q) {
	if(p<1 || q<1 || p>h || q>w || v[p][q]) return;
	v[p][q] = 1;
	if(a[p][q]=='#') ca++; else cb++;
	if(a[p][q] != a[p+1][q]) f(p+1, q);
	if(a[p][q] != a[p-1][q]) f(p-1, q);
	if(a[p][q] != a[p][q+1]) f(p, q+1);
	if(a[p][q] != a[p][q-1]) f(p, q-1);
}

int main() {
	ll i, j;
	cin>>h>>w;
	for(i=1; i<=h; i++) scanf("%s", &a[i][1]);
	for(i=1; i<=h; i++) for(j=1; j<=w; j++) {
		if(!v[i][j]) {
			ca = cb = 0;
			f(i, j);
			ans += ca * cb;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 13056
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc=new Scanner(System.in);
    String S=sc.next();
    String T=sc.next();
    char[] s=S.toCharArray();
	char[] t=T.toCharArray();
    int count=0;
    for(int i=0;i<3;i++) if(s[i]==t[i]) count++;
    System.out.println(count);
  }
}

Measured memory_bytes: 21844
#include<iostream>
using namespace std;
int main(void){
  int n,m,x;
  for(;;){
    cin >> n >> m;
    if(!n && !m) break;
    int a[1000]={0};
    x=0;
    for(int i=1;i<=n;i++){
      for(int j=0;j<m;){
	if(a[(j+x)%n+1]==0){
	  if(j==m-1){
	    a[(j+x)%n+1]=i;
	    x=(j+x)%n+1;
	  }
	  j++;
	}
	else x++;
	x%=n;
      }
    }
    for(int i=1;i<=n;i++){
      if(a[i]==n){
	cout << i << endl;
	break;
      }
    }
  }
}


Measured memory_bytes: 1160
# -*- coding: utf-8 -*-
# 整数の入力
N = int(input())
# スペース区切りの整数の入力
high_list = [int(e) for e in input().split()]

ans=1

for i in range(1,N,1):
  
  look_flag=0
  #print("旅館の高さ:",high_list[i]) #旅館の高さ

  for j in range(0,i,1):
    #print(high_list[j]," ",end="") #左側のどれかの旅館の高さ
    if high_list[j] > high_list[i]:
      look_flag=1
      #print("NG")
      break
  
  if look_flag != 1:
    #print("OK")
    ans=ans+1
  
print(ans)

Measured memory_bytes: 3060
// Problem : D - Alter Altar
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)


#include<bits/stdc++.h>
#define 	ll		    long long
#define 	rep(i,a,n)  for(int i=a;i<n;i++)
#define 	MOD 		1000000007
#define 	vp 			vector<pair<int,int> >
#define 	ff 			first
#define 	ss 			second
#define 	pb 			push_back
#define 	all(x) 		(x.begin(),x.end())
#define 	dg(x)		cerr<<"--- x = "<<x<<"\n"
#define 	endl		"\n"


using namespace std;
const int N = 1e5;
ll ar[N];
ll dp[200005][2];
string s ;
int n;
char toggle(char ch,int last){
	
	if(last)
		return ( (ch == 'W') ? 'R' : 'W');
	return ch;
}

/*int func(int cur,int last){
	if(dp[cur][last] != -1)
		return dp[cur][last];
	
	if(cur >= n)
		return 0;
	
	
	if(s[cur] == 'W'){
			char ch2 = toggle(s[cur-1] , last);
			if(s[cur] == ch2){
				 dp[cur+1][0] =  func(cur+1,0);
				 return dp[cur][last] = dp[cur+1][0];
			}
			
			else{
				
				dp[cur+1][0] = func(cur+1,0);
				dp[cur+1][1] = func(cur+1,1);
				return dp[cur][last] = min(dp[cur+1][0] , 1 + dp[cur+1][1]);
			}
	}
	else{
			char ch2 = toggle(s[cur-1] , last);
			if(s[cur] == ch2){
				dp[cur+1][0] = func(cur+1,0);
				dp[cur+1][1] = func(cur+1,1);
				return dp[cur][last] = min(dp[cur+1][0] , 1 + dp[cur+1][1]);
			}
			
			else{
				
				dp[cur+1][1] = func(cur+1,1);
				return dp[cur][last] = 1 + dp[cur+1][1];
			}
	}
		
}
*/
void solve(){
    cin >> n;
    cin >> s;
   // memset(dp,-1,sizeof(dp));
//	cout << min(func(1,0), 1  + func(1,1));
	int ans = 0;
	stack<int> st;
	rep(i , 0, n){
		if(s[i] == 'R')
			st.push(i);
	}
	rep(i,0,n){
		if(st.empty())
			break;
		if(s[i] == 'W')
		{
			int j= st.top();
			st.pop();
			if(j > i)
				//swap(s[j], s[i]);
				ans++;
			else
				break;
		}
	}
	cout << ans;

}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
}


Measured memory_bytes: 4252
package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r:rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf) + 1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf) + 1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

func main() {

	sc := NewScanner()
	N := sc.NextInt()
	T := sc.NextIntArray()
	A := sc.NextIntArray()

	mns := make([]int, N)
	mxs := make([]int, N)

	mns[0] = T[0]
	mxs[0] = T[0]
	for i := 1; i < N; i++ {
		if T[i - 1] == T[i] {
			mns[i] = 1
		} else {
			mns[i] = T[i]
		}
		mxs[i] = T[i]

	}

	if mxs[N - 1] < A[N - 1] {
		fmt.Println(0)
		return
	}
	if N > 1 {
		if T[N - 2] == T[N - 1] {
			mxs[N - 1] = A[N - 1]
			mns[N - 1] = A[N - 1]
		}
	} else {
		if mxs[N - 1] != A[N - 1] {
			fmt.Println(0)
			return
		}
	}

	for i := N - 2; i >= 0; i-- {

		if A[i + 1] == A[i] {
			mns[i] = min(mns[i], A[i])
			if mxs[i] > A[i] {
				mxs[i] = A[i]
			}
		} else {
			mns[i] = max(mns[i], A[i])
			if A[i + 1] < A[i] && mxs[i] < A[i] {
				fmt.Println(0)
				return
			}
			mxs[i] = A[i]

		}

	}
	//fmt.Printf("%+v\n", mns)
	//fmt.Printf("%+v\n", mxs)

	l := 1
	for i := 0; i < N; i++ {
		l *= mxs[i] - mns[i] + 1
		l %= (1e9) + 7
	}
	fmt.Println(l)

}

func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a int, b int) int {
	if a < b {
		return b
	}
	return a
}


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

using namespace std;

int main()
{
	int a, b;
	char c[100][100];
	cin >> a >> b;
	
	for (int i = 0; i < 100; i++)
		for (int j = 0; j < 100; j++)
			c[i][j] = (j >= 50 ? '#' : '.');
			
	a--;
	b--;

	for (int i = 1; i < 99 && b; i += 2)
		for (int j = 1; (j < 49) & (b > 0); j += 2)
		{
			c[i][j] = '#';
			b--;
		}
		
	for (int i = 1; i < 99 && a; i += 2)
		for (int j = 51; (j < 99) && (a > 0); j+= 2)
		{
			c[i][j] = '.';
			a--;
		}
	cout << "100 100\n";	
	for (int i = 0; i < 100; i++)
	{
		for (int j = 0; j < 100; j++)
			cout << c[i][j];
			
		cout << endl;
	}
}

Measured memory_bytes: 256
s=input()

if s == s[::-1]:
    if s[0:(len(s)-1)//2] ==s[0:(len(s)-1)//2][::-1]:
        if s[(len(s)+2)//2:] == s[(len(s)+2)//2:][::-1]:
            print("Yes")
            exit()
print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <numeric>
#include <set>
#include <list>
#include <map>
#include<queue>

const int INF = 1 << 28;
const long long MOD = 1000000007;
using namespace std;
using Graph = vector<vector<int>>;

template<class T> bool chmin(T &a, T &b) { if (a > b) { a = b; return 1; }return 0; }
template<class T> bool chmax(T &a, T &b) { if (a < b) { a = b; return 1; }return 0; }
template<class T, class U> using P = pair<T, U>;

vector<int> seen(50,-1);
int counter_for_dfs = 0;
void dfs(Graph &G, int v) {
	seen[v] = counter_for_dfs;
	counter_for_dfs++;
	for (auto v_next : G[v]) {
		if (seen[v_next]>=0)continue;

		dfs(G, v_next);
	}
}

void bfs(Graph &G) {
	vector<int> dist(G.size(), -1);
	queue<int> que;
	
	dist[0] = 0;
	que.push(0);
	while (!que.empty()) {
		int v = que.front();
		que.pop();

		for (int g : G[v]) {
			if (dist[g] != -1)continue;
			dist[g] = dist[v] + 1;
			que.push(g);
		}
	}
	for (auto i : dist) {
		cout << i << " ";
	}
}

int counter[200005] = {};
void bfs2(Graph &G,int p,int x) {
	vector<int> dist(G.size() , -1);
	queue<int> que;
	
	dist[p] = 0;
	que.push(p);
	while (!que.empty()) {
		int v = que.front();
		que.pop();

		for (int g : G[v]) {
			if (dist[g] != -1)continue;
			dist[g] = dist[v] + 1;
			que.push(g);
			counter[g] += x;
		}
	}
}
int main()
{
	int n;
	std::cin >> n;
	vector<std::pair<int,int>> a;
	for (int i = 0; i < n; i++) {
		int b;
		std::cin >> b;
		a.push_back(std::make_pair(b,i+1));
	}
	sort(a.begin(), a.end());

	for (auto b : a) {
		std::cout << b.second << " ";
	}



	return 0;
}

Measured memory_bytes: 1780
#!python3.4
# -*- coding: utf-8 -*-
# abc160/abc160_c
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    K, N = i2nn()
    A = i2nn()
    A.append(K + A[0])
    max_d = 0
    for i in range(N):
        d = A[i + 1] - A[i]
        max_d = max(max_d, d)
    print(K - max_d)
    return

main()


Measured memory_bytes: 26836
#include<bits/stdc++.h>	
 
#define f first
#define s second
#define pb push_back
 
#define ll long long
 
#define int ll
 
#define mp make_pair
  
using namespace std;
                       
 
const int inf = 1e9 + 7;
 
const ll ll_inf = 1e18 + 7;
const int K = 2e5;
const int N = 2e5 + 300;
                                         
ll binpow (ll a, ll n)
{
	if(n == 0)
		return 1ll;
    ll res = 1;
    while (n) {
        if (n & 1)
        {
            res *= a;
            res %= inf;
        }      	
        a *= a;
        n >>= 1;
        a %= inf;
    }                          
    return res;
}   
          
  
 
void boost()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}  
 
int n,dp[2010][2010]; 
 
pair<int, int> a[2020];
 
int rec(int l, int r, int v) 
{
	if(l == r) 
		return 0;              
 
	if(dp[l][r] != -1) 
		return dp[l][r];
	dp[l][r] = max(rec(l + 1, r, v - 1) + abs(l - a[v].s) * a[v].f, rec(l, r - 1, v - 1) + abs(r - 1 - a[v].s) * a[v].f);
	return dp[l][r];
}
 
main() 
{
	cin >> n;
	for (int i = 0;i <= n + 1;i++)
	{
		for (int j = 0;j <= n + 1;++j)
			dp[i][j] = -1;
	}
	for(int i = 1;i <= n;++i) 
	{
		cin >> a[i].f;
		a[i].s = i;
	}
	sort(a + 1, a + n + 1);         
	cout << rec(1, n + 1, n);
}

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

int main() {
    int n,ma,mb,ans=1000000;
    cin>> n >> ma >> mb;
    vector<vector<int>> a(500,vector<int>(500));
    int t,y,u;
    rep(i,500){
        rep(j,500) a.at(i).at(j)=1000000;
    }
    a.at(0).at(0)=0;
    rep(i,n){
        cin >> t >> y >> u;
        for(int j=499;j>-1;j--){
            for (int k=499;k>-1;k--){
                if (j+t>=500 || k+y>=500) continue;
                if (a.at(j).at(k)!=1000000){
                    
                    a.at(j+t).at(y+k)=min(a.at(j).at(k)+u,a.at(j+t).at(y+k));
                    int o=__gcd(j+t,k+y);
                    if ((j+t)/o==ma && (k+y)/o==mb) ans=min(ans,a.at(j).at(k)+u);
                }
            }
        }
    }
    if (ans==1000000) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 1280
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define INIVAL 2147483647

int *a, *ts, c, s, t, v;

void update(int k, int l, int r)
{
  if (r<s || t<=l) return;
  if (s<=l && r<=t) {
    a[k] = v;
    ts[k] = c;
  } else if (l<r-1) {
    update(((k+1)<<1)-1, l, (l+r)>>1);
    update((k+1)<<1, (l+r)>>1, r);
  }
}

int main()
{
  int i, k, n, z, w, latest;
  char *p,buf[64] = {0};
  buf[62] = '\n';
  fgets(buf, 64, stdin);
  for (n=0,p=buf; *p>' '; n=n*10+*(p++)-'0');
  w = n>1 ? pow(2,(int)ceil(log2(n)))-1 : 1;
  ts = (a = (int*)malloc((w+n)*2*sizeof(int))) + w+n;
  for (i=0; i<w+n; i++)  ts[i] = -1;
  a[0] = INIVAL;
  ts[0] = 0;
  c = 0;
  while (fgets(buf, 64, stdin)) {
    for (s=0,p=buf+2; *p>' '; s=s*10+*(p++)-'0');
    if (*buf=='0') { // update(s, t, x)
      for (t=0,p++; *p>' '; t=t*10+*(p++)-'0');
      for (v=0,p++; *p>' '; v=v*10+*(p++)-'0');
      t++;
      update(0, 0, w+1);
      c++;
    } else { // find(x) x->s
      latest = -1;
      for (k=w+s; ; k=(k-1)>>1) {
	if (ts[k]>latest) {
          latest = ts[k];
          z = a[k];
        }
	if (k==0) break;
      }
      if (z<10) {
	putc_unlocked('0'+z, stdout);
	putc_unlocked('\n', stdout);
      } else {
        for (i=62; z>0; buf[--i]='0'+z%10,z/=10);
        fputs(buf+i, stdout);
      }
    }
  }
  return 0;
}



Measured memory_bytes: 4480
/*           pmaik
    ░▒▓█►─═ Maneesh ═─◄█▓▒░


          ( •̪●)
        ███████]▄▄▄▄▄▄▄▄▃  ▃  ▃ 
    ▂▄▅█████████▅▄▃▂
   [███████████████████]
  ...◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤......  */

#include<bits/stdc++.h>
using namespace std;
#define inf() ifstream cin("in00.txt")
#define onf() ofstream cout("out00.txt")
#define ll long long int
#define pb push_back
#define pf push_front
#define mp make_pair
#define pii pair<ll,ll>
#define fi first
#define se second
#define M 1000000007
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);

void solve()
{
	ll n,k;
	cin>>n>>k;
	ll a[n+1],i,j;
	for(i=1; i<=n; i++)
		cin>>a[i];
	
	ll dp[n+1];
	dp[0]=0; dp[1]=0; dp[2]=abs(a[1]-a[2]);

	for(i=3; i<=n; i++)
	{
		ll mn=INT_MAX;
		for(j=i-1; j>=i-k && j>=1; j--)
		{
			mn=min(mn, dp[j]+abs(a[i]-a[j]));
		}
		dp[i]=mn;

		// cout<<dp[i]<<" ";
	}

	cout<<dp[n]<<endl;
}

int main()
{
    fastio;
    
    solve();

    return 0;
}


Measured memory_bytes: 5188
#include<bits/stdc++.h>
using namespace std;
#define watch(x) cout<<(#x)<<" is "<<(x)<<endl;
#define mod 1000000007
#define pb push_back
#define endl '\n'


int main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cout.tie(0);

	int n;
	cin>>n;
	string s;
	map<string,int> m;
	for(int i=0;i<n;i++)
	{
		
		cin>>s;
		m[s]++;
	}

	vector<pair<int,string>>  v;

	for(auto it:m)
	{
		v.push_back({it.second,it.first});
	}

	sort(v.begin(),v.end());

	reverse(v.begin(),v.end());

	int count = v[0].first;
	stack<string> ko;

	for(auto it:v)
	{
		if(it.first >= count) ko.push(it.second);
		else break;
	}

	while(ko.size()>0) 
	{
		cout<<ko.top()<<endl;
		ko.pop();
	}




}

Measured memory_bytes: 29548
#include <iostream>
#define REP(i, a, n) for(int i = a; i < n; i++)
using namespace std;
 
 
int n;
long M, m, s;
 
int main(void) {
  cin >> n;
 
  M = -1000000;
  m =  1000000;
  s = 0;
 
  REP(i, 0, n) {
    long a;
    cin >> a;
    M = max(M, a);
    m = min(m, a);
    s += a;
  }
 
  cout << m << " " << M << " " << s << endl;
 
  return 0;
}


Measured memory_bytes: 3084
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<functional>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const LL mod=1000000007;
LL N;
string s,t;
priority_queue<int,vector<int>,greater<int> > pq;
int main(){
    cin>>N;
    pq.push(0);
    for(int i=0;i<N;i++){
        LL M;
        cin>>M;
        vector<int> v;
        for(int j=0;j<M;j++){
            int c;
            cin>>c;
            v.push_back(c);
        }
        sort(v.begin(),v.end());
        for(int j=0;j<=min(i+1,(int)v.size()-1);j++){
            if(pq.size()<i+1){
                pq.push(v[v.size()-1-j]);
            }
            else if(v[v.size()-1-j]>pq.top()){
                pq.pop();
                pq.push(v[v.size()-1-j]);
            }
        }
    }
    LL ans=0;
    while(!pq.empty()){
        ans+=pq.top();pq.pop();
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4784
import java.util.*;
public class Main{
  public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int[] N = new int[3];
   	N[0] = sc.nextInt();
   	N[1] = sc.nextInt();
   	N[2] = sc.nextInt();
    
    Arrays.sort(N);
	System.out.println(N[0]+N[1]);
 }
}

Measured memory_bytes: 23124
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
#include <atcoder/all>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) for(int sz=0;sz<int(vec.size());sz++) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q; cin >> n >> q;
    atcoder::fenwick_tree<ll> fw(n);
    for (int i = 0; i < n; i++) {
        ll a; cin >> a;
        fw.add(i, a);
    }

    for (int i = 0; i < q; i++) {
        int t, a, b; cin >> t >> a >> b;
        if (t == 0) fw.add(a, b);
        else cout << fw.sum(a, b) << '\n';
    }
    return 0;
}


Measured memory_bytes: 8252
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        int a[] = new int[m];
        for(int i = 0; i < m; i++){
            a[i] = scan.nextInt();
        }
        
        for(int i = 0; i < m; i++){
            n = n - a[i];
        }

        if(n < 0){
            System.out.println("-1");
        }else{
            System.out.println(n);
        }
    }
}

Measured memory_bytes: 46148
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

int main() {
	string s;
	cin >> s;
	int n = s.length();
	int ans = 0, ans1 = 0;
	if (n % 2) {
		for (int i = 0; i < n; i++) {
			if (i % 2) {
				if (s[i] == 'g')ans++;
				continue;
			}
			else {
				if (s[i] != 'g')ans--;
				continue;
			}
		}
	}
	else {
		for (int i = 0; i < n; i++) {
			if (i % 2) {
				if (s[i] == 'g')ans++;
				continue;
			}
			else {
				if (s[i] != 'g')ans--;
				continue;
			}
		}
		for (int i = 1; i < n; i++) {
			if (i % 2) {
				if (s[i] != 'g')ans1--;
				continue;
			}
			else {
				if (s[i] == 'g')ans1++;
				continue;
			}
		}
		ans = max(ans, ans1);
	}
	cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define rt return 0
#define endln "\n"
#define all(v) v.begin(), v.end()
#define for1(i, a, b) for (long long int i = a; i < b; i++)
#define for2(i, a, b) for (long long int i = a; i > b; i--)
//  cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;typedef long long int i;
typedef long long int lli;
typedef pair<lli, lli> pll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli x;
    cin >> x;
    if (x >= 1800)
    {
        cout << "1" << endl;
        return 0;
    }
    if (x >= 1600)
    {
        cout << "2" << endl;
        return 0;
    }
    if (x >= 1400)
    {
        cout << "3" << endl;
        return 0;
    }
    if (x >= 1200)
    {
        cout << "4" << endl;
        return 0;
    }
    if (x >= 1000)
    {
        cout << "5" << endl;
        return 0;
    }
    if (x >= 800)
    {
        cout << "6" << endl;
        return 0;
    }
    if (x >= 600)
    {
        cout << "7" << endl;
        return 0;
    }
    cout << "8" << endl;

    vector<lli> v;
}

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

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

    int n;
    cin >> n;
    
    int ans = 0;
    
    if(n > 99999){
        ans += 90909;
    }
    else if(n > 999){
        ans += 909;
        
        if(n >= 10000){
            ans += n - 9999;
        }
    }
    else if(n > 9){
        ans += 9;
        
        if(n >= 100){
            ans += n - 99;
        }
    }
    else{
        ans = n;
    }
    
    cout << ans << endl;

    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long int lli;
typedef long long ll;

int main(){
    int n,k; cin >> n >> k;
    vector<int> h(n); rep(i,n) cin >> h[i];

    sort(all(h));

    int ans = inf;
    rep(i,n){
        if(i+k-1 >= n) break;
        ans = min(ans, h[i+k-1]-h[i]);
    }

    cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define fr(i,n) for(ll i=0;i<n;i++)
using namespace std;
const ll mod=1e9+7;
/*const ll A = 1000005;
ll k[A],j[A];ll a,b,ans=0,n=0,gc;
ll solve(){
for(ll i=0;i<n;i++)
    {

        for(ll ii=i+1;ii<n;ii++)
        {
            cout<<j[i]<<" "<<j[ii]<<endl;
            if(__gcd(j[i],j[ii])==1)ans++;
        }

    }
    return ans;}
*/

ll current;

int main() {
   /* cin>>a>>b;gc=__gcd(a,b);
    for(ll i=1;i<=gc;i++)
    {if(a%i==0&&b%i==0)j[n]=i,n++;}


    cout<<solve();
    */
ll n;
cin>>n;
map<ll,ll>k;
for(ll i=1;i<=n;i++){
     current =i;
    for(ll j=2;j*j<=current;j++){
        while(current%j==0)
        {
            current/=j;
            k[j]++;
        }
    }
if(current!=1)k[current]++;}

    ll ans =1;
    map<ll,ll>::iterator i=k.begin();
    for(;i!=k.end();i++)
    {
        ans=(ans*((i)->second +1))%mod;

    }
    cout<<ans;}


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

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

int main(void){
    int n, len = 0, count;
    cin >> n;

    int x = n;
    while(x != 0){
        x = x / 10;
        len++;
    }

    rep(i, len){
        if((i + 1) % 2 == 1){
            if(i + 1 == len){
                count += n - pow(10, i) + 1;
            }else{
                count += pow(10, i + 1) - pow(10, i);
            }
        }
    }

    cout << count << endl;
}


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

int main()
{
	int m, f, r;
	while (cin >> m >> f >> r, !(m == -1 && f == -1 && r == -1)) {
		if (m == -1 || f == -1) cout << "F" << endl;
		else if (m + f >= 80) cout << "A" << endl;
		else if (m + f >= 65 && m + f < 80) cout << "B" << endl;
		else if (m + f >= 50 && m + f < 65) cout << "C" << endl;
		else if ((m + f >= 30 && m + f < 50) && r >= 50) cout << "C" << endl;
		else if (m + f >= 30 && m + f < 50) cout << "D" << endl;
		else cout << "F" << endl;
	}
    return 0;
}

Measured memory_bytes: 1156
import collections
import math
n = int(input())
ai = [int(i) for i in input().split()]

mod = 10**9+7

if n == 1:
    print(1)
    exit()
    
    
# 素因数分解、辞書で返すやつ
# mathをimportする
def prime(n):
    factor = {}
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            if not num in factor.keys():
                factor[num] = 1
            else:
                factor[num] += 1
        if num > n:
            break
    if n != 1:
        if not n in factor.keys():
            factor[n] = 1
        else:
            factor[n] += 1
    return factor


dic = {}
for a in ai:
    pr = prime(a)
    for num, count in pr.items():
        if not num in dic.keys():
            dic[num] = count
        else:
            if dic[num] < count:
                dic[num] = count

kari = 1
for num,count in dic.items():
    kari *= pow(num,count,mod)
    kari %= mod

kari_old = kari
ans = 0

for i in range(n):
    kari = kari_old
    #com_ab_new = copy.deepcopy(com_ab)
    #print(com_ab,com_ab_new)
    #kari = 1
    #for j in range(kosu):
    #kari *= pow(sosu_li[j][0],com_ab[sosu_li[j][0]],mod)
    kari *= pow(ai[i],mod-2,mod)
    ans += kari
    ans %= mod
    #print(ans)
    #print(ans)
        
print(ans)


Measured memory_bytes: 4972
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int n, c[500], s[500], f[500];

    cin >> n;
    for (int i = 0; i < n - 1; i++)
        cin >> c[i] >> s[i] >> f[i];

    for (int i = 0; i < n; i++)
    {
        int ans = 0;
        int j = i;
        while (j < n - 1)
        {

            if (ans > s[j])
            {
                int tmp = (ans - s[j]) / f[j];
                if ((ans - s[j]) % f[j] != 0)
                    tmp++;
                ans = s[j] + tmp * f[j] + c[j];
            }
            else
            {
                ans = s[j] + c[j];
            }

            j++;
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
x,y = map(int,input().split())

A = [1,3,5,7,8,10,12]
B = [4,6,9,11]

if x == 2 or  y == 2:
    print ("No")

elif ( x in A and y in A) or ( x in B and y in B ):
    print ( "Yes" )

else:
    print ( "No" )

Measured memory_bytes: 3060
N = int(input())
L = list(map(int,input().split()))
c = 0
for i in range(N):
    for j in range(N):
        for k in range(N):
            if i != j and j != k and k != i :
                if L[i] != L[j] and L[j] != L[k] and L[k] != L[i] :
                    if L[i] + L[j] > L[k] and L[j] + L[k] > L[i] and L[k] + L[i] > L[j] :
                        c = c + 1

print(int(c/6))

Measured memory_bytes: 9204