akhauriyash/Code-Regression huggingface dataset:
a = gets.chomp.split("")
b = gets.chomp.split("")
c = gets.chomp.split("")

v = a.shift
loop do
    case v
    when 'a'
        if a.size == 0
            puts "A"
            exit
        end
        v = a.shift
    when 'b'
        if b.size == 0
            puts "B"
            exit
        end
        v = b.shift
    when 'c'
        if c.size == 0
            puts "C"
            exit
        end
        v = c.shift
    end
end


Measured memory_bytes: 1788
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
 
public class Main {
	private static FastScanner sc = new FastScanner();
	
	public static void main(String[] args) {
		int N = sc.nextInt();
		
		PriorityQueue<Long> que = new PriorityQueue<>();
		for(int i=0; i<N; i++) {
			que.add(-sc.nextLong());
		}
		
		long cnt = 0;
		while(true) {
			long x = que.poll();
			if(x >= cnt - N + 1) {
				System.out.println(cnt);
				return;
			}
			
			long d = ((cnt - N + 1) - x)/50 + 1;
			que.add(x + (N + 1) * d);
			cnt += d;
		}
	}
	
	static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 24020
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    string s;
    cin>>s;
    s[5]=' ';
    s[13]=' ';
    cout << s<<endl;



}


Measured memory_bytes: 256
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.buffer.readline().rstrip()

class SegmentTree(object):
    def __init__(self, A):
        n = 1 << (len(A) - 1).bit_length()
        tree = [0] * (2 * n)
        for i, v in enumerate(A):
            tree[i + n] = v
        for i in range(n - 1, 0, -1):
            tree[i] = tree[i << 1] + tree[i << 1 | 1]
        self._n = n
        self._tree = tree

    def __getitem__(self, i):
        return self._tree[i + self._n]

    def update(self, i, v):
        i += self._n
        self._tree[i] = v
        while i != 1:
            i >>= 1
            self._tree[i] = self._tree[i << 1] + self._tree[i << 1 | 1]

    def add(self, i, v):
        self.update(i, self[i] + v)

    def sum(self, l, r):
        l += self._n
        r += self._n
        l_val = r_val = 0
        while l < r:
            if l & 1:
                l_val = l_val + self._tree[l]
                l += 1
            if r & 1:
                r -= 1
                r_val = self._tree[r] + r_val
            l >>= 1
            r >>= 1
        return l_val + r_val


def resolve():
    n, q = map(int, input().split())
    C = list(map(lambda x : int(x) - 1, input().split()))

    A = [0] * n
    next = [-1] * n
    used = [-1] * n
    for i in range(n - 1, -1, -1):
        c = C[i]
        A[i] = 1
        if used[c] != -1:
            next[i] = used[c]
            A[used[c]] = 0
        used[c] = i

    tree = SegmentTree(A)
    queries = [[] for _ in range(n)]
    for i in range(q):
        l, r = map(int, input().split())
        queries[l - 1].append((r, i))

    ans = [0] * q
    for l in range(n):
        for r, i in queries[l]:
            ans[i] = tree.sum(l, r)
        if next[l] != -1:
            tree.add(next[l], 1)

    print(*ans, sep = '\n')
resolve()

Measured memory_bytes: 203540
// inputに入力データ全体が入る
    function Main(input) {
      var x = parseInt(input,10);
      var ans = 0;
      var y =  (x - x % 500)/500;
      ans += y * 1000;
      x = x - y * 500;
      var z =  (x - x % 5)/5;
      ans += z * 5;
      console.log(ans);
    }
    //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
    Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <limits.h>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 1000000007;
const int INF = LLONG_MAX/3;

signed main(){
    int n;
    cin>>n;
    int a[20],b[20],c[20];
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>b[i];
    for(int i=0;i<n-1;i++)cin>>c[i];
    int ans=0;
    for(int i=0;i<n;i++){
        ans+=b[a[i]-1];
        if(i>0&&a[i]-a[i-1]==1)ans+=c[a[i]-2];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;



int main(){
int L,R,d;
cin>>L>>R>>d;
int count=0;
rep2(i,L,R+1){
    if(i%d==0)count++;
}
cout<<count<<endl;



return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    int a,b;
    char op;
    while(1){
        cin>>a>>op>>b;
        if(op=='+'){cout<<a+b<<endl;}
        else if(op=='-'){cout<<a-b<<endl;}
        else if(op=='*'){cout<<a*b<<endl;}
        else if (op=='/'){printf("%d",a/b);cout<<endl;}
        
            
        else{break;}
    }
return 0;
}

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

const int mod = 998244353;
string S;

int memo[5000][5000];
bool visited[5000][5000];

long long f(int p, int x, int y) {
	if (p > 0 && x == 0 && y == 0) return 1;
	if (visited[p][x]) return memo[p][x];
	visited[p][x] = true;
	int xx = x;
	if (p < (int)S.length()) {
		x += S[p]-'0';
		y += 2 - (S[p]-'0');
	}
	auto r = 0;
	if (x > 0) r += f(p+1, x-1, y);
	if (y > 0) r += f(p+1, x, y-1);
	//cerr << p << " " << x << " " << y << " " << r % mod << endl;
	return memo[p][xx] = r % mod;
}

int main() {
	cin >> S;
	cout << f(0,0,0) << endl;
}


Measured memory_bytes: 102656
#include<stdio.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
const int p=1e9+7;
int n;
long long f[110][4][4][4],ans;
int main(){
	scanf("%d",&n);
	fo(a,0,3)
		fo(b,0,3)
			fo(c,0,3){
				if (a==0&&b==1&&c==2) continue;
				if (a==1&&b==0&&c==2) continue;
				if (a==0&&b==2&&c==1) continue;
				f[3][a][b][c]++;
			}
	fo(i,3,n-1)
		fo(a,0,3)
			fo(b,0,3)
				fo(c,0,3)
					fo(d,0,3){
						if (b==0&&c==1&&d==2) continue;
						if (b==1&&c==0&&d==2) continue;
						if (b==0&&c==2&&d==1) continue;
						if (a==0&&c==1&&d==2) continue;
						if (a==0&&b==1&&d==2) continue;
						f[i+1][b][c][d]+=f[i][a][b][c];
						if (f[i+1][b][c][d]>=p) f[i+1][b][c][d]-=p;						
					}
	fo(a,0,3)
		fo(b,0,3)
			fo(c,0,3)
				ans+=f[n][a][b][c];
	ans%=p;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	const int mod=1000000007;
	const long o=1;
	static void Main(){
		Sc sc=new Sc();
		int n=sc.I;
		int[][] a=new int[n][];
		int p=0;
		double[] ans=new double[n];
		for(int i = 0;i<n;i++) {
			a[i]=sc.Ia;
			if(a[i][1]<a[p][1]){p=i;}
		}
		Gs gs=new Gs(a,p);
		int m=gs.li.Count-1;
		for(int i = 1;i<m;i++) {ans[gs.li[i].n]=1.0*(180-Gp4(gs.li[i-1].x,gs.li[i-1].y,gs.li[i].x,gs.li[i].y,gs.li[i+1].x,gs.li[i+1].y))/360;}
		ans[gs.li[0].n]=1.0*(180-Gp4(gs.li[m].x,gs.li[m].y,gs.li[0].x,gs.li[0].y,gs.li[1].x,gs.li[1].y))/360;
		ans[gs.li[m].n]=1.0*(180-Gp4(gs.li[m-1].x,gs.li[m-1].y,gs.li[m].x,gs.li[m].y,gs.li[0].x,gs.li[0].y))/360;
		Console.WriteLine(String.Join("\n",ans));
	}
	static double Gp4(double ax,double ay,double bx,double by,double cx,double cy){
		double a1=ax-bx,a2=ay-by,c1=cx-bx,c2=cy-by;
		return Math.Acos((a1*c1+a2*c2)/Math.Sqrt((a1*a1+a2*a2)*(c1*c1+c2*c2)))*180/Math.PI;
	}
}
public class Gs{
	public class Mo{
		public int n;
		public long x,y;
		public double d;
		public Mo(double d,int n,int x,int y){this.d=d;this.n=n;this.x=x;this.y=y;}
	}
	private Mo[] arr;
	public List<Mo> li=new List<Mo>();
	public Gs(int[][] a,int p){
		int n=a.Length,q=2;
		arr=new Mo[n];
		for(int i=0;i<n;i++){
			if(i!=p){arr[i]=new Mo(Math.Atan2(a[i][1]-a[p][1],a[i][0]-a[p][0])*180/Math.PI,i,a[i][0],a[i][1]);}
		}
		arr[p]=new Mo(-512,p,a[p][0],a[p][1]);
		Array.Sort(arr,Ca);
		li.Add(arr[0]);
		li.Add(arr[1]);
		while(q!=n){
			li.Add(arr[q]);
			q++;
			while(li.Count>2&&(li[li.Count-1].x-li[li.Count-2].x)*(li[li.Count-3].y-li[li.Count-2].y)-(li[li.Count-1].y-li[li.Count-2].y)*(li[li.Count-3].x-li[li.Count-2].x)<=0){li.RemoveAt(li.Count-2);}//
		}
	}
	private int Ca(Mo a,Mo b){
		if(a.d>b.d){return 1;}
		else if(a.d<b.d){return -1;}
		else if(a.y>b.y){return 1;}
		else if(a.y<b.y){return -1;}
		else{return 0;}
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

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

using namespace std;

int N,K,num;
int day[101];
int a[101][4][3];

long long int dp(int d,int k,int n){
	if(n == 3)return 0;

	if(a[d][k][n] >= 0)return a[d][k][n];

	if(d == N)return a[d][k][n] = 1;

	long long int b = 0; 
	if(day[d+1] != -1){
		if(day[d+1] == k){
			b += dp(d+1, day[d+1], n+1) % 10000;
		}else{
			b += dp(d+1, day[d+1], 1) % 10000;
		}
	}else{
		for(int i = 1;i <= 3;i++){
			if(i == k){
				b += dp(d+1, i, n+1) % 10000;
			}else{
				b += dp(d+1, i, 1) % 10000;
			}
		}
	}
	return a[d][k][n] = b % 10000;
}

int main(){
	fill_n(**a,101*4*3,-1);
	fill_n(day,101,-1);
	cin >>N >> K;
	for(int i = 0;i<K;i++){
		cin >> num;
		cin >> day[num];
	}
	cout <<dp(0,0,0)<<endl; 
}

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>

int	main()
{
	char	w[101];
	int	*alpha;

	scanf("%s\n", w);
//	fgets(w, sizeof(w), stdin);
	alpha = (int *)calloc(27, sizeof(int));
	for (int i = 0; w[i]; i++)
		alpha[w[i] - 'a']++;
	for (int i = 0; i < 27; i++)
	{
		if (alpha[i] % 2)
		{
			printf("No\n");
			return (0);
		}
	}
	printf("Yes\n");
	return (0);
}

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

int main() {
  int a, b, x;
  double a_d, b_d, x_d;
  cin >> a >> b;
  a_d = a * 1.0;
  b_d = b * 1.0;
  
  x = ( a + b ) / 2;
  x_d = ( a_d + b_d ) / 2.0;
  if(x_d > x)
    x++;
  
  cout << x << endl;
  
}

Measured memory_bytes: 256
import math
D,G=[int(s) for s in input().split()]
ls=[[int(s) for s in input().split()] for i in range(D)]
maxD=2**D-1
def need(num):
  val=num
  score=0
  prob=0
  for i in range(D):
    if val%2==1:
      score+=ls[i][0]*(i+1)*100+ls[i][1]
      prob+=ls[i][0]
    val//=2
  if score>=G:
    return prob
  else:
 #   print(score)
    k=int(math.log2(num^maxD))
    x=(score-G)//((k+1)*100)
    if -x<=ls[k][0]:
      return -x+prob
    else:
      return 10000
print(min([need(i) for i in range(2**D)]))    
      

Measured memory_bytes: 3064
while True:
    m,n_min,n_max = list(map(int,input().split()))
    if m == 0:
        break
    v  = [int(input()) for _ in range(m)]
    
    max_gap = 0
    max_index = n_min


    for i in range(n_min,n_max+1):
        gap = v[i-1]-v[i]

        
        if gap > max_gap:
            max_gap = gap
            max_index = i
        elif gap == max_gap:
            max_index = i
            
    
    print(max_index)


Measured memory_bytes: 5624
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 7;
int n;
long long X, D;

struct Node{
	long long x, l, r, num;
	bool operator <(const Node &b) const{
		return num > b.num;
	}
}node[maxn];
long long sum[maxn];

bool check(long long x) {
	int d = x / X, o = x % X;
	long long now = 0;
	for (int i = 1; i <= n; ++i) {
		if(o < node[i].x) now = (o - node[i].x) * node[i].l;
		else now = (o - node[i].x) * node[i].r;
		if(i <= d) now += sum[d + 1] - node[i].num + node[i].x * node[i].l;
		else now += sum[d] + node[i].x * node[i].l;
		if(now >= D) return 1;
	}
	return 0;
}

int main() {
	scanf("%d%lld", &n, &X);
	long long l = -1, r = 0, mid;
	for (int i = 1; i <= n; ++i) {
		scanf("%lld%lld%lld", &node[i].x, &node[i].l, &node[i].r);
		node[i].num = node[i].x * node[i].l;
		D += node[i].num;
		node[i].num += (X - node[i].x) * node[i].r;
		r += node[i].x;
	}
	sort(node + 1, node + n + 1);
	for (int i = 1; i <= n; ++i) sum[i] = sum[i - 1] + node[i].num;
	while(l < r - 1) {
		mid = (l + r) >> 1;
		if(check(mid)) r = mid;
		else l = mid;
	}
	printf("%lld\n", r);
	return 0;
}

Measured memory_bytes: 7632
#include<stdio.h>

int main(){
  char str[4];
  int ans = 700;
  int i;
  scanf("%s", &str);
  for(i = 0; i < 3; i++){
    if(str[i] == 'o'){
      ans += 100;
    }
  }
  printf("%d", ans);
}


Measured memory_bytes: 128
N = int(input())
A = list(map(int, input().split()))
X = 0

for i in range(N):
    if i % 2 == 0:
        X += A[i]
    else:
        X += -A[i]

ans = [X]

for i in range(N-1):
    X = ans[i]
    ans.append(2 * A[i] - X)
print(*ans)

Measured memory_bytes: 14032
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a := intScanner()
	b := intScanner()
	c := intScanner()
	if a == b {
		fmt.Println(c)
	} else if b == c {
		fmt.Println(a)
	} else {
		fmt.Println(b)
	}
}


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

int main() {
  int n;
  cin >> n;
  vector<int> t(n);
  for (int i = 0; i < n; i ++) {
    cin >> t.at(i);
  }
  int m;
  cin >> m;
  vector<int> p(m);
  vector<int> x(m);
  for (int i = 0; i < m; i ++) {
    cin >> p.at(i) >> x.at(i);
  }

  for (int i = 0; i < m; i ++) {
    int sum = 0;
    for (int j = 0; j < n; j ++) {
      if (p.at(i) == j + 1) {
        sum += x.at(i);
      } else {
        sum += t.at(j);
      }
    }
    cout << sum << endl;
  }
}


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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int memo[105][105];

bool rec(int x, int y, bool a){
	if(x < 2 && y < 2){
		//cout << !a << endl;
		return false;
	}

	if(memo[x][y] != -1) return memo[x][y];

	if(memo[x][y] == -1){
		for(int i=1; 2*i <= x; i++){
			//cout << x << y << endl;
			if(rec(x-2*i, y+i, !a) == false){
				return memo[x][y] = 1;
			}
		}
		for(int i=1; 2*i <= y; i++){
			//cout << x << y << endl;
			if(rec(x+i, y-2*i, !a) == false){
				return memo[x][y] = 1;
			}
		}
	}
	return memo[x][y] = 0;
}

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	//cout << rec(2, 1, true) << endl;
	
	memset(memo, 0xff, sizeof(memo));

	//rec(3, 3, true);
	
	/*
	for(int i=0; i<=20; i++){
		for(int j=0; j<=20; j++){
			if(rec(i, j, true) == true){
				printf("A");
			}else{
				printf("B");
			}
		}
		puts("");
	}
	*/

	ll x, y;
	cin >> x >> y;
	printf("%s\n", (abs(x - y) <= 1) ? "Brown" : "Alice");

	
	return 0;
}


Measured memory_bytes: 256
require 'set'
n = gets.to_i
s = gets.chomp
r=Set.new
g=Set.new
b=Set.new
n.times{|t|
    if s[t] == "R"
        r<<(t)
    elsif s[t] == "G"
        g<<(t)
    else
        b<<(t)
    end
} 

sum=0
r.each{|r_num|
    g.each{|g_num|
    sum += b.length
    if r_num>g_num
        max=r_num
        min=g_num
    else
        max=g_num
        min=r_num
    end
    if (max-min)%2==0 and b.include?(((max-min)/2)+min)
        sum -=1
    end
    if b.include?(2*max-min)
        sum -=1
    end
    if b.include?(min-(max-min))
        sum -=1
    end
    }
}
puts sum

Measured memory_bytes: 14612
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  ll N;
  while (cin >> N) {
    ll res = N * (N + 1) / 2 - N;
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import numpy as np

d = int(input())    # Day
C = list(map(int, input().split()))  # 満足度の減少係数
S = []  # 各日にち、各タイプの満足度
T = []  # d日目の開催タイプ
L = [0] * 26    # 各コンテストが開催された最後の日付

for _ in range(d):
    S.append(list(map(int, input().split())))  # Si,d type_iをdayDに開いた時の満足度 [5, 26]

for _ in range(d):
    T.append(int(input()))

# print("d:", d)
# print("C:", C)
# print("S:", S)
# print("T:", T)

sat = 0
S = np.array(S)

for i in range(d):
    con_type = T[i]
    # print("開催するコンテストタイプ：", con_type)
    complain = 0
    L[con_type - 1] = i + 1     # 最終開催日の更新
    for j in range(26):
        # print("{} + {} * ({} - {})".format(complain, C[j], i+1, L[j]))
        complain = complain + C[j] * (i + 1 - L[j])

    # print("complain:", complain)
    # print("S:", S[i][con_type - 1])
    # print("satの計算: {} + {} - {}".format(sat, S[i][con_type - 1], complain ))

    sat = sat + S[i][con_type - 1] - complain

    print(sat)



Measured memory_bytes: 27388
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
// #define ll int128_t
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define f(i,j,l) for(i=j;i<l;i++)
#define smax(a,b) a=max(a,b)
#if !defined(ONLINE_JUDGE)
#include "debugging.h"
#endif
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set

int const mod = 1e9+7;
int power(int a,int b,int m){
    int res = 1;
    while(b){
        if(b&1){
            res = res*a;
            res %= m;
        }
        a=a*a;
        a%=m;
        b=b/2;
    }
    return res;
}

int inverse(int x){
    return power(x,mod-2,mod);
}

int const N = 1e5+5;
int const inf = 2e9;

void solve(){  
    int i,j;
    string s;
    cin>>s;
    int cnt[2019] =  {0};
    cnt[0]++;

    int x = 0;
    int p = 1;
    for(i=(int)s.size()-1;i>=0;i--){
        x = x + p*(s[i]-'0');
        x %= 2019LL;
        cnt[x]++;
        p = p*10;
        p %= 2019LL;
    }
    int ans = 0;

    for(i=0;i<2019;i++){
        if(cnt[i] > 0){
            int x = cnt[i]*(cnt[i]-1)/2;
            ans += x;
        }
    }

    cout<<ans<<endl;
}           

int32_t main(){
    IOS;
    int t;
    t = 1;
    // precompute();
    // cin>>t;
    for(int tt=1;tt<=t;tt++){
        solve();
    }
    return 0;
}


/*

*/

Measured memory_bytes: 3752
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b;

    scanf("%d", &a);
    scanf("%d", &b);

    if(a==1 && b==2){
        printf("3\n");
    }
    else if(a==2 && b==3){
        printf("1\n");
    }
    else if(a==1 && b==3){
        printf("2\n");
    }
    else if(a==2 && b==1){
        printf("3\n");
    }
    else if(a==3 && b==2){
        printf("1\n");
    }
    else if(a==3 && b==1){
        printf("2\n");
    }

    return 0;
}


Measured memory_bytes: 1640
#include <stdio.h>
#include <stdlib.h>

#include <string.h>

#define MIN       (1)
#define MAX       (100)
#define INFTY (0x7FFFFFFF)

typedef enum
{
    ERROR  =-1,
    SUCCESS= 0
} ResultType;

static ResultType checkRangeOfNum(int, int, int);
static int getMinimumOfScalarMultiplication(int);

int R[MAX + 1];      // row and column table R[x], as follows;
                     // R[0]=row    of 1st Matrix "M1" (x=0)
                     // R[1]=column of 1st Matrix "M1" (x=1)
                     // R[2]=column of 2nd Matrix "M2" (x=2)
                     // R[3]=column of 3rd Matrix "M3" (x=3)
                     // ...

int C[MAX][MAX + 1]; // cost table C[i][i+j], which means 
                     // minimum of scalar multiplication (Mi * Mi+1 * ... Mi+j)
                     // (where i>=1, j>=1)
int main(void)
{

int x, y;
int N;

    ResultType eResult;

    /* input line 1 */
    scanf("%d",&N);
    eResult = checkRangeOfNum(N, MIN, MAX);
    if(eResult < SUCCESS)
    {
        printf("Err: %d is out of range.", N);
        return eResult;
    }

    /* input line 2 */
    for(x=0; x<=1; x++)
    {
        scanf("%d",&R[x]);
        eResult = checkRangeOfNum(R[x], MIN, MAX);
        if(eResult < SUCCESS)
        {
            printf("Err: %d is out of range.", R[x]);
            return eResult;
        }
    }

    /* input line from 3 to (N + 1) */
    for(y=2; y<N*2; y++)
    {
        x = (y+1)/2;
        scanf("%d",&R[x]);
        eResult = checkRangeOfNum(R[x], MIN, MAX);
        if(eResult < SUCCESS)
        {
            printf("Err: %d is out of range.", R[x]);
            return eResult;
        }
    }

    /* print minimum of scalar multiplication */
    printf("%d\n", getMinimumOfScalarMultiplication(N));

    return SUCCESS;
}

static ResultType checkRangeOfNum(int n, int nMin, int nMax)
{
    if((n < nMin) || (nMax < n))
    {
        return ERROR;
    }
    return SUCCESS;
}

static int getMinimumOfScalarMultiplication(int n)
{
    int i, j, k;
    int cost;
    for(i = 1; i <= n; i++)
    {
        for(j = 1; j <= n; j++)
        {
            C[i][j] = INFTY;
        }
    }
    
    for(i = 1; i <= n; i++)
    {
        C[i][i] = 0;
    }
    
    for(j = 1; j <= n - 1; j++)
    {
        for (i = 1; i <= n - j; i++)
        {
            for (k = i + 1; k <= i + j; k++)
            {
                // C[i][i+j] = min( C[i][i+j], 
                //                  C[i][k-1] + C[k][i+j] + R[i-1]*R[k-1]*R[i+j] );
                cost = C[i][k-1] + C[k][i+j] + R[i-1]*R[k-1]*R[i+j];
                if (cost < C[i][i+j])
                {
                    C[i][i+j] = cost;
                }
                
            }
        }
    }
    return C[1][n];
}



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

using namespace std;

typedef long long ll;
int main(){
    
    ll ans=2019,R,L,i,j;

    cin>>L>>R;
    if(R-L>2019){
        ans=0;
    }else{
        for(i=L; i<R; i++){
            for(j=i+1; j<R+1; j++){
                ans=min(ans,i*j%2019); 
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
int main(){
    int a,b,k;
    cin>>a>>b>>k;
    map<int,int> p;
    //a~a+k-1,b~b-(k-1)
    for(int i=0;i<k;i++){
        p[a+i]++;
        if(a+i<=b)
        cout<<a+i<<endl;
    }
    for(int i=k-1;i>=0;i--){
        p[b-i]++;
        if(p[b-i]==1&&b-i>=a){
            cout<<b-i<<endl;
        }
    }
}

Measured memory_bytes: 256
n,m = map(int,input().split())
a = [int(input()) for _ in range(m)]
fibo = [1,1]
ans = 1

for i in range(n):
            fibo.append((fibo[-1]+fibo[-2])%1000000007)

if m:
    r = [a[0]-1]

    for i in range(m-1):
        r.append((a[i+1]-a[i])-2)
        if a[i+1]-a[i] == 1:
            print(0)
            exit()

    else:
        r.append(n-a[-1]-1)

        for i in range(len(r)):
            ans = (fibo[r[i]] * ans)%1000000007

        print(ans)
else:
    print(fibo[n])

Measured memory_bytes: 11048
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

int cnt[100000+7] = {};
int N,Q;

void solve()
{
	cin>>N;

	ll sum = 0;

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

	cin>>Q;

	while(Q--)
	{
		int B,C;
		cin>>B>>C;

		sum = sum + (C-B)*cnt[B];
		cnt[C] += cnt[B];
		cnt[B] = 0;

		cout<<sum<<endl;
	}
}

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

	solve();

	return 0;
} 

Measured memory_bytes: 3964
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

int main() {

    long long x;
    cin >> x;

    long long d = x / 11LL;
    long long ans = 2 * d;
    x -= 11 * d;

    if (x == 0);
    else if (x <= 6)ans++;
    else if (x <= 11) ans += 2;

    cout << ans << endl;
}
















































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

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

   if (N>=1 && N<2)
      cout << 1 << endl;
   else if (N>=2 && N<4)
      cout << 2 <<endl;
   else if (N>=4 && N<8)
      cout << 4 << endl;
   else if (N>=8 && N<16)
      cout << 8 << endl;
   else if (N>=16 && N<32)
      cout << 16 << endl;
   else if (N>=32 && N<64)
      cout << 32 << endl;
   else
      cout << 64 << endl;

}



Measured memory_bytes: 256
#-*- coding:utf-8 -*-
import math

if __name__ == "__main__":
    """
    操作1：２つを選んで、その両方を+1する
    操作2：１つを選んで、その数字を+2する
    """
    nums = list(map(int, input().split()))
    # (1) 2番目に大きい数字が、最も大きい数字になるように、操作1を繰り返す
    # (2) その後、最も小さい数字が、最も大きい数字に鳴るように操作2を繰り返す

    # (1)
    nums.sort()
    A = nums[0]
    B = nums[1]
    C = nums[2]
    ans = 0
    n = C - B # 操作回数
    A += n
    B += n
    ans += n

    # (2)
    diff = C - A
    if diff%2 != 0:
        C += 1
        B += 1
        ans += 1 # 最も大きい数字に追加で操作1を行う
    diff = C - A
    ans += math.floor(diff/2)
    print(ans)


Measured memory_bytes: 3064
#include<cstdio>
using namespace std;
int main(void){
	int n,s;
	int i,j;
	int x,cnt;
	scanf("%d %d",&n,&s);
	cnt=0;
	for(i=0;i<=n;i++){
		for(j=0;j<=n;j++){
			x=s-(i+j);
			//printf("X=%d Y=%d Z=%d\n",i,j,x);
			if(0<=x&&x<=n)	cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 128
class Dice
	def initialize()
		# top bottom N E S W
		@dice_number = [1, 6, 5, 3, 2, 4]
	end

	def throw(command)
		swap_number = []

		case command
		when 'N'
			swap_number = [2, 1, 4]
			swap(swap_number)
		when 'E'
			swap_number = [3, 1, 5]
			swap(swap_number)
		when 'S'
			swap_number = [4, 1, 2]
			swap(swap_number)
		when 'W'
			swap_number = [5, 1, 3]
			swap(swap_number)
		end
	end

	def swap(number)
		number.map do |n|
			@dice_number[0], @dice_number[n] = @dice_number[n], @dice_number[0]
		end
	end

	def top
		@dice_number[0]
	end
end

number = gets.split.map(&:to_i)
command = gets.chomp.split("")

dice = Dice.new

command.map do |c|
	dice.throw(c)
end

puts number[dice.top-1]

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

colors = [False] * 8
crown_owners = 0

for rate in a:
	if rate <= 399:
		colors[0] = True
	elif rate <= 799:
		colors[1] = True
	elif rate <= 1199:
		colors[2] = True
	elif rate <= 1599:
		colors[3] = True
	elif rate <= 1999:
		colors[4] = True
	elif rate <= 2399:
		colors[5] = True
	elif rate <= 2799:
		colors[6] = True
	elif rate <= 3199:
		colors[7] = True
	else:
		crown_owners += 1

if colors.count(True) == 0:
	print(1, crown_owners)
else:
	print(colors.count(True), colors.count(True) + crown_owners)

Measured memory_bytes: 3064
N=gets.chomp!.to_i
a=gets.chomp!.split(" ")
a.map!{|n| n.to_i}
o=0
for i in 0..(N-1) do
  if ((a[i]%2)==1) then
    o+=1
  end
end

if N==1
  print "YES"
elsif o%2==0
  print "YES"
else
  print "NO"
end

Measured memory_bytes: 9732
#include<stdio.h>
int main()
{
	int a, b;
	scanf("%d", &a);
	scanf("%d", &b);
	if (a < b)
		printf("a < b\n");
	else if (a == b)
		printf("a == b\n");
	else
		printf("a > b\n");
	return 0;
}


Measured memory_bytes: 2624
N = int(input())
*A, = map(int,input().split())
*B, = map(int,input().split())

ans = min(A[0],B[0])
B[0] -= ans
for i in range(N):
    tmp = min(A[i+1],B[i])
    ans += tmp
    A[i+1] -= tmp
    if i==N-1:break
    tmp = min(A[i+1],B[i+1])
    ans += tmp
    B[i+1] -= tmp
print(ans)

Measured memory_bytes: 88036
k = int(input())

if k % 2 ==0 or k % 5 == 0:
    print(-1)
else:
    ans = 1
    tempmod = 0
    while True:
        tempmod = (tempmod + 7*pow(10, ans-1, k)) % k
        if tempmod == 0:
            print(ans)
            exit()
        else:
            ans = ans + 1


Measured memory_bytes: 63420
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int d=in.nextInt();
        int count=0;
        for(int i=0;i<n;i++){
            int x=in.nextInt();
            int y=in.nextInt();
            double dist=Math.sqrt((double)x*x + (double)y*y);
           // System.out.println(dist);
            if(dist<=(double)d)
                count++;
        }
        System.out.println(count);

    }
}


Measured memory_bytes: 59008
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

ll N, M;

void solve()
{
    ll ans = 0;
    if(M/2 < N) ans = M/2;
    else{
        ans = N;
        M -= 2*N;
        ans += M/4;
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <stdio.h>

using namespace std;

int main() {
  int A;
    string B;
    stringstream ss;
    cin >> A;
    ss << setw(3)<<setfill('0')<<A;
    ss >> B;
    A = atoi(B.substr(2,1).c_str());
    switch (A) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon" << endl;
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon" << endl;
            break;
        default:
            cout << "bon" << endl;
            break;
    }
        return 0;
}


Measured memory_bytes: 3616
#include <iostream>

using namespace std;

int main() {
  int N, A;
  double T;
  cin >> N >> T >> A;

  double diff = 100000;
  int res = -1;
  for (int n = 1; n <= N; ++n) {
    double H;
    cin >> H;
    double t = T - H * 0.006;
    double d = abs(A-t);
    if (d < diff) {
      diff = d;
      res = n;
    }
  }
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void solve(){
  string s;
  cin>>s;
  if(s=="RSR") cout<<1<<endl;
  else{
    int c=0;
    rep(i,0,3) if(s[i]=='R') c++;
    cout<<c<<endl;
  }
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3636
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	string s, t;
	cin >> s >> t;

	const int s_len = (int)s.size(), t_len = (int)t.size();
	vector<vector<int>> dp(s_len + 1, vector<int>(t_len + 1));

	for (int i = 1; i <= s_len; i++) {
		for (int j = 1; j <= t_len; j++) {

			if (s[i - 1] == t[j - 1]) dp[i][j] = dp[i - 1][j - 1] + 1;
			else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);

		}
	}
	
	string ans;
	int x = s_len, y = t_len;
	while (x > 0 && y > 0) {

		if (dp[x][y] == dp[x - 1][y]) x--;
		else if (dp[x][y] == dp[x][y - 1]) y--;
		else {
			ans.push_back(s[x - 1]);
			x--, y--;
		}
	}

	reverse(ans.begin(), ans.end());
	cout << ans << "\n";

	return 0;

}

Measured memory_bytes: 35584
#include<bits/stdc++.h>
#define long long long
using namespace std;
int n,m,ans;
string s;
map<string,int>mp;
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  cin>>n;
  for(int i=1;i<=n;i++)
  {
    cin>>s;
    mp[s]++;
  }
  cin>>m;
  for(int i=1;i<=m;i++)
  {
    cin>>s;
    mp[s]--;
  }
  for(auto x:mp)ans=max(ans,x.second);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define mod 1000000007

const int sz=1e5+5;
ll inf=1e15;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll ans=0;
        for(ll i=1;i<n;i++){
            ll res=n/i;
            if(n%i==0){
                res--;
            }
            ans+=res;
        }

        cout<<ans;
    }

    return 0;
}

Measured memory_bytes: 3688
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

//long mod = 10^^9 + 7;
long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { x.modm(y.modpow(mod - 2)); }

void main()
{
	auto N = RD!string;
	bool ans;
	foreach (i; 0..3)
	{
		if (N[i] == '7')
			ans = true;
	}

	writeln(ans ? "Yes" : "No");
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 2680
d,n =map(int,input().split())
if d==0:
    if n==100:
        print(101)
    else:
        print(n)
else:
    if n==100 and d==1:
        print(100**1*100+100)
    elif n==100 and d==2:
        print(100**2*100+10000)
    else :
        print(100**d*n)

Measured memory_bytes: 61548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	string s;
	cin>>s;
	ll ans=0,cnt=0;
	for(ll i=0;i<s.size();i++){
		if(s[i]=='T'){
			if(cnt==0){
				ans++;
			}
			else{
				cnt--;
			}
		}
		else{
			cnt++;
		}
	}
	cout << ans+cnt;
	// your code goes here
	return 0;
}

Measured memory_bytes: 640
n = int(input())

a = [list(map(int, input().split())) for i in range(n)]

for i in range(n):
    temp = 0 if a[i][0] - a[i][1] < 0 else a[i][0] - a[i][1]
    a[i][1] = a[i][0]+a[i][1]
    a[i][0] = temp

a.sort(key = lambda x:x[1])

ans = n
right = 0
for j in a:
    if right > j[0]:
        ans -= 1
    else:
        right = j[1]

print(ans)

Measured memory_bytes: 28712
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
int main(){
  	int N;
  	cin >> N;
  	ll A[N], B[N];
  	for(int i=0;i<N;i++){
  		cin >> A[i] >> B[i];
  	}
    
    ll ans = 0;
	ll cnt = 0;
	for(int i=N-1;i>=0;i--){
		if((A[i]+cnt)%B[i]!=0){
			ll button = B[i] - (A[i]+cnt)%B[i];
			ans += button;
			cnt += button;
		}		
	}
	cout << ans <<endl;
  	return 0;
}


Measured memory_bytes: 1792
N, M, X, Y = map(int, input().split())
X_list = list(map(int, input().split()))
Y_list = list(map(int, input().split()))
maxX = max(X_list)
minY = min(Y_list)
for z in range(maxX+1, minY+1):
    if z > X and Y >= z:
        print("No War")
        exit()
print("War")

Measured memory_bytes: 9068
#include<bits/stdc++.h>
using namespace std;
int main(){
	long int n;
	cin>>n;
	long int arr[n+1][3];
	for(long int i=1;i<=n;i++)
	cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
	long long int dp[n+1][3];
	for(long int j=2;j<=n;j++){
		dp[j][0]=0;
		dp[j][1]=0;
		dp[j][2]=0;
	}
	dp[1][0]=arr[1][0];
	dp[1][1]=arr[1][1];
	dp[1][2]=arr[1][2];
	for(long int j=2;j<=n;j++){
		dp[j][0]=max(dp[j-1][1]+arr[j][0],dp[j-1][2]+arr[j][0]);
		dp[j][1]=max(dp[j-1][0]+arr[j][1],dp[j-1][2]+arr[j][1]);
		dp[j][2]=max(dp[j-1][0]+arr[j][2],dp[j-1][1]+arr[j][2]);
	}
	long long int ans=max(dp[n][0],dp[n][1]);
	ans=max(ans,dp[n][2]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5;
string s;
int len;
int main()
{
    while(cin>>s>>len)
    {
        int sz=s.size();
        for(int i=0;i<sz;i++)
        {
            if(i%len==0)
                cout<<s[i];
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int N = sc.nextInt();
   int Q = sc.nextInt();
   char[] S = sc.next().toCharArray();
   
   int l;
   int r;
   int ans=0;
   int[] forans = new int[N]; 
   for(int i=1;i<N;i++)
     {
       if(S[i-1]=='A'&&S[i]=='C') 
       {
         ans++;
       }
         forans[i]=ans;
     }
   for(int i=0;i<Q;i++)
   {
     l=sc.nextInt();
     r=sc.nextInt();
     ans = forans[r-1] - forans[l-1];       
     System.out.println(ans);
   }
 }
}

Measured memory_bytes: 68392
from collections import defaultdict, Counter

N = int(input())
A = list(map(int, input().split()))

C = Counter(A)

k = 0
d = defaultdict(int)

for i,j in C.items():
  if j == 1:
    k += 0
    d[i] = 0
  else:
    k += j*(j-1)//2
    d[i] = j-1

for i in A:
  print(k-d[i])



Measured memory_bytes: 30896
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

A = input()

print("Yes" if A[0] == A[1] == A[2] or A[1] == A[2] == A[3] else "No")

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A,B,C;
    cin >> A >> B >> C;
    if((A-B)>=C){
        cout << 0 << endl;
    }
    else{
    cout << C-(A-B) << endl;
    }
    return 0;

} 

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

int main() {
  int n;
  ll ans=0;
  map<int,int> wa;
  cin>>n;
  rep(i,n){
    ll a;
    cin>>a;
    wa[i+a]++;
    ans+=wa[i-a];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 20580
#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

const ll MOD = 998244353;
int main(){
    int a,b,c,d;
    cin >> a>> b>>c>>d;
    
    vector<vector<vector<ll>>> dp(c+1,vector<vector<ll>>(d+1,vector<ll>(3)));
    dp[a][b][0]=1;
    for(int i=a;i<=c;i++){
        for(int j=b;j<=d;j++){
            if(i==a && b==j) continue;
            if(i!=a){
                dp[i][j][0] = dp[i][j-1][0]*(i-1);
                dp[i][j][1] = (dp[i-1][j][0]+dp[i-1][j][1]+dp[i-1][j][2])*j+dp[i][j-1][0];
                dp[i][j][2] = dp[i][j-1][1]+dp[i][j-1][2]*i;
            }
            else{
                dp[i][j][0] = dp[i][j-1][0]*(i-1);
                dp[i][j][1] = dp[i][j-1][1]*(i-1)+dp[i][j-1][0];
                dp[i][j][2] = dp[i][j-1][2]*i+dp[i][j-1][1];
            }
            // cerr<<i<<" "<<j<<" "<<" ";
            for(int k=0;k<3;k++){
                dp[i][j][k]%=MOD;
                // cerr<<dp[i][j][k]<<" ";
            }
            // cerr<<endl;
        }
    }
    cout<<(dp[c][d][0]+dp[c][d][1]+dp[c][d][2])%MOD<<endl;
    
    return 0;
}


Measured memory_bytes: 495800