akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "trace.h"
#else
#define trace(args...)
#endif

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()

void solve(int test) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt0 = 0, cnt1 = 0;
    for (char c : s) {
        cnt0 += (c == 'R');
        cnt1 += (c == 'W');
    }
    int ans = 0;
    for (int i = 0; i < cnt0; i++)
        if (s[i] != 'R') ans++;
    cout << ans << '\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; i++) {
        solve(i);
    }
}


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

using namespace std;

double square(double, double, double, double, double, double);

int main() {

	double x1, y1, x2, y2, x3, y3, xp, yp, S123, SP12, SP23, SP31;

	while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp) {
		S123=square(x1, y1, x2, y2, x3, y3);
		SP12=square(xp, yp, x1, y1, x2, y2);
		SP23=square(xp, yp, x2, y2, x3, y3);
		SP31=square(xp, yp, x3, y3, x1, y1);

		if(S123==SP12+SP23+SP31)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}

	return 0;

}

double square(double x1, double y1, double x2, double y2, double x3, double y3) {

	double a, b, c, d;

	a=x2-x1;
	b=y2-y1;
	c=x3-x1;
	d=y3-y1;

	return abs(a*d-c*b)/2;

}

Measured memory_bytes: 0
from heapq import heappush, heappop

V, E = map(int, raw_input().split())
parent = range(V)
def root(x):
    if parent[x] != x:
        x = parent[x] = root(parent[x])
    return x
def unite(x, y):
    rx = root(x); ry = root(y)
    if rx < ry:
        parent[ry] = rx
    else:
        parent[rx] = ry
def same(x, y):
    return root(x) == root(y)
que = []
for i in xrange(E):
    s, t, w = map(int, raw_input().split())
    heappush(que, (w, s, t))

ans = 0
while que:
    w, s, t = heappop(que)
    if not same(s, t):
        unite(s, t)
        ans += w
print ans

Measured memory_bytes: 22596
#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

int bo[201][201];

void solve() {
  int N, M, R; cin >> N >> M >> R;
  rep(i, N) rep(j, N) {
    if (i == j) bo[i][j] = 0; else bo[i][j] = 1e9;
  }
  vi32 r(R); cin >> r;
  rep(i, R) r[i]--;
  rep(i, M) {
    int a, b, c; cin >> a >> b >> c;
    a--, b--;
    bo[a][b] = c;
    bo[b][a] = c;
  }
  rep(k, N) rep(i, N) rep(j, N) {
    amin(bo[i][j], bo[i][k] + bo[k][j]);
  }
  sort(all(r));
  int ans = 1e9;
  do {
    int sum = 0;
    reps(i, R - 1) {
      sum += bo[r[i - 1]][r[i]];
    }
    amin(ans, sum);
  } while (next_permutation(all(r)));
  cout << ans << '\n';
}


Measured memory_bytes: 384
w, h, x, y = list(map(int, input().split()))
area_ans = w * h / 2
cog_x = w/2 
cog_y = h/2
if cog_x == x and cog_y == y: 
    cog_ans = 1
    print(str(area_ans) +" "+ str(cog_ans))
else:
    cog_ans = 0
    print(str(area_ans) +" "+ str(cog_ans))

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Text;
class Solve{
    int AB;
    int B;
    int N;
    string s;
    public Solve(){}
    public static int Main(){
        new Solve().Calc();
        return 0;
    }
    void Calc(){
        getinput();
        StringBuilder sb = new StringBuilder(N);
        string ans;
        int ab = 0;
        int b = 0;
        for(int i=0;i<N;i++){
            if(s[i] == 'a'){
                if(ab < AB){
                    ab++;
                    sb.Append("Yes\n");
                }
                else{
                    sb.Append("No\n");
                }
            }
            else if(s[i] == 'b'){
                if(ab < AB && b < B){
                    ab++;
                    b++;
                    sb.Append("Yes\n");
                }
                else{
                    sb.Append("No\n");
                }
            }
            else{
                sb.Append("No\n");
            }
        }
        ans = sb.ToString();
        Console.Write(ans);
    }
    void getinput(){
        string[] str = Console.ReadLine().Split(' ');
        N = int.Parse(str[0]);
        AB = int.Parse(str[1])+int.Parse(str[2]);
        B = int.Parse(str[2]);
        s = Console.ReadLine();
    }    
}

Measured memory_bytes: 5080
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

int64_t gcd(int64_t a, int64_t b) {return b?gcd(b, a%b):a;}
int64_t lcm(int64_t a, int64_t b) {return a/gcd(a,b)*b;}

int main() {
    int n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, n) {
        cin >> a[i];
    }

    sort(rall(a));

    int g=a[0];
    rep(i, n) {
        g = gcd(g, a[i]);
    }

    if(k%g || k > a[0]) cout << "IMPOSSIBLE" << endl;
    else cout << "POSSIBLE" << endl;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()

using namespace std;

int main()
{
	int seireki = 0;
	int tuki = 0;
	int hiniti = 0;

	scanf("%d/%d/%d", &seireki, &tuki, &hiniti);

	if (seireki <= 2019 && tuki <= 4 && hiniti <= 30)
	{
		cout << "Heisei";
	}
	else
	{
		cout << "TBD";
	}

	return 0;
}

Measured memory_bytes: 256
import numpy as np

mod = 10 ** 9 + 7


def regularize(a, b):
    if a < 0 or (a == 0 and b < 0):
        a, b = -a, -b
    if b > 0:
        return 0, a, b
    else:
        return 1, -b, a


n = int(input())
edict = dict()
zero_num = 0
for _ in range(n):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        zero_num += 1
        continue
    ab_gcd = np.gcd(a, b)
    a, b = a // ab_gcd, b // ab_gcd
    index, a, b = regularize(a, b)
    key = (a, b)
    if key not in edict.keys():
        edict[key] = [0, 0]
    edict[key][index] += 1


not_zeros = 1
for key in edict.keys():
    a, b = key
    pp, pm = edict[key]
    not_zeros *= (pow(2, pp, mod) + pow(2, pm, mod) - 1) % mod
    not_zeros %= mod

print((zero_num + not_zeros - 1) % mod)



Measured memory_bytes: 78132
while s = gets do
    n = s.to_i
    res = 0
    for i in 0..9 do
        for j in 0..9 do
            for k in 0..9 do
                for l in 0..9 do
                    if i + j + k + l == n
                        res += 1
                    end
                end
            end
        end
    end
    puts res
end

Measured memory_bytes: 8596
import bisect
N = int(input())
L = list(map(int, input().split()))
L = sorted(L)

ans = 0
for i in range(N):
  for j in range(i+1, N):
    idx = bisect.bisect_left(L[j+1:], L[i]+L[j])
    ans += idx 
print(ans)
    

Measured memory_bytes: 51804
#![allow(
  non_snake_case,
  unused_variables,
  unused_assignments,
  unused_mut,
  unused_imports,
  dead_code,
  unused_macros
)]
//use proconio::fastout;
use proconio::input;
use proconio::marker::*;
//use std::collections::HashSet;
use std::cmp::*;
use std::collections::*;
macro_rules! debug {
  ($($a:expr),* $(,)*) => {
      #[cfg(debug_assertions)]
      eprintln!(concat!($("| ", stringify!($a), "={:?} "),*, "|"), $(&$a),*);
  };
}
fn main() {
  input! {
     H:usize,
     W:usize,
     C:(Usize1, Usize1),
     D:(Usize1, Usize1),
     S:[Chars;H]
  }
  let C: (usize, usize) = (C.0 + 2, C.1 + 2);
  let D: (usize, usize) = (D.0 + 2, D.1 + 2);
  let S: Vec<Vec<char>> = S;
  let mut kabe = vec![vec![true; W + 10]; H + 10];
  for x in 0..H {
    for y in 0..W {
      if S[x][y] == '.' {
        kabe[x + 2][y + 2] = false;
      }
    }
  }
  let kabe: Vec<Vec<bool>> = kabe;
  // Cを基準に幅優先探索。
  // (n=ワープ回数, 位置)
  let mut h = BinaryHeap::new();
  //訪問済み
  let mut v = vec![vec![false; W + 10]; H + 10];
  // ワープ回数
  let mut d = vec![vec![std::u64::MAX; W + 10]; H + 10];
  v[C.0][C.1] = true;
  d[C.0][C.1] = 0;
  h.push((Reverse(0), C.0, C.1));
  while let Some((Reverse(c), x, y)) = h.pop() {
    toho(&kabe, &mut d, &mut h, c, x - 1, y);
    toho(&kabe, &mut d, &mut h, c, x + 1, y);
    toho(&kabe, &mut d, &mut h, c, x, y - 1);
    toho(&kabe, &mut d, &mut h, c, x, y + 1);

    warp(&kabe, &mut d, &mut h, c, x - 2, y - 2);
    warp(&kabe, &mut d, &mut h, c, x - 2, y - 1);
    warp(&kabe, &mut d, &mut h, c, x - 2, y);
    warp(&kabe, &mut d, &mut h, c, x - 2, y + 1);
    warp(&kabe, &mut d, &mut h, c, x - 2, y + 2);
    warp(&kabe, &mut d, &mut h, c, x - 1, y - 2);
    warp(&kabe, &mut d, &mut h, c, x - 1, y - 1);
    warp(&kabe, &mut d, &mut h, c, x - 1, y + 1);
    warp(&kabe, &mut d, &mut h, c, x - 1, y + 2);
    warp(&kabe, &mut d, &mut h, c, x, y - 2);
    warp(&kabe, &mut d, &mut h, c, x, y + 2);
    warp(&kabe, &mut d, &mut h, c, x + 1, y - 2);
    warp(&kabe, &mut d, &mut h, c, x + 1, y - 1);
    warp(&kabe, &mut d, &mut h, c, x + 1, y + 1);
    warp(&kabe, &mut d, &mut h, c, x + 1, y + 2);
    warp(&kabe, &mut d, &mut h, c, x + 2, y - 2);
    warp(&kabe, &mut d, &mut h, c, x + 2, y - 1);
    warp(&kabe, &mut d, &mut h, c, x + 2, y);
    warp(&kabe, &mut d, &mut h, c, x + 2, y + 1);
    warp(&kabe, &mut d, &mut h, c, x + 2, y + 2);
  }
  let ans = d[D.0][D.1];
  if ans < std::u64::MAX {
    println!("{}", ans);
  } else {
    println!("-1");
  }
}

fn warp(
  kabe: &Vec<Vec<bool>>,
  d: &mut Vec<Vec<u64>>,
  h: &mut BinaryHeap<(Reverse<u64>, usize, usize)>,
  c: u64,
  x: usize,
  y: usize,
) -> () {
  if kabe[x][y] == false {
    let c = c + 1;
    if d[x][y] > c {
      d[x][y] = c;
      h.push((Reverse(c), x, y));
    }
  }
}

fn toho(
  kabe: &Vec<Vec<bool>>,
  d: &mut Vec<Vec<u64>>,
  h: &mut BinaryHeap<(Reverse<u64>, usize, usize)>,
  c: u64,
  x: usize,
  y: usize,
) -> bool {
  if kabe[x][y] == false {
    if d[x][y] > c {
      d[x][y] = c;
      h.push((Reverse(c), x, y));
    }
    true
  } else {
    false
  }
}


Measured memory_bytes: 17340
#スタックで深さ優先探索
def dfs(start, goal, g, pre)
  stack = [ [start, 0, pre] ]
  #stack = [探索する頂点番号, 使用した辺の記録, １つ手前の頂点]
  catch(:loop) do
    while stack.length > 0 do
      current = stack.pop
      #ゴールなら終了
      if current[0] == goal
        @path = current[1]
        throw :loop
      end
      g[ current[0] ].each do |p|
        #戻るなら追加しない
        next if p[0] == current[2]
        #スタックに追加
        bit = current[1] | (1 << p[1])
        stack.push([p[0], bit, current[0]])
      end
    end
  end
end

def main
  n = gets.chomp.to_i
  graph = []

  (n-1).times do |i|
    a, b = gets.chomp.split.map(&:to_i)
    
    graph[a] = [] if !graph[a]
    graph[b] = [] if !graph[b]
    graph[a].push([b, i])
    graph[b].push([a, i])
  end

  m = gets.chomp.to_i
  paths = []
  m.times do |i|
    @path = 0
    x, y = gets.chomp.split.map(&:to_i)
    dfs(x, y, graph, -1)
    paths.push(@path)
  end

  ans = (1 << (n - 1))
  #回答の導出
  (1..m).each do |i|
    sum = 0
    paths.combination(i).each do |cm|
      bit = cm.inject(:|).to_s(2).count('1')
      sum += (1 << (n - 1 - bit))
    end

    ans += i.odd? ? -1 * sum : sum
  end

  puts ans

end

main

Measured memory_bytes: 2172
import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 6)

def main():
    n = int(input())
    s = defaultdict(int)
    for _ in range(n):
        s[input()] += 1
    m = int(input())
    for _ in range(m):
        t = input()
        if t in s:
            s[t] -= 1
    print(max(max(s.values()), 0))

main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
string divide[4] = {"dream", "dreamer", "erase", "eraser"};
main(void){
  string s;
  cin >> s;
  reverse(s.begin(),s.end());
  for(int i=0;i<4;i++) reverse(divide[i].begin(),divide[i].end());
  bool can=true;
  for(int i=0;i<s.size();){
    bool can2=false;
    for(int j=0;j<4;j++){
      string d=divide[j];
      if(s.substr(i,d.size())==d){
        can2=true;
        i+=d.size();
      } 
    }
    if(!can2){
      can=false;
      break;
    }
  }
  if(can) cout << "YES";
  else cout << "NO";
}
  

Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        while (i < n - 1 && s[i] == s[i + 1]) {
            i++;
        }
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
import sys,math,collections
from collections import defaultdict

#from itertools import permutations,combinations
    
def file():
    sys.stdin = open('input.py', 'r')
    sys.stdout = open('output.py', 'w') 
def get_array():
    l=list(map(int, input().split()))
    return l
def get_ints():   
    return map(int, input().split())
    #return a,b
def get_3_ints():   
    a,b,c=map(int, input().split())
    return a,b,c    
def sod(n):
    n,c=str(n),0
    for i in n: 
        c+=int(i)
    return c    
def isPrime(n):
    if (n <= 1):
        return False
    if (n <= 3):
        return True
    if (n % 2 == 0 or n % 3 == 0):
        return False
    i = 5
    while(i * i <= n):
        if (n % i == 0 or n % (i + 2) == 0):
            return False
        i = i + 6
  
    return True
def getFloor(A, x):

    (left, right) = (0, len(A) - 1)

    floor = -1
    while left <= right:
        mid = (left + right) // 2
        if A[mid] == x:
            return A[mid]
        elif x < A[mid]:
            right = mid - 1
        else:
            floor = A[mid]
            left = mid + 1
            
    return floor
def chk(aa,bb):
	f=0
	for i in aa:
		for j in bb:
			if(j[0]>=i[0] and j[1]<=i[1]):
				f+=1
			elif(j[0]<=i[0] and j[1]>=i[1]):	
				f+=1
			elif(i[0]==j[1] or i[1]==j[0]):
				f+=1
			else:
				continue
	return f			

#file()
def main():
	s=input()
	print(s[:4]+' '+s[4:])
	



		




				





		


	





        
            
        























    

    
    

        











        
        

        























































                

            







            
            
































        








if __name__ == '__main__':
    main()


Measured memory_bytes: 9380
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
     ll n,x,temp;
     cin>>x>>n;
     ll a[400]={0};


     for(int i=0;i<n;i++)
        {
            cin>>temp;
            a[temp]=1;
        }
        for(int i=0;;i++)
        {
            if(a[x-i]==0)
            {
                cout<<x-i<<endl;
                break;
            }
            if(a[x+i]==0)
            {
                cout<<x+i<<endl;
                break;
            }
        }



 return 0;
}


Measured memory_bytes: 3680
#include<stdio.h>

int A[260];

void parent(int b){
  printf("parent key = %d, ",A[b/2]);
}

void left(int f){
  printf("left key = %d, ",A[f*2]);
}

void right(int s){
  printf("right key = %d, ",A[s*2+1]);
}



int main(){
  int H;
  int i;
  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }

  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(i/2>0) parent(i);
    if(i*2<=H) left(i);
    if(i*2+1<=H) right(i);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > piii;
#define pb push_back
#define debug(x) cout << x << endl
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
#define PI acos(-1)
#define all(c) c.begin(), c.end()
#define SET(x, y) memset((x), y, sizeof(x))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const LL INF64 = 1e18;

const int N = 1e5 + 5;

LL table[3005][3005];
LL arr[3005];

LL optimalStrategyOfGame(LL n) 
{ 
    // Create a table to store solutions of subproblems 
  
    // Fill table using above recursive formula. Note  
    // that the table is filled in diagonal fashion (similar 
    // to http:// goo.gl/PQqoS), from diagonal elements to 
    // table[0][n-1] which is the result. 
    for (LL gap = 0; gap < n; ++gap) { 
        for (LL i = 0, j = gap; j < n; ++i, ++j) { 
  
            // Here x is value of F(i+2, j), y is F(i+1, j-1) and 
            // z is F(i, j-2) in above recursive formula 
            LL x = ((i + 2) <= j) ? table[i + 2][j] : 0; 
            LL y = ((i + 1) <= (j - 1)) ? table[i + 1][j - 1] : 0; 
            LL z = (i <= (j - 2)) ? table[i][j - 2] : 0; 
  
            table[i][j] = max(arr[i] + min(x, y), arr[j] + min(y, z)); 
        } 
    } 
  
    return table[0][n - 1]; 
} 

int main() {
	int n;
	scanf("%d", &n);
	LL sum = 0LL;
	for (int i = 0; i < n; i++) {
		scanf("%lld", arr + i);
		sum += arr[i];
	}
	LL ans = optimalStrategyOfGame(n);
	printf("%lld\n", ans - (sum - ans));
	return 0;
}
		

Measured memory_bytes: 70016
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>

using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    vector<int> memo(n);
    int m = 0;
    for (int i = n; i > 0; i--)
    {
        int sum = 0;
        for (int j = i; j <= n; j += i)
        {
            sum += memo[j - 1];
        }
        bool flag1 = sum % 2 == 0;
        bool flag2 = a[i - 1] == 0;
        if (flag1 ^ flag2)
        {
            memo[i - 1] = 1;
            m++;
        }
    }
    cout << m << endl;
    for (int i = 0; i < n; i++)
    {
        if (memo[i] == 0)
            continue;
        cout << i + 1 << " ";
    }
    return 0;
}

Measured memory_bytes: 4788
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int q = sc.nextInt();
        for(int a = 0; a < q; a++) {
            String x = sc.next();
            String y = sc.next();

            // xの(i + 1)番目までとyの(j + 1)番目までの最長共通部分列
            int[][] dp = new int[x.length() + 1][y.length() + 1];
            for(int i = 0; i < x.length(); i++) {
                for(int j = 0; j < y.length(); j++) {
                    if(x.charAt(i) == y.charAt(j)) dp[i + 1][j + 1] = dp[i][j] + 1;
                    else dp[i + 1][j + 1] = Math.max(dp[i + 1][j], dp[i][j + 1]);
                }
            }

            System.out.println(dp[x.length()][y.length()]);
        }

        sc.close();
    }
}



Measured memory_bytes: 64368
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main()
{
    int N;
    double L, T;
    cin >> N >> L >> T;
    vector<int> X(N), W(N);
    rep(i, N)
    {
        cin >> X[i] >> W[i];
    }
    int count = 0;
    int one = 0;
    if (W[0] == 1)
    {
        rep(i, N)
        {
            if (W[i] != W[0])
            {
                double d = X[i] - X[0];
                count += (2 * (T - d / 2)) / L + 1;
            }
        }
    }
    else
    {
        rep(i, N)
        {
            if (W[i] != W[0])
            {
                double d = L - X[i] + X[0];
                count -= (2 * (T - d / 2)) / L + 1;
            }
        }
    }
    one += count;
    one %= N;
    if (one < 0)
    {
        one += N;
    }
    vector<int> ap(N);
    rep(i, N)
    {
        int position = ((int(X[i]) + int(T) * (3 - 2 * W[i]))) % int(L);
        if (position < 0)
        {
            position += L;
        }
        ap[i] = position;
    }
    int oneposition = ap[0];
    sort(ap.begin(), ap.end());
    int oneope = 0;
    rep(i, N)
    {
        if (ap[i] == oneposition)
        {
            if (i != N - 1)
            {
                if (W[0] == 1 && ap[i + 1] == oneposition)
                {
                    oneope = i + 1;
                    break;
                }
            }
            oneope = i;
            break;
        }
    }
    rep(i, N)
    {
        int index = (oneope - one + i) % N;
        if (index < 0)
        {
            index += N;
        }
        cout << ap[index] << endl;
    }
}

Measured memory_bytes: 4564
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String str = br.readLine();
			
			if(str == null){
				break;
			}
			
			String[] seed = new String[12];
			
			for(int i = 0; i < 12; i++){
				seed[i] = str;
				str = br.readLine();
			}
			
			//System.out.println("str "+str);
			
			World world = new World(seed);
			Explorer exp = new Explorer(world);
			
			exp.searchNewIsland();
			System.out.println(exp.discoveredIsland());
		}
	}

}

class Explorer {
	private int island = 0;
	private World world;
	
	public Explorer(World world){
		this.world = world;
	}
	
	public void searchNewIsland(){
		for(int i = 0; i < world.height; i++){
			for(int j = 0; j < world.width ; j++){
				if(world.isAvailable(j, i)){
					island++;
					walk(j, i);
				}
			}
		}
	}
	
	public int discoveredIsland(){
		return island;
	}
	
	private void walk(int x, int y){
		world.areas[y][x].visit();
		
		if(world.isAvailable(x+1, y)){
			walk(x+1, y);
		}
		if(world.isAvailable(x, y+1)){
			walk(x, y+1);
		}
		if(world.isAvailable(x-1, y)){
			walk(x-1, y);
		}
		if(world.isAvailable(x, y-1)){
			walk(x, y-1);
		}
	}
}

class World {
	Area[][] areas;
	public final int width;
	public final int height;
	
	public World(String[] seed){
		height = seed.length;
		width = seed[0].length();
		areas = new Area[height][width];
		
		for(int i = 0; i < height; i++){
			for(int j = 0; j < width ; j++){
				areas[i][j] = new Area(areaType(seed[i].charAt(j)));
			}
		}
		
	}
	
	private int areaType(char c){
		if(c == '1'){
			return Area.LAND;
		}
		else if(c == '0'){
			return Area.SEA;
		}
		else {
			return -1;
		}
	}
	
	public boolean isAvailable(int x, int y){
		if(x < 0 || x >= width){
			return false;
		}
		
		if(y < 0 || y >= height){
			return false;
		}
		
		if(areas[y][x].isVisited() || areas[y][x].type() == Area.SEA){
			return false;
		}
		
		return true;
	}
}

class Area {
	private int type;
	static final int LAND = 1;
	static final int SEA = 2;
	private boolean visited = false;
	
	public Area(int type){
		this.type = type;
	}
	
	public boolean isVisited(){
		return visited;
	}
	
	public int type(){
		return type;
	}
	
	public void visit(){
		this.visited = true;
	}
}

Measured memory_bytes: 24360
#include <iostream>
#include <cstdio>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない
//UnionFind

const int maxn=40;
const int maxnum=10;

int n,ma,mb;
int dp[maxn+1][maxn*maxnum+1][maxn*maxnum+1];
int a[maxn],b[maxn],c[maxn];

int main(){
    
    cin >> n>>ma>>mb;
    
    rep(i,n){
        cin >> a[i]>>b[i]>>c[i];
    }
    
    for(int i=0;i<=maxn;i++){
        for(int j=0;j<=maxn*maxnum;j++){
            for(int k=0;k<=maxn*maxnum;k++){
                //if(i==0)dp[i][j][k]=0;
                 dp[i][j][k]=INF;
            }
        }
    }
    
    dp[0][0][0]=0;
    
    for(int i=0;i<n;i++){
        for(int j=0;j<=maxn*maxnum;j++){
            for(int k=0;k<=maxn*maxnum;k++){
                if(dp[i][j][k]==INF)continue;
                dp[i+1][j][k]=min(dp[i][j][k],dp[i+1][j][k]);
                dp[i+1][j+a[i]][k+b[i]]=min(dp[i][j][k]+c[i],dp[i+1][j+a[i]][k+b[i]]);
            }
        }
    }
    
    int ans=INF;
    
    for(int i=1;i<=maxn*maxnum;i++){
        for(int j=1;j<=maxn*maxnum;j++){
            if(i*mb==j*ma)ans=min(dp[n][i][j],ans);
        }
    }
    
    if(ans==INF)ans=-1;
    
    cout << ans<<endl;
    
    return 0;
}


Measured memory_bytes: 26112
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
#define LL long long
const LL inf = 1e17;
string S;
string k = "keyence";
int main() {
	cin >> S;
	bool flag = false;
	int idx1 = 0;
	for (int i = 0; i < 7; i++) {
		if (S[i] != k[i]) {
			idx1 = i;
			break;
		}
		if (i == 6) flag = true;
	}
	int idx2 = 0;
	for (int i = 1; i <= 7; i++) {
		if (S[S.size() - i] != k[7 - i]) {
			idx2 = i - 1;
			break;
		}
		if (i == 7) flag = true;
	}
	if (flag || idx1 + idx2 >= 7) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm> 
#include<cstring>
#define lc(x) x<<1
#define rc(x) x<<1|1
#define LL long long
using namespace std;
const int N=5e3+5;
const int M=205;
int n,m,L,R,cnt;
int d[N],w[N][M],mx[M];
int q[N],nex[N][M];
LL val,ans,anss,s[N],a[N],t[N*4],tag[N*4];
int read()
{
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}
void up(int x){t[x]=max(t[lc(x)],t[rc(x)]);}
void dn(int x)
{
	if(!tag[x])return;
	t[lc(x)]+=tag[x];tag[lc(x)]+=tag[x];
	t[rc(x)]+=tag[x];tag[rc(x)]+=tag[x];
	tag[x]=0;
}
void build(int x,int l,int r)
{
	if(l==r){t[x]=a[l];return;}
	int mid=(l+r)>>1;
	build(lc(x),l,mid);
	build(rc(x),mid+1,r);
	up(x);
}
void modify(int x,int l,int r)
{
	if(L<=l&&r<=R){t[x]+=val;tag[x]+=val;return;}
	dn(x);int mid=(l+r)>>1;
	if(L<=mid)modify(lc(x),l,mid);
	if(R>mid)modify(rc(x),mid+1,r);
	up(x);
}
void query(int x,int l,int r)
{
	if(L<=l&&r<=R){anss=max(anss,t[x]);return;}
	dn(x);int mid=(l+r)>>1;
	if(L<=mid)query(lc(x),l,mid);
	if(R>mid)query(rc(x),mid+1,r);
}
int main()
{
	n=read();m=read();
	for(int i=1;i<n;i++)d[i]=read();
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			w[i][j]=read();
	for(int j=1;j<=m;j++)
	{
		cnt=0;
		for(int i=1;i<=n;i++)nex[i][j]=n+1;
		for(int i=1;i<=n;i++)
		{
			while(cnt&&w[q[cnt]][j]<w[i][j])nex[q[cnt]][j]=i,cnt--;
			q[++cnt]=i;
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			mx[j]=max(mx[j],w[i][j]);
			a[i]+=mx[j];
		}
		a[i]-=s[i];s[i+1]=s[i]+d[i];
	}
	build(1,1,n);ans=t[1];
	for(int i=1;i<n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			for(int k=i+1;k<nex[i][j];k=nex[k][j])
			{
				L=k;R=nex[k][j]-1;val=w[k][j]-w[i][j];
				if(L<=R)modify(1,1,n);
			}
		}
		anss=-1e16;L=i+1;R=n;
		query(1,1,n);
		ans=max(ans,anss+s[i+1]);
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 8576
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;

//for debugging 
/*
g++ -D_GLIBCXX_ASSERTIONS -DDEBUG -ggdb3 -std=c++14 
*/
int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
	os<<"[";
	for(auto& x:v){os<<x<<", ";}
	return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
	return os<<"{"<<p.first<<", "<<p.second<<"}";
}
// debugging ends here

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

void solve(){
	
	string n;
	cin >> n;
	int ans = 0;
	for(int i =0;i<n.length();i++){
		ans = (ans + (n[i]-'0'))%9;
	}

	cout << (ans?"No":"Yes") << endl;
}

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

	// int t;cin >> t;while(t--)
		solve();
}


Measured memory_bytes: 3772
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a = 1;
		
		while(true) {
			int i = sc.nextInt();
			
			if(i == 0) {
				break;
			}else {
				System.out.println("Case " + a + ": " + i);
				a++;
			}
		}
	}
}



Measured memory_bytes: 41216
#include <iostream>
#define rep(i,b) for(int i = 0; i <b; i++)
using namespace std;
bool e[300001]={0};
int main(){
	rep(i,300001)if(i%7==1||i%7==6)e[i]=1;
	e[1]=0;
	rep(i,300001)if(e[i])for(int j=i*2;j<300001;j+=i)e[j]=0;
	for(int n;cin>>n,n!=1;){
			cout<<n<<":";
			rep(i,n+1)if(e[i]&&n%i==0)cout<<" "<<i;
			cout<<endl;
		}
	return 0;
}


Measured memory_bytes: 1448
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#include<iostream>
#include<cstdio>
#include<vector>
#include<cstring>
#define ll long long
#define p 1000000007
using namespace std;
namespace ywy{
	typedef struct _b{
		int dest;int nxt;
	}bian;bian memchi[1000001];int gn=1,heads[5001];ll jc[5001],jcny[5001];ll dp[5001];
	inline void add(int s,int t){
		memchi[gn].dest=t;memchi[gn].nxt=heads[s];heads[s]=gn;gn++;
	}int size[5001],n;
	inline ll mi(int a,int b){
		ll ans=1,tmp=a;while(b){
			if(b&1)ans=(ans*tmp)%p;tmp=(tmp*tmp)%p;b>>=1;
		}return(ans);
	}vector<int> vec;
	void dfs(int pt,int baba){
		int mx=0;size[pt]=1;for(register int i=heads[pt];i;i=memchi[i].nxt){
			if(memchi[i].dest==baba)continue;dfs(memchi[i].dest,pt);size[pt]+=size[memchi[i].dest];
			mx=max(mx,size[memchi[i].dest]);
		}if(max(mx,n-size[pt])<=n/2)vec.push_back(pt);
	}
	void efs(int pt,int baba){
		size[pt]=1;for(register int i=heads[pt];i;i=memchi[i].nxt){
			if(memchi[i].dest==baba)continue;efs(memchi[i].dest,pt);size[pt]+=size[memchi[i].dest];
		}
	}
	inline ll cnm(int n,int m){
		if(n<m)return(0);ll cjr=jc[n];cjr*=jcny[m];cjr%=p;cjr*=jcny[n-m];return(cjr%p);
	}
	inline ll anm(int n,int m){
		if(n<m)return(0);ll cjr=jc[n];cjr*=jcny[n-m];return(cjr%p);
	}
	void ywymain(){
		cin>>n;for(register int i=1;i<n;i++){
			int s,t;cin>>s>>t;add(s,t);add(t,s);
		}dfs(1,0);jc[0]=1;for(register int i=1;i<=n;i++)jc[i]=(jc[i-1]*i)%p;jcny[n]=mi(jc[n],p-2);
		for(register int i=n-1;i>=0;i--)jcny[i]=(jcny[i+1]*(i+1))%p;if(vec.size()==2){
			cout<<(jc[n/2]*jc[n/2])%p<<endl;return;
		}dp[0]=1;int rt=vec[0];efs(rt,0);int tot=0;for(register int i=heads[rt];i;i=memchi[i].nxt){
			tot+=size[memchi[i].dest];for(register int j=tot;j>=0;j--){
				for(register int k=1;k<=min(j,size[memchi[i].dest]);k++){
					ll cjr=dp[j-k];cjr*=cnm(size[memchi[i].dest],k);cjr%=p;cjr*=anm(size[memchi[i].dest],k);
					dp[j]=(dp[j]+cjr)%p;
				}
			}
		}ll ans=0;for(register int i=0;i<=n;i++){
			if(i&1)ans-=dp[i]*jc[n-i],ans%=p,ans+=p,ans%=p;else ans=(ans+dp[i]*jc[n-i])%p;
		}cout<<ans<<endl;
	}
}
int main(){
	ywy::ywymain();return(0);
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  string s; cin >> s;
  while (s.back() != 'Z') s.pop_back();
  reverse(ALL(s));
  while (s.back() != 'A') s.pop_back();
  cout << s.length() << '\n';
  return 0;
}


Measured memory_bytes: 720
#include <stdio.h>

int main(void){
	int n, a;
	int num[50] = {0};
	long dp[51][51][2501] = {{{0}}}, sum = 0;

	scanf("%d%d", &n, &a);
	for(int i=0; i < n; i++) {
		scanf("%d", &num[i]);
	}

	for(int i=0; i <= n; i++) {
		for(int j=0; j <= i; j++) {
			for(int k=0; k <= 2500; k++) {
				if(i==0 && j==0 && k==0) {
					dp[0][0][0] = 1;
				}else if(i >= 1 && k < num[i-1]) {
					dp[i][j][k] = dp[i-1][j][k];
				}else if(i >= 1 && j >= 1 && k >= num[i-1]) {
					dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-num[i-1]];
				}else{
					dp[i][j][k] = 0;
				}
			}
		}
	}

	for(int i=1; i <= n; i++) {
		sum += dp[n][i][i*a];
	}
	printf("%ld", sum);

	return 0;
}


Measured memory_bytes: 50944
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;

ll m(ll a) {
    return ((a%MOD)+MOD)%MOD;
}

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

    string number;
    cin>>number;
    int n = (int)number.length();
    int d;
    cin>>d;
    vector<ll> dp(d, 0);
    int digit;
    digit = number[0]-'0';
    for (int i=0; i<digit; i++) {
        dp[i%d]++;
    }

    ll rem_for_max = digit%d;

    for (int i=1; i<n; i++) {
        vector<ll> new_dp(d, 0);
        for (int j=0; j<d; j++) {
            for (int k=0; k<=9; k++) {
                int value_to_be_added = (((j-k)%d)+d)%d;
                new_dp[j] = m(new_dp[j]+dp[value_to_be_added]);
            }
        }

        digit = number[i] - '0';

        for (int j=0; j<digit; j++) {
            new_dp[(j+rem_for_max)%d]++;
        }

        rem_for_max = (rem_for_max+digit)%d;

        new_dp.swap(dp);
    }

    if (rem_for_max==0) {
        dp[0]++;
    }

    cout << m(dp[0]-1) << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <cmath>
#include <tuple>
#include <queue>
#include <set>

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


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

    int N;
    double T, A;

    cin >> N >> T >> A;

    vector<double> H(N);

    for(int i = 0; i < N; i++){
        cin >> H[i];
    }

    double tmp_minimum = 1000.0;
    int ans;

    for(int i = 0; i < N; i++){
        if(chmin(tmp_minimum, abs(A - (T - H[i] * 0.006)))){
            ans = i;
        }
    }

    cout << ans + 1 << endl;


    return 0;
}


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

import math

h_min=h*60
rad=5.5*(h_min+m)%360
#print(rad)
cos=math.cos(math.radians(rad))
#print(cos)
c2 =a**2+b**2-2*a*b*cos
print(math.sqrt(c2))







Measured memory_bytes: 9440
program ABC166B
    implicit none
    integer(8)::N,K,d,i,j,ans,A(110)
    integer(8),allocatable,dimension(:)::S
    read*,N,K
    allocate(S(N))
    S=0
    ans=0

    do i=1,K
        read*,d
        read*,(A(j),j=1,d)
        do j=1,d
            S(A(j))=1
        end do
    end do

    do i=1,N
        if(S(i)==0)ans=ans+1
    end do

    print'(i0)',ans
end program ABC166B

Measured memory_bytes: 2872
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int a[202020];
int main()
{
	int n;
	long long ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		a[i]-=i;
	}
	sort(a+1,a+1+n);
	for(int i=1;i<=n/2;i++)
		ans+=a[n+1-i]-a[i];
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1024
/**
 * ******* Created on 27/10/19 5:23 PM*******
 */

import java.io.*;
import java.util.*;

public class Main implements Runnable {

    private void solve() throws IOException {
        long n = reader.nextLong();
        int a = (int) Math.sqrt(n);
        long ans = Long.MAX_VALUE;
        for(int i=1;i<=a;i++){
            if(n%i ==0){
                long x = i;
                long y = n/i;
                if(x+y-2< ans)
                    ans =x+y-2;
            }
        }
        writer.println(ans);
    }

    public static void main(String[] args) throws IOException {
        try (Input reader = new StandardInput(); PrintWriter writer = new PrintWriter(System.out)) {
            new Main().run();
        }
    }

    StandardInput reader;
    PrintWriter writer;

    @Override
    public void run() {
        try {
            reader = new StandardInput();
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    interface Input extends Closeable {
        String next() throws IOException;

        default int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        default long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        default double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        default int[] readIntArray() throws IOException {
            return readIntArray(nextInt());
        }

        default int[] readIntArray(int size) throws IOException {
            int[] array = new int[size];
            for (int i = 0; i < array.length; i++) {
                array[i] = nextInt();
            }
            return array;
        }

        default long[] readLongArray(int size) throws IOException {
            long[] array = new long[size];
            for (int i = 0; i < array.length; i++) {
                array[i] = nextLong();
            }
            return array;
        }
    }

    private static class StandardInput implements Input {
        private final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        private StringTokenizer stringTokenizer;

        @Override
        public void close() throws IOException {
            reader.close();
        }

        @Override
        public String next() throws IOException {
            if (stringTokenizer == null || !stringTokenizer.hasMoreTokens()) {
                stringTokenizer = new StringTokenizer(reader.readLine());
            }
            return stringTokenizer.nextToken();
        }
    }
}


Measured memory_bytes: 22484
n = int(input())
words = [input() for _ in range(n)]

answered = set([words[0]])
ans = "Yes"

for i in range(1, n):
    if words[i] in answered:
        ans = "No"
        break

    if words[i][0] != words[i-1][-1]:
        ans = "No"
        break

    answered.update([words[i]])

print(ans)

Measured memory_bytes: 3188
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cmath>
#include <climits>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
#include <functional>
#include <algorithm>

using namespace std;

#define fast_cin() ios_base::sync_with_stdio(false)

typedef long double ld;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int max_N = 1e5 + 10;
int A[max_N];

int main()
{
	fast_cin();

	int N;
	cin >> N;
	for (int i = 1; i <= N; ++i) {
		cin >> A[i];
	}

	int ans = 1, curr = 0;
	A[0] = A[1];
	for (int i = 1; i <= N; ++i) {
		if (A[i] > A[i - 1] && curr == -1) {
			curr = 0;
			++ans;
		} else if (A[i] < A[i - 1] && curr == 1) {
			curr = 0;
			++ans;
		} else if (A[i] > A[i - 1]) {
			curr = 1;
		} else if (A[i] < A[i - 1]) {
			curr = -1;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 764
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<ll,ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n,m;
	cin>>n>>m;
	vi in(n);
	rep(i,n)cin>>in[i];
	ll out=0;
	if(in[0]>m){
		out+=in[0]-m;
		in[0]=m;
	}
	loop(i,1,n){
		ll t=in[i]+in[i-1];
		if(t>m){
			out+=t-m;
			in[i]=m-in[i-1];
		}
	}
	cout<<out<<endl;
}










Measured memory_bytes: 1152
def main():
    import sys
    input = sys.stdin.readline
    from collections import defaultdict
    N = int(input())
    ans = defaultdict(int)
    while N % 2 == 0:
        ans[2] += 1
        N //= 2
    f = 3
    while f * f <= N:
        if N % f == 0:
            ans[f] += 1
            N //= f
        else:
            f += 2
    if N != 1:
        ans[N] += 1
    
    Ans = 0
    for v in ans.values():
        x = 1
        while x * (x+1) // 2 <= v:
            x += 1
        Ans += x-1
    print(Ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 65924
#include <stdio.h>
#include <math.h>

int main(void) {
	int count, x[1001], y[1001];
	double p1=0,p2=0,p3=0,pn=0,max=0;
	for (int i = 0; i < 1001; i++) {
		x[i] = 0;
		y[i] = 0;
	}
	scanf("%d", &count);
	for (int i = 0; i < count; i++) {
		scanf("%d", &x[i]);
	}
	for (int i = 0; i < count; i++) {
		scanf("%d", &y[i]);
	}
	for (int i = 0; i < count; i++) {
		p1 += fabs(x[i] - y[i]);
		p2 += pow(fabs(x[i] - y[i]),2);
		p3 += pow(fabs(x[i] - y[i]), 3);
		if (fabs(x[i] - y[i]) > max) {
			max = fabs(x[i] - y[i]);
		}
	}
	p2 = pow(p2,1.0/2.0);
	p3 = pow(p3,1.0/3.0);
	
	printf("%lf\n", p1);
	printf("%lf\n", p2);
	printf("%lf\n", p3);
	printf("%lf\n", max);
}


Measured memory_bytes: 2940
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//																				NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define mod 100000007
#define testcases() ll t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
 
//----------------------------------------------------------------------------------------------------------------------------------------------------

vector<vector<int>> g;
vector<pair<int,int>> v;
vector<int> visited;

void dfs(int u, int id, int *cnt){
	visited[u] = id;
	*cnt = *cnt + 1;
	for(auto it: g[u]){
		if(visited[it] == -1){
			dfs(it, id, cnt);
		}
	}
}

int main()
{
	fast;
	int n,m,k,x,y;
	cin>>n>>m>>k;
	g.resize(n);
	visited.resize(n);
	fill(visited.begin(), visited.end(), -1);
	map<pair<int,int>,int> mp;
	for(int i=0;i<m;i++){
		cin>>x>>y;
		--x;
		--y;
		g[x].pb(y);
		g[y].pb(x);
		mp[{x,y}]=1;
		mp[{y,x}]=1;
	}
	for(int i=0;i<k;i++){
		cin>>x>>y;
		--x;
		--y;
		v.pb({x,y});
	}
	int cnt=0;
	vector<int> group_size;
	for(int i=0;i<n;i++){
		int size = 0;
		if(visited[i] == -1){
			dfs(i,cnt,&size);
			group_size.pb(size);
			++cnt;
		}
	}
	vector<int> ans(n,0);
	for(int i=0;i<n;i++){
		ans[i]=group_size[visited[i]]-1-g[i].size();
	}
    //for(auto it:ans){
    //    cout<<it<<" ";
    //}
    //debug2(visited[0], visited[3])
	for(int i=0;i<k;i++){
		if(visited[v[i].fi]==visited[v[i].se] && (mp.find(v[i])==mp.end())){
			//debug2(v[i].fi,v[i].se)
            --ans[v[i].fi];
			--ans[v[i].se];
		}
	}
	for(int i=0;i<n;i++){
		cout<<ans[i]<<" ";
	}
	return 0;
}

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

using namespace std;

const int MAX_N = 2e5 + 5;

int dp [MAX_N][3];

int main () {
  ios::sync_with_stdio(false);

  string str;
  cin >> str;

  int n = str.size();

  if (n == 1) {
    cout << 1 << endl;
    return 0;
  }
  
  dp[0][1] = 1;
  dp[0][2] = -MAX_N;

  dp[1][1] = (str[0] == str[1] ? -MAX_N : 2);
  dp[1][2] = 1;
  
  for (int i = 2; i < n; i++) {
    dp[i][1] = 1 + dp[i - 1][2];
    if (str[i] != str[i - 1]) {
      dp[i][1] = max(dp[i][1], 1 + dp[i - 1][1]);
    }

    dp[i][2] = 1 + dp[i - 2][1];
    if (i >= 3) {
      if (str[i] != str[i - 2] || str[i - 1] != str[i - 3]) {
        dp[i][2] = max(dp[i][2], 1 + dp[i - 2][2]);
      }
    }
  }

  cout << max(dp[n - 1][1], dp[n - 1][2]) << endl;
}


Measured memory_bytes: 2964
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
       int x = input.nextInt();
       String s = input.next();
       
        int c=0;
        for(int i = 0;i<x-2;i++){
            
           if(s.charAt(i)=='A'&&s.charAt(i+1)=='B'&&s.charAt(i+2)=='C'){
               c++;
               
           }
            
            
    
    }
        System.out.println(c);
    
}}

Measured memory_bytes: 23252
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main(void)
{
     int i,j,k,n,m;
     int a,b,c,d;
     char s[10];
     scanf("%s",s);
     a=s[0]-'0';
     b=s[1]-'0';
     c=s[2]-'0';
     d=s[3]-'0';
     if((a==b&&b==c)||(b==c&&c==d))
          printf("Yes\n");
     else
          printf("No\n");
     return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n, d;
int main()
{
    cin >> n >> d; d = 2 * d + 1;
    if(n % d == 0) cout << n / d;
    else cout << (n/d) + 1;
    cout << endl;
//    system("pause");
}

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

int main() {
  string S;
  cin >> S;
  if(S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
    cout << "Yes" << endl;
  }
  else {
  cout << "No" << endl;
  }
}


Measured memory_bytes: 256