akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

const int H = 8;
const int W = 8;
const int C = 6;
const int dy[4] = {0,1,0,-1};
const int dx[4] = {1,0,-1,0};

int h,w,c;
int v[H][W];

void init_next(int field[H][W], int next[H][W]){
  for(int i=0;i<h;i++) for(int j=0;j<w;j++) next[i][j] = field[i][j];
}

bool check(int y, int x){
  if(y < 0 || y >= h) return false;
  if(x < 0 || x >= w) return false;
  return true;
}

void area_dfs(const int &y, const int &x, bool f[H][W], int &res, int field[H][W]){
  for(int i=0;i<4;i++){
    int ny = y + dy[i];
    int nx = x + dx[i];
    if(!check(ny, nx) || f[ny][nx] || field[ny][nx] != field[0][0]) continue;
    f[ny][nx] = true;
    res++;
    area_dfs(ny, nx, f, res, field);
  }
}

int area(int res[H][W]){
  bool f[H][W];
  int ans = 1;
  fill(f[0], f[h], false);
  f[0][0] = true;
  area_dfs(0, 0, f, ans, res);
  return ans;
}

void fill(const int &y, const int &x, int field[H][W], const int &num){
  assert(num != field[0][0]);
  for(int i=0;i<4;i++){
    int ny = y + dy[i];
    int nx = x + dx[i];
    if(!check(ny, nx) || (ny == 0 && nx == 0) || field[ny][nx] != field[0][0]) continue;
    field[ny][nx] = num;
    fill(ny, nx, field, num);
  }
}

int func(int cnt, int field[H][W]){
  int next[H][W], res = 0;
  
  init_next(field, next);  
  if(next[0][0] != c) {
    fill(0, 0, next, c);
    next[0][0] = c;
  }
  res = area(next);
  
  if(cnt < 4){
    for(int i=1;i<=6;i++){
      if(i == field[0][0]) continue;
      init_next(field, next);
      fill(0, 0, next, i);
      next[0][0] = i;
      res = max(res, func(cnt+1, next));
    }
  }

  return res;
}

void solve(){
  cout << func(0, v) << endl;
}

int main(){
  while(cin >> h >> w >> c && (h|w|c)){
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        cin >> v[i][j];
      }
    }
    solve();
  }
}

Measured memory_bytes: 1164
# abc138_b.py
# https://atcoder.jp/contests/abc138/tasks/abc138_b

# B - Resistors in Parallel /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# N個の整数の列 A1,…,ANが与えられます。
# これらの逆数の総和の逆数 1/((1/A1)+…+(1/AN))を求めてください。

# 制約
#     1≤N≤100
#     1≤Ai≤1000

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N
# A1 A2 … AN

# 出力
# 11A1+…+1ANの値を表す小数 (または整数) を出力せよ。
# 出力は、ジャッジの出力との絶対誤差または相対誤差が 10−5以下のとき正解と判定される。

# 入力例 1
# 2
# 10 30

# 出力例 1
# 7.5

# 1/((1/10)+(1/30))=1/(4/30)=30/4=7.5です。
# なお、7.50001, 7.49999 などと出力しても正解と判定されます。

# 入力例 2
# 3
# 200 200 200

# 出力例 2
# 66.66666666666667

# 11200+1200+1200=13200=2003=66.6666...です。
# なお、6.66666e+1 などと出力しても正解と判定されます。

# 入力例 3
# 1
# 1000

# 出力例 3
# 1000

# 111000=1000です。
# なお、+1000.0 などと出力しても正解と判定されます。


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    N = int(lines[0])
    # X, A = list(map(int, lines[0].split()))
    values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(6):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(M):
    #     valueses.append(list(map(int, lines[i+1].split())))

    su = 0

    for n in range(N):
        su += 1/values[n]

    return [1/su]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['2', '10 30']
        lines_export = [7.5]
    if pattern == 2:
        lines_input = ['3', '200 200 200']
        lines_export = [66.66666666666667]
    if pattern == 3:
        lines_input = ['1', '1000']
        lines_export = [1000]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(2)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9280
/+ dub.sdl:
    name "A"
    dependency "dcomp" version=">=0.0.2"
+/

import std.algorithm, std.range, std.stdio, std.math, std.conv, core.bitop;

// import dcomp.scanner;
// import dcomp.algorithm;

int n;
struct Edge {
    int to;
    long dist;
}
Edge[][] g;
long md;

long[2][] dfs(int p) {
    if (g[p].empty) {
        return [[0L, 0L]];
    }
    Edge le = g[p][0], re = g[p][1];
    auto lt = dfs(le.to);
    auto rt = dfs(re.to);
    if (lt.length > rt.length) {
        swap(le, re);
        swap(lt, rt);
    }
    long ld = le.dist, rd = re.dist;
    long[2][] ans;
    foreach (co; lt) {
        //co[1] + ld + rd + rco[0] <= md
        int idx = binSearch!((i){return co[1]+ld+rd+rt[i][0] > md;})(-1L, rt.length).to!int-1;
        if (idx == -1) continue;
        ans ~= [co[0]+ld, rt[idx][1]+rd];
        ans ~= [rt[idx][1]+rd, co[0]+ld];
    }
    sort(ans);
    if (ans.empty) return ans;
    long[2][] buf;
    long ma = 10L^^15;
    foreach (e; ans) {
        if (ma <= e[1]) continue;
        ma = min(ma, e[1]);
        buf ~= e;
    }
    return buf;
}

//md以下にできるか？
bool solve(long _md) {
    md = _md;
    return !dfs(0).empty;
}

int main() {
    auto sc = new Scanner();
    int n;
    sc.read(n);
    g = new Edge[][](n);
    foreach (i; 1..n) {
        int a; long b;
        sc.read(a, b); a--;
        g[a] ~= Edge(i, b);
    }

    writeln(binSearch!solve(-1L, 10L^^12));
    return 0;
}
/* IMPORT /Users/yosupo/Program/dcomp/source/dcomp/scanner.d */
// module dcomp.scanner;

class Scanner {
    import std.stdio : File, readln, stdin;
    import std.conv : to;
    import std.range : front, popFront, array, ElementType;
    import std.array : split;
    import std.traits : isSomeString, isDynamicArray;
    import std.algorithm : map;
    File f;
    this(File f = stdin) {
        this.f = f;
    }
    string[] buf;
    bool succ() {
        while (!buf.length) {
            if (f.eof) return false;
            buf = readln.split;
        }
        return true;
    }
    int read(Args...)(auto ref Args args) {
        foreach (i, ref v; args) {
            if (!succ()) return i;
            alias VT = typeof(v);
            static if (!isSomeString!VT && isDynamicArray!VT) {
                v = buf.map!(to!(ElementType!VT)).array;
                buf.length = 0;
            } else {
                v = buf.front.to!VT;
                buf.popFront();
            }
        }
        return args.length;
    }
}
/* IMPORT /Users/yosupo/Program/dcomp/source/dcomp/algorithm.d */
// module dcomp.algorithm;

//[0,0,0,...,1,1,1]で、初めて1となる場所を探す。pred(l) == 0, pred(r) == 1と仮定
T binSearch(alias pred, T)(T l, T r) {
    while (r-l > 1) {
        T md = (l+r)/2;
        if (!pred(md)) l = md;
        else r = md;
    }
    return r;
}


Measured memory_bytes: 47484
#include <iostream>
#include <utility>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main() {
	int n, c;
	cin >> n >> c;
	vector<pair<pair<int,int>, int>> p(n);
	vector<int> st[100001], en[100001];
	
	for(int i = 0; n > i; i++){
		cin >> p[i].first.first >> p[i].first.second >> p[i].second;
		st[p[i].first.first].push_back(i);
		en[p[i].first.second].push_back(i);
	}
	
	int sum = 0;
	
	int coming[31] = {};
	int rest = 0;
	
	
	for(int i = 1; 100001 > i; i++){
		
		for(auto a : en[i]){
			coming[p[a].second]++;
		}
		
		vector<int> needs;
		
		for(auto a : st[i]){
			if(coming[p[a].second])
				coming[p[a].second]--;
			else{
				if(rest == 0)
					sum++;
				else
					rest--;
			}
		}
		
		for(int j = 0; 31 > j; j++){
			rest += coming[j];coming[j] = 0;
		}
	}
	
	cout << sum << endl;
	
	
	return 0;
}

Measured memory_bytes: 12416
#include<bits/stdc++.h>
using namespace std;
int const mod = 1e9 + 7;
void plusle(int &a, int b){
    if((a += b) >= mod) a -= mod;
}
void minun(int &a, int b){
    if((a -= b) < 0) a += mod;
}
int add(int a, int b){
    return (a += b) >= mod ? a - mod : a;
}

const int M = (1 << 18) + 21;
int dp[42][M];
int n, x, y, z;

int main(){
    scanf("%d %d %d %d", &n, &x, &y , &z);
    dp[0][1] = 1;
    int ans = 0;
    const int success = (1 << z) + (1 << (z + y)) + (1 << (x + y + z));
    const int reduce = (1 << (x + y + z + 1)) - 1;
    for(int i = 1 ; i <= n ; i ++){
        ans = 10LL * ans % mod;
        for(int mask = 0 ; mask < (1 << x + y + z + 1) ; ++ mask){
            for(int p = 1 ; p <= 10 ; ++ p){
                int nmask = (mask << p) | 1;
                if((nmask & success) == success) {
                    ans = add(ans, dp[i - 1][mask]);
                    continue;
                }
                nmask &= reduce;
                plusle(dp[i][nmask], dp[i - 1][mask]);
            }
        }
    }


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


Measured memory_bytes: 44692
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

int main() {
	string s; cin >> s;
	map<char, int> a;
	bool x = 1;
	for (int i = 0; i < s.size(); i++) {
		a[s[i]]++;
	}
	for (int i = 0; i < s.size(); i++) {
		if (a[s[i]] != 2)x = 0;
	}
	if (x)cout << "Yes" << endl;
	else cout << "No" << endl;

}



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

using namespace std;

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

    string s,t;cin>>s>>t;
    int sidx=0,tidx=0,slen=s.length(),tlen=t.length();
    for(int i=0;i<slen;i++){
        bool flag=false;
        if(i%2==0){//t->s->t->s....
            for(int j=tidx;j<tlen;j++){
                if(s[i]==t[j]){
                    tidx=j+1;
                    flag=true;
                    break;
                }
            }
        }
        else{
            for(int j=sidx;j<slen;j++){
                if(s[i]==s[j]){
                    sidx=j+1;
                    flag=true;
                    break;
                }
            }
        }
        if(!flag) goto done;
    }
    cout<<"Yes"<<endl;
    return 0;
    done:
    sidx=0,tidx=0;
    for(int i=0;i<slen;i++){
        bool flag=false;
        if(i%2){//s->t->s->t....
            for(int j=tidx;j<tlen;j++){
                if(s[i]==t[j]){
                    tidx=j+1;
                    flag=true;
                    break;
                }
            }
        }
        else{
            for(int j=sidx;j<slen;j++){
                if(s[i]==s[j]){
                    sidx=j+1;
                    flag=true;
                    break;
                }
            }
        }
        if(!flag) goto done2;
    }
    cout<<"Yes"<<endl;
    return 0;
    done2:
    cout<<"No"<<endl;
}

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

int main()
{
	int N,l,r,i,ans = 0;
	cin >> N;

	for (i = 0; i < N; i++){
		cin >> l >> r;
		ans = (ans + ((r - l) + 1));
	}
	cout << ans << endl;
}

Measured memory_bytes: 3568
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
#define MAX 10001
#define INF (1<<29)
 
int main()
{
    int Tc,N;
    string s;
    cin >> Tc;
    while(Tc--)
    {
        cin >> N >> s;
        bool b[2][MAX] = {{}};
        for(int i = 0 ; i <= N ; i++)
        {
            if(i != 0 && s[2*i-1] == 'Y') b[0][i] = 1;
            if(i != N && s[2*i] == 'Y') b[0][i] = 1;
            if(i != 0 && s[2*i-1+2*N] == 'Y') b[1][i] = 1;
            if(i != N && s[2*i+2*N] == 'Y') b[1][i] = 1;
        }
         
        auto solve = [=]()
            {
                vector<vector<int>> dp(2, vector<int>(MAX, INF));
                if(b[0][0] && b[1][0])
                {
                    dp[1][0] = 2;
                }
                if(b[0][0] && !b[1][0])
                {
                    dp[0][0] = 1;
                    dp[1][0] = 1;
                }
                if(!b[0][0] && b[1][0])
                {
                    dp[1][0] = 2;
                }
                if(!b[0][0] && !b[1][0])
                {
                    dp[0][0] = 0;
                    dp[1][0] = 1;
                }
                
                for(int i = 1 ; i <= N ; i++)
                {
                    if(b[0][i] == 1 && b[1][i] == 1)
                    {
                        dp[0][i] = min(dp[0][i],min(dp[0][i-1]+4,dp[1][i-1]+3));
                        dp[1][i] = min(dp[1][i],min(dp[0][i-1]+3,dp[1][i-1]+3));
                    }
                    if(b[0][i] == 1 && b[1][i] == 0)
                    {
                        dp[0][i] = min(dp[0][i],min(dp[0][i-1]+2,dp[1][i-1]+2));
                        dp[1][i] = min(dp[1][i],min(dp[0][i-1]+2,dp[1][i-1]+2));
                    }
                    if(b[0][i] == 0 && b[1][i] == 1)
                    {
                        dp[0][i] = min(dp[0][i],min(dp[0][i-1]+4,dp[1][i-1]+3));
                        dp[1][i] = min(dp[1][i],min(dp[0][i-1]+3,dp[1][i-1]+2));
                    }
                    if(b[0][i] == 0 && b[1][i] == 0)
                    {
                        dp[0][i] = min(dp[0][i],min(dp[0][i-1]+1,dp[1][i-1]+2));
                        dp[1][i] = min(dp[1][i],min(dp[0][i-1]+2,dp[1][i-1]+1));
                    }
                }
                return dp[0][N];
            };
         
        cout << solve() << endl;
    }   
    return 0;
}

Measured memory_bytes: 3264
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(ll i=0;i<(n);++i)
#define Fr(i,n) for(long long i=1;i<=(n);++i)
#define ifr(i,n) for(long long i=(n)-1;i>=0;--i)
#define iFr(i,n) for(long long i=(n);i>0;--i)

int main() {
  cin.tie(nullptr);
  ll n,a,c,ans;
  a=0;
  c=0;
  ans=0;
  cin>>n;
  vector<pair<int, int> > pairs(n*3);
  fr(i,3*n){
    ll s;
    cin>>s;
    pairs[i]=make_pair(s, 3-i/n);
  }
  sort(pairs.begin(), pairs.end());
  fr(i,3*n){
    if(pairs[i].second==3){
      ++a;
    }
    else if(pairs[i].second==1){
      ++c;
    }
    else if(pairs[i].second==2){
      ans+=a*(n-c);
      }
  }
  cout<<ans;
}

Measured memory_bytes: 2560
n,m = map(int,input().split())
ab = [[0 for i in range(n)] for j in range(n)]

for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    ab[a][b] += 1
    ab[b][a] += 1

for i in range(n):
    cnt = 0
    for j in range(n):
        cnt += ab[i][j]
    print(cnt)


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

int main(){
  string S;
  cin >>S;
  string x=S;
  char c1=x[0];
  char c2=x[1];
  char c3=x[2];
  
  cout << c1 << c2 << c3 << endl;

return 0;
}


Measured memory_bytes: 3576
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	int n;
	int d[101]={0};
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>d[i];
	}
	sort(d,d+n);
	int tmp=0;
	int check=0;
	for(int i=0;i<n;i++){
		if(tmp<d[i]){
			check++;
			tmp=d[i];
		}

	}
	cout<<check<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
string = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
res = ""
for _s in s:
    ind = string.find(_s)
    new_ind = ind + n if ind + n < 26 else (ind + n) % 26
    res += string[new_ind]
print(res)

Measured memory_bytes: 3060
// A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<vector>
#include<string>
using namespace std;

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


    if (0 <= n && n <= 9) {
        if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
            cout << "hon" << endl;
        }
        else if (n == 0 || n == 1 || n == 6 || n == 8) {
            cout << "pon" << endl;
        }
        else {
            cout << "bon" << endl;
        }
    }
    else  {
        n = n % 10;
        if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
            cout << "hon" << endl;
        }
        else if (n == 0 || n == 1 || n == 6 || n == 8) {
            cout << "pon" << endl;
        }
        else {
            cout << "bon" << endl;
        }
    }

    return 0;

}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
#import <atcoder/all>
using namespace std;
int T, n, m, a, b;
class FastIO
{
    static const int rdata_sz = (1 << 25), wdata_sz = (1 << 25);
    char rdata[rdata_sz], wdata[wdata_sz], *rb, *wb;
    char tmp_s[20];

public:
    FastIO()
    {
        fread(rdata, 1, rdata_sz, stdin);
        rb = rdata;
        wb = wdata;
    }
    ~FastIO()
    {
        fwrite(wdata, 1, wb - wdata, stdout);
    }

    template <typename T>
    inline void read(T &x)
    {
        bool neg = false;
        x = 0;
        while ((*rb < '0' || *rb > '9') && *rb != '-')
            ++rb;
        if (*rb == '-')
        {
            neg = true;
            ++rb;
        }
        while ('0' <= *rb && *rb <= '9')
        {
            x = 10 * x + (*rb - '0');
            ++rb;
        }
        if (neg)
            x = -x;
    }

#define pc(x) *(wb++) = x
    template <typename T>
    inline void write(T x)
    {
        if (x == 0)
        {
            pc('0');
            pc('\n');
            return;
        }
        if (x < 0)
        {
            pc('-');
            x = -x;
        }
        char *t = tmp_s;
        while (x)
        {
            T y = x / 10;
            *(t++) = (x - y * 10) + '0';
            x = y;
        }
        while (t != tmp_s)
            pc(*(--t));
        pc('\n');
    }
#undef pc
};
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    FastIO io;
    io.read(T);
    for (int i = 0; i < T; i++)
    {
        io.read(n);
        io.read(m);
        io.read(a);
        io.read(b);
        io.write(atcoder::floor_sum(n, m, a, b));
    }
}


Measured memory_bytes: 7580
#include<stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
    int n,m;
    while(cin>>n>>m)
    {
        int k;
        int vis[12]={0};
        for(int i=0;i<m;i++ )
        {
            cin>>k;
            vis[k]=1;
        }
        while(1)
        {
            int flag=1;
            k=n;
            while(k)
            {
                int t =k%10;
                if(vis[t])
                {
                    flag=0;
                    break;
                }
                k/=10;
            }
            if(flag)
            {
                cout<<n<<endl;
                break;
            }
            n++;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
    }
    ll ans = 0;
    rep(i,60){
        ll x = 0;
        rep(j,N){
            if(((A[j] >> i)&1LL)) x++;
        }
        ll now = x*(N-x)%mo;
        rep(j,i){
            now *= 2;
            now %= mo;
        }
        ans += now;
        ans %= mo;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
int main() {
string s;
  int w;
cin>>s;
  int q=s.size();
  string k;
  cin>>w;
  for(int i=0;i<q;i +=w){
  k =k+ s[i];
  
  }
  cout << k <<endl;
}


Measured memory_bytes: 3648
import java.util.Scanner

fun main() {
	val scn = Scanner(System.`in`)
	val a = scn.nextInt()
	val b = scn.nextInt()
	val c = scn.nextInt()
	val k = scn.nextInt()
	println(when{
		k<=a -> k
		k<=a+b -> a
		else -> 2*a+b-k
	})
}

Measured memory_bytes: 36024
n = gets.to_i
strs = []
n.times do
  strs << gets.to_s.chomp
end

sorted_strs = []
strs.each do |str|
  sorted_strs << str.chars.sort.join
end

arr = sorted_strs.group_by(&:itself).values.select { |value| value.size > 1 }
cnt = 0
arr.each do |elm|
  if elm.size > 1
    (1..elm.size - 1).each { |num| cnt += num }
  end
end
puts cnt


Measured memory_bytes: 41620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

vector<int> distance_list(vector<vector<pair<int,int>>> tree,int u){
    vector<int> color(tree.size(),0);
    vector<int> distance_list(tree.size());
    distance_list[u] = 0;
    color[u] = 1;
    queue<int> s;
    s.push(u);
    while(!s.empty()){
        int v = s.front();
        s.pop();
        REP(i,tree[v].size()){
            int child = tree[v][i].first;
            if(color[child] == 0){
                s.push(child);
                color[child] = 1;
                distance_list[child] = distance_list[v] + tree[v][i].second;
            }
        }
    }

    return distance_list;
}

int main(void)
{
    int n;
    cin >> n;
    vector<vector<pair<int,int>>> tree(n);
    REP(i,n-1){
        int u,v,w;
        cin >> u >> v >> w;
        u--;
        v--;
        tree[u].push_back(pair<int,int>(v,w));
        tree[v].push_back(pair<int,int>(u,w));
    }

    vector<bool> visited(n,false);
    vector<int> color(n,0);
    vector<int> distance_from_zero = distance_list(tree,0);

    REP(i,n){
        if(distance_from_zero[i] % 2 == 0){
            color[i] = 1;
        }
    }

    REP(i,n){
        cout << color[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 13056
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    IH=[(i,h) for i,h in enumerate(map(int,input().split()))]
    IH.append((n,0))
    ans=0
    Q=[[-1,0]]
    for i,h in IH:
        while(Q[-1][1]>h):
            i0,h0=Q.pop()
            ans=max(ans,h0*(i-Q[-1][0]-1))
        if(Q[-1][1]<h): Q.append([i,h])
        elif(Q[-1][1]==h): Q[-1][0]=i

    print(ans)
resolve()


Measured memory_bytes: 27536
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #ifdef ONLINE_JUDGE
        #pragma GCC target ("avx512f")
    #else
        #pragma GCC target ("avx")
    #endif
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

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

int n;
vi a;

signed main(){
    I(n);
    REP(i,n){
        int ai;
        I(ai);
        a.pb(ai-i);
    }
    map<int,int> pr;
    for(auto c:a) pr[c]++;

    // REP(i,n) cerr << a[i] << " "; cerr << endl;

    int ret = 0;
    REP(i,n){
        int tgt = -2 * i - a[i];
        
        pr[a[i]]--;
        ret += pr[tgt];
    }
    cout << ret << endl;
}

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

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

    int64_t ans = 0;
    for (int64_t i = 1; i < N; i++) {
        ans += (N - 1) / i;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3632
def main():
    buf = input()
    s = buf
    characters = []
    for i in s:
        if not i in characters:
            characters.append(i)
    min_iter_count = 999
    for i in characters:
        iter_count = 0
        t = s
        while True:
            flag = False
            new_t = ""
            for j in range(len(t) - 1):
                if t[j] == i:
                    new_t += i
                elif t[j+1] == i:
                    new_t += i
                    flag = True
                else:
                    new_t += t[j]
                    flag = True
            if t[-1] != i:
                flag = True
            t = new_t
            if flag:
                iter_count += 1
            else:
                break
        if iter_count < min_iter_count:
            min_iter_count = iter_count
    print(min_iter_count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll ans=0,n,m,x;
	cin>>n>>m;
	while(m--)
	{
		cin>>x;
		ans+=x;
	}
	cout<<(n>=ans?n-ans:-1);
}

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

int main(){
    double pai=3.141592653589;
    int n,a,b;
    char c[1000],rc[1000],s[10];
    scanf("%s",&c);
    scanf("%d",&n);
    string w;
    for(int i=0;i<n;i++){
        scanf("%s",&s);
        w=s;
        if(w=="print"){
            scanf("%d %d",&a,&b);
            for(int i=a;i<=b;i++){
                printf("%c",c[i]);
            }
            printf("\n");
        }else if(w=="replace"){
            scanf("%d %d %s",&a,&b,&rc);
            int j=0;
            for(int i=a;i<=b;i++){
                c[i]=rc[j];
                j++;
            }
        }else{
            scanf("%d %d",&a,&b);
            int j=b;
            strcpy(rc,c);
            for(int i=a;i<=b;i++){
                c[i]=rc[j];
                j--;
            }
        }
    }
    return 0;
}


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

using namespace std;

int main()
{
    int q, i, x, p, d;

    deque <int> v;

    scanf("%d", &q);

    for(i = 0; i < q; i++) {
        scanf("%d", &p);
        if(p == 0) {
            scanf("%d %d", &d, &x);
            if(d == 0)
                v.push_front(x);
            else
                v.push_back(x);
        }
        else if(p == 1) {
            scanf("%d", &x);
            printf("%d\n", v[x]);
        }
        else {
            scanf("%d", &d);
            if(d == 0)
                v.pop_front();
            else
                v.pop_back();
        }
    }
    return 0;
}



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

int main() {
    long long x[3];
    cin >> x[0] >> x[1] >> x[2];
    sort(x,x + 3);
    long long min = x[0] * x[1];
    long long max = x[1] * x[2];

    if(max % 2 == 0){
        cout << 0;
    } else{
        cout << min;
    }
    return 0;
}

Measured memory_bytes: 256
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstring>
using namespace std;
#define U(v) cerr << #v << ": " << (v) << endl

int main() {
    int N;
    while (cin >> N) {
        vector<int> a(N);
        for (auto& p : a)
            cin >> p;
        sort(a.begin(), a.end());
        int l = a.back();
        a.pop_back();
        int bi = -1;
        double be = 1e9;
        for (int p : a) {
            int q = p;
            if (l - p > p)
                q = l - p;
            double e = q / (double)l;
            if (be > e) {
                be = e;
                bi = p;
            }
        }
        cout << l << ' ' << bi << endl;
    }
    return 0;
}


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

int main() {
  int a , b;
  cin >> a >> b;
  
  int total;
  int mean;
  total = a + b;
  mean = total / 2;
    if (total % 2 != 0){
    mean++;
    }

  cout << mean << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
  int n;
  char s[100010];
  scanf("%s",s);
  n=strlen(s);
  for(int i=0;i<n;i++)
    if(i%2==0)
      printf("%c",s[i]);
  printf("\n");
}

Measured memory_bytes: 256
//***Little by little one travels far***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main()
{
  ll k,x;
  cin>>k>>x;

  if((500*k)>=x) cout<<"Yes";
  else cout<<"No";
}

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

int stringTOlint(string s) {
	//string→lint
	lint Z = s.size();
	lint ret = 0;
	reverse(s);
	rep(i, Z) {
		ret += ((s[i] - '0') * pow(10, i));
	}
	return ret;
}

int main() {
	lint W, N;
	cin >> W >> N;
	vector<string>S(N);
	rep(i, N) {
		cin >> S[i];
	}
	bool flag = false;
	vector<string>A(N);
	vector<string>B(N);
	rep(i, N) {
		flag = false;
		rep(j, S[i].size()) {
			if (S[i][j] == ',') {
				flag = true;
			}
			else {
				if (flag) {
					B[i].push_back(S[i][j]);
				}
				else {
					A[i].push_back(S[i][j]);
				}
			}
		}
	}
	vector<lint>IA(N);
	vector<lint>IB(N);
	rep(i, N) {
		IA[i] = stringTOlint(A[i]);
		IB[i] = stringTOlint(B[i]);
	}
	lint now = 0;
	vector<lint>ANS;
	for (int i = 1; i <= W; i++) {
		now = i;
		rep(j, N) {
			if (IA[j] == now) {
				now = IB[j];
			}
			else if (IB[j] == now) {
				now = IA[j];
			}
		}
		ANS.push_back(now);
	}
	vector<IP>P(W);
	rep(i, W) {
		P[i].first = ANS[i];
		P[i].second = i + 1;
	}
	sort(P);
	rep(i, W) {
		cout << P[i].second << endl;
	}
}


Measured memory_bytes: 3352
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];

    int ans = 0;

    rep(si, h) rep(sj, w)
    {
        if (s[si][sj] == '#')
            continue;

        vvi dist(h, vi(w, INF));
        queue<P> q;
        auto update = [&](int i, int j, int x) {
            if (dist[i][j] != INF)
                return 0;
            dist[i][j] = x;
            q.push(P(i, j));
        };

        update(si, sj, 0);

        while (!q.empty())
        {
            int i = q.front().fi;
            int j = q.front().se;
            q.pop();

            rep(dir, 4)
            {
                int ni = i + di[dir];
                int nj = j + dj[dir];
                if (ni < 0 || ni >= h || nj < 0 || nj >= w)
                    continue;
                if (s[ni][nj] == '#')
                    continue;
                update(ni, nj, dist[i][j] + 1);
            }
        }
        rep(i, h) rep(j, w)
        {
            if (dist[i][j] == INF)
                continue;
            ans = max(ans, dist[i][j]);
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int N;
    scanf("%d",&N);
    int COST[N];
    for(int i=0;i<N;i++){
        scanf("%d",&COST[i]);
    }
    int C;
    int sum = 0;
    for(int i=0;i<N;i++){
        scanf("%d",&C);
        if(COST[i]-C>0){
            sum += COST[i]-C;
        }
    }
    printf("%d",sum);
    return 0;
}

Measured memory_bytes: 128
import sys

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


def resolve():
    n, a, b = map(int, input().split())
    q, r = divmod(n, a + b)
    if r < a:
        res = q * a + r
    else:
        res = q * a + a

    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3060
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  while (cin >> n) {
    int s = 0;
    rep(a, 10) rep(b, 10) rep(c, 10) rep(d, 10) {
      s += a + b + c + d == n;
    }
    cout << s << endl;
  }
}

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

int main(){

int t,n,count=0;
int A[100];
cin >> t;


do{
cin >> n;
int a=0;
for(int i=0;i<n;i++){
int x,y;
cin >>x>>y;
a+=(y-x);
}
if(a >= t) A[count]=0;
else A[count]=t-a;
count++;
cin>>t;
}while(t!=0);

for (int i=0;i<count;i++){
if(A[i]) cout << A[i] <<"\n";
else cout << "OK\n";
}
}

Measured memory_bytes: 1160
import numpy as np
N, M, C = map(int, input().split())
B = np.array(list(map(int, input().split())))

ans = 0

for i in range(N):
    tmp = np.dot(np.array(list(map(int, input().split()))), B)
    if (tmp.sum() + C) > 0:
        ans += 1

print(ans)


Measured memory_bytes: 21500
#include<bits/stdc++.h>
    using namespace std;
    #define ll long long
    #define pll pair<ll,ll>
    #define pii pair<int,int>
    #define mii map<int,int>
    #define msi map<string,int>
    #define pb push_back
    #define mp make_pair
    #define M 1101
    #define MOD 1000000007
    #define fi first
    #define se second
    #define vi vector<int>
    #define vl vector<ll>
    #define all(v) v.begin(),v.end()
    #define allr(v) v.rbegin(),v.rend()
    #define repl(i,l,r) for(long long i=l;i<=r;++i)
    #define rep(i,l,r) for(int i=l;i<=r;++i)
    #define ins insert
    #define inf INT_MAX
    #define vpi vector< pair<int,int> >
    #define vpl vector< pair<ll,ll> >
    #define eps 0.00001
    const int maxn=2e5+10;
    ll x[maxn],y[maxn];
    char d[maxn];
    double b1[maxn],b2[maxn];
    int n;
    double f(double xx)
    {
        double xmin=1e12,xmax=-1e12,ymin=1e12,ymax=-1e12;
        rep(i,1,n)
        {
            b1[i]=x[i];b2[i]=y[i];
        }
        rep(i,1,n)
        {
            if(d[i]=='R')
            {
                b1[i]+=xx;
            }
            else
                if(d[i]=='L')
            {
                b1[i]-=xx;
            }
            else
                if(d[i]=='U')
            {
                b2[i]+=xx;
            }
            else
                if(d[i]=='D')
            {
                b2[i]-=xx;
            }
            xmin=min(xmin,b1[i]);
            xmax=max(xmax,b1[i]);
            ymin=min(ymin,b2[i]);
            ymax=max(ymax,b2[i]);
        }
        return (xmax-xmin)*(ymax-ymin);
    }
    double ts(double l,double r)
    {
        rep(i,1,500)
        {
            double m1=l+(r-l)/3;
            double m2=r-(r-l)/3;
            double f1=f(m1);double f2=f(m2);
            if(f1>=f2)
            {
                l=m1;
            }
            else
            {
                r=m2;
            }
        }
        return f(l);
    }
    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        cin>>n;
        rep(i,1,n)
        {
            cin>>x[i]>>y[i]>>d[i];
     
        }
        cout<<fixed<<setprecision(12)<<ts(0,2e8)<<"\n";
     
        return 0;
     
        //check for long long or int
    }

Measured memory_bytes: 5632
#include <iostream>
#include <ctype.h>
#define r(i,n) for(int i;i<n;i++)
int a,b,s;
void dfs(int i,int y,int n){
  if(!n&&y==b){
    s++;
    return;
  }
  if(y>b)return;
  if(!n||i==10)return;
  dfs(i+1,y+i,n-1);
  dfs(i+1,y,n);
}
using namespace std;
int main(){
  while(cin>>a>>b,a||b){
    s=0;
    dfs(0,0,a);
    cout<<s<<endl;
  }
}

Measured memory_bytes: 3092
#include <cassert>
#include <iostream>
#include <vector>

class Combination {
private:
  const int max;
  const int mod;
  std::vector<long long> fac;  // fac[k] = k! in Fp
  std::vector<long long> finv; // finv[k] = (k!)^-1 in Fp
public:
  Combination(const int max_, const int mod_)
      : max(max_), mod(mod_), fac(max_, -1), finv(max_, -1) {
    assert(max >= 2);
    std::vector<long long> inv(max, -1); // inv[k] = k^-1 in Fp
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < max; ++i) {
      fac[i] = fac[i - 1] * i % mod;
      inv[i] = mod - inv[mod % i] * (mod / i) % mod;
      finv[i] = finv[i - 1] * inv[i] % mod;
    }
  }

  long long get(const int n, const int k) const {
    if (n < k)
      return 0;
    if (n < 0 or k < 0)
      return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
  }
};

int main() {
  int N, K;
  std::cin >> N >> K;

  int mod = 1000000007;

  Combination com(N + 1, mod);
  for (int i = 1; i <= K; ++i) {
    long long res = 1;
    res = res * com.get(N - K + 1, i) % mod;
    res = res * com.get(K - 1, i - 1) % mod;
    std::cout << res << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
vector<int> dy={1,0,-1,0};
vector<int> dx={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int main(){
    string s;
    cin>>s;
    if(s=="Sunny") cout<<"Cloudy"<<endl;
    if(s=="Cloudy") cout<<"Rainy"<<endl;
    if(s=="Rainy") cout<<"Sunny"<<endl;
}


Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<vector>
#include<algorithm>

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

using namespace std;

typedef long long ll;

const double EPS=1e-8;

inline double f(double a,double p,double q,double x){
	return a*(x-p)*(x-p)+q;
}

double parabola_perimeter(double a,double b,double c,double x1,double x2){
	x1+=b/(2*a);
	x2+=b/(2*a);
	double A=1/(4*a*a);
	return abs(a)*((x2*sqrt(x2*x2+A)+A*log(2*(sqrt(x2*x2+A)+x2)))
				  -(x1*sqrt(x1*x1+A)+A*log(2*(sqrt(x1*x1+A)+x1))));
}

int main(){
	int W,n; scanf("%d%*d%d",&W,&n);
	int a[50],p[50],q[50];
	rep(i,n) scanf("%d%d%d",a+i,p+i,q+i);

	vector<double> X;
	X.push_back(0);
	X.push_back(W);
	rep(i,n){
		// 山 i と窓枠の下辺との交点
		double cx=sqrt(-1.0*q[i]/a[i]);
		if(-EPS<p[i]-cx && p[i]-cx<W+EPS) X.push_back(p[i]-cx);
		if(-EPS<p[i]+cx && p[i]+cx<W+EPS) X.push_back(p[i]+cx);

		rep(j,i){ // 山 i と山 j の交点
			ll A=a[i]-a[j];
			ll B=-2*a[i]*p[i]+2*a[j]*p[j];
			ll C=a[i]*p[i]*p[i]+q[i]-a[j]*p[j]*p[j]-q[j];

			if(A!=0){ // Ax^2+Bx+C=0
				if(B*B-4*A*C>=0){
					double x;
					x=(-B-sqrt(B*B-4*A*C))/(2*A);
					if(-EPS<x && x<W+EPS) X.push_back(x);
					x=(-B+sqrt(B*B-4*A*C))/(2*A);
					if(-EPS<x && x<W+EPS) X.push_back(x);
				}
			}
			else if(B!=0){ // Bx+C=0
				double x=-1.0*C/B;
				if(-EPS<x && x<W+EPS) X.push_back(x);
			}
		}
	}

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

	double ans=0;
	rep(i,(int)X.size()-1){
		double x1=X[i],x2=X[i+1];

		int j0=-1;
		rep(j,n){
			if(f(a[j],p[j],q[j],(x1+x2)/2)>0
			&& (j0==-1 || f(a[j0],p[j0],q[j0],(x1+x2)/2)<f(a[j],p[j],q[j],(x1+x2)/2))){
				j0=j;
			}
		}

		if(j0!=-1) ans+=parabola_perimeter(a[j0],-2*a[j0]*p[j0],p[j0]*p[j0]+q[j0],x1,x2);
	}

	printf("%.9f\n",ans);

	return 0;
}

Measured memory_bytes: 1164
#include<cstdio>
#include<string.h>

int main(){
    int s[6];
    int t[6];
    char h[101];
    for(int i = 0;i < 6;i++){
        scanf("%d",&s[i]);
    }
    scanf("%s",h);
    for(int i = 0;h[i] != 0;i++){
        if(h[i] == 'N'){
            t[4] = s[0];
            t[0] = s[1];
            t[1] = s[5];
            t[5] = s[4];
            t[2] = s[2];
            t[3] = s[3];
        }
        if(h[i] == 'S'){
            t[0] = s[4];
            t[1] = s[0];
            t[5] = s[1];
            t[4] = s[5];
            t[2] = s[2];
            t[3] = s[3];
        }
        if(h[i] == 'W'){
            t[0] = s[2];
            t[2] = s[5];
            t[5] = s[3];
            t[3] = s[0];
            t[1] = s[1];
            t[4] = s[4];
        }
        if(h[i] == 'E'){
            t[2] = s[0];
            t[5] = s[2];
            t[3] = s[5];
            t[0] = s[3];
            t[1] = s[1];
            t[4] = s[4];
        }
        for(int j = 0;j < 6;j++){
            s[j] = t[j];
        }
    }
    printf("%d\n",s[0]);
}


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

long long a[200009], n;

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i]; a[i] -= i;
	}
	sort(a + 1, a + n + 1); long long v = a[n / 2 + 1];
	long long sum = 0; for (int i = 1; i <= n; i++) sum += abs(a[i] - v);
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;
//printf("%.10f\n", n);

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll modpow(ll x, ll y) {
	ll res = 1;
	while (y) {
		if (y % 2) { res *= x; res %= mod; }
		x = x * x % mod; y /= 2;
	}
	return res;
}

//頂点fromから頂点toへのコストcostの辺
struct edge { ll from, to, cost; };
edge es[345678]; //辺
ll d[345678]; //最短距離
//Vは頂点数、Eは辺数
//s番目の頂点から各頂点への最短距離を求める
void Bellman_Ford(ll V, ll E, ll s) {
	for (int i = 0; i <= V; i++) d[i] = INF;
	d[s] = 0; ll sum = 0;
	for (int z = 0; z < V; z++) {
		for (int i = 0; i < E; i++) {
			edge e = es[i];
			if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
			}
		}
	}
}
//trueなら負の経路が存在する
bool find_negative_loop(ll V, ll E) { //Vは頂点数、Eは辺数
	memset(d, 0, sizeof(d)); ll sum = 0;
	for (int i = 0; i < V; i++) {
		for (int j = 0; j < E; j++) {
			edge e = es[j];
			if (d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				//n回目にも更新があるなら負の経路が存在
				if (i == V - 1 && d[V] != sum)return true;
			}
		}
		if (i == V - 2) { sum = d[V]; }
	}
	return false;
}
ll test[12345678];
signed main() {
	ll n, m, a, b, c; cin >> n >> m;
	for (int h = 0; h < m; h++) {
		cin >> a >> b >> c;
		es[h] = { a, b, 0 - c };
	}
	if (find_negative_loop(n, m)) { cout << "inf" << endl; return 0; }
	Bellman_Ford(n, m, 1);
	cout << 0 - d[n] << endl;
	return 0;
}

Measured memory_bytes: 6384