akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
typedef long long ll;
using namespace std;

int N;
ll C, K;
ll arr[100005];

int solve(int count) {
      sort(arr, arr+N);
      int start = arr[0];
      int bus = 1; 
      for(int i=1; i<N; i++) {
            if(arr[i] <= (start + K) && bus < C) {
                  bus++;
            }
            else {
                  count++;
                  bus = 1;
                  start = arr[i]; 
            }
      } 
      return count;
}

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

      cin >> N >> C >> K;

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

      cout << solve(1) << endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin>>N;
    vll a(N);
    rep(i,N) cin>>a[i];
    rep(i,N)if(a[i]==0){
        cout<<"0\n";
        return 0;
    }
    ll ans=1;
    const ll INF = 1e18;
    rep(i,N){
        if (ans>INF/a[i]){
            ans=-1;
            break;
        }
        ans*=a[i];
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 3996
// Shift-JIS（シフトジス）

#include <bits/stdc++.h>
using namespace std;

int main()
{
    long long A, B, C, D;
    cin >> A >> B >> C >> D;

    long long Nc, Nd, Ncd;
    Nc = (B / C) - ((A - 1) / C);
    Nd = (B / D) - ((A - 1) / D);

    long long a = C, b = D, r, x, tmp;

    x = a * b;

    if (a < b)
    {
        tmp = a;
        a = b;
        b = tmp;
    }

    r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }

    long long lcm = x / b;

    Ncd = (B / lcm) - ((A - 1) / lcm);
    
    cout << (B - A + 1) - (Nc + Nd - Ncd) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scanner = new Scanner(System.in);
		System.out.print(" ");

		int K = scanner.nextInt();
		int A = scanner.nextInt();
		int B = scanner.nextInt();

		int largest = (B / K) * K;
		
		if (A <= largest) {
			System.out.println("OK");
		} else {
			System.out.println("NG");
		}
		scanner.close();
     
	}
}

Measured memory_bytes: 27068
#include<stdio.h>
#define N 252

int parent(int i){return i/2;}
int left(int i){return 2*i;}
int right(int i){return 2*i+1;} 

int main(){
  int h,i,a[N];

  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(parent(i)>=1) printf("parent key = %d, ",a[parent(i)]);
    if(left(i)<=h) printf("left key = %d, ",a[left(i)]);
    if(right(i)<=h) printf("right key = %d, ",a[right(i)]);
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 1984
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
a = ii()

if n%500 > a:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;


int main(){
	int w[] = {1,2,4,8,16,32,64,128,256,512};
	int n;
	while(cin >> n){
		int flag[10], num[10];
		int end = 0;
		for(int i = 0;i < 10;i++){
			flag[i] = 0;
			num[i] = 0;
		}
		num[0] = n;
		for(int i = 0;i < 10;i++){
			flag[i] = num[i] % 2;
			num[i+1] = num[i] / 2;
			if(num[i+1] == 0) break;
		}
		for(int i = 0;i < 10;i++){
			if(flag[i] == 1) end = i; 
		}
		for(int i = 0;i < 10;i++){
			if(i == end) cout << w[i] << endl;
			else if(flag[i] == 1) cout << w[i] << " ";
		}

	}
	return 0;
}

Measured memory_bytes: 1160
T_HP, T_S, A_HP, A_S = list(map(int, input().split()))

T_Turn = True
while T_HP > 0 and A_HP > 0:
    if T_Turn:
        A_HP -= T_S
    else:
        T_HP -= A_S
    T_Turn = not T_Turn
if T_HP > 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9176
#![allow(non_snake_case)]

use std::io;

fn main() {
    let sin = io::stdin();
    let mut buf = String::new();
    sin.read_line(&mut buf).ok();
    let mut ws = buf.split_whitespace();

    let a: i32 = ws.next().unwrap().parse().unwrap();
    let b: i32 = ws.next().unwrap().parse().unwrap();
    let c: i32 = ws.next().unwrap().parse().unwrap();

    let mut cnt = 0;
    for i in a..b+1 {
        if c % i == 0 {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}



Measured memory_bytes: 5028
import collections
N = int(input()) 
S = [0]*N
m = 0
for i in range(N):
    S[i] = input()
c = collections.Counter(S)
values,counts = zip(*c.most_common())
X = c.most_common()[0][1]
list = []
for i in range(0,len(c.most_common())):
    if counts[i] == X:
        list.append(values[i])
        m+=1
    else:
        break
list.sort()
for i in range(0,m):
    print(list[i])

Measured memory_bytes: 59492
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 100100100100;


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}

int keta(ll num){
    int digits = 0;
    while(num > 0){
        num /= 10;
        digits++;
    }
    return digits;
}


int main(){
    int r, D, x;
    cin >> r >> D >> x;
    rep(i, 10){
        x = r * x - D;
        cout << x << endl;
    }
}

Measured memory_bytes: 256
a = gets.to_i
if a < 600 then
  print(8)
elsif a < 800 then
  print(7)
elsif a < 1000 then
  print(6)
elsif a < 1200 then
  print(5)
elsif a < 1400 then
  print(4)
elsif a < 1600 then
  print(3)
elsif a < 1800 then
  print(2)
elsif a < 2000 then
  print(1)
end

Measured memory_bytes: 14292
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int64 n,a,b;
    cin >> n >> a >> b;

    int64 r = n / (a+b);
    int64 ans = r * a;
    n -= (a+b) * r;
    ans += max(0LL, min(n,a));

    cout << ans << endl;
}

Measured memory_bytes: 888
N = int(input())
K = int(input())
L = len(str(N))

def solve(num_str, k, smaller):
    if num_str == "" and k > 0:
        return 0
    if k == 0 or num_str == "":
        return 1

    elif smaller:
        keta = len(num_str)
        if k == 1:
            return keta * 9
        elif k == 2:
            return keta * (keta-1)//2 * 9 * 9
        else:
            return keta * (keta-1) * (keta -2)//6 * 9 * 9 * 9
    else:   
        num = int(num_str)
        num_str = str(num_str)
        top = int(num_str[0])
        if top:
            zero = solve(num_str[1:], k, True)
            non_zero = solve(num_str[1:], k-1, True) * (top - 1)
            just = solve(num_str[1:], k-1, False)
            return zero + non_zero + just
        else:
            return solve(num_str[1:], k, False)
print(solve(str(N), K, False))

Measured memory_bytes: 3064
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        long K = sc.nextLong();
        sc.close();
 
        long ans1 = (A < K) ? 0 : A - K;
        long ans2 = (A < K) ? B - (K - A) : B;
        if (ans2 < 0) ans2 = 0;
        System.out.println(ans1 + " " + ans2);
    }
}

Measured memory_bytes: 22612
a=[input().split() for i in range(3)]
n=int(input())
b=[input() for i in range(n)]
flg=0
for i in range(3):
  for j in range(3):
    if a[i][j] in b:
      a[i][j]=0
for n in range(3):
  if a[0][n]==a[1][n]==a[2][n]:
    flg=1
  elif a[n][0]==a[n][1]==a[n][2]:
    flg=1
  elif a[0][0]==a[1][1]==a[2][2]:
    flg=1
  elif a[0][2]==a[1][1]==a[2][0]:
    flg=1
print(['No','Yes'][flg])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1e18;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int N;
ll h[100010];

int main() {
    cin >> N;
    rep(i, N) cin >> h[i];

    bool flg = true;
    for (int i = N - 2; i >= 0; i--) {
        if (h[i] <= h[i + 1]) continue;
        else if (h[i] - h[i + 1] == 1) h[i]--;
        else {
            flg = false;
            break;
        }
    }
    cout << (flg ? "Yes" : "No") << endl;
}


Measured memory_bytes: 1024
N, M = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
A.sort()
sumcost = 0
for i in range(M):
    sumcost += A[0][0]
    A[0][1] -= 1
    if A[0][1] < 1:
        A.pop(0)

print(sumcost)

Measured memory_bytes: 27760
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,b;
    scanf("%d %d %d",&n,&a,&b);
    if((n*a)>b){
        printf("%d",b);
    }
    else{
        printf("%d",n*a);
    }
    return 0;

}


Measured memory_bytes: 256
//#define NDEBUG
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <thread>
#include <mutex>
#include <iomanip>
#include <cassert>

#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define INF(a) memset(a, 0x3f, sizeof(a))
#define ALL(t) (t).begin(),(t).end()
#define FILL(a,c) fill(a, a+ sizeof(a)/sizeof(*a),c)
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
#define REP(i,m) for(int i=0;i<(m);++i)
// closed interval, inverse repeat
#define CIREP(i,start,fin) for(int i=(start);i>=(fin);i--)
#define CREP(i,start,fin) for(int i=(start);i<=(fin);i++)
#define RNG(i,start,fin) for(int i=(start);i<(fin);i++)
#define IN(a, x, b) (a<=x && x<b)
#define PB push_back
#define SZ(x) (int)(x).size()

using namespace std;

using LL = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<LL,LL>;
using VI = vector<int>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VVI = vector<VI>;
const LL LINF = 1001002003004005006ll;
/* 
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,SZ(v))i>>v[j];return i;}

template<typename T>string join(const vector<T>&v)
{stringstream s;REP(i,SZ(v))s<<' '<<v[i];return s.str().substr(1);}

template<typename T>inline ostream& operator<<(ostream&o,const vector<T>&v)
{if(SZ(v))o<<join(v);return o;}
*/

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;
}




/*
constant values
*/

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

//const ll INF= 1LL<<60 ;//INF = 1001001001001; //1e9


// Main program
void solve(){
    int N;cin >> N;
    int H[100100];
    REP(i,N){
        cin >> H[i];
    }
    int ans=0;
    int cnt=0;

    REP(i,N-1){
        if(H[i] < H[i+1]){
            chmax(ans,cnt);
            cnt=0;
        }
        else{
            ++cnt;
        }
    }
    chmax(ans,cnt);
    cout << ans << endl;
    return;
}



// ----------------------------------------------
int main(){

    int T=1; 

    for (int i = 0; i < T; ++i) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main()
{
	int N;
	scanf("%d",&N);
	int a[N] ;
	
	for(int i=0;i<N;i++)
	{
		scanf("%d",&a[i]);
	}
	int temp;
	for(int i=0;i<N;i++)
	{
		for(int j = N-1;j>i;j--)
		{
			if(a[j-1]<a[j])
			{
				temp = a[j];
				a[j] = a[j-1];
				a[j-1] = temp;
			}
		}
	}				

		
	int Alice = 0,Bob = 0;

	for(int p=0;p<N;p++)
	{

		if(p % 2 == 0)
		{
			Alice = Alice+a[p];
		}
		else if(p % 2 == 1)
		  {
			  Bob = Bob+a[p];
		  }

     }
	
	printf("%d\n",Alice-Bob);		

	return 0 ;
}


Measured memory_bytes: 128
N = int(input())
F = []
for i in range(N):
  F.append(list(map(str,input().split())))
P = []
for i in range(N):
  P.append(list(map(int,input().split())))

ans = -float('inf')
for i in range(1,2**10):
  sum = 0
  for idx, j in enumerate(F):
    bin_num = int("".join(j), 2)
    num = bin(i & bin_num)[2:].count('1')
    sum += P[idx][num]
  if (sum > ans):
    ans = sum
print(ans)

Measured memory_bytes: 41580
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node {
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;   // 宣言時ポインタにはNULL(0x0)が入っているため, 木の根が設定されていなければroot == NILとなる.

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }

    z->parent = y;
    if (y == NIL) {
        root = z;
    } else {
        if (z->key < y->key) {
            y->left = z;
        }
        else {
            y->right = z;
        }
    }
}

Node * find(Node *u, int k) {
    while (u != NIL && k != u->key) {
        if (k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

void deleteNode(int k) {
    Node *y;
    Node *z = find(root, k);
    if (z->left == NIL && z->right == NIL) {
        if (z->parent->left == z) z->parent->left = NIL;
        else z->parent->right = NIL;
        free(z);
    } else if (z->left != NIL && z->right == NIL) {
        if (z->parent->left == z) z->parent->left = z->left;
        else z->parent->right = z->left;
        z->left->parent = z->parent;
        free(z);
    } else if (z->left == NIL && z->right != NIL) {
        if (z->parent->left == z) z->parent->left = z->right;
        else z->parent->right = z->right;
        z->right->parent = z->parent;
        free(z);
    } else {
        y = z->right;
        while (y->left != NIL) y = y->left;
        z->key = y->key;
        if (y->parent->left == y) y->parent->left = NIL;
        else y->parent->right = NIL;
        free(y);
    }
}

void inorder(Node *u) {
    if (u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u) {
    if (u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main() {
    int n, i, x;
    string com;

    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        cin >> com;
        if (com == "insert") {
            scanf("%d", &x);
            insert(x);
        } else if (com == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        } else if (com == "find") {
            scanf("%d", &x);
            Node *t = find(root, x);
            if (t != NIL) printf("yes\n");
            else printf("no\n");
        } else {
            scanf("%d", &x);
            deleteNode(x);
        }
    }

    return 0;
}


Measured memory_bytes: 21972
def main():
    N, M = map(int, input().split())
    bulbs = []
    for _ in range(M):
        b = tuple(map(int, input().split()))
        bulbs.append(b[1:])

    P = list(map(int, input().split()))

    ans = 0

    for switch in range(2**N):
        check = [0] * M
        for i, bulb in enumerate(bulbs):
            cnt = 0
            for b in bulb:
                if switch >> (b - 1) & 1:
                    cnt += 1
            if cnt % 2 == P[i]:
                check[i] = 1
        if all(check):
            ans += 1
    return(ans)

if __name__ == '__main__':
    print(main())


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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int n , m;

int main()
{
    _FastIO;
    cin >> n >> m;
    vector<int> v;
    for(int i = 1; i * i < m; i++){
        if(m % i == 0){
            v.push_back(i);
            v.push_back(m / i);
        }
    }
    if(floor(sqrt(m)) == ceil(sqrt(m))){
        v.push_back(int(sqrt(m)));
    }
    sort(v.begin() , v.end());
    reverse(v.begin() , v.end());
    for(int i = 0; i < v.size(); i++){
        int k = m / v[i];
        if(n <= k){
            cout << v[i] << endl;
            return 0;
        }
    }
    cout << "1" << endl;
    return 0;
}


Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            
            //入力読取。
           string strTarget = Console.ReadLine();
           string strBreak = "END_OF_TEXT";
           int intCount = 0;
            while(true){
                string strText = Console.ReadLine();
                if(strBreak == strText){
                    break;
                }
                
                //単語ごとに分割。
                string[] strWordArray = strText.Split(' ');
                
                //同じ単語の数を数える。
                for(int wordIndex = 0; wordIndex < strWordArray.Length; wordIndex++){
                    if(strWordArray[wordIndex].ToLower() == strTarget.ToLower()){
                        intCount++;
                    }
                }
                
            }

            //出力
            Console.WriteLine(intCount);  
            
        }
    }

}



Measured memory_bytes: 15800
S = input()
if len(S) < 26:
    for i in range(26):
        c = chr(ord('a') + i)
        if c in S:
            continue
        print(S + c)
        exit()
if S == 'zyxwvutsrqponmlkjihgfedcba':
    print(-1)
    exit()

s = []
for i in range(24,-1,-1):
    if S[i] > S[i+1]:
        s.append(S[i+1])
        continue
    else:
        s.append(S[i+1])
        last = 'z'
        for c in s:
            if c < S[i]: continue
            last = min(last, c)
        print(S[:i] + last)
        exit()

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define ti3 tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
ll int MOD=998244353;
#define N 3000000
 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

main(){
    ll int n,m,d;
    cin>>n>>m>>d;
    double s=((double)n-(double)d)/((double)n*(double)n);
    if(d!=0) s*=2;
    s*=m-1;
    printf("%.10lf",s);
    return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
dp = [0] * n
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(2, n):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])


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

int main()
{
	int n;
	scanf("%d",&n);
	long long mi=0x7fffffffffffffff,sum=0;
	for(int i=0;i<n;i++)
	{
		long long x,y;
		scanf("%lld%lld",&x,&y);
		if(y<x && y<mi)mi=y;
		sum+=y;
	}
	if(mi==0x7fffffffffffffff)puts("0");else printf("%lld\n",sum-mi);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<stack>
#include<vector>
using namespace std;

int main() {
	char input[20000];
	cin >> input;

	stack<int> st1;
	stack<int> st2;
	stack<int> st3;
	int lv = 0;
	int total = 0;
	for (unsigned int i = 0; i < strlen(input); i++) {
		char c = input[i];
		if (c == '\\') {
			lv--;
			st1.push(i);
		}
		else if (c == '/') {
			lv++;
			if (!st1.empty()) {
				int newArea = i - st1.top(); st1.pop();
				total += newArea;
				int prevArea = 0;
				while (!st2.empty() && st3.top() < lv) {
					st3.pop();
					prevArea += st2.top(); st2.pop();
				}
				st2.push(newArea + prevArea);
				st3.push(lv);
			}
			else if (!st3.empty()) {
				st3.pop();
				st3.push(lv);
			}
		}
	}

	cout << total << endl;
	int n = st2.size();
	cout << n;
	vector<int> vec;
	while (!st2.empty()) {
		vec.push_back(st2.top());
		st2.pop();
	}
	for (int i = 0; i < n; i++) {
		cout << " " << vec[n-i-1];
	}
	cout << endl;
}



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

using namespace std;

int main() {
    int n;
    string s,t;

    cin >> n >> s >> t;

    for(int l = n; l <= 2*n; l++) {
        bool flag = false;
        for(int i = 0; i < 2*n-l; i++){
            if(s[n-1-i] != t[2*n-l-1-i]){
                flag = true;
                break;
            }
        }
        if(!flag) {
            cout << l << endl;
            return 0;
        }
    }

    cout << 2 * n << endl;

    return 0;
}

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

main()
{
   int a,b,c,k;
   cin>>a>>b>>c>>k;
   if(k<=a)
   {
       cout<<k<<endl;
   }
   else if(k<=(a+b))
   {
       cout<<a<<endl;
   }
   else
   {
       cout<<a-(k-(a+b))<<endl;
   }
}

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

string s;
int mat[311][311][311];

int main()
{
    cin >> s;
    int kmax;
    cin >> kmax;
    int n = s.size();
    s = "$" + s;
    int ans(0);
    for (int i(1); i <= n; i++) {
        for (int j(1); i + j <= n; j++) {
            for (int k(0); k <= kmax; k++) {
                if (s[i] == s[n - j + 1])
                    mat[i][j][k] = mat[i - 1][j - 1][k] + 1;
                if (k > 0)
                    mat[i][j][k] = max(mat[i][j][k], mat[i - 1][j - 1][k - 1] + 1);
                mat[i][j][k] = max(mat[i][j][k], mat[i - 1][j][k]);
                mat[i][j][k] = max(mat[i][j][k], mat[i][j - 1][k]);
            }
        }
    }

    for (int i(1); i <= n; i++)
        for (int j(0); j <= kmax; j++)
            ans = max(ans, 2 * mat[i][n - i][j]);
    for (int i(1); i <= n; i++)
        for (int j(0); j <= kmax; j++)
            ans = max(ans, 2 * mat[i - 1][n - i][j] + 1);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 114560
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= int(n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;

typedef long long lo;

template<typename tp> inline void read(tp &x) {
    x = 0; char c = getchar(); int f = 0;
    for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
    for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
    if (f) x = -x;
}
const int N = 66;
int n;
int faF[N], faG[N], visit[N];
set <int> G[N], F[N];
set <pair <int, int> > edgeF;
vector <int> H[N]; int du[N];

inline void replace() {
	re0 (i, n + 1) {
		G[i].clear(); F[i].clear();
	}
	edgeF.clear();
}

inline void add(int x, int y) {
	G[x].insert(y); G[y].insert(x);
}

inline void rem(int x, int y) {
	G[x].erase(y); G[y].erase(x);
}

inline void dfsF(int u, int fat) {
	faF[u] = fat;
	for (int v : F[u]) if (v != fat) dfsF(v, u);
}

inline void dfsG(int u, int fat) {
	faG[u] = fat;
	for (int v : G[u]) if (v != fat) dfsG(v, u);
}

inline void dfsC(int u, int fat) {
	visit[u] = true;
	for (int v : G[u]) if (v != fat && edgeF.count({u, v})) dfsC(v, u);
}

inline void Hadde(int x, int y) {
	H[x].push_back(y); ++du[y];
}

inline bool valid() {
	rep (i, n) H[i].clear(), du[i] = 0;
	rep (i, n) if (faG[i] && !visit[faG[i]]) Hadde(i, faG[i]);
	rep (i, n) if (faF[i] && !visit[faF[i]]) Hadde(faF[i], i);
	queue <int> Q;
	rep (i, n) if (!du[i]) Q.push(i);
	while (!Q.empty()) {
		int u = Q.front(); Q.pop();
		for (int v : H[u])
			if (!--du[v]) Q.push(v);
	}
	rep (i, n) if (du[i]) return false;
	return true;
}

inline int doit(int u) {
	rep (i, n) faF[i] = faG[i] = visit[i] = 0;
	dfsF(u, 0); dfsG(u, 0); dfsC(u, 0);
	int cnt = 0;
	rep (i, n) cnt += !visit[i];
	if (valid()) return cnt;
	return 1e9;
}

inline void solve() {
	read(n);
	rep (i, n - 1) {
		int x, y; read(x); read(y);
		add(x, y);
	}
	rep (i, n - 1) {
		int x, y; read(x); read(y);
		edgeF.insert({x, y});
		edgeF.insert({y, x});
		F[x].insert(y);
		F[y].insert(x);
	}
	int ans = 1e9;
	rep (i, n) ans = min(ans, doit(i));
	if (ans < n) return cout << ans << "\n", void();
	rep (first, n) if (G[first].size() == 1) {
		rep (i, n) {
			int j = *G[first].begin();
			if (i == j || i == first) continue;
			add(first, i); rem(first, j);
			// cout << first << " " << i << " " << doit(first) << "\n";
			ans = min(ans, doit(first) + 1);
			rem(first, i); add(first, j);
		}
	}
	cout << (ans <= n ? n : -1) << "\n";
}

int main(void) {
	int T;
	for (read(T); T--; solve(), replace());
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b-1);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  char c;cin>>c;
  cout<<++c<<endl;

  return 0;

}


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

int main () {
  int N;
  cin >> N;
  if (N<2) {
    cout << N << endl;
  }
  
  else if (N<4) {
    cout << 2 << endl;
  }
  else if (N<8){
    cout << 4 << endl;
  }
  else if (N<16){
    cout << 8 << endl;
  }
  else if (N<32){
    cout << 16 << endl;
  }
  else if (N<64){
    cout << 32 << endl;
  }
  else if (N<101){
    cout << 64 << endl;
  }
}

Measured memory_bytes: 3620
N,K = list(map(int,input().split()))
mod = int(1e9+7)
d = dict()
ans = 0
for X in range(K,0,-1):
  res = pow(K//X,N,mod)
  for k in range(2*X,K+1,X):
    res -= d[k]
  d[X] = res%mod
  ans += (res*X)%mod
  
print(ans%mod)

Measured memory_bytes: 20764
#include<iostream>

using namespace std;

int main()
{
	int n,i,j;
	
	for(;;)
	{
		cin >> n;
		if(n==0)
			break;
		
		int ans=0;
		
		for(i=0;i<n;i++)
		{
			int size=0,weight;
			for(j=0;j<3;j++)
			{
				int a;
				cin >> a;
				size+=a;
			}
			cin >> weight;
			if(size<=160 && weight<=25)
			{
				if(size>140 || weight>20)
				{
					ans+=1600;
				}
				else if(size>120 || weight>15)
				{
					ans+=1400;
				}
				else if(size>100 || weight>10)
				{
					ans+=1200;
				}
				else if(size>80 || weight>5)
				{
					ans+=1000;
				}
				else if(size>60 || weight>2)
				{
					ans+=800;
				}
				else
				{
					ans+=600;
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<string,int>;
using T = tuple<string,int,int>;

int main(){
  int n,k; cin >> n >> k;
  vector<int> v(n);
  for(int i = 0; i < n; i++){
    cin >> v[i];
  }
  int ans = 0;
  for(int l = 0; l <= k; l++){
    for(int r = 0; r <= k-l; r++){
      if(l + r > n) continue;
      int d = k - l - r;
      int temp = 0;
      vector<int> h;
      for(int i = 0; i < l; i++){
        temp += v[i];
        h.push_back(v[i]);
      }
      for(int i = n-r; i < n; i++){
        temp += v[i];
        h.push_back(v[i]);
      }
      sort(h.begin(), h.end());
      for(int i = 0; i < d; i++){
        if(i >= h.size()) break;
        if(h[i] > 0) break;
        temp -= h[i];
      }
      ans = max(ans,temp);
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  while(1){
  int n,l,r,cnt=0; cin>>n>>l>>r;
  if(n==0&&l==0&&r==0) break;
    vector<int>a(n);
  rep(i,n) cin>>a.at(i);
  
    for(int i=l;i<=r;i++){
 for(int k=0;k<n;k++){
   
   if(i%a.at(k)==0){
  if((k+1)%2==1) cnt++;
  break;
  }
 
   else if(k==n-1) {
 if(n%2==0) cnt++;
   break;
 }
   
 }
  }
    
   cout<<cnt<<endl; 
  }
}


Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    vector<string> shiritori;
    string buf;
    int N;
    cin >> N;
    for(int i = 0;i < N;i++){
        cin >> buf;
        shiritori.push_back(buf);
    }
    for(int i = 0;i < N;i++){
        for(int j = 0;j < i ;j++){
            if(shiritori[j] == shiritori[i]){
                cout << "No";
                return 0;
            }
        }
        if(i < N - 1){
            if(shiritori[i][shiritori[i].size() - 1] != shiritori[i + 1][0]){
                cout << "No";
                return 0;
            }
        }
    }
    cout << "Yes";
    return 0;
}


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

int main(){

const int MAX_NO=100000;
int m[MAX_NO],f[MAX_NO],r[MAX_NO];
char hyouka[MAX_NO];
int a=0;
int b=0;
int c=0;

for(int i=1;i<MAX_NO;i++){

cin>>m[i]>>f[i]>>r[i];

a++;

for(int j=1;j<200000000;j++){
b++;
b--;
b++;
if(b%2==0){
c++;
}
}

if(m[i]==-1 && f[i]==-1 && r[i]==-1){
goto aa;
}

if(m[i]==-1 || f[i]==-1){
hyouka[i]='F';
}

else if((m[i]+f[i])>=80){
hyouka[i]='A';
}
else if((m[i]+f[i])>=65){
hyouka[i]='B';
}

else if((m[i]+f[i])>=50){
hyouka[i]='C';
}

else if((m[i]+f[i])>=30 && r[i]<50){
hyouka[i]='D';
}
else if((m[i]+f[i])>=30 && r[i]>=50){
hyouka[i]='C';
}

else if((m[i]+f[i])<30){
hyouka[i]='F';
}

}

aa:;

for(int i=1;i<a;i++){

cout<<hyouka[i]<<endl;

}

return 0;
}

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

int N;
int a;
int c[100007];

int main()
{
  cin >> N;
  for(int i=0;i<N;i++)
  {
    cin >> a;
    c[a]++;
    c[a+1]++;
    c[a+2]++;
  }

  int res = 0;
  for(int i=0;i<100002;i++)
  {
    if(res < c[i]) res = c[i];
  }
  cout << res << endl;
}


Measured memory_bytes: 640
A,B = gets.split.map(&:to_i)
m = Array.new
m[0] = A+A-1
m[1] = A+B
m[2] = B+B-1

max = 0
for i in 0..2
 if max < m[i]
  max = m[i]
 end
end

puts(max)

Measured memory_bytes: 1788
S=input()
n=4
lis=[0,4,6,8]
t=1
for i in range(n**2):
    A=["A","K","I","H","A","B","A","R","A"]
    for j in range(n):
        if((i>>j)&1):
            A[lis[j]]=""
    TMP="".join(A)
    if(TMP==S):
        print("YES")
        t=0
        break
if(t==1):
    print("NO")

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define REP(i, n) for (size_t i = 0; i < (n); i++)
#define nvec(T, v, n) vector<T> v(n); REP(i, n) {cin>>(v)[i];}
#define npairs(T1, T2, v, n) vector<pair<T1, T2>> v(n); REP(i, n){cin>>v[i].first>>v[i].second;}
#define ntuples(T1, T2, T3, v, n) vector<tuple<T1, T2, T3>> v(n); REP(i, n){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}
#define vec2d(T, v, m, n) vector<vector<T>> (v)(m, vector<T>(n))
#define nvec2d(T, v, m, n) vec2d(T, v, m, n); REP(j, m){REP(i, n) {cin>>(v[j])[i];}}

#define min_index(v) size_t( min_element(all(v)) - (v).begin() )
#define max_index(v) size_t( max_element(all(v)) - (v).begin() )
#define min_e(v) *min_element(ALL(v))
#define max_e(v) *max_element(ALL(v))

#define count_le(v, a) size_t( upper_bound(ALL(v), a) - (v).begin() )
#define count_lt(v, a) size_t( lower_bound(ALL(v), a) - (v).begin() )
#define count_ge(v, a) size_t( (v).end() - lower_bound(ALL(v), a) )
#define count_gt(v, a) size_t( (v).end() - upper_bound(ALL(v), a) )

#define order(neq_sl) [](const auto s, const auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) accumulate(ALL(v), 0l)
#define SORT(v) sort(ALL(v))
#define P 1000000007
long powP (long a, long b) {
  if (b == 1) return a;
  else if (b == 0) return 1;
  else if (b < 0) return powP(a, P + b - 1);
  else return (powP(a, b/2) * powP(a, b/2 + b%2)) % P;
}

#define GCD(v) gcd(ALL(v), 0l)

/*template <typename T>
T gcd(T a, T b) {
    if (a > b) swap(a, b);
    if (a == 0) return b;
    return gcd(b%a, a);
}
template <typename InputItr, typename T>
T gcd(InputItr first, InputItr last, T init) {
    for (; first != last; ++first) init = gcd(init, *first);
    return init;
}*/

template <typename T>
using vec = vector<T>;

template <typename T>
using vvec = vector<vector<T>>;


int main() {
  int n,k; cin>>n>>k;
  vec<int> l(k),r(k);
  for (int i = 0; i < k; i++) {
    cin>>l[i]>>r[i];
  }
  vec<long long> dp(n+1,0);
  dp[0]=1;
  for (int i = 1; i <= n; i++) {
    dp[i]=dp[i-1];
    if(i==1)dp[i]=0;
    for (int j = 0; j < k; j++) {
      if(i-l[j]>=0) dp[i]+=dp[i-l[j]];
      if(i-r[j]-1>=0) {dp[i]-=dp[i-r[j]-1]; dp[i]+=998244353;}
      dp[i]%=998244353;
    }
  }
  cout<<dp[n-1];
}


/* きょむ〜 */


Measured memory_bytes: 4844
n = gets.to_i
as = gets.split.map(&:to_i).sort
bs = gets.split.map(&:to_i)
cs = gets.split.map(&:to_i).sort

count = 0

bs.each do |b|
  a_index = as.bsearch_index { |a| a >= b }
  c_index = cs.bsearch_index { |c| b < c }
  if a_index.nil?
    a_count = as.size
  else
    a_count = as[0...a_index].size
  end

  if c_index.nil?
    next
  else
    c_count = cs[c_index..-1].size
    count += a_count * c_count
  end
end

puts count


Measured memory_bytes: 32488
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void recurse(string s,int n,map <char,int> mark)
{
    if(n==0)
    {
        cout<<s<<'\n';
        return;
    }
    ll choices=0;
    for(char j='a';j<='z';j++)
    {
        choices++;
        if(mark[j]==0)
        {
            break;
        }
    }
    for(int j=0;j<choices;j++)
    {
        s.pb('a'+j);
        mark[(char)('a'+j)]=1;
        recurse(s,n-1,mark);
        s.erase(s.length()-1,1);
        mark[(char)('a'+choices-1)]=0;
    }
}
void solve()
{
    ll n;
    cin>>n;
    map <char,int> mark;
    string s="";
    recurse(s,n,mark);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 13184
#include <iostream>

using namespace std;

int main() {
	int X;
	int i, j;
	cin >> X;

	for (i = 1; i * 500 <= X; i++) {

	}
	--i;

	X -= (i * 500);

	cout << i * 1000 + (X - (X % 5));

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
long long n,a[100005],b[100005],sum=0,ans=0;
inline long long read(){
	char c=getchar();
	long long x=0;
	for(;c>'9'||c<'0';) c=getchar();
	for(;c>='0'&&c<='9';){
		x=(x<<3)+(x<<1)+c-'0';
		c=getchar();
	}
	return x;
}
int main(){
	n=read();
	for(long long i=1;i<=n;i++) a[i]=read(),sum+=a[i];
	if(sum%(n*(n+1)/2)){
		puts("NO");
		return 0;
	}
	sum/=(n*(n+1))/2;
	b[1]=a[1]-a[n];
	for(long long i=2;i<=n;i++) b[i]=a[i]-a[i-1];
	for(long long i=1;i<=n;i++)
		if((sum-b[i]<0)||(sum-b[i])%n){
			puts("NO"); 
			return 0;
		}
		else ans+=(sum-b[i])/n;
	if(ans!=sum) puts("NO");
	else puts("YES");
	return 0;
}

Measured memory_bytes: 1792
/******************************************
* NICK : nikhilsinghh59 *
******************************************/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"

#define PB push_back
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
const int M = 1e9+7;

int main()
{   
    

    
    ll n , m;
    cin >> n >> m;

    cout << (n*(n-1))/2 + (m*(m-1))/2 <<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  while(cin>>n,n){
    vi A(n);
    ll sum=0;
    ll ans=0;
    for(auto &a:A){cin>>a;sum+=a;}
    for(int i=0;i<n;i++){
      ans+=(sum>=(A[i]*n));
    }
    cout<<ans<<endl;
  }
  return 0;
}



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

int main() {
  int X, Y, Z;
  cin >> X >> Y >> Z;
  int A = 0;
  A = X;
  X = Y;
  Y = A;
  
  A = X;
  X = Z;
  Z = A;
  
  cout << X << endl;
  cout << Y << endl;
  cout << Z << endl;
}


Measured memory_bytes: 3600
//package com.example.myPackage;

import java.util.Scanner;

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

        String str = s.next();

        int size = str.length();
        long sum =0l;
        for(int i=0;i<size;i++)
        {
            sum += ( str.charAt(i) -'0');

        }
//        System.out.println((int) str.charAt(0));
//        System.out.println(sum);
//        if(sum==0)
//            System.out.println("Yes");
//        else {
            if (sum % 9 == 0)
                System.out.println("Yes");
            else
                System.out.println("No");



    }
}


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

int main(){
    int n;
    cin >> n;
    vector<int> t(n+1,0);
    vector<int> x(n+1,0);
    vector<int> y(n+1,0);
    rep(i, n) cin >> t.at(i+1) >> x.at(i+1) >> y.at(i+1);

    string ans = "Yes";
    for (int i = 0; i < n; ++i) {
        int dist = abs(x.at(i+1) - x.at(i)) + abs(y.at(i+1) - y.at(i));
        int time = t.at(i+1)-t.at(i);
        if(dist > time) ans = "No";  
        if(dist%2 != time%2) ans = "No"; //パリティ
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
/*Just Testing if the judge is fine ;-p */

 #include <iostream>
 using namespace std;
 int main(){
 string S;
 cin >> S;
 int L = S.size();
 string ans = "AC";
 if(S[0] != 'A'){
 ans = "WA";
 }
 int cnt = 0;
 for(int i = 1; i < L; ++i){
 if(isupper(S[i])){
 if(i == 1 || i == L - 1 || S[i] != 'C'){
 ans = "WA";
 }
 ++cnt;
 }
 }
 if(cnt != 1){
 ans = "WA";
 }
 cout << ans << endl;
 }


Measured memory_bytes: 256
//Bishop.java
import java.util.Scanner;
class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		long h=sc.nextInt();
        long w=sc.nextInt();

        if(h==1&&w==1){
            System.out.println(1);
        }
        else if(h==1||w==1){
            System.out.println(1);
        }
        else{
            if((h*w)%2==0){
                System.out.println(h*w/2);
            }
            else{
                System.out.println(h*w/2+1);
            }
        }
        sc.close();
    }
}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N; i >= 0; i--)
const ll INF = 1000000000000000000;

//input
string S;

//processing
int ans;


//dpTable
//int dp[100050];

int main(){
    cin >> S;
    if (S.at(0) == '1') ans++;
    if (S.at(1) == '1') ans++;
    if (S.at(2) == '1') ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3556
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        List<Integer> A = new ArrayList<Integer>();
        for (int i=0; i<N; i++) {
            A.add(sc.nextInt());
        }
        Map<Object, Long> countDict = A.stream().collect(
                        Collectors.groupingBy(x -> x, Collectors.counting()));
        long total = 0;
        for (Object key: countDict.keySet()) {
            long count = countDict.get(key);;
            total += count * (count - 1) / 2;
        }
        for (int k=0; k<N; k++) {
            System.out.println(total - countDict.get(A.get(k)) + 1);
        }
    }
}

Measured memory_bytes: 112388
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.Bool (bool)

main :: IO ()
main = do
  s <- T.getLine :: IO T.Text
  (q : _) <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  queries <- sequence . replicate q $ query . T.words <$> T.getLine :: IO [Query]
  let
    result :: (Bool, String, String)
    result = foldl step (True, "", "") $ queries
      where
        step :: (Bool, String, String) -> Query -> (Bool, String, String)
        step (b, pf, sf) = g
          where
            g Reverse   = (not b, sf, pf)
            g (Cons c)  = (b, c : pf, sf)
            g (Snoc c)  = (b, pf, c : sf)
    (b, pf, sf) = result
  putStr pf
  T.putStr . bool T.reverse id b $ s
  putStrLn . reverse $ sf

data Query = Reverse | Cons Char | Snoc Char

query :: [T.Text] -> Query
query = arguments . command
  where
    command (cmd : args) = (unsafeTextToInt cmd, args)
    arguments (1, _)                = Reverse
    arguments (_, args) | f == 1    = Cons c
                        | otherwise = Snoc c
      where
        (f, c) = pairMap unsafeTextToInt T.head fc
          where
            fc = unsafeListToTuple args

pairMap :: (a -> a') -> (b -> b') -> (a, b) -> (a', b')
pairMap f g (x, y) = (f x, g y)

unsafeUncons :: [a] -> (a, [a])
unsafeUncons (x : xs) = (x, xs)

unsafeListToTuple :: [a] -> (a, a)
unsafeListToTuple (x : y : _) = (x, y)

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 82556
package main

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

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	n := io.NextInt()
	// ans := solve(n)
	// ans := solve2(n)
	ans := solve3(n)
	io.Println(ans)
}

// O(n^2 log n) -> TLE

// O(n log n)

// O(n)
func solve3(n int) (ans int) {
	for i := 1; i <= n; i++ {
		ans += i * csum(n/i)
	}
	return ans
}

func csum(n int) int {
	return n * (n + 1) / 2
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 1804
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

int main() {
    // source
    ll n, k;
    cin >> n >> k;
    ll ans = 0;

    rep(i, n) {
        ll ans_temp = 0;
        ll number = i + 1;
        ll quo = n / number;
        if (number > k) {
            ans_temp += (number - k) * quo;
        }

        ll rem = n - quo * number;
        if (rem >= k) {
            ans_temp += rem - k + 1;
            if (k == 0) {
                ans_temp--;
            }
        }
        ans += ans_temp;
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 210000
using namespace std;
int a[N],n,i,j,k,l;
long long ans; 
bool cmp(int x,int y)
{
	return x>y;
}
int main()
{
	scanf("%d%d",&n,&k);
	for (i=1;i<=n;i++)
	scanf("%d",&a[i]);
	sort(a+1,a+n+1,cmp);
	if (k>=n) printf("0");else
	{
		for (i=k+1;i<=n;i++)
		ans+=a[i];
		printf("%lld",ans);
	}
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
	int n, k, q;
	scanf("%d %d %d", &n, &k, &q);
	int i;
	int point[100005];
	for (i = 0; i < n; i++)
		point[i] = k - q;
	int a;
	for (i = 0; i < q; i++)
	{
		scanf("%d", &a);
		point[a - 1]++;
	}
	for (i = 0; i < n; i++)
	{
		if (point[i] > 0)
			printf("Yes\n");
		else
			printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 896