akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

int main()
{
  int n;
  int h[100];
  cin >> n;
  rep(i, n)
  {
    cin >> h[i];
  }
  int max = h[0];
  int ans = 1;
  for (int j = 1; j < n; j++)
  {
    if (h[j] >= max)
    {
      max = h[j];
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3564
#include <iostream>
#include <string>
using namespace std;
int main()
{
  int N;
  string A[50];
  int B[50];
  string C;
  int i;
  int x=0;
  int S=0;
  
  cin >> N;
  for(i=0;i<N;i++){
    cin >> A[i];
    cin >> B[i];
  }
  cin >> C;
  for(i=0;i<N;i++){
    if(x==1){
      S+=B[i];
    }
    if(A[i]==C){
      x=1;
    }
  }
  cout << S;
}



Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    char buffer[25];
    int n, x, solution;
    int i, j, k;
    int ways[100], count;
    
    for(count=0;;count++)
    {
        fgets(buffer, 25, stdin);
        sscanf(buffer, "%d %d", &n, &x);
        if(0 == n && 0 == x) break;
        solution=0;
        for(i=1;i<=n;i++)
        {
            for(j=i+1;j<=n;j++)
            {
                for(k=j+1;k<=n;k++)
                {
                    if(i+j+k==x)solution++;
                }
            }
        }
        ways[count]=solution;
    }
    for(i=0;i<count;i++)
    {
        printf("%d\n", ways[i]);
    }
    return(0);
}


Measured memory_bytes: 2100
fun abs(x: Int) = if (x < 0) -x else x

fun main(args: Array<String>) {
    val inputs = readLine()!!.split(' ').map { it.toInt() }
    val n = inputs[0]
    val l = inputs[1]
    val tastes = (0.until(n)).map { i -> l + i }
    val allapplepietaste = tastes.sum()
    val subtastes = (0.until(n)).map { i -> allapplepietaste - tastes[i] }
    val subtaste = subtastes.minBy { sub -> abs(allapplepietaste - sub) }
    println(subtaste)
}

Measured memory_bytes: 38296
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  int h, n;
  cin >> h >> n;
  vector<int> a(n);
  for (auto &x: a) cin >> x;

  for (auto &x: a) h -= x;
  if (h <= 0) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>

#define lowbit(x) (x&(-x))
#define MAX(a,b) (a<b?b:a)
#define MIN(a,b) (a<b?a:b)
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int N = 1e7;
const int maxn = 2e5 + 5;
ll mod = 1e9 + 7;

int cnt[maxn];
char s[maxn];

int main()
{
	scanf("%s", s);
	ll sum = 0, ans = 1;
	for (int i = 0; s[i]; i++)
	{
		ans += sum - cnt[s[i]];
		sum++;
		cnt[s[i]]++;
	}

	printf("%lld", ans);
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<climits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;

using namespace std;

int main(){
int N;
cin >> N;
int64_t luc[90];
luc[0] = 2;
luc[1] = 1;
for (int i = 2; i <= N; i++)
{
    luc[i] = luc[i-1] + luc[i-2];
    
}



cout << luc[N] << endl;


}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(){
    int tower[999];
    int a, b;
    int i, i_cnt = 0;

    scanf("%d %d", &a, &b);
    tower[0] = 1;
    for(i = 1; i < 999; i++){
        tower[i] = tower[i - 1] + (i + 1);
        if(tower[i] - tower[i - 1] == (b - a)){
            i_cnt = i;
            break;
        }
    }
    //printf("%d\n", i_cnt);
    printf("%d\n", tower[i_cnt] - b);

    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>

#define NODE (100)
#define TICKET (10)
#define INF (100000000)

int U[NODE];
int dist[TICKET + 1][NODE];
int cost[NODE][NODE];
int c, n, s, d;
int V;

int min(int a, int b)
{
    return (a > b ? b : a);
}

void dijkstra(int s)
{
	int i, j, k;
	int v;
	
	for (i = 0; i < V; i++){
		U[i] = 1;
	}
    
    for (i = 0; i <= c; i++){
        for (j = 0; j < V; j++){
            dist[i][j] = INF;
        }
    }
    
    
    for (i = 0; i <= c; i++){
        dist[i][s] = 0;
    }
    for (k = 0; k <= c; k++){
        memset(U, 0, sizeof(U));
    	for (i = 0; i < V; i++){
    		v = -1;
		    for (j = 0; j < V; j++){
			    if (U[j] == 0 && (v == -1 || dist[k][v] > dist[k][j])){
				    v = j;
    			}
	    	}
		    
    		if (v == -1){
	    		break;
		    }
		    
    		U[v] = 1;
            
		    for (j = 0; j < V; j++){
                if (U[j] == 0){
                    if (k == 0){
                        dist[k][j] = min(dist[k][j], dist[k][v] + cost[v][j]);
                    }
                    else {
                        dist[k][j] = min(dist[k][j], min(dist[k][v] + cost[v][j], dist[k - 1][v] + cost[v][j] / 2));
                    }
                }
		    }
	    }
    }
}

int main(void)
{
	int i, j;
	int from, to, m;
	
	while (1){
		scanf("%d%d%d%d%d", &c, &V, &n, &s, &d);
		
		if (c + V + n + s + d == 0){
			break;
		}
		
		for (i = 0; i < V; i++){
			for (j = 0; j < V; j++){
				cost[i][j] = INF;
			}
		}
		
		while (n-- != 0){
			scanf("%d%d%d", &from, &to, &m);
			cost[from - 1][to - 1] = cost[to - 1][from - 1] = m;
		}
        
		dijkstra(s - 1);
        
        printf("%d\n", dist[c][d - 1]);
	}
	return (0);
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<functional>
#include<string>
#include<string.h>
#include<limits.h>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#define int long long
using namespace std;

signed main() {
	int a, b; cin >> a >> b;
	int c = b * 1900 + (a - b) * 100;
	cout << c*(1 << b) << endl;
}

Measured memory_bytes: 764
s = gets.chomp
t = gets.chomp
 
counter = -1
i = s.length
t.each_char do |char|
  i = s.index(char, i + 1)
  if i.nil?
    counter += 1
    i = s.index(char)
    break if i.nil?
  end
end
 
if i.nil?
  puts(-1)
else
  puts((s.length * counter + i + 1).to_s)
end

Measured memory_bytes: 2172
require "set"
n, k = gets.chomp.split(" ").map(&:to_i)
s = Set.new
k.times {
  d = gets.chomp.to_i
  a_row = gets.chomp.split(" ").map(&:to_i)
  a_row.each { |col| s << col }
}
puts n - s.count

Measured memory_bytes: 14536
#define N 100005
#define NIL -1
struct Node{
    int p;
    int l;
    int r;
};
struct Node T[N];
int depth(int);
int child(int);
int main(){
    int i, j;
    int n, b, d, c, m;
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        T[i].p = NIL;
        T[i].l = NIL;
        T[i].r = NIL;
    }
    for(i = 0; i < n; i++){
        scanf("%d %d", &b, &d);
        for(j = 0; j < d; j++){
            scanf("%d", &c);
            T[c].p = b;
            if(j == 0){
                T[b].l = c;
            } else {
                T[m].r = c; }
            m = c; }
    }
    for(i = 0; i < n; i++){
        printf("node %d: parent = %d, depth = %d, ", i, T[i].p, depth(i));
        if(T[i].p == NIL){
            printf("root, [");
        } else if(T[i].l == NIL){
            printf("leaf, [");
        } else{
            printf("internal node, [");
        }
        child(T[i].l);
        printf("]\n");
    }
    return 0; }
int depth(int x){
    int a;
    if(T[x].p == NIL){
        return 0;
    } else{
        a = depth(T[x].p) + 1;
        return a; }
}
int child(int x){
    if(x==NIL){

        return 0;
    } else {
        if(T[x].r == NIL){
            printf("%d", x);
        } else{
            printf("%d, ", x);
            child(T[x].r);
        } }
}


Measured memory_bytes: 2908
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


int main(){
    int n,k;
    cin>>n>>k;
    rep(i,n){
        int a;
        cin>>a;
    }
  
    int ans=0;
    int r=0;
    while(r<n-1){
        ans++;
        r+=k-1;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3596
#include <stdio.h>

int isright(int, int, int);

int main(void){
	int i, N, a, b, c;
	scanf("%d\n", &N);
	for(i = 0; i < N; i++){
		scanf("%d %d %d", &a, &b, &c);
		if((a*a == b*b + c*c) || (b*b == c*c + a*a) || (c*c == a*a + b*b)){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	
	return 0;	
}

Measured memory_bytes: 580
/* ****revpro**** */
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl     '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii      map<ll,ll>
using namespace std;

#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define N  100005
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;  
#define ordered_set tree<double, null_type,less<double>, rb_tree_tag,tree_order_statistics_node_update> 
void solve()
{ 
  ll n,k,c;
  cin>>n>>k>>c;
  ll a[n];
  ll idx,cnt=0;
  rep(i,0,n)
  {
    char c;
    cin>>c;
    if(c=='o') {
      a[i]=1;
      idx=i;
      cnt++;
    }
    else a[i]=0; 
  }
  // rep(i,0,n) cout<<a[i]<<' ';
  // cout<<endl;
  if(k==1)
  {
    if(cnt==1)
    {
      cout<<idx+1<<endl;
      return ;
    }
    else 
    {
      return;
    }
  }
  ll l[n+1],r[n+1];
  rep(i,0,n+1) l[i]=n+1,r[i]=0;
  l[0]=0;
  r[0]=n+1;
  ll cur=0;
  ll pre[n+2]={0};
  rep(i,0,n)
  {
    if(a[i])
    {
      if(cur==0) {
        l[cur+1]=i+1;
        cur++;
      }
      else{
        if(i+1-l[cur]>c)
        {
          l[cur+1]=i+1;
          cur++;
        }
      }
    }
  }
  cur=0;
  repr(i,0,n)
  {
    if(a[i])
    {
      if(cur==0) {
        r[cur+1]=i+1;
        cur++;
      }
      else{
        if(r[cur]-(i+1)>c)
        {
          r[cur+1]=i+1;
          cur++;
        }
      }
    }
  }
  rep(i,0,k+1)
  {    

    // cout<<l[i]<<' '<<r[k-i]<<endl;
    if(i==0)
    {
      pre[0]++;
      pre[r[k]]--;
    }
    else if(i==k)
    {
      pre[l[k]+1]++;
      pre[n+1]--;
    }
    else if((-l[i]+r[k-i]>c)){
      // cout<<l[i]<<' '<<r[k-i]<<endl;
      pre[l[i]+1]++;
      pre[r[k-i]]--;
    }
  }
  ll s=pre[0];
  rep(i,1,n+1)
  {
    s+=pre[i];
    pre[i]=s;
    if((pre[i]==0)&&(a[i-1]==1)) cout<<i<<endl;
  }
}
signed main()
{
  
    /***********************************/
    unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
    mt19937_64 generator (seed);
    /***********************************/
 
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS=1;
//  cin>>TESTS;
  while(TESTS--)
  {
    solve();
    
  }
  TIME
  return 0;
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
#include <complex>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

#define EPS 1.0e-8

typedef complex<double> P;
namespace std{bool operator<(const P& a, const P& b){
  return real(a)!=real(b)?real(a)<real(b):imag(a)<imag(b);
}}
double inP(const P& p, const P& q){ return real(conj(p)*q); }
double outP(const P& p, const P& q){ return imag(conj(p)*q); }
struct L : public vector<P> {
  L(const P& a, const P& b){ push_back(a); push_back(b); }
};
typedef vector<P> G;

int ccw(P a, P b, P c){
  b-=a; c-=a;
  if(outP(b,c)>0) return +1;
  if(outP(b,c)<0) return -1;
  if(inP(b,c)<0) return +2;
  if(norm(b)<norm(c)) return -2;
  return 0;
}

G convex_hull(vector<P> &ps){
  int n=ps.size(),k=0;
  sort(ps.begin(),ps.end());
  vector<P> ch(2*n);
  for(int i=0;i<n;ch[k++]=ps[i++])
    while(k>=2&&ccw(ch[k-2],ch[k-1],ps[i])<=0)--k;
  for(int i=n-2,t=k+1;i>=0;ch[k++]=ps[i--])
    while(k>=t&&ccw(ch[k-2],ch[k-1],ps[i])<= 0)--k;
  ch.resize(k-1);
  return ch;
}

double dist(const P& x, const P& y){
  return sqrt((real(x)-real(y))*(real(x)-real(y)) + (imag(x)-imag(y))*(imag(x)-imag(y)));
}

bool check(const P& U, double R, const vector<P>& v){
  rep(i,v.size()){
    double tmp = dist(U, v[i]);
    if(R + EPS < tmp) return false;
  }
  return true;
}

int main(){
  int N;
  cin >> N;
  vector<P> ps;
  rep(i,N){
    int x, y;
    cin >> x >> y;
    ps.push_back(P(x,y));
  }

  if(N == 2){
    printf("%.12lf\n", dist(ps[0], ps[1]) / 2.0);
    return 0;
  }

  //G cvx = convex_hull(ps);
  G cvx = ps;
  
  double ret = 10000000000;
  double PI = acos(0)*2.0;
  rep(i,cvx.size()){
    rep(j,cvx.size()){
      double a = dist(cvx[i], cvx[j]);
      double R = a/2.0;
      P U = (cvx[j]-cvx[i])/2.0 + cvx[i];
      if(check(U,R,ps)){
        ret = min(ret, R);
      }
    }
  }
  rep(i,cvx.size()){
    rep(j,cvx.size()){
      rep(k,cvx.size()){
        double a = dist(cvx[i], cvx[j]);
        double b = dist(cvx[j], cvx[k]);
        double c = dist(cvx[k], cvx[i]);

        P A = cvx[k];
        P B = cvx[i];
        P C = cvx[j];
        
        P U = a*a*(b*b+c*c-a*a)*A + b*b*(c*c+a*a-b*b)*B + c*c*(a*a+b*b-c*c)*C;
        U /= a*a*(b*b+c*c-a*a) + b*b*(c*c+a*a-b*b) + c*c*(a*a+b*b-c*c);
        
        double R = (a*b*c) / sqrt((a+b+c)*(-a+b+c)*(a-b+c)*(a+b-c));
        if(check(U,R,ps)){
          ret = min(ret, R);
        }
      }
    }
  }

  printf("%.12lf\n", ret);
  
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>
#include <queue>

using namespace std;
typedef long long ll;
#define MOD 1000000007

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

    ll A[N], a=0, b=0;
    for(int i=0; i<N; i++) {
        cin >> A[i];
        if(A[i] > a) {
            b = a;
            a = A[i];
        } else if(A[i] > b) {
            b = A[i];
        }
    }

    for(int i=0; i<N; i++) {
        if(A[i] == a) {
            cout << b << endl;
        } else {
            cout << a << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
 
int main () {
	int n,m,c;
	cin >> n >> m >> c;
	vector <int> b(m+1);
	rep(i, m+1) {
		if (i == 0) continue;
		cin >> b[i];
	}
	int count = 0;
	vector <vector<int>> a(n+1, vector<int>(m+1));
	for (int i=1;i<=n;i++) {
		int sum = 0;
		for(int j=1; j <=m;j++) {
			cin >> a[i][j];
			sum += a[i][j] * b[j];
		}
		if (sum +c >0) count++;
	}
	cout << count << endl;
}


Measured memory_bytes: 888
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans = a - b * 2;
		
		if(ans > 0) {
			System.out.println(ans);
		} else {
			System.out.println(0);
		}
		
		
		
		
	}

}


Measured memory_bytes: 21844
{-# LANGUAGE BangPatterns #-}
import Data.List
import Data.Maybe
import Data.Function (fix)
import Data.Array (Array, array, (!))
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as BS8

modular :: Integer
modular = 1000000007
 
getInts :: IO [Int]
getInts = (map parseInt . BS8.words) <$> BS.getLine 
    where parseInt = fst . fromJust . BS8.readInt

solve :: Integer -> Integer
solve n
    | n == 0 = 0
    | n <= 6 = 1
    | n < 11 = 2
    | otherwise = 2 * (n `div` 11) + solve (n `mod` 11)

main :: IO ()
main = do
    [n] <- getInts
    print $ solve (fromIntegral n)

Measured memory_bytes: 380
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

S = input()

if S == 'ABC':
    print('ARC')
else:
    print('ABC')


Measured memory_bytes: 9184
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

class OrderedSet:
    def __init__(self,a):
        self.c = {}
        #self.a_sort = sorted(list(set(a)))
        self.a_sort = a # 今回はソートがいらないので
        for i,a in enumerate(self.a_sort):
            self.c[a] = i + 1
        self.r = {v: k for k, v in self.c.items()}
        self.size = len(self.c)
        self.tree = [0]*(self.size + 1)
        self.num = [0]*self.size
        self.all_count = 0  # 全要素数

    # BITのsum関数
    def _sum(self,index):
        s = 0
        while index:
            s += self.tree[index]
            index -= index & (-index)
        return s

    # xをk個挿入する
    def insert(self,x,k=1):
        index = self.c[x]
        self.num[index-1] += k
        while index <= self.size:
            self.tree[index] += k
            index += index & (-index)
        self.all_count += k
    
    # xをk個削除する
    def erase(self,x,k=1):
        self.insert(x,k=-k)

    # 格納しているxの数を返す
    def count(self,x):
        return self.num[self.c[x]-1]

    # 下から数えてk番目の要素を返す（要素がk個未満のときNoneを返す）
    def get_kth_bottom(self,k):
        if k <= 0:
            return None
        elif self.all_count < k:
            return None
        else:
            i = 0
            s = 0
            step = 1 << (self.size.bit_length() - 1)
            while step:
                if i+step <= self.size and s+self.tree[i+step] < k:
                    i += step
                    s += self.tree[i]
                step >>= 1
            return self.r[i+1]
    
    # 上から数えてk番目の要素を返す（要素がk個未満のときNoneを返す）
    def get_kth_top(self,k):
        return self.get_kth_bottom(self.all_count-k+1)
    
    # x以上の最小要素を返す
    def lower_bound(self,x):
        p = bisect_left(self.a_sort,x)
        if p == 0:
            k = 1
        else:
            k = self._sum(p) + 1
        return self.get_kth_bottom(k)
    
    # x以下の最大要素を返す
    def upper_bound(self,x):
        p = bisect_right(self.a_sort,x)
        if p == 0:
            return None
        else:
            k = self._sum(p)
            return self.get_kth_bottom(k)

N = I()
P = LI()

places = [0]*(N+1)
for i in range(N):
    places[P[i]] = i+1

s = OrderedSet([i for i in range(1,N+1)])
ans = 0
for i in range(1,N+1)[::-1]:
    p = places[i]
    c = s.lower_bound(p)
    d = None if c is None else s.lower_bound(c+1)
    b = s.upper_bound(p)
    a = None if b is None else s.upper_bound(b-1)
    
    a = a if a is not None else 0
    d = d if d is not None else N+1

    if b is None:
        if c is not None:
            ans += i*p*(d-c)
    elif c is None:
        ans += i*(b-a)*(N-p+1)
    else:
        ans += i*((b-a)*(c-p)+(p-b)*(d-c))

    s.insert(p)

print(ans)

Measured memory_bytes: 86040
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
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;
            continue;
        }

        int sum = m + f;
        if (sum >= 80) {
            cout << "A" << endl;
        } else if (sum >= 65) {
            cout << "B" << endl;
        } else if (sum >= 50) {
            cout << "C" << endl;
        } else if (sum >= 30) {
            if (r >= 50) {
                cout << "C" << endl;
            } else {
                cout << "D" << endl;
            }
        } else {
            cout << "F" << endl;
        }
    }
}

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

#define REP(i,n) for(int i = 0;i < n;++i)
#define PB(s) push_back(s)
#define ST(n) sort(n.begin(),n.end())

using namespace std;
typedef long long ll;

int main(){
	int a,b;
	cin >> a >> b;
	if(a*b%2)
		cout << "Odd" << endl;
	else cout << "Even" << endl;
}

Measured memory_bytes: 3640
#include <sstream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cassert>
#include <ctime>
#include <map>
#include <math.h>
#include <cstdio>
#include <set>
#include <deque>
#include <memory.h>
#include <queue>

#pragma comment(linker, "/STACK:64000000")
typedef long long ll;

using namespace std;

const int MAXK = -1;
const int MAXN = 1 << MAXK;
const int MOD = 1000 * 1000 * 1000 + 7;
const int INF = 1.01e9;

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

int main() {
#ifdef _MSC_VER
	freopen("input.txt", "r", stdin);
#endif

	int n, m, k;
	while (cin >> n >> m >> k) {
		vector<string> a(n);
		for (int i = 0; i < n; i++) cin >> a[i];

		vector<vector<int> > d(n, vector<int>(m, INF));
		queue<pair<int, int> > q;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (a[i][j] == 'S') {
					d[i][j] = 0;
					q.push(make_pair(i, j));
				}
			}
		}
		queue<pair<int, int> > q2;
		while (!q.empty() || !q2.empty()) {
			if (q.empty()) {
				while (!q2.empty()) {
					q.push(q2.front());
					q2.pop();
				}
			}
			int x = q.front().first;
			int y = q.front().second;
			q.pop();
			if (d[x][y] == k) {
				while (!q2.empty()) {
					q.push(q2.front());
					q2.pop();
				}
			}
			for (int dk = 0; dk < 4; dk++) {
				int nx = x + dx[dk];
				int ny = y + dy[dk];
				if (nx < 0 || nx >= n || ny < 0 || ny >= m) continue;
				int nd = d[x][y] + 1;
				if (a[nx][ny] == '#') nd = max(nd, k + 1);
				if (d[nx][ny] <= nd) continue;
				d[nx][ny] = nd;
				if (a[nx][ny] == '#' && d[x][y] < k) {
					q2.push(make_pair(nx, ny));
				}
				else {
					q.push(make_pair(nx, ny));
				}
			}
		}
		int ans = INF;
		for (int i = 0; i < n; i++) {
			ans = min(ans, (d[i][0] + k - 1) / k);
			ans = min(ans, (d[i][m - 1] + k - 1) / k);
		}
		for (int i = 0; i < m; i++) {
			ans = min(ans, (d[0][i] + k - 1) / k);
			ans = min(ans, (d[n - 1][i] + k - 1) / k);
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 4864
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe

ll gcd(ll c, ll d) { return d ? gcd(d, c%d) : c;}
ll lcm(ll c, ll d) { return c / gcd(c,   d) * d;}


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
int s[5]={},m = 9,ans=0,dis=0,S=0;
rep(i,5){
    cin >> s[i];
}
rep(i,5){
    S += s[i];
}
if (s[0]%10 ==0 && s[1]%10==0 && s[2]%10==0 && s[3]%10==0 && s[4]%10==0)
{
    cout << S << endl;
}else{
rep(i,5){
    if (s[i]%10 != 0)
    {
        m = min(s[i]%10,m);
        s[i] = (s[i]/10+1)*10;
    }
}

rep(i,5){
    ans += s[i];
}

    dis = ((m/10+1)*10)-m;
    cout << ans-dis << endl;
    
}











//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			// 整数の入力
			int n = sc.nextInt();
			int k = sc.nextInt();
			List<Double> an = new ArrayList<>();
			for (double i = 0; i < n; i++) {
				an.add(sc.nextDouble());
			}
			double maxSum = 0;
			double beforeSum = 0;
			for (int i = 0; i <= n - k; i++) {
				double sum = 0;
				if (i == 0) {
					for (int j = i; j < i + k; j++) {
						sum = sum + ((1 + an.get(j)) / 2);
					}
				} else {
					sum = beforeSum - (1 + an.get(i - 1) / 2) + (1 + an.get(i + k - 1) / 2);
				}
				beforeSum = sum;
				if (sum > maxSum) {
					maxSum = sum;
				}
			}
			System.out.println(maxSum);
		}
	}

	/**
	 * 最小公倍数
	 */
	static long lcm(long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return c / b;
	}

	/**
	 * 最大公約数
	 */
	static long gcd(long a, long b) {
		long temp;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return b;
	}
}


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

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut buf = String::new();
    input.read_line(&mut buf).unwrap();
    let (h, w): (usize, usize) = {
        let mut split = buf.split_whitespace();
        (
            split.next().unwrap().parse().unwrap(),
            split.next().unwrap().parse().unwrap(),
        )
    };
    let s: Vec<_> = (0..h)
        .map(|_| {
            buf.clear();
            input.read_line(&mut buf).unwrap();
            buf.trim_right().as_bytes().to_owned()
        })
        .collect();
    for x in 0..h {
        for y in 0..w {
            let adjacent = [
                if x != 0 { s[x - 1][y] } else { b'.' },
                if x != h - 1 { s[x + 1][y] } else { b'.' },
                if y != 0 { s[x][y - 1] } else { b'.' },
                if y != w - 1 { s[x][y + 1] } else { b'.' },
            ].iter()
                .filter(|&&x| x == b'#')
                .count();
            if s[x][y]==b'#' && adjacent == 0 {
                writeln!(output,"No").unwrap();
                return;
            }
        }
    }
    writeln!(output,"Yes").unwrap();
}

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

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v: Vec<u8> = Vec::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }

    #[test]
    fn case1() {
        test(
            "3 3
.#.
###
.#.
", "Yes\n",
        );
    }

    #[test]
    fn case2() {
        test(
            "5 5
#.#.#
.#.#.
#.#.#
.#.#.
#.#.#
",
            "No\n",
        );
    }

    #[test]
    fn case3() {
        test(
            "11 11
...#####...
.##.....##.
#..##.##..#
#..##.##..#
#.........#
#...###...#
.#########.
.#.#.#.#.#.
##.#.#.#.##
..##.#.##..
.##..#..##.
",
            "Yes\n",
        );
    }
}


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

#define y1 aklsdja
#define ii pair < int , int >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define pb push_back
#define t top()
#define fr front()

#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define REP(i , x) for(int i = 0 ; i < x ; ++i)
#define FORD(i , x , n) for(int i = x ; i >= n ; --i)

#define oo 1e17 + 5
#define ll long long
#define int long long
#define pow poww

const int N = 1e2 + 5;
const int VAL = 1e5 + 5;
int n , W , res;
int w[N] , v[N];
int dp[N][VAL];

main()
{
    //freopen("D.inp","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> W;
    FOR(i , 1 , n)
        cin >> w[i] >> v[i];
    memset(dp , -1 , sizeof(dp));
    dp[0][0] = 0;
    FOR(i , 1 , n)
        FOR(j , 0 , W)
        {
            dp[i][j] = dp[i - 1][j];
            if(j >= w[i] && dp[i - 1][j - w[i]] != -1)
                dp[i][j] = max(dp[i][j] , dp[i - 1][j - w[i]] + v[i]);
        }
    FOR(j , 0 , W)
        res = max(res , dp[n][j]);
    cout << res;
}


Measured memory_bytes: 82432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
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(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k,a,b;cin>>k>>a>>b;
    for(int i=0; i<=100; i++){
        int t = k*i;
        if(t>=a && t<=b){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;

int main() {
  int n, m;
  cin >> n >> m;
  string k = "";
  for (int i = 0; i < n; i++) {
    k += ".";
  }
  bool ans = true;
  for (int i = 0; i < m; i++) {
    int s;
    cin >> s;
    s--;
    char c;
    cin >> c;

    if (k[s] == '.') {
      k[s] = c;
    } else {
      if (k[s] != c) ans = false;
    }
  }
  if (k[0] == '.' && n != 1) k[0] = '1';
  if (k[0] == '.' && n == 1) k[0] = '0';
  if (n != 1 && k[0] == '0') ans = false;
  for (int i = 1; i < n; i++) {
    if (k[i] == '.') k[i] = '0';
  }
  if (ans)
    cout << k << endl;
  else
    cout << -1 << endl;
}

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

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

  ll min = a[0];
  ll sum = 0;
  rep(i, n){
    if (i == 0) continue;
    if(a[i] < min){
      sum += min - a[i];
    } else {
      min = a[i];
    }
  }
  cout << sum << endl;
}


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

using namespace std;

const int maxn = 2000;

int a[maxn];
bitset<(maxn * maxn)> subsetSums;

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

    int sum = 0;

    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }

    subsetSums.set(0);
    for (int i = 0; i < n; i++)
        subsetSums |= subsetSums << a[i];

    int answer = 0;
    for (int i = (sum + 1) / 2; i < (maxn * maxn) and !answer; i++)
        if (subsetSums[i])
            answer = i;

    cout << answer << endl;

    return 0;
}


Measured memory_bytes: 5040
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,d,a;
    cin>>n>>d>>a;
    vc<pi> mon(n);
    for(int i=0;i<n;i++)
        cin>>mon[i].first>>mon[i].second;
    sort(mon.begin(),mon.end());
    ll ans=0;
    deque<ll> q;
    q.push_back(mon[0].second);
    int l=0;
    int p=1;
    while(l<n)
    {
        while(p<n&&mon[p].first-mon[l].first<=2*d)
        {
            q.push_back(mon[p].second+ans*a);
            p++;
        }
        ans=max(ans,(q.front()+a-1)/a);
        q.pop_front();
        l++;
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using std::cout;
using std::endl;
using std::cin;

int main(){
	int a, b; cin >> a >> b;
	
	
	if(a < 9 and b < 9) cout << "Yay!" << endl;
	else cout << ":(" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int ans=0,N;cin>>N;
    vector<int> d(N,0);
    REP(i,N)cin>>d[i];
    sort(d.begin(),d.end(),greater<int>());
    REP(i,N){
        if(i==0||d[i-1]-d[i]>0){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    ll n;
    map<ll,ll> ma;
    cin>>n;
    rep(i,n){
        ll a;
        cin>>a;
        ma[a]++;
    }
    ll m;
    cin>>m;
    vector<ll> mm(m);
    rep(i,m){
        cin>>mm[i];
    }



    rep(i,m){
        if(ma[mm[i]]>=1){
            ma[mm[i]]--;
        }else{
            cout<<"NO"<<endl;
            return 0;
        }

    }
    cout<<"YES"<<endl;


    return 0;
}


Measured memory_bytes: 14336
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)			 	 cerr<<#x<<": "<<x<<endl
#define trace2(x, y)		 	 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)		 	 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)	 	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}



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

	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin >> n;
	ll a[n+1];
	rep(i,1,n+1){
		cin>> a[i];
	}
	ll dp[n+1]={0};
	rep(i,1,n+1){
		dp[i]=dp[i-1]+a[i];
	}
	ll dp1[n+2]={0};
	for(ll i=n; i>=0; i--){
		dp1[i]=dp1[i+1]+a[i];
	}
	ll mini=inf;
	rep(i,1,n){
		mini=min(mini,abs(dp[i]-dp1[i+1]));
	}
	cout << mini;
	return 0;
}
/* The judge is never wrong! Your code is buggy 
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */

Measured memory_bytes: 256
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#pragma GCC optimize ("O3")
	#define NDEBUG
#endif
// #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

const array<int, 4> dx = {0, 1, 0, -1};
const array<int, 4> dy = {1, 0, -1, 0};


typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	string s;
	while(cin >> s) {
		vector<string> v  = {"Sunny", "Cloudy", "Rainy"} ;
		REP(i, SZ(v)) {
			if(v[i] == s) {
				cout << v[(i+1) % 3] << endl;
			}
		}
	}
	return 0;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int32 modpow(int32 a, int32 r){
    if(r == 0){
        return 1;
    }
    if(r % 2 == 0){
        int32 x = modpow(a, r / 2);
        return x * x % 13;
    }else{
        return modpow(a, r - 1) * a % 13;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int32 n = s.size();
    vector<vector<int64>> dp(n+1, vector<int64>(13, 0));
    dp[0][0] = 1;
    REP(i,n){
        if(s[i] == '?'){
            REP(k,10){
                int32 x = k * modpow(10, n - i - 1) % 13;
                REP(j,13){
                    dp[i+1][j] += dp[i][(j - x + 13) % 13];
                    dp[i+1][j] %= MOD;
                }
            }
        }else{
            int32 x = (s[i] - '0') * modpow(10, n - i - 1) % 13;
            REP(j,13){
                dp[i+1][j] = dp[i][(j - x + 13) % 13];
            }
        }
    }
    // REP(i,n+1){
    //     REP(j,13){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    cout << dp[n][5] << endl;
    return 0;
}

Measured memory_bytes: 13648
import sys
def 解():
    iN = int(input())
    aS = [_.rstrip() for _ in sys.stdin.readlines()]
    def buildDic(s):
        d = {}
        aABC = sorted(set(list(s)))
        for es in aABC:
            d[es]= s.count(es)
        return d
    d0 = buildDic(aS[0])
    for s in aS[1:]:
        aABC = sorted(set(list(s)))
        for ts in set(d0.keys()) - set(aABC):
            del d0[ts]
        for ts in aABC:
            if ts in d0:
                i = min(d0[ts],s.count(ts))
                if i :
                    d0[ts] = i
                else:
                    del d0[ts]
            if len(d0) == 0:
                print("")
                exit()
    aNS = sorted(d0.keys())
    sR = ""
    for ts in aNS:
        sR += ts * d0[ts]
    print(sR)
解()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

int main(){
    ll N;
    cin >> N;
    ll sum = 0;
    for(int i = 1; i <= N; i++){
        sum += i;
    }
    for(int i = 1; i <= N; i++){
        if(i % 3 == 0){
            sum -= i;
        }
        if(i % 5 == 0){
            sum -= i;
        }
        if(i % 3 == 0 && i % 5 == 0){
            sum += i;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3632
from time import time
from random import random

limit_secs = 2
start_time = time()

D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

def calc_score():
    score = 0
    S = 0
    last = [-1] * 26
    for d in range(D):
        S += s[d][t[d]]
        last[t[d]] = d
        for i in range(26):
            S -= c[i] * (d - last[i])
        score += max(10 ** 6 + S, 0)
    return score

def calc_satisfaction():
    S = 0
    last = [-1] * 26
    for d in range(D):
        S += s[d][t[d]]
        last[t[d]] = d
        for i in range(26):
            S -= c[i] * (d - last[i])
    return S

def solution():
    return [i % 26 for i in range(D)]

t = solution()
S = calc_satisfaction()
while time() - start_time < limit_secs * 0.9:
    d = int(random() * D)
    q = int(random() * 26)
    old = t[d]
    t[d] = q
    new_S = calc_satisfaction()
    if new_S < S:
        t[d] = old
    else:
        S = new_S
print('\n'.join(str(e + 1) for e in t))


Measured memory_bytes: 9880
import math
a,b,c,d=map(int, input().split())
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
	
e = round(c * d / gcd(c, d))

f=(a-1)//c
g=b//c
h=(a-1)//d 
k=b//d
l=(a-1)//e
m=b//e

x=(b-a+1)
y=g-f
z=k-h
w=m-l

print(x-y-z+w)

Measured memory_bytes: 3064
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun nextPermutation(array: MutableList<Int>): Boolean {
    var tmp = 0
    for (i in array.size-2 downTo 0) {
        if (array[i] < array[i+1]) {
            for (j in array.size-1 downTo i+1) {
                if (array[j] > array[i]) {
                    tmp = array[i]
                    array[i] = array[j]
                    array[j] = tmp

                    val tmpArray = array.takeLast(array.size-(i+1)).sorted()
                    tmpArray.forEachIndexed { index, e ->
                        array[i+1+index] = e
                    }

                    return true
                }
            }
        }
    }

    return false
}

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val p = Array(n) { sc.nextInt() }
    val q = Array(n) { sc.nextInt() }
    val a = (1..n).toMutableList()
    var ans = 0
    do {
        if ((0 until n).all { p[it] == a[it] }) {
            break
        }
        ans++
    } while (nextPermutation(a))
    a.sort()
    do {
        if ((0 until n).all { q[it] == a[it] }) {
            break
        }
        ans--
    } while (nextPermutation(a))
    println(Math.abs(ans))
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 39348
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <numeric>
#include <cmath>
#include <map>
#include <set>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int d;
    cin >> d;
    if(d%2==1 && d!=1 && d!=9){
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;


    return 0;
}

Measured memory_bytes: 256
N=int(input())
lst=[]
count=0
for i in range(N):
    S,P=input().split()
    lst.append([S,int(P),i+1])
lst=sorted(lst)

flag=1
finished=0
while flag:
    flag=0
    for i in range(N-1-finished):
        if lst[i][0]==lst[i+1][0] and lst[i][1]<lst[i+1][1]:
            lst[i],lst[i+1]=lst[i+1],lst[i]
            flag=1
    finished+=1

for i in lst:
    print(i[2])

Measured memory_bytes: 3064