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

using namespace std;

#define int long long
#define sz(x) (int)x.size()
#define yes cout << "Yes\n"
#define  no cout << "No\n"
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ft first
#define sd second
typedef pair<int, int> pii;
typedef long double ld;
typedef vector<int> vi;
typedef vector<bool> vb;
mt19937_64 rnd(time(0));

void start() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout << fixed << setprecision(10);
    // cerr << fixed << setprecision(10);
#ifdef MY
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int n, m, w = 0;
vector<vi> g;
vb u;
vi d;

int dfs(int v) {
    if (!u[v]) {
        int dist = 0;
        u[v] = 1;
        for (int to : g[v]) {
            if (!u[to])
                dist = max(dfs(to), dist);
            d[v] = max(d[v], d[to] + 1);
        }
        d[v] = max(d[v], dist);
    }
    return d[v] + 1;
}

signed main() {
    start();
    cin >> n >> m;
    g.resize(n);
    u.resize(n);
    d.resize(n);
    for (int i = 0; i < m; ++i) {
        int r, h;
        cin >> r >> h;
        g[r - 1].push_back(h - 1);
    }
    for (int i = 0; i < n; ++i) {
        dfs(i);
    }
    for (int i : d)
        w = max(w, i);
    cout << w;

}


Measured memory_bytes: 12808
#include<bits/stdc++.h>
#define lint long long int
using namespace std;
int main() 
{
	lint s=0;
	lint w=0;
	cin>>s>>w;
	if(w>=s)
	{
		cout<<"unsafe"<<endl;
	}
	else
	{
		cout<<"safe";
	}
	return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>

int main(void){

    int N;
	int H;
	int W;
	int A[1000];
	int B[1000];
	int i;
	int cntr = 0;
	
	scanf("%d", &N);
    scanf("%d", &H);
    scanf("%d", &W);
	
	for(i=0;i<N;i++){
	    scanf("%d", A + i);
		scanf("%d", B + i);
		
		if(A[i] >= H && B[i] >= W){
		    cntr++;
		}
		
	}
	
	printf("%d", cntr);

}

Measured memory_bytes: 128
function main(input){
  var N = Number(input[0]);
  var A = input[1].split(' ').map(parseFloat);
  var rev = [];
  
  for(var i = 0;i < N;i++) rev[A[i] - 1] = i + 1;
  console.log(rev.join(' '));
}
main(require('fs').readFileSync('/dev/stdin','utf8').split('\n'));

Measured memory_bytes: 43860
import scala.collection.mutable

object Main extends App {
  import scala.io.StdIn._
  val n = readLine.trim.toInt
  val store = readLine.trim
  val fromStart = Array.tabulate(n + 1){_ ⇒ Array.tabulate(4){it ⇒ if (it == 0) 1L else 0L}}
  for (i ← 0 until n){
    for (j ← 0 until 4) fromStart(i + 1)(j) = fromStart(i)(j)
    store(i) match{
      case 'J' ⇒ fromStart(i + 1)(1) += fromStart(i)(0)
      case 'O' ⇒ fromStart(i + 1)(2) += fromStart(i)(1)
      case 'I' ⇒ fromStart(i + 1)(3) += fromStart(i)(2)
      case _ ⇒
    }
  }//fromStart(i)(s) [0, i)の店でs個のスタンプをもらう
  val toEnd = Array.tabulate(n + 1){_ ⇒ Array.tabulate(4){it ⇒ if (it == 0) 1L else 0}}
  for (i ← (0 until n).reverse){
    for (j ← 0 until 4) toEnd(i)(j) = toEnd(i + 1)(j)
    store(i) match{
      case 'J' ⇒ toEnd(i)(3) += toEnd(i + 1)(2)
      case 'O' ⇒ toEnd(i)(2) += toEnd(i + 1)(1)
      case 'I' ⇒ toEnd(i)(1) += toEnd(i + 1)(0)
      case _ ⇒
    }
  }//toEnd(i)(s) [i, n)の店でs個のスタンプをもらう
  var maxIncrease = 0L
  for (i ← 0 to n){//i番目の店の前に店を出す場合
    for (j ← 1 to 3){
      if (maxIncrease < fromStart(i)(j - 1) * toEnd(i)(3 - j)) maxIncrease = fromStart(i)(j - 1) * toEnd(i)(3 - j)
    }
  }
  println(
    toEnd(0)(3) + maxIncrease
  )
}



Measured memory_bytes: 75348
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;
unsigned gcd(unsigned a, unsigned b) {
    if(a < b) return gcd(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

int main() {
    ll A,B;
    cin >> A >> B;
    ll C = gcd(A,B);
    cout << A / C * B << endl;



}


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

#define MOD 1000000007

long long A[300005];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    int N;
    cin >> N;

    for(int i=1; i<=N; i++)
        cin >> A[i];
    
    long long ans = 0;

    for(int i=0; i<60; i++)
    {
        int x = 0;

        for(int j=1; j<=N; j++)
            if(A[j] & (1LL << i))
                x++;
        
        ans += 1LL * x * (N - x) % MOD * ((1LL << i) % MOD) % MOD;
    }

    cout << ans % MOD << "\n";
    return 0;
}


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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

void solved(int n, vector<int>& a, int mid) {
    cout << mid*2 << " ";
    for(int i = 0; i < n-1; ++i) {
        int cur = a[i] - mid;
        cout << cur*2 << " ";
        mid = cur;
    }
    cout << '\n';
}

int doit(int n, vector<int>& a, int mid) {
    int prev = mid;
    for(int i = 0; i < n; ++i) {
        int cur = a[i] - prev;
        if(cur < 0) {
            return i%2 ? 1 : -1;
        }
        prev = cur;
    }
    if(prev == mid) return 0;
    else if(prev < mid) return -1;
    else return 1;
}

int32_t main() {

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

    int l = 0, r = a[0]+1;

    while(r-l > 0) {
        int mid = (l+r)/2;
        int blah = doit(n, a, mid);
        if(blah == -1) {
            r = mid;
        } else if(blah == 1) {
            l = mid+1;
        } else {
            solved(n, a, mid);
            break;
        }
    }
    
    return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
#include<string>
#include<set>
using namespace std;

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

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)


int N,M;
int ans;
string str;


int main(){
	cin>>str;
	int siz = str.size();
	set<char> strs;
	REP(i,siz){
		strs.insert(str[i]);
	}
	bool kekka = true;	

	if( strs.find('N') != strs.end() ){
		if(strs.find('S') == strs.end()){
			kekka = false;
		}
	}else{
		if(strs.find('S') != strs.end() ){
			kekka = false;
		}
	}

	if( strs.find('W') != strs.end() ){
		if(strs.find('E') == strs.end()){
			kekka = false;
		}
	}else{
		if(strs.find('E') != strs.end() ){
			kekka = false;
		}
	}


	if(kekka){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())
#define mp make_pair

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef pair<int, int> P;
//typedef pair<int, pair<int, int> > PP;
//const int MAX=;



int main(){
	int N;
	cin>>N;
	ll a[50];
	rep(i,N)cin>>a[i];
	
	ll ans=0;
	while(true){
		ll b[50];
		ll s=0;
		rep(i,N){
			b[i]=a[i]/(ll)N;
			s+=b[i];
		}
		ans+=s;
		rep(i,N) a[i]=a[i]%(ll)N+s-b[i];
		
		sort(a, a+N);
		if(a[N-1]<N)break;
/*
		else{
			ans+=a[0]*(ll)N;
			rep(i,N)a[i]-=a[0];
		}
*/
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
package main

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

// 三角形
func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	ary := strings.Split(sc.Text(), " ")
	a, _ := strconv.ParseFloat(ary[0], 64)
	b, _ := strconv.ParseFloat(ary[1], 64)
	c, _ := strconv.ParseFloat(ary[2], 64)
	sin := math.Sin(c * math.Pi / 180)
	cos := math.Cos(c * math.Pi / 180)
	fmt.Printf("%f\n", a*b*sin/2)
	fmt.Printf("%f\n", a+b+(math.Sqrt(math.Pow(a, 2)+math.Pow(b, 2)-2*a*b*cos)))
	fmt.Printf("%f\n", b*sin)
}



Measured memory_bytes: 1096
#include <iostream>
#include <string>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <vector>
#define ll long long 

using namespace std;
int res = 0;
int cnt[1000000];


int main(){
    int n; cin >> n;
    int a[n-1];
    for(int i=0; i<n-1; i++) cin >> a[i];
    for(int i=0; i<n-1; i++) cnt[a[i]]++;

    for(int i=1; i<=n; i++) cout << cnt[i] << endl;
}

Measured memory_bytes: 5132
#include<bits/stdc++.h>         //可以处理负权边
using namespace std;
const int INF =  0x3f3f3f;
#define rep(i,n) for( i = 0; i < n; i++)
#define rep2(i,n) for(i = n-1; i >= 0; i--)
#define rep3(i,n,m) for(i = m; i < n; i++)
#define CloseIo   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
typedef long long ll;
const int N = 10000+50;
typedef pair<int, int> P;
typedef vector<P> vctp;
int arry[N] = {0};
int main(){
    CloseIo;
    int a,b,c;
    cin>>a>>b>>c;
    int mx = max(a,b);
    int t = 0;
    for(int i = 1; i <= mx; i++){
      if(a%i == 0 && b %i == 0){
        arry[t++] = i;
      }
    }
    cout<<arry[t-c];
}


Measured memory_bytes: 256
s = gets.chomp
p = gets.chomp
s = s + s
ok = false

for i in 0..(s.length - 1)
    for j in 0..(p.length - 1)
        if s[i + j] != p[j]
            break
        end
        if j == p.length - 1
            ok = true
        end
    end
end
if ok == true
    puts "Yes"
else
    puts "No"
end

Measured memory_bytes: 8712
def main():
  import math
  N = int(input())
  ans=0
  for i in range(1,N+1):
    for j in range(1, N+1):
      for k in range(1, N+1):
          t=math.gcd(i,j)
          t=math.gcd(t,k)
          ans+=t
        
  print(ans)
 
if __name__=='__main__':
  main()

Measured memory_bytes: 9180
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
#include <utility>
#include<iomanip>
// #include <numeric>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef vector<string> vstring;
typedef vector<vector<string>> vvstring;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<long double> vdouble;
typedef vector<vector<long double>> vvdouble;
typedef vector<vector<vector<long double>>> vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define LLONG_MAX 9223372036854775807
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define DIVIDER 1000000007


//
// struct Node{
//   vint children;
//   ll index;
//   ll prop;
// };
// struct edge{ll to; ll cost;};



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

// ll X,Y,Z,K;
// ll pmax = 30000000000;
// vint A,B,C;




// struct UnionFind {
//     vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
//
//     UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
//         for(int i = 0; i < N; i++) par[i] = i;
//     }
//
//     int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
//         if (par[x] == x) return x;
//         return par[x] = root(par[x]);
//     }
//
//     void unite(int x, int y) { // xとyの木を併合
//         int rx = root(x); //xの根をrx
//         int ry = root(y); //yの根をry
//         if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
//         par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
//     }
//
//     bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };
//
// vint divisor(ll n){ // nの約数
//   vint ret;
//   for(ll i=1;i*i<=n;i++){
//     if(n%i == 0){
//       ret.pb(i);
//       if(i*i!=n) ret.pb(n/i);
//     }
//   }
//   vsort(ret);
//   return ret;
// }
//
// ll get_digits_num(ll n){
//   ll ret=0;
//   while(n){
//     n/=10;
//     ret++;
//   }
//   return ret;
// }



int main() {
  cout<<fixed<<setprecision(10);

  ll N;cin>>N;
  vint a(N);
  rep(i,N)cin>>a[i];

  string ans = "second";
  for(auto e:a){
    if(e%2==1){
      ans = "first";
      break;
    }
  }

  cout << ans << endl;


}

















//


Measured memory_bytes: 1024
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int[] l = new int[n];
    int cnt = 0;
    
    for(int i=0; i < n; i++){
      l[i] = sc.nextInt();
    }
    
    for(int i = 0; i < n-2; i++){
      int li = l[i];
      for(int j = i+1; j < n-1; j++){
        int lj = l[j];
        if(li == lj){
          continue;
        }
        for(int k = j+1; k < n; k++){
		  int lk = l[k];
          if(li == lk || lj == lk){
            continue;
          }
          if((li + lj > lk) && (li + lk > lj) && (lj + lk > li))
            cnt++;
        }
      }
    }
    
    System.out.println(cnt);
  }
}

Measured memory_bytes: 27804
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;
int main()
{
  ll n;
  string s[100];
  ll cnt[26];
  cin>>n;
  rep(i,n){
    cin>>s[i];
    sort(s[i].begin(),s[i].end());
  }
  ll min;
  for(char l='a';l<='z';l++){
    min=1000000;
    rep(i,n){
      ll tmp=0;
      rep(j,s[i].length()){
        if(s[i][j]==l)tmp++;
      }
      if(tmp<min)min=tmp;
    }
    cnt[l-'a']=min;
  }

  rep(i,26){
    rep(j,cnt[i]){
      printf("%c",'a'+i);
    }
  }

  cout<<endl;

  return 0;
}


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

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

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

Measured memory_bytes: 4008
#! /usr/bin/env python3
#! /usr/bin/env python3
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def bit_search(n):
    res = []
    for i in range(2**n):
        st = set()
        for j in range(n): 
            if ((i >> j) & 1):
                st.add(j)
        res.append(st)
    return res

def main():
    H,W,K=mi()
    
    G = []
    for i in range(H):
        G.append(list(input()))
    
    v = [[0] * W for _ in range(H+1)]
    for w in range(W):
        for h in range(H):
            white_choc = G[h][w] == "1"
            v[h+1][w] = v[h][w] + white_choc
    
    ans = INF
    for borders in bit_search(H):
        counts = [[0] for _ in range(20)]
        k_fact = 1
        W_borders = []

        failed = False
        from_zero = True
        w = 0
        while w < W:
            pre = 0
            over_K = False

            max_diff = 0
            for i,border in enumerate(borders):
                if border == 0: continue
                count = v[border][w] - v[pre][w]
                if not from_zero:
                    count += counts[i][-1]
                else:
                    if count > K:
                        failed = True
                        break
                
                if count > K:
                    over_K = True
                

                counts[i].append(count)
                pre = border
            
            count = v[H][w] - v[pre][w]
            if not from_zero:
                count += counts[i+1][-1]
            else:
                if count > K:
                    failed = True
                    break

    
            if count > K:
                over_K = True


            counts[i+1].append(count)
            if over_K:
                W_borders.append(w-1)
                from_zero = True

                for c in counts:
                    if len(c) == 0: continue
                    c.pop() # 直前のカウント履歴を消す
            else:
                from_zero = False
                w += 1

            
            if failed:
                break

        # print(counts)
        if not failed:
            # print(borders)
            # print(W_borders)
            # print(counts)
            # # # print(v[2])
            # # exit()
            count_of_ope = len(borders) + len(W_borders)
            ans = min(count_of_ope,ans)


    print(ans)




if __name__ == "__main__":
    main()


Measured memory_bytes: 79252
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iomanip>
#include<sstream>
#include<map>
#include<set>
#include<cmath>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}
#define rep(i,n) for(ll i = 0;i < n;i++)
#define req(i,n) for(ll i = 1;i <=n;i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
typedef long double ld;
const ll INF =  1LL << 60;
const int inf = 1 << 25;
ll n, m, x, y, q, d, z, w,  sum = 0, ans = 0;
const int MAX = 510000;
const int MOD = 1000000007;
vector<ll> a, b;
int main(void) {
	cin >> n >> m >> q;  a.resize(n+1,0), b.resize(m+1,0);
	req(i, n) {
		cin >> a[i];
		a[i] += a[i - 1];
	}
	req(i, m) {
		cin >> b[i];
		b[i] += b[i - 1];
	}
	rep(i, n+1) {
		w = q - a[i];
		if (w < 0) break;
		int right = m + 1, left = 0;
		while (abs(right - left) > 1) {
			int mid = (left + right) / 2;
			if (b[mid] > w) right = mid;
			else left = mid;
		}
		ans = max(ans, i + left);
	}cout << ans << endl;
}

Measured memory_bytes: 6360
#!/usr/bin/env python3
# n,m = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(sys.stdin.readline() for _ in range(n)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# n = int(sys.stdin.readline())
# INF = float("inf")

import sys,collections
sys.setrecursionlimit(100000)
V,E = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
#sdw = [[src1 dist1 d1][src1 dist1 d1]...]# vect source1 -> distance1 distances
INF = float("inf")

st = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(E)) # multi line with multi param

G = [[] for _ in range(V)]

for s,t in st:
    G[s].append(t)
    G[t].append(s)

visited = set()
prenum = [0]*V
parent = [0]*V
lowest = [0]*V
timer = 0

def dfs(current,prev):
    global timer
    parent[current]=prev
    prenum[current]=lowest[current]=timer
    timer += 1
    visited.add(current)
    for nex in G[current]:
        if not nex in visited:
            dfs(nex,current)
            lowest[current]=min(lowest[current],lowest[nex])
        elif nex != prev:
            lowest[current]=min(lowest[current],prenum[nex])
dfs(0,-1)

ret = set()
if sum(1 for p in parent if p==0) > 1:
    ret.add(0)

for i in range(1,V):
    p = parent[i]
    if p != 0 and prenum[p] <= lowest[i]:
        ret.add(p)
ret = sorted(list(ret))

if ret:
    print(*ret,sep='\n')



Measured memory_bytes: 23784
#include <bits/stdc++.h>
#define REP(i, a, n) for (ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

int main(void) {
  ll N, M;
  cin >> N >> M;
  vector<ll> A(M), B(M);
  REP(i, 0, M) cin >> A[i] >> B[i];

  map<pll, ll> p;
  REP(i, 0, M) p[pll(A[i], B[i])]++;

  vector<ll> x(N, M);
  for (auto q : p) {
    ll a = q.first.first, b = q.first.second, cnt = q.second;
    x[0] += a * cnt;
    for (ll j = b - a; j - 1 < N; j += b) {
      x[j - 1] -= b * cnt;
    }
  }

  REP(i, 0, N - 1) x[i + 1] += x[i];
  REP(i, 0, N) cout << x[i] << endl;
}


Measured memory_bytes: 11268
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef vector< pii > vii;

#define ll          long long
#define ff          first
#define ss          second
#define pb          push_back
#define mkp         make_pair
#define sz          size()

#define forf(a,b,c)    for(int i=a;i<=b;i+=c)
#define forr(a,b,c)    for(int i=a;i>=b;i-=c)
#define all(a)      a.begin(),a.end()
#define mem(a,b)    memset(a,b,sizeof(a))
#define pi          2*acos(0.0)
#define End         return 0;

#define scan1(a)    scanf("%d",&a)
#define scan2(a,b)  scanf("%d %d",&a,&b)
#define scan3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define scanl(a)    scanf("%lld",&a)
#define scanll(a,b) scanf("%lld %lld",&a,&b)
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)

#define print1(a)    printf("%d",a)
#define print2(a,b)  printf("%d %d",a,b)
#define print3(a,b,c)  printf("%d %d %d",a,b,c)
#define printl(a)    printf("%lld",a)
#define printll(a,b) printf("%lld %lld",a,b)
#define printlll(a,b,c) printf("%lld %lld %lld",a,b,c)

#define MAXN        100000007
#define INF 0x3f3f3f3f
//int dx[]={+1,-1,+0,+0};///Four Directions
//int dy[]={+0,+0,+1,-1};///Four directions
//int dx [] = {+1,-1,+0,+0,-1,-1,+1,+1};///Eight Directions
//int dy [] = {+0,+0,+1,-1,+1,-1,-1,+1};///Eight Directions

//int mark[10007];vi prime;void seive(){for(int i=2;i<10000;i++){if(mark[i]==0){prime.pb(i);for(int j=i+i;j<=10000;j+=i)mark[j]=1;}}}

//freopen("input.txt", "r", stdin);

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

   string s,t; cin>>s>>t;
   for(int i=0;i<s.sz;i++){
    if(s[i]!=t[i]){
        cout<<"No"<<endl;
        return 0;
    }
   }
   cout<<"Yes"<<endl;
   End;
}


Measured memory_bytes: 3652
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const x = parseInt(args[0][0], 10)
	const a = parseInt(args[0][1], 10)
	const b = parseInt(args[0][2], 10)
	if (Math.abs(a - x) < Math.abs(b - x)) console.log('A')
	else console.log('B')
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7372
// written by @kakira9618
// problem: http://icpc.iisf.or.jp/past-icpc/domestic2016/problems/all_ja.html#section_D

#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>

using namespace std;

int n;
vector<int> W;
int dp[301][301];

// O(n^3)
int dfs(int l, int r) {
    if (r - l <= 1) return dp[l][r] = 0;
    if (dp[l][r] != -1) return dp[l][r]; // ?????¢???
    int ans = 0;
    
    // i????????§??????????????????????¨?????????????????§£??????
    for(int i = l + 1; i < r; i++) {
        ans = max(ans, dfs(l, i) + dfs(i, r));
    }
    
    // ?????£???2??????????????¶?????????1??\???????????????????????¨????¶??????????????????°?????£????????????????¶???????
    if (abs(W[r - 1] - W[l]) <= 1) {
        if (dfs(l + 1, r - 1) == r - l - 2) {
            ans = max(ans, dfs(l + 1, r - 1) + 2);
        }
    }
    return dp[l][r] = ans;
}

int main() {
    while(cin >> n, n) {
        memset(dp, -1, sizeof(int) * 301 * 301);
        W.clear();
        W.resize(n);
        for(int i = 0; i < n; i++) {
            cin >> W[i];
        }
        cout << dfs(0, n) << endl;
    }
    return 0;
}

Measured memory_bytes: 3484
#方針: 横にスライスして、島の数を数える

n = gets.to_i
h = gets.split.map(&:to_i)
now = [0]*n
ans = 0

while !h.all?{|h| (h<=0)}
  cnt=0
  l = 0
  dl = 0
  while l < h.length
    if h[l]<=0
      l+=1
      next
    end

    while l+dl < h.length && h[l+dl]>0
      dl+=1
    end
    cnt+=1
    l = l+dl
    dl = 0
  end
  ans += cnt
  h = h.map{|h| h-1}
end

p ans

Measured memory_bytes: 1916
/*
                                             ::                     ::
                                             ':                     :
                                              :.                    :
                                           ;' ::                   ::  '
                                          .'  ';                   ;'  '.
                                         ::    :;                 ;:    ::
                                         ;      :;.             ,;:     ::
                                         :;      :;:           ,;"      ::
                                         ::.      ':;  ..,.;  ;:'     ,.;:
                                          "'"...   '::,::::: ;:   .;.;""'
                                              '"""....;:::::;,;.;"""
                                          .:::.....'"':::::::'",...;::::;.
                                         ;:' '""'"";.,;:::::;.'""""""  ':;
                                        ::'         ;::;:::;::..         :;
                                       ::         ,;:::::::::::;:..       ::
                                       ;'     ,;;:;::::::::::::::;";..    ':.
                                      ::     ;:"  ::::::"""'::::::  ":     ::
                                       :.    ::   ::::::;  :::::::   :     ;
                                        ;    ::   :::::::  :::::::   :    ;
                                         '   ::   ::::::....:::::'  ,:   '
                                          '  ::    :::::::::::::"   ::
                                             ::     ':::::::::"'    ::
                                             ':       """""""'      ::
                                              ::                   ;:
                                              ':;                 ;:"


                                                     P_r_A_d_Y
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define mod 1000000007
#define inf 1e18
const int N = 300005;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
void cs(int &x)
{
    cout << "Case #" << x << ": ";
}
bool cmp(string a, string b)
{
    return a + b < b + a;
}

int32_t main()
{
    fastIO;
    // int t; cin >> t;
    // int x = 1;
    // while (t--)
    // {
        int n,k;
        cin>>n>>k;

        int ans=0;

        for(int i=k;i<=n+1;i++)
        {
            int d=i-1;
            int suml=(d*(d+1))/2;

            int sumr=(n*(n+1))/2;
            d=n-i;
            sumr-=(d*(d+1))/2;

            //cout<<suml<<" "<<sumr<<endl;

            ans+=sumr-suml+1;
            ans%=mod;

        }

        cout<<ans<<endl;


    // }
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
vi zyoutai(int bit,int n){
    vi S;
    //cout << bit;
    rep(i,n){
        //cout << (bit & (1 < i));
        if(bit & (1 << i)){
            S.pb(1);
        }
        else{S.pb(0);}
    }
    return S;
}


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

    int n,m;
    cin >> n >> m;
    vi seikai(n); //これとonのスイッチの個数が一致の時電球がon
    vi k(m); //電球についてるスイッチの個数
    vi swi(n,0); //スイッチの判定on/off
    vector<vi>  s(m); //どのスイッチが電球に関連しているのか
    int ans = 0;
    rep(i,m){
        cin >> k[i];
        rep(j,k[i]){
            int x;
            cin >> x;
            s[i].pb(x);
        }
    }
    rep(i,m){
        cin >> seikai[i];
    }
    

    for(int bit = 0;bit < (1<<n);++bit){
        bool ok = true;
        swi = zyoutai(bit,n); //スイッチを確定
        rep(i,m){
            int tmp = 0;
            //cout<<k[i]<<endl;
            rep(j,k[i]){
                if(swi[s[i][j]-1]==1)tmp++;
            }
            if(tmp%2 != seikai[i])ok =false ;
        }
        if(ok)ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import Data.Char
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector as V
main=mapM_ print.solve.unfoldr(B.readInt.B.dropWhile isSpace)=<<B.getContents
solve(n:as)=snd$mapAccumL f(1,1)[1..n+1]where
  k=(\[i,j]->n-j+i)$(elemIndices=<<head.head.filter((1<).length).group.sort)as
  f(c1,c2)i=((c12,c22),(c12+m-c2)`mod`m)where
    [c12,c22]=map(\(c,j)->c*(j-i+1)`mod`m*inv V.! i`mod`m)[(c1,n+1),(c2,k)]
  inv=V.generate(n+2)$ \i->if i<2 then 1 else inv V.!(m`mod`i)*(m-m`div`i)`mod`m
m=10^9+7

Measured memory_bytes: 37776
from collections import defaultdict                              

n = int(input())
name_count_dic = defaultdict(int)

for i in range(n):
    name = input()
    if name.startswith('M'):
        name_count_dic['M'] += 1
    elif name.startswith('A'):
        name_count_dic['A'] += 1
    elif name.startswith('R'):
        name_count_dic['R'] += 1
    elif name.startswith('C'):
        name_count_dic['C'] += 1
    elif name.startswith('H'):
        name_count_dic['H'] += 1

count_list = list(name_count_dic.values())
char_num = len(count_list)
if char_num < 3:
    num = 0 
else:
    num = 0 
    for i in range(char_num - 2): 
        for j in range(i + 1, char_num - 1): 
            for k in range(j + 1, char_num):
                num += count_list[i] * count_list[j] * count_list[k]

print(num)


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

using namespace std;

int main() {
	string S, T;
	int sa = 0;

	cin >> S >> T;

	for (int i = 0; i < S.size(); i++) {
		if (S[i] != T[i]) {
			sa++;
		}
	}
	cout << sa << endl;
}

Measured memory_bytes: 3832
import java.util.*;

import static java.lang.Math.*;

class Main {
    final Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        int n = sc.nextInt();
        int ac = 0;
        int wa = 0;
        int tle = 0;
        int re = 0;
        for (int i = 0; i < n; i++) {
            String s = sc.next();
            if (s.equals("AC")) {
                ac++;
            } else if (s.equals("WA")) {
                wa++;
            } else if (s.equals("TLE")) {
                tle++;
            } else if (s.equals("RE")) {
                re++;
            }
        }
        System.out.println("AC x "  + ac);
        System.out.println("WA x "  + wa);
        System.out.println("TLE x "  + tle);
        System.out.println("RE x "  + re);
    }
}


Measured memory_bytes: 58432
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt(),m=sc.nextInt(),sum=0;
		int[] a=new int[n];
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
			sum+=a[i];
		}
		int count=0;
		for(int i=0;i<n;i++) {
			if(sum%(4*m)!=0&&sum/(4*m)<a[i])count++;
			else if(sum%(4*m)==0&&sum/(4*m)<=a[i])count++;
		}
		System.out.println(count>=m?"Yes":"No");
		sc.close();
	}
}


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

//change min, aを小さい方の値にする
void chmin(int &a, int b) { a = min(a, b); }

int INF = 1e+15;
int N, M, L;
int d1[300][300];
int d2[300][300];

signed main() {
	int i, j, k;
	
	cin >> N >> M >> L;
	
	rep(i, N) rep(j, N) d1[i][j] = INF;
	rep(i, N) d1[i][i] = 0;
	rep(i, M) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		chmin(d1[a][b], c);
		chmin(d1[b][a], c);
	}
	rep(k, N) rep(i, N) rep(j, N) chmin(d1[i][j], d1[i][k] + d1[k][j]);
	
	rep(i, N) rep(j, N) d2[i][j] = INF;
	rep(i, N) d2[i][i] = 0;
	rep(i, N) rep(j, N) if (d1[i][j] <= L) d2[i][j] = 1;
	
	rep(k, N) rep(i, N) rep(j, N) chmin(d2[i][j], d2[i][k] + d2[k][j]);
	
	int Q;
	cin >> Q;
	rep(i, Q) {
		int s, t;
		cin >> s >> t;	//Assume : s ≠ t
		s--; t--;
		if (d2[s][t] >= INF) cout << -1 << endl;
		else cout << d2[s][t] - 1 << endl;
	}
	return 0;
}

//(頂点, 量) = 給油回数minだとTLE. ある移動に注目すると、ギリギリまで給油しないべき。
//つまり、給油する町の間を一回の移動と考えると、「距離L以下の頂点に移動→給油」の繰り返しだと分かる。
//これが条件を満たす行動であることは明らかで、最適行動もそのような形を取る。
//よって、「距離L以下の頂点に移動する」回数の最小値をMとおくと、M - 1が答え。
//Mは、あらかじめ「距離L以下の頂点対(a,b)」に対してコスト1の辺を張ったグラフG'についての、
//最短経路長になる。今回は全頂点対についてMを求めたいので、G'についてワーシャルフロイドを行えばよい。
//「距離L以下の頂点対(a,b)」自体も、ワーシャルフロイドによってO(N^3)で求めることができる。
//以上をまとめると、この問題は、ワーシャルフロイドを2回おこなうことでO(N^3)で答えることができる。
//
//なお、以下の解法はsample3のクエリ8などで上手くいかない（反例L=4, 辺コスト：2-3-2）
//・各頂点対(a,b)について、dp[a][b] = (給油回数, L - 現在の量)の辞書順最小を「ワーシャルフロイドで」求める。
//なぜかというと、dp[a][b]は「ガソリン満タンで頂点aを出発したとき」の解になっているから。
//a-->b-->cと遷移するとき（a-->b, b-->cは直接移動とは限らない）、a->bでガソリンを消費しているのに、b-->cではガソリン満タンの
//ときの答えを得てしまっている。ここからdp[a][c]を計算するのは難しい。
//（例えば、残りのガソリンの量の遷移として「4->2|4->1(給油1回)->2」があるとき, 全体として「4->0(給油1回)」になるわけではないので）
//
//なお、ダイクストラを使えば、ワーシャルフロイドと違って、雑にやっても上手く行くと思う。
//ダイクストラでは、a-->b->cと遷移する（-->は間接移動, ->は直接移動）。つまり、今までの経路に辺を1つ追加する形になっている。
//この場合、このdp式でも、遷移を容易に書くことができる。
//具体的には、
//・cnt = dp[a][b].first + dp[b][c].first
//・ryo = dp[a][b].second + dp[b][c].second
// if (ryo > L) { ryo = dp[b][c].second; cnt++; }
//・dp[a][c] = pair<int, int>(cnt, ryo)
//などで上手く行くと思う。（これはワーシャルフロイドでは上手く機能しない）
//ということで、「aからbへの間接移動」をa-->b、a-->bに対して求めたい量（最短経路長など）をf(a-->b)で表し、集計(minを取るなど)をg
//で表すとき、f(a-->c) = g(all b, f(a-->b) + f(b-->c))の形で表せればワーシャルフロイドが使える。一方、
//f(a-->c) = g(all b, f(a-->b) + f(b->c))の形で表せればダイクストラが使える。なお、+の部分は、適当な2項演算に置き換えてもよい。
//つまり、より一般化すると、f(a-->c) = g(all b, h(f(a-->b), f(b-->c)))と表せるか否かで判断…という感じか。(hはa-->b-->cに対する求めたい量）


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

int main(void) {
	int N;
	scanf("%d", &N);
	int a[100100];
	for (int i = 0; i < N; i++) {
		scanf("%d", &a[i]);
	}
	int target = 1;
	int cnt = 0;
	while (cnt <= N) {
		cnt++;
		if (a[target - 1] == 2) {
			printf("%d\n", cnt);
			return 0;
		} else {
			target = a[target - 1];
		}
	}
	printf("-1\n");
	return 0;
}


Measured memory_bytes: 4152
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

constexpr int num = 26;
int D;
vector<int> c(num);

vector<vector<int>> s; 

int point(vector<int> &t){
	int res = 0;
	
	vector<int> last(num);
	
	for(int i = 0; i < D; i++){
		res += s[i][t[i]];
		
		for(int j = 0; j < num; j++){
			last[j]++;
		}
		
		last[t[i]] = 0;
		
		for(int j = 0; j < num; j++){
			res -= c[j] * last[j];
		}
	}
	
	return res + 1'000'000;
}

vector<int> solve(int Z){
	vector<int> t(D);
	
	vector<int> last(num);
	
	for(int i = 0; i < D; i++){
		for(int j = 0; j < num; j++){
			cin>>s[i][j];
			// s[i][j] = rand()%20000;
			
			if(s[i][t[i]] + last[t[i]] * last[t[i]]/Z * c[t[i]] < s[i][j] + last[j] * last[j]/Z * c[j]) {
				t[i] = j;
			}
		}
		
		for(int j = 0; j < num; j++){
			if(j == t[i]) {
				last[j] = 0;
			} else {
				last[j]++;
			}
		}
	}
	
	return t;
}

signed main(){
	cout<<fixed<<setprecision(10);
	
	vector<int> t;
	// srand(time(NULL));
	
	cin>>D;
	
	// D = 365;
	
	s.resize(D, vector<int>(num));
	t.resize(D, 0);
	
	for(int i = 0; i < num; i++){
		cin>>c[i];
		// c[i] = rand()%100;
	}
	
	int p;
	
	t = solve(1);
	
	p = point(t);
	// cout<<1<<" "<<p<<endl;
	
	for(int i = 2; i <= 100; i++){
		vector<int> nt;
		
		nt = solve(i);
		int np = point(nt);
		
		// cout<<i<<" "<<np<<endl;
		
		if(p < np) {
			t = nt;
			p = np;
		}
	}
	
	for(int i = 0; i < 100000; i++){
		int d = rand()%D, x = rand()%num, np;
		int tx;
		
		tx = t[d];
		
		t[d] = x;
		
		np = point(t);
		
		if(p < np) {
			np = p;
		} else {
			t[d] = tx;
		}
		
	}
	
	for(int i = 0; i < D; i++){
		cout<<t[i]+1<<endl;
	}
	
	// cout<<point(t)<<endl;
	
	return 0;
}

Measured memory_bytes: 3760
#include <string>
#include <vector>
#include <iostream>

using namespace std;

int main()
{
	int N, M; string S;

	while (true)
	{
		cin >> N;

		if (N == 0) { break; }
		
		cin >> M >> S;

		vector<int> IOI;

		for (int i = 2; i < M; i++)
		{
			if (S[i - 2] == 'I' && S[i - 1] == 'O' && S[i] == 'I')
			{
				IOI.push_back(i);
			}
		}

		int count_ = (N == 1 && IOI.size() != 0) ? 1 : 0;
		int connect = 1;

		for (int i = 1; i < IOI.size(); i++)
		{
			if (IOI[i - 1] + 2 == IOI[i])
			{
				connect++;
			}
			else
			{
				connect = 1;
			}

			if (connect >= N)
			{
				count_++;
			}
		}

		cout << count_ << endl;
	}

	return 0;
}

Measured memory_bytes: 6356
#include<bits/stdc++.h>
using namespace std;
int main(){
  int p[4][3][10]={0},n,b,f,r,v;
  cin>>n;
  for(int i=1;i<=n;++i){
    cin>>b>>f>>r>>v;
    p[b-1][f-1][r-1]+=v;
  }
  for(int i=0;i<4;++i){
    if(i) cout<<"####################"<<endl;
    for(int j=0;j<3;++j){
      for(int k=0;k<10;++k){
	cout<<" "<<p[i][j][k];
      }
      cout<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3100
N = int(input())
a = [int(i) for i in input().split(" ")]
dic = dict()

for A in a:
    l = [A-1,A,A+1]
    for i in l:
        if not i in dic:
            dic[i] = 1
        else:
            dic[i] += 1
            
dic = sorted(dic.items(), key=lambda x: x[1])
dic.reverse()
print(dic[0][1])


Measured memory_bytes: 23292
package main

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

type arm struct{ l, r int }
type arms []arm

func (a arms) Len() int           { return len(a) }
func (a arms) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a arms) Less(i, j int) bool { return a[i].r < a[j].r }

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	as := arms(make([]arm, n))
	for i := range as {
		x, l := scanInt(), scanInt()
		as[i].l = x - l
		as[i].r = x + l

	}
	sort.Sort(as)

	ans := 1
	r := as[0].r
	for i := 1; i < n; i++ {
		if as[i].l >= r {
			ans++
			r = as[i].r
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 4608
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
int main(){
  int n, w, d;
  while(cin >> n >> w >> d, n||w||d){
    int p, s;
    vector< pair<int, int> > C;
    C.push_back(make_pair(w,d));
    for(int i = 0; i < n; ++i){
      cin >> p >> s;
      w = C[p-1].first;
      d = C[p-1].second;
      C.erase(C.begin() + p-1);
      s %= w + d;
      if(s < w){
	C.push_back(make_pair(min(s, w-s), d));
	C.push_back(make_pair(max(s, w-s), d));
      }else{
	s -= w;
	C.push_back(make_pair(w, min(s, d-s)));
	C.push_back(make_pair(w, max(s, d-s)));
      }
    }
    vector<int> S;
    for(int i = 0; i <= n; ++i)
      S.push_back(C[i].first*C[i].second);
    sort(S.begin(),S.end());
    for(int i = 0; i < n; ++i){
      cout << S[i] << " ";
    }
    cout << S[n] << endl;
  }
  return 0;
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  string s; cin>>s;
  int ans=700;
  rep(i,3){
    if(s[i]=='o')
    ans+=100;
  }
  cout<<ans<<endl;

  return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k, x, y; cin >> n >> k >> x >> y;
    if (n <= k) {
        cout << n * x << endl;
    } else {
        cout << k * x + (n - k) * y << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int main() {
  FOR(i, 1, 10) FOR(j, 1, 10) printf("%dx%d=%d\n", i, j, i * j);
  return 0;
}

Measured memory_bytes: 3152
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <numeric>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
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;}
constexpr ll TEN(ll n){return n==0?1:10ll*TEN(n-1);}

constexpr ll inf = TEN(9)+5;
constexpr ll linf = 3*TEN(18);

#define int long long

ll N;
int X, M;

int idx[100010];

signed main()
{
    cin >> N >> X >> M;

    vector<int> S, hoge;
    S.emplace_back(X);

    memset(idx, -1, sizeof idx);
    idx[X] = 0;
    int len = 1;

    int til_idx = -1;

    ll sum1 = 0, sum2 = 0;
    int seq_len = -1;

    bool too_long = false;

    for (int i = 0; i < N - 1; ++i) {
        int nxt = (ll)S[i] * S[i] % M;
        //printf("S[%d] = %d\n", i+1,nxt);
        //printf("idx[%d] = %d\n", nxt, idx[nxt]);
        if (idx[nxt] != -1) {
            //printf("idx[nxt] = %d\n", idx[nxt]);
            too_long = true;
            til_idx = idx[nxt];
            for (int j = 0; j < til_idx; ++j) sum1 += S[j];
            for (int j = til_idx; j <= S.size() - 1; ++j) {
                sum2 += S[j];
                hoge.emplace_back(S[j]);
            }
            N -= S.size();
            seq_len = i - til_idx + 1;
            break;
        }
        S.emplace_back(nxt);
        idx[nxt] = i + 1;
        len++;
    }

    if (not too_long) {
        cout << accumulate(all(S), 0ll) << endl;
    } else {
        ll ans = sum1 + sum2;

        ans += (ll)N / seq_len * sum2;

        N %= seq_len;

        rep(i, N) ans += hoge[i];

        cout << ans << endl;
    }
}


Measured memory_bytes: 5088
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <map>

using namespace std;
#define LL long long
const int maxn = 1e5 + 10;
int a[maxn], b[maxn], book[maxn];
int n;
struct node
{
	int val, IS;
	int num;
}q[maxn * 2];
bool cmp(node a, node b)
{
	return a.val < b.val;
}
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i ++)
		scanf("%d %d", &a[i], &b[i]);
	for(int i = 1; i <= n; i ++)
	{
		q[i].val = a[i]; q[i + n].val = b[i];
		q[i].IS = 1; q[i + n].IS = 0;
		q[i].num = i; q[i + n].num = i;
	}
	sort(a + 1, a + n + 1);
	sort(b + 1, b + n + 1);
	sort(q + 1, q + n * 2 + 1, cmp);
	int flag = 1;
	LL ans1 = 1e18, ans2 = 1e18, ans3 = 0;
	
	for(int i = 1; i <= n; i ++)
	{
		if(a[i] > b[i])
		{
			flag = 0;
			break;
		}
	}
	if(flag)
	{
		ans1 = 0;
		for(int i = 1; i <= n; i ++)
			ans1 += a[i];
	}
	//cout << "! " << ans1 << endl;
	flag = 1;
	for(int i = 1; i <= n; i ++)
	{
		if(b[i] > a[i])
		{
			flag = 0;
			break;
		}
	}
	if(flag)
	{
		ans2 = 0;
		for(int i = 1; i <= n; i ++)
			ans2 += b[i];
	}
	//cout << "! " << ans2 << endl;
	for(int i = 1; i <= n; i ++)
	{
		book[q[i].num] ++;
	}
	flag = 0;
	for(int i = 1; i <= n; i ++)
	{
		if(book[i] > 1)
		{
			flag = 1;
			break;
		}
	}
	if(flag)
	{
		for(int i = 1; i <= n; i ++)
			ans3 += q[i].val;
	}
	else
	{
		if(q[n].num != q[n + 1].num)
		{
			for(int i = 1; i < n; i ++)
				ans3 += q[i].val;
			ans3 += q[n + 1].val;
		}
		else
		{
		ans3 = 1e18;
		LL sum = 0;
		for(int i = 1; i <= n; i ++)
			sum += q[i].val;
		//LL temp = ans3;
		for(int i = 1; i <= n; i ++)
		{
			LL t_ans = sum;
			t_ans -= q[i].val;
			if(q[n + 1].num == q[i].num)
				t_ans += q[n + 2].val;
			else
				t_ans += q[n + 1].val;
			ans3 = min (ans3, t_ans);
		}
		}
	}
	//cout << ans1 << " " << ans2 << " " << ans3 << endl;
	ans1 = min (ans1, ans2);
	ans1 = min (ans1, ans3);
	cout << ans1 << endl;
	return 0;
}


Measured memory_bytes: 3712
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,x = na()

def loop(a,b):
    h = max(a,b)
    w = min(a,b)
    if h%w == 0:
        return int((2*h/w-1)*w)
    else:
        m = h%w
        q = h//w
        return 2*q*w + loop(m,w)

print(loop(x,n-x)+n)

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

int main() {
    string str;
    cin>>str;
    int best=0;
    int count=0;
    for(int i=0;i<str.size();i++)
    {
      if(str[i]=='R')
      {
        count++;
        if(count>best)best=count;
      }else{
        count=0;
      }  
    }
    cout<<best<<endl;
    return 0;
}

Measured memory_bytes: 3588